From 73bbdfd8253dc7b9757d9b67244ad981688d5fb7 Mon Sep 17 00:00:00 2001 From: gr0vity-dev <85646666+gr0vity-dev@users.noreply.github.com> Date: Thu, 5 Dec 2024 17:31:32 +0100 Subject: [PATCH] Fix timing issue in active_elections.fork_replacement_tally (#4802) * fix timing issue in active_elections.fork_replacement_tally Wait for election insertion before processing forks * Assert election exists and is the same for each iteration --------- Co-authored-by: gr0vity --- nano/core_test/active_elections.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nano/core_test/active_elections.cpp b/nano/core_test/active_elections.cpp index 5bbc51c818..18a6d91821 100644 --- a/nano/core_test/active_elections.cpp +++ b/nano/core_test/active_elections.cpp @@ -901,6 +901,7 @@ TEST (active_elections, fork_replacement_tally) .build (); // Forks without votes + std::shared_ptr election; for (auto i (0); i < reps_count; i++) { auto fork = builder.make_block () @@ -913,10 +914,12 @@ TEST (active_elections, fork_replacement_tally) .work (*system.work.generate (latest)) .build (); node1.process_active (fork); + + // Assert election exists and is the same for each fork + ASSERT_TIMELY (1s, election = node1.active.election (fork->qualified_root ())); } // Check overflow of blocks - std::shared_ptr election; ASSERT_TIMELY (5s, election = node1.active.election (send_last->qualified_root ())); ASSERT_TIMELY_EQ (5s, max_blocks, election->blocks ().size ());