Fix race condition in the syncing sim (#944)

* Fix race condition in the syncing sim

* Update another strategy
This commit is contained in:
Age Manning 2020-03-23 18:28:13 +11:00 committed by GitHub
parent 47aef629d1
commit f8bc045a01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 5 deletions

View File

@ -94,7 +94,7 @@ impl<E: EthSpec> LocalNetwork<E> {
.expect("bootnode must have a network"), .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(); let index = self.beacon_nodes.read().len();

View File

@ -94,8 +94,10 @@ pub fn verify_two_nodes_sync<E: EthSpec>(
// Add beacon nodes // Add beacon nodes
network network
.add_beacon_node(beacon_config.clone()) .add_beacon_node(beacon_config.clone())
.join(network.add_beacon_node(beacon_config.clone())) .map(|_| (network, beacon_config))
.map(|_| network) .and_then(|(network, beacon_config)| {
network.add_beacon_node(beacon_config).map(|_| network)
})
}) })
.and_then(move |network| { .and_then(move |network| {
// Delay for `sync_delay` epochs before verifying synced state. // Delay for `sync_delay` epochs before verifying synced state.
@ -128,8 +130,10 @@ pub fn verify_in_between_sync<E: EthSpec>(
// Add a beacon node // Add a beacon node
network network
.add_beacon_node(beacon_config.clone()) .add_beacon_node(beacon_config.clone())
.join(network.add_beacon_node(beacon_config.clone())) .map(|_| (network, beacon_config))
.map(|_| network) .and_then(|(network, beacon_config)| {
network.add_beacon_node(beacon_config).map(|_| network)
})
}) })
.and_then(move |network| { .and_then(move |network| {
// Delay before adding additional syncing nodes. // Delay before adding additional syncing nodes.