mirror of
https://seed.radicle.dev/rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5.git
synced 2026-11-21 18:40:39 +08:00
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:
@@ -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(),
|
||||
);
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user