More tests

This commit is contained in:
Dennis Schwerdel 2020-10-11 22:47:55 +02:00
parent 5bb0187726
commit 7b0718399c
1 changed files with 15 additions and 1 deletions

View File

@ -449,6 +449,7 @@ impl<P: Payload> InitState<P> {
self.repeat_last_message(out); self.repeat_last_message(out);
Ok(()) Ok(())
} else { } else {
self.next_stage = CLOSING;
Err(Error::CryptoInit("Initialization timeout")) Err(Error::CryptoInit("Initialization timeout"))
} }
} }
@ -777,7 +778,20 @@ mod tests {
} }
} }
// TODO Test: timeout after 5 retries #[test]
fn timeout() {
let (mut sender, _receiver) = create_pair();
let mut out = MsgBuffer::new(8);
sender.send_ping(&mut out);
assert_eq!(sender.stage(), STAGE_PONG);
for _ in 0..5 {
out.clear();
sender.every_second(&mut out).unwrap();
}
out.clear();
assert!(sender.every_second(&mut out).is_err());
assert_eq!(sender.stage(), CLOSING);
}
// TODO Test: duplicated message or replay attacks // TODO Test: duplicated message or replay attacks