From f8bc045a01764f81c32f48c496cabee8281f965e Mon Sep 17 00:00:00 2001 From: Age Manning Date: Mon, 23 Mar 2020 18:28:13 +1100 Subject: [PATCH] Fix race condition in the syncing sim (#944) * Fix race condition in the syncing sim * Update another strategy --- tests/simulator/src/local_network.rs | 2 +- tests/simulator/src/sync_sim.rs | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/simulator/src/local_network.rs b/tests/simulator/src/local_network.rs index c659b2f65..ad01eaf25 100644 --- a/tests/simulator/src/local_network.rs +++ b/tests/simulator/src/local_network.rs @@ -94,7 +94,7 @@ impl LocalNetwork { .expect("bootnode must have a network"), ); }) - .expect("should have atleast one node"); + .expect("should have at least one node"); let index = self.beacon_nodes.read().len(); diff --git a/tests/simulator/src/sync_sim.rs b/tests/simulator/src/sync_sim.rs index 6c18406b6..13fa61d04 100644 --- a/tests/simulator/src/sync_sim.rs +++ b/tests/simulator/src/sync_sim.rs @@ -94,8 +94,10 @@ pub fn verify_two_nodes_sync( // Add beacon nodes network .add_beacon_node(beacon_config.clone()) - .join(network.add_beacon_node(beacon_config.clone())) - .map(|_| network) + .map(|_| (network, beacon_config)) + .and_then(|(network, beacon_config)| { + network.add_beacon_node(beacon_config).map(|_| network) + }) }) .and_then(move |network| { // Delay for `sync_delay` epochs before verifying synced state. @@ -128,8 +130,10 @@ pub fn verify_in_between_sync( // Add a beacon node network .add_beacon_node(beacon_config.clone()) - .join(network.add_beacon_node(beacon_config.clone())) - .map(|_| network) + .map(|_| (network, beacon_config)) + .and_then(|(network, beacon_config)| { + network.add_beacon_node(beacon_config).map(|_| network) + }) }) .and_then(move |network| { // Delay before adding additional syncing nodes.