Skip to content

Commit

Permalink
Fix timing issue in active_elections.fork_replacement_tally (#4802)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
gr0vity-dev and gr0vity authored Dec 5, 2024
1 parent 61e6a6b commit 73bbdfd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion nano/core_test/active_elections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,7 @@ TEST (active_elections, fork_replacement_tally)
.build ();

// Forks without votes
std::shared_ptr<nano::election> election;
for (auto i (0); i < reps_count; i++)
{
auto fork = builder.make_block ()
Expand All @@ -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<nano::election> election;
ASSERT_TIMELY (5s, election = node1.active.election (send_last->qualified_root ()));
ASSERT_TIMELY_EQ (5s, max_blocks, election->blocks ().size ());

Expand Down

0 comments on commit 73bbdfd

Please sign in to comment.