mirror of
https://seed.radicle.dev/rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5.git
synced 2026-11-16 00:00:37 +08:00
node: Don't allow timestamps with too much delta
Signed-off-by: Alexis Sellier <self@cloudhead.io>
This commit is contained in:
@@ -122,12 +122,14 @@ fn test_inventory_fetch() {
|
||||
fn test_inventory_relay_bad_timestamp() {
|
||||
let mut alice = Peer::new("alice", [7, 7, 7, 7], MockStorage::empty());
|
||||
let bob = Peer::new("bob", [8, 8, 8, 8], MockStorage::empty());
|
||||
let two_hours = 3600 * 2;
|
||||
let timestamp = alice.local_time.as_secs() - two_hours;
|
||||
|
||||
alice.connect_to(&bob.addr());
|
||||
alice.receive(
|
||||
&bob.addr(),
|
||||
Message::Inventory {
|
||||
timestamp: 0,
|
||||
timestamp,
|
||||
inv: vec![],
|
||||
origin: None,
|
||||
},
|
||||
@@ -135,7 +137,7 @@ fn test_inventory_relay_bad_timestamp() {
|
||||
assert_matches!(
|
||||
alice.outbox().next(),
|
||||
Some(Io::Disconnect(addr, DisconnectReason::Error(PeerError::InvalidTimestamp(t))))
|
||||
if addr == bob.addr() && t == 0
|
||||
if addr == bob.addr() && t == timestamp
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user