From 1e6edaf590608c6319dd6d4a0e5470334fd52631 Mon Sep 17 00:00:00 2001 From: driftluo Date: Fri, 11 Oct 2019 10:58:02 +0800 Subject: [PATCH 1/2] test: generate blocks during connected state --- test/src/specs/sync/ibd_process.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/test/src/specs/sync/ibd_process.rs b/test/src/specs/sync/ibd_process.rs index ee2b02c7c5..206f0da239 100644 --- a/test/src/specs/sync/ibd_process.rs +++ b/test/src/specs/sync/ibd_process.rs @@ -138,7 +138,9 @@ impl Spec for IBDProcessWithWhiteList { panic!("refuse to connect fail"); } - node6.disconnect(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); @@ -147,7 +149,12 @@ impl Spec for IBDProcessWithWhiteList { panic!("node6 can't generate blocks to 2"); } - node0.connect_uncheck(node6); + // 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); // IBD only with outbound/whitelist node let rpc_client1 = node1.rpc_client(); From 84defd880cde7ee4f64c9c1793841889681c8bb1 Mon Sep 17 00:00:00 2001 From: driftluo Date: Fri, 11 Oct 2019 12:52:15 +0800 Subject: [PATCH 2/2] test: Remove outbound limit test because of asynchronous timing issues and auto-connect with whiteli --- test/src/specs/p2p/whitelist.rs | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/test/src/specs/p2p/whitelist.rs b/test/src/specs/p2p/whitelist.rs index c2f760945e..f73da78d7f 100644 --- a/test/src/specs/p2p/whitelist.rs +++ b/test/src/specs/p2p/whitelist.rs @@ -98,21 +98,5 @@ impl Spec for WhitelistOnSessionLimit { if !is_connect_peer_num_eq_3 { panic!("whitelist connect fail"); } - - node1.disconnect(&node0); - // whitelist will be connected on inbound reach limit - node1.connect(&node0); - - let is_connect_peer_num_eq_3 = wait_until(10, || { - let peers = rpc_client0.get_peers(); - peers.len() == 3 - && peers - .into_iter() - .all(|node| id_set.contains(&node.node_id.as_str())) - }); - - if !is_connect_peer_num_eq_3 { - panic!("connect fail"); - } } }