Handle background heartbeat in wake replay fixture

Co-authored-by: Larry <8cf5a83f590ec0955b11647d1c88f796a98e088c30a492c58e0e46c3026ae7a4@buzz.block.builderlab.xyz>
Signed-off-by: Larry <8cf5a83f590ec0955b11647d1c88f796a98e088c30a492c58e0e46c3026ae7a4@buzz.block.builderlab.xyz>
Signed-off-by: Logan Johnson <loganj@squareup.com>
This commit is contained in:
Logan Johnson
2026-08-28 14:03:47 -04:00
parent fee84a6ba5
commit fa0f57e534

View File

@@ -97,7 +97,7 @@ async fn exhausted_authority_failure_replays_exact_wake_and_verifies_before_disp
)
.await
.unwrap();
let initial = next_test_frame(&mut server).await;
let initial = next_data_frame(&mut server).await;
let frame = json!(["EVENT", channel_sub_id(channel), wake]).to_string();
server
.send(Message::Text(frame.clone().into()))
@@ -126,7 +126,7 @@ async fn exhausted_authority_failure_replays_exact_wake_and_verifies_before_disp
)
.await
.unwrap();
let replay = next_test_frame(&mut server).await;
let replay = next_data_frame(&mut server).await;
assert_eq!(replay[0], "REQ");
assert_eq!(replay[1], initial[1]);
assert_eq!(replay[2]["kinds"], json!([KIND_WORKFLOW_MENTION_WAKE]));
@@ -166,3 +166,17 @@ async fn exhausted_authority_failure_replays_exact_wake_and_verifies_before_disp
http_server.await.unwrap();
harness.shutdown().await;
}
async fn next_data_frame(server: &mut WebSocketStream<tokio::net::TcpStream>) -> Value {
timeout(Duration::from_secs(2), async {
loop {
match server.next().await.expect("websocket open").expect("frame") {
Message::Text(text) => return serde_json::from_str(&text).expect("JSON frame"),
Message::Ping(payload) => server.send(Message::Pong(payload)).await.expect("pong"),
other => panic!("unexpected frame {other:?}"),
}
}
})
.await
.expect("data frame before timeout")
}