Fix for node.fork_publish_inactive (#4382)

By taking a copy of blocks and saving it into a variable we are not giving
a chance to the ASSET_TIMELY to work if the result is not immediately
correct.
This commit is contained in:
Dimitrios Siganos 2024-01-22 16:07:36 +07:00 committed by GitHub
commit 815ac36ae2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -644,10 +644,15 @@ TEST (node, fork_publish_inactive)
ASSERT_EQ (nano::process_result::fork, node.process_local (send2).value ().code);
auto blocks = election->blocks ();
ASSERT_TIMELY_EQ (5s, blocks.size (), 2);
ASSERT_NE (blocks.end (), blocks.find (send1->hash ()));
ASSERT_NE (blocks.end (), blocks.find (send2->hash ()));
ASSERT_TIMELY_EQ (5s, election->blocks ().size (), 2);
auto find_block = [&election] (nano::block_hash hash_a) -> bool {
auto blocks = election->blocks ();
return blocks.end () != blocks.find (hash_a);
};
ASSERT_TRUE (find_block (send1->hash ()));
ASSERT_TRUE (find_block (send2->hash ()));
ASSERT_EQ (election->winner ()->hash (), send1->hash ());
ASSERT_NE (election->winner ()->hash (), send2->hash ());
}