From 59d647cfa16464b6ce44181f370527fa981fb332 Mon Sep 17 00:00:00 2001 From: Arya Date: Mon, 3 Oct 2022 22:52:03 -0400 Subject: [PATCH] wait for chain_tip_update before cancelling download in mempool_cancel_mined (#5322) --- zebrad/src/components/mempool/tests/vector.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/zebrad/src/components/mempool/tests/vector.rs b/zebrad/src/components/mempool/tests/vector.rs index 1ecb04193..32c157ea3 100644 --- a/zebrad/src/components/mempool/tests/vector.rs +++ b/zebrad/src/components/mempool/tests/vector.rs @@ -394,7 +394,7 @@ async fn mempool_cancel_mined() -> Result<(), Report> { mut mempool, _peer_set, mut state_service, - _chain_tip_change, + mut chain_tip_change, _tx_verifier, mut recent_syncs, ) = setup(network, u64::MAX).await; @@ -461,6 +461,21 @@ async fn mempool_cancel_mined() -> Result<(), Report> { .await .unwrap(); + // Wait for the chain tip update + if let Err(timeout_error) = timeout( + CHAIN_TIP_UPDATE_WAIT_LIMIT, + chain_tip_change.wait_for_tip_change(), + ) + .await + .map(|change_result| change_result.expect("unexpected chain tip update failure")) + { + info!( + timeout = ?humantime_seconds(CHAIN_TIP_UPDATE_WAIT_LIMIT), + ?timeout_error, + "timeout waiting for chain tip change after committing block" + ); + } + // This is done twice because after the first query the cancellation // is picked up by select!, and after the second the mempool gets the // result and the download future is removed.