Fix intermittent failure in ledger.work_validation due to random work being above threshold (#2708)
This commit is contained in:
parent
41ce708a55
commit
70dff44aa0
1 changed files with 7 additions and 1 deletions
|
@ -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);
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue