Skip to content

Commit

Permalink
test: generate blocks during connected state
Browse files Browse the repository at this point in the history
  • Loading branch information
driftluo committed Oct 11, 2019
1 parent f25304e commit c1a3185
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions test/src/specs/sync/ibd_process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);

Expand Down

0 comments on commit c1a3185

Please sign in to comment.