Skip to content

Commit 2493eac

Browse files
committed
add test for poll response after long delay
1 parent 59cf3a9 commit 2493eac

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

bfd-async/src/sm/tests.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,23 @@ fn poll_triggers_immediate_final_response() {
8484
assert!(!out.poll(), "poll response must not itself set poll");
8585
}
8686

87+
#[test]
88+
fn poll_remains_queued_past_tx_interval() {
89+
let now = Instant::now();
90+
let mut sm = StateMachine::start(local_info(), now);
91+
92+
let mut pkt = packet_with(BfdPeerState::Down);
93+
pkt.set_poll();
94+
sm.packet_received(pkt, now);
95+
96+
// A final-flagged response must be queued and available even if we don't
97+
// ask for a packet to send for a very long time.
98+
let later = now + Duration::from_secs(60);
99+
let out = sm.packet_to_send(later).expect("a response is queued");
100+
assert!(out.r#final(), "poll response must set the final flag");
101+
assert!(!out.poll(), "poll response must not itself set poll");
102+
}
103+
87104
#[test]
88105
fn demand_mode_suppresses_unsolicited_sends() {
89106
let now = Instant::now();

0 commit comments

Comments
 (0)