Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix failure in ledger.work_validation due to random work being above threshold #2708

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion nano/core_test/ledger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2999,8 +2999,14 @@ TEST (ledger, work_validation)

// With random work the block doesn't pass, then modifies the block with sufficient work and ensures a correct result
auto process_block = [&store, &ledger, &pool](nano::block & block_a, nano::block_details const details_a) {
auto threshold = nano::work_threshold (block_a.work_version (), details_a);
// Rarely failed with random work, so modify until it doesn't have enough difficulty
while (block_a.difficulty () >= threshold)
{
block_a.block_work_set (block_a.block_work () + 1);
}
EXPECT_EQ (nano::process_result::insufficient_work, ledger.process (store->tx_begin_write (), block_a).code);
block_a.block_work_set (*pool.generate (block_a.root (), nano::work_threshold (block_a.work_version (), details_a)));
block_a.block_work_set (*pool.generate (block_a.root (), threshold));
EXPECT_EQ (nano::process_result::progress, ledger.process (store->tx_begin_write (), block_a).code);
};

Expand Down