Skip to content

Commit

Permalink
During setup, use direct ledger confirmation rather than starting / f…
Browse files Browse the repository at this point in the history
…orcing an election.

Tests wanting to test election behaviour directly can start their own elections.
Though this doesn't fix any specific test problem, this change should be friendly to reducing intermittent test failure due to object interaction effects of running actual network elections.
  • Loading branch information
clemahieu committed May 9, 2024
1 parent 1c44ade commit 92764ee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
6 changes: 2 additions & 4 deletions nano/slow_test/vote_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ nano::keypair setup_rep (nano::test::system & system, nano::node & node, nano::u
.build ();

EXPECT_TRUE (nano::test::process (node, { send, open }));
EXPECT_TRUE (nano::test::start_elections (system, node, { send, open }, true));
EXPECT_TIMELY (5s, nano::test::confirmed (node, { send, open }));
nano::test::confirm (node.ledger, open->hash ());

return key;
}
Expand Down Expand Up @@ -107,8 +106,7 @@ std::vector<std::shared_ptr<nano::block>> setup_blocks (nano::test::system & sys
EXPECT_TRUE (nano::test::process (node, receives));

// Confirm whole genesis chain at once
EXPECT_TRUE (nano::test::start_elections (system, node, { sends.back () }, true));
EXPECT_TIMELY (5s, nano::test::confirmed (node, { sends }));
nano::test::confirm (node.ledger, sends.back ()->hash ());

std::cout << "setup_blocks done" << std::endl;

Expand Down
15 changes: 7 additions & 8 deletions nano/test_common/chains.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ nano::block_list_t nano::test::setup_chain (nano::test::system & system, nano::n
if (confirm)
{
// Confirm whole chain at once
EXPECT_TRUE (nano::test::start_elections (system, node, { blocks.back () }, true));
EXPECT_TIMELY (5s, nano::test::confirmed (node, blocks));
nano::test::confirm (node.ledger, blocks);
}

return blocks;
Expand Down Expand Up @@ -84,8 +83,7 @@ std::vector<std::pair<nano::account, nano::block_list_t>> nano::test::setup_chai
if (confirm)
{
// Ensure blocks are in the ledger and confirmed
EXPECT_TRUE (nano::test::start_elections (system, node, { send, open }, true));
EXPECT_TIMELY (5s, nano::test::confirmed (node, { send, open }));
nano::test::confirm (node.ledger, open);
}

auto added_blocks = nano::test::setup_chain (system, node, block_count, key, confirm);
Expand Down Expand Up @@ -143,8 +141,7 @@ nano::block_list_t nano::test::setup_independent_blocks (nano::test::system & sy
}

// Confirm whole genesis chain at once
EXPECT_TRUE (nano::test::start_elections (system, node, { latest }, true));
EXPECT_TIMELY (5s, nano::test::confirmed (node, { latest }));
nano::test::confirm (node.ledger, latest);

return blocks;
}
Expand Down Expand Up @@ -177,8 +174,10 @@ std::pair<std::shared_ptr<nano::block>, std::shared_ptr<nano::block>> nano::test
.build ();

EXPECT_TRUE (nano::test::process (node, { send, open }));
EXPECT_TRUE (nano::test::start_elections (system, node, { send, open }, force_confirm));
EXPECT_TIMELY (5s, nano::test::confirmed (node, { send, open }));
if (force_confirm)
{
nano::test::confirm (node.ledger, open);
}
return std::make_pair (send, open);
}

Expand Down

0 comments on commit 92764ee

Please sign in to comment.