From edf250cea9a0f19158e2090ff0a8f12f433ac553 Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Mon, 27 Jul 2020 08:42:19 +0000 Subject: [PATCH] Fix block check in simulator (#1398) ## Issue Addressed Closes #1397 ## Proposed Changes This race condition seemed to be cropping up a lot (again in #1381), so I figured I'd fix it ASAP --- testing/simulator/src/checks.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/testing/simulator/src/checks.rs b/testing/simulator/src/checks.rs index 2e93d1b4e55..43ceaa14fdb 100644 --- a/testing/simulator/src/checks.rs +++ b/testing/simulator/src/checks.rs @@ -136,11 +136,16 @@ pub async fn verify_full_block_production_up_to( slot_delay(slot, slot_duration).await; let beacon_nodes = network.beacon_nodes.read(); let beacon_chain = beacon_nodes[0].client.beacon_chain().unwrap(); - let chain_dump = beacon_chain.chain_dump().unwrap(); - if chain_dump.len() != slot.as_usize() + 1 { + let num_blocks = beacon_chain + .chain_dump() + .unwrap() + .iter() + .take_while(|s| s.beacon_block.slot() <= slot) + .count(); + if num_blocks != slot.as_usize() + 1 { return Err(format!( "There wasn't a block produced at every slot, got: {}, expected: {}", - chain_dump.len(), + num_blocks, slot.as_usize() + 1 )); }