diff --git a/test/src/specs/sync/ibd_process.rs b/test/src/specs/sync/ibd_process.rs index a5176c9dca7..206f0da2397 100644 --- a/test/src/specs/sync/ibd_process.rs +++ b/test/src/specs/sync/ibd_process.rs @@ -138,18 +138,9 @@ impl Spec for IBDProcessWithWhiteList { panic!("refuse to connect fail"); } - node6.disconnect(node0); - - // Make sure both sides are disconnected - let is_disconnect_already = wait_until(10, || { - let peers = rpc_client0.get_peers(); - peers.iter().any(|peer| peer.node_id == node6.node_id()) - }); - - if is_disconnect_already { - panic!("node6 can't disconnect with node0"); - } - + // After the whitelist is disconnected, it will always try to reconnect. + // In order to ensure that the node6 has already generated two blocks when reconnecting, + // it must be in the connected state, and then disconnected. node6.generate_blocks(2); let generate_res = wait_until(10, || net.nodes[6].get_tip_block_number() == 2); @@ -158,6 +149,10 @@ impl Spec for IBDProcessWithWhiteList { panic!("node6 can't generate blocks to 2"); } + // Although the disconnection of the whitelist is automatically reconnected for node0, + // the disconnect operation is still needed here to instantly refresh the state of node6 in node0. + node6.disconnect(node0); + // Make sure node0 re-connect with node6 node0.connect(node6);