Skip to content

Commit b660184

Browse files
committed
test(poa): use PING readiness probe for redis test server startup
`wait_for_redis_ready` was checking only TCP connectability, which succeeds as soon as redis-server's listener binds — before the process is ready to handle commands. On a cold start this is fast enough to mask, but the restart-and-lose-data test (`unreconciled_blocks__when_redis_node_restarts_and_loses_data__drops_block_below_quorum`) hit the gap consistently enough to flake locally and in CI: adapter_b's first command on the restarted node would fail because redis was still warming up. Same class of half-ready issue as the 2026-04-22 mainnet hang — TCP accept doesn't imply protocol readiness. Replace the TCP probe with a real PING/PONG round-trip so we only return once redis is actually serving commands. Stress: previously flaky test now passes 20/20 in isolation and the full leader_lock suite passes 5/5.
1 parent 1891e64 commit b660184

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

  • crates/fuel-core/src/service/adapters/consensus_module

crates/fuel-core/src/service/adapters/consensus_module/poa.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1650,7 +1650,6 @@ mod tests {
16501650
net::{
16511651
SocketAddrV4,
16521652
TcpListener,
1653-
TcpStream,
16541653
},
16551654
process::{
16561655
Child,
@@ -3406,12 +3405,22 @@ mod tests {
34063405
.expect("Failed to spawn redis-server")
34073406
}
34083407

3408+
/// Probe redis with a real `PING`/`PONG` round-trip — TCP accept can
3409+
/// succeed before redis-server is ready to process commands (the
3410+
/// same class of half-ready state that caused the 2026-04-22
3411+
/// mainnet hang). On a fresh start this is usually instant; on
3412+
/// restart it can take a few extra ticks while redis re-binds.
34093413
fn wait_for_redis_ready(port: u16) {
3410-
let addr = SocketAddrV4::new(std::net::Ipv4Addr::LOCALHOST, port);
3414+
let url = format!("redis://127.0.0.1:{port}/");
34113415
let start = std::time::Instant::now();
34123416
let timeout = Duration::from_secs(5);
3417+
let per_attempt = Duration::from_millis(200);
34133418
while start.elapsed() < timeout {
3414-
if TcpStream::connect(addr).is_ok() {
3419+
if let Ok(client) = redis::Client::open(url.as_str())
3420+
&& let Ok(mut conn) = client.get_connection_with_timeout(per_attempt)
3421+
&& let Ok(reply) = redis::cmd("PING").query::<String>(&mut conn)
3422+
&& reply == "PONG"
3423+
{
34153424
return;
34163425
}
34173426
thread::sleep(Duration::from_millis(10));

0 commit comments

Comments
 (0)