txpool: TestApi best_block fix (#12992)

This is a minor clean up.

There was a minor bug in TestApi::add_block: the best block flag for
given number was not cleared when the new best block with the same
number was added.

The usage of is_best_block argument in add_block method in txpool tests
were aligned with the BestBlock event.
This commit is contained in:
Michal Kucharczyk
2022-12-21 17:36:08 +01:00
committed by GitHub
parent 4dc62d7e71
commit a1a9dff12c
2 changed files with 27 additions and 10 deletions
@@ -178,6 +178,18 @@ impl TestApi {
let mut chain = self.chain.write();
chain.block_by_hash.insert(hash, block.clone());
if is_best_block {
chain
.block_by_number
.entry(*block_number)
.or_default()
.iter_mut()
.for_each(|x| {
x.1 = IsBestBlock::No;
});
}
chain
.block_by_number
.entry(*block_number)