Skip to content

Commit

Permalink
chore: use large timeout value for integration test (#954)
Browse files Browse the repository at this point in the history
  • Loading branch information
quake authored and doitian committed Jun 5, 2019
1 parent c38856c commit 41ea649
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 37 deletions.
5 changes: 3 additions & 2 deletions test/src/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,11 @@ impl Net {
});
}

pub fn waiting_for_sync(&self, target: BlockNumber, timeout: u64) {
pub fn waiting_for_sync(&self, target: BlockNumber) {
let rpc_clients: Vec<_> = self.nodes.iter().map(Node::rpc_client).collect();
let mut tip_numbers: HashSet<BlockNumber> = HashSet::with_capacity(self.nodes.len());
let result = wait_until(timeout, || {
// 60 seconds is a reasonable timeout to sync, even for poor CI server
let result = wait_until(60, || {
tip_numbers = rpc_clients
.iter()
.map(|rpc_client| rpc_client.get_tip_block_number())
Expand Down
6 changes: 3 additions & 3 deletions test/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,12 @@ impl Node {
}
}

pub fn waiting_for_sync(&self, node: &Node, target: BlockNumber, timeout: u64) {
pub fn waiting_for_sync(&self, node: &Node, target: BlockNumber) {
let self_rpc_client = self.rpc_client();
let node_rpc_client = node.rpc_client();
let (mut self_tip_number, mut node_tip_number) = (0, 0);

let result = wait_until(timeout, || {
// 60 seconds is a reasonable timeout to sync, even for poor CI server
let result = wait_until(60, || {
self_tip_number = self_rpc_client.get_tip_block_number();
node_tip_number = node_rpc_client.get_tip_block_number();
self_tip_number == node_tip_number && target == self_tip_number
Expand Down
4 changes: 2 additions & 2 deletions test/src/specs/relay/compact_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ impl CompactBlockBasic {
// Make node0 and node1 reach the same height
node1.generate_block();
node0.connect(node1);
node0.waiting_for_sync(node1, node0.get_tip_block().header().number(), 20);
node0.waiting_for_sync(node1, node0.get_tip_block().header().number());

// Net consume and ignore the recent blocks
clear_messages(net);
Expand Down Expand Up @@ -191,7 +191,7 @@ impl CompactBlockBasic {

// Submit the new block to node1. We expect node1 will relay the new block to node0.
node1.submit_block(&block);
node1.waiting_for_sync(node0, node1.get_tip_block().header().number(), 20);
node1.waiting_for_sync(node0, node1.get_tip_block().header().number());
}
}

Expand Down
4 changes: 2 additions & 2 deletions test/src/specs/relay/transaction_relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl Spec for TransactionRelayMultiple {
node0.generate_block();
node0.generate_block();
node0.generate_block();
net.waiting_for_sync(4, 10);
net.waiting_for_sync(4);

info!("Send multiple transactions to node0");
let tx_hash = transaction.hash().to_owned();
Expand All @@ -101,7 +101,7 @@ impl Spec for TransactionRelayMultiple {
node0.generate_block();
node0.generate_block();
node0.generate_block();
net.waiting_for_sync(7, 30);
net.waiting_for_sync(7);

info!("All transactions should be relayed and mined");
node0.assert_tx_pool_size(0, 0);
Expand Down
42 changes: 21 additions & 21 deletions test/src/specs/sync/chain_forks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl Spec for ChainFork1 {

info!("Connect node0 to node1");
node0.connect(node1);
node0.waiting_for_sync(node1, 2, 10);
node0.waiting_for_sync(node1, 2);
info!("Disconnect node1");
node0.disconnect(node1);

Expand All @@ -34,7 +34,7 @@ impl Spec for ChainFork1 {

info!("Reconnect node0 to node1");
node0.connect(node1);
net.waiting_for_sync(4, 10);
net.waiting_for_sync(4);
}

fn num_nodes(&self) -> usize {
Expand Down Expand Up @@ -66,29 +66,29 @@ impl Spec for ChainFork2 {
info!("Connect all nodes");
node0.connect(node1);
node0.connect(node2);
net.waiting_for_sync(2, 10);
net.waiting_for_sync(2);
info!("Disconnect all nodes");
net.disconnect_all();

info!("Generate 1 block (C) on node0");
node0.generate_blocks(1);
node0.connect(node2);
node0.waiting_for_sync(node2, 3, 10);
node0.waiting_for_sync(node2, 3);
info!("Disconnect node2");
node0.disconnect(node2);

info!("Generate 2 blocks (D, E) on node1");
node1.generate_blocks(2);
info!("Reconnect node1");
node0.connect(node1);
node0.waiting_for_sync(node1, 4, 10);
node0.waiting_for_sync(node1, 4);

info!("Generate 2 blocks (F, G) on node2");
node2.generate_blocks(2);
info!("Reconnect node2");
node0.connect(node2);
node1.connect(node2);
net.waiting_for_sync(5, 10);
net.waiting_for_sync(5);
}

fn num_nodes(&self) -> usize {
Expand Down Expand Up @@ -125,15 +125,15 @@ impl Spec for ChainFork3 {
info!("Connect all nodes");
node0.connect(node1);
node0.connect(node2);
net.waiting_for_sync(2, 10);
net.waiting_for_sync(2);

info!("Disconnect all nodes");
net.disconnect_all();

info!("Generate 1 block (C) on node0");
node0.generate_blocks(1);
node0.connect(node2);
node0.waiting_for_sync(node2, 3, 10);
node0.waiting_for_sync(node2, 3);
info!("Disconnect node2");
node0.disconnect(node2);

Expand All @@ -160,7 +160,7 @@ impl Spec for ChainFork3 {
info!("Reconnect node2");
node0.connect(node2);
node1.connect(node2);
node0.waiting_for_sync(node2, 4, 10);
node0.waiting_for_sync(node2, 4);
}

fn num_nodes(&self) -> usize {
Expand Down Expand Up @@ -197,15 +197,15 @@ impl Spec for ChainFork4 {
info!("Connect all nodes");
node0.connect(node1);
node0.connect(node2);
net.waiting_for_sync(2, 10);
net.waiting_for_sync(2);

info!("Disconnect all nodes");
net.disconnect_all();

info!("Generate 1 block (C) on node0");
node0.generate_blocks(1);
node0.connect(node2);
node0.waiting_for_sync(node2, 3, 10);
node0.waiting_for_sync(node2, 3);
info!("Disconnect node2");
node0.disconnect(node2);

Expand All @@ -232,7 +232,7 @@ impl Spec for ChainFork4 {
info!("Reconnect node2");
node0.connect(node2);
node1.connect(node2);
node0.waiting_for_sync(node2, 4, 10);
node0.waiting_for_sync(node2, 4);
}

fn num_nodes(&self) -> usize {
Expand Down Expand Up @@ -272,15 +272,15 @@ impl Spec for ChainFork5 {
info!("Connect all nodes");
node0.connect(node1);
node0.connect(node2);
net.waiting_for_sync(2, 10);
net.waiting_for_sync(2);

info!("Disconnect all nodes");
net.disconnect_all();

info!("Generate 1 block (C) on node0");
node0.generate_blocks(1);
node0.connect(node2);
node0.waiting_for_sync(node2, 3, 10);
node0.waiting_for_sync(node2, 3);
info!("Disconnect node2");
node0.disconnect(node2);

Expand Down Expand Up @@ -308,7 +308,7 @@ impl Spec for ChainFork5 {
info!("Reconnect node2");
node0.connect(node2);
node1.connect(node2);
node0.waiting_for_sync(node2, 4, 10);
node0.waiting_for_sync(node2, 4);
}

fn num_nodes(&self) -> usize {
Expand Down Expand Up @@ -345,15 +345,15 @@ impl Spec for ChainFork6 {
info!("Connect all nodes");
node0.connect(node1);
node0.connect(node2);
net.waiting_for_sync(2, 10);
net.waiting_for_sync(2);

info!("Disconnect all nodes");
net.disconnect_all();

info!("Generate 1 block (C) on node0");
node0.generate_blocks(1);
node0.connect(node2);
node0.waiting_for_sync(node2, 3, 10);
node0.waiting_for_sync(node2, 3);
info!("Disconnect node2");
node0.disconnect(node2);

Expand All @@ -376,7 +376,7 @@ impl Spec for ChainFork6 {
info!("Reconnect node2");
node0.connect(node2);
node1.connect(node2);
node0.waiting_for_sync(node2, 4, 10);
node0.waiting_for_sync(node2, 4);
}

fn num_nodes(&self) -> usize {
Expand Down Expand Up @@ -413,15 +413,15 @@ impl Spec for ChainFork7 {
info!("Connect all nodes");
node0.connect(node1);
node0.connect(node2);
net.waiting_for_sync(2, 10);
net.waiting_for_sync(2);

info!("Disconnect all nodes");
net.disconnect_all();

info!("Generate 1 block (C) on node0");
node0.generate_blocks(1);
node0.connect(node2);
node0.waiting_for_sync(node2, 3, 10);
node0.waiting_for_sync(node2, 3);
info!("Disconnect node2");
node0.disconnect(node2);

Expand Down Expand Up @@ -452,7 +452,7 @@ impl Spec for ChainFork7 {
info!("Reconnect node2");
node0.connect(node2);
node1.connect(node2);
node0.waiting_for_sync(node2, 4, 10);
node0.waiting_for_sync(node2, 4);
}

fn num_nodes(&self) -> usize {
Expand Down
8 changes: 3 additions & 5 deletions test/src/specs/sync/sync_timeout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl Spec for SyncTimeout {
node0.connect(node2);
node0.connect(node3);
node0.connect(node4);
net.waiting_for_sync(2, 10);
net.waiting_for_sync(2);

info!("Disconnect all nodes");
net.disconnect_all();
Expand All @@ -30,9 +30,8 @@ impl Spec for SyncTimeout {
node0.generate_blocks(200);

node0.connect(node1);
// 60 seconds is a reasonable timeout to sync, even for poor CI server
info!("Waiting for node0 and node1 sync");
node0.waiting_for_sync(node1, 202, 60);
node0.waiting_for_sync(node1, 202);

info!("Generate 200 blocks on node1");
node1.generate_blocks(200);
Expand All @@ -43,9 +42,8 @@ impl Spec for SyncTimeout {
node3.connect(node1);
node4.connect(node0);
node4.connect(node1);
// 60 seconds is a reasonable timeout to sync, even for poor CI server
info!("Waiting for all nodes sync");
net.waiting_for_sync(402, 60);
net.waiting_for_sync(402);
}

fn num_nodes(&self) -> usize {
Expand Down
2 changes: 1 addition & 1 deletion test/src/specs/tx_pool/pool_reconcile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl Spec for PoolReconcile {
info!("Connect node0 to node1");
node0.connect(node1);

net.waiting_for_sync(5, 10);
net.waiting_for_sync(5);

info!("Tx should be re-added to node0's pool");
assert!(node0
Expand Down
2 changes: 1 addition & 1 deletion test/src/specs/tx_pool/pool_resurrect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl Spec for PoolResurrect {

info!("Connect node0 to node1, waiting for sync");
node0.connect(node1);
net.waiting_for_sync(5, 10);
net.waiting_for_sync(5);

info!("6 txs should be returned to node0 pending pool");
node0.assert_tx_pool_size(txs_hash.len() as u64, 0);
Expand Down

0 comments on commit 41ea649

Please sign in to comment.