From a0e7463732c8bd6b80ad978805a21affb18e6073 Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Tue, 28 Sep 2021 18:27:44 +0200 Subject: [PATCH] fix `mockBlock` for current slot (#2915) In #2867 a regression was introduced that broke `mockBlock` when used to compute a block for the current state. This patch fixes the regression. --- tests/mocking/mock_blocks.nim | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/mocking/mock_blocks.nim b/tests/mocking/mock_blocks.nim index 7505eb6a2..5e272caf5 100644 --- a/tests/mocking/mock_blocks.nim +++ b/tests/mocking/mock_blocks.nim @@ -52,10 +52,12 @@ proc mockBlock*( ## TODO don't do this gradual construction, for exception safety ## Mock a BeaconBlock for the specific slot - var cache = StateCache() - var rewards = RewardInfo() - var tmpState = assignClone(state) - doAssert process_slots(cfg, tmpState[], slot, cache, rewards, flags = {}) + var + cache = StateCache() + tmpState = assignClone(state) + if getStateField(state, slot) != slot: + var rewards = RewardInfo() + doAssert process_slots(cfg, tmpState[], slot, cache, rewards, flags = {}) var previous_block_header = getStateField(tmpState[], latest_block_header) if previous_block_header.state_root == ZERO_HASH: