node: Use millisecond precision for timestamps

Previously we used seconds, which could result in false positives
when checking for stale announcements, if things happened too quickly.
This commit is contained in:
Alexis Sellier
2023-02-14 20:31:40 +01:00
parent 867eea5c38
commit 7919c7ea61
10 changed files with 36 additions and 36 deletions
+2 -2
View File
@@ -440,7 +440,7 @@ mod tests {
let msg: Message = AnnouncementMessage::from(RefsAnnouncement {
id: arbitrary::gen(1),
refs: bounded_refs,
timestamp: LocalTime::now().as_secs(),
timestamp: LocalTime::now().as_millis(),
})
.signed(&MockSigner::default())
.into();
@@ -470,7 +470,7 @@ mod tests {
inventory: arbitrary::vec(INVENTORY_LIMIT)
.try_into()
.expect("size within bounds limit"),
timestamp: LocalTime::now().as_secs(),
timestamp: LocalTime::now().as_millis(),
},
&MockSigner::default(),
);
+5 -5
View File
@@ -312,7 +312,7 @@ mod test {
let node = arbitrary::gen(1);
for id in ids {
db.insert(id, node, LocalTime::now().as_secs()).unwrap();
db.insert(id, node, LocalTime::now().as_millis()).unwrap();
}
assert_eq!(10, db.len().unwrap(), "correct number of rows in table");
@@ -328,7 +328,7 @@ mod test {
for id in &ids {
for node in &nodes {
let time = rng.u64(..now.as_secs());
let time = rng.u64(..now.as_millis());
db.insert(*id, *node, time).unwrap();
}
}
@@ -338,18 +338,18 @@ mod test {
for id in &ids {
for node in &nodes {
let time = rng.u64(now.as_secs()..i64::MAX as u64);
let time = rng.u64(now.as_millis()..i64::MAX as u64);
db.insert(*id, *node, time).unwrap();
}
}
let pruned = db.prune(now.as_secs(), None).unwrap();
let pruned = db.prune(now.as_millis(), None).unwrap();
assert_eq!(pruned, ids.len() * nodes.len());
for id in &ids {
for node in &nodes {
let t = db.entry(id, node).unwrap().unwrap();
assert!(t >= now.as_secs());
assert!(t >= now.as_millis());
}
}
}