From f632d92c896c2ae192349a98f3f666bda73bba7b Mon Sep 17 00:00:00 2001 From: gr0vity Date: Wed, 4 Dec 2024 22:01:13 +0100 Subject: [PATCH 1/2] fix timing issue in active_elections.fork_replacement_tally Wait for election insertion before processing forks --- nano/core_test/active_elections.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/nano/core_test/active_elections.cpp b/nano/core_test/active_elections.cpp index 5bbc51c818..2edb0c7844 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,15 @@ TEST (active_elections, fork_replacement_tally) .work (*system.work.generate (latest)) .build (); node1.process_active (fork); + + // Assert election exists on first iteration + if (i == 0) + { + ASSERT_TIMELY (5s, 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 ()); From 9a92ec25ee8da8f3036ce9dc23b5be1fdf2c0ab3 Mon Sep 17 00:00:00 2001 From: gr0vity Date: Thu, 5 Dec 2024 14:52:00 +0100 Subject: [PATCH 2/2] Assert election exists and is the same for each iteration --- nano/core_test/active_elections.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/nano/core_test/active_elections.cpp b/nano/core_test/active_elections.cpp index 2edb0c7844..18a6d91821 100644 --- a/nano/core_test/active_elections.cpp +++ b/nano/core_test/active_elections.cpp @@ -915,11 +915,8 @@ TEST (active_elections, fork_replacement_tally) .build (); node1.process_active (fork); - // Assert election exists on first iteration - if (i == 0) - { - ASSERT_TIMELY (5s, election = node1.active.election (fork->qualified_root ())); - } + // Assert election exists and is the same for each fork + ASSERT_TIMELY (1s, election = node1.active.election (fork->qualified_root ())); } // Check overflow of blocks