Fix use after scope error active_transactions.vacancy test (#4002)

This commit is contained in:
Thiago Silva 2022-11-22 21:41:55 -03:00 committed by GitHub
commit f05cb7dfb5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1286,6 +1286,8 @@ TEST (active_transactions, list_active)
} }
TEST (active_transactions, vacancy) TEST (active_transactions, vacancy)
{
std::atomic<bool> updated = false;
{ {
nano::test::system system; nano::test::system system;
nano::node_config config{ nano::test::get_available_port (), system.logging }; nano::node_config config{ nano::test::get_available_port (), system.logging };
@ -1301,7 +1303,6 @@ TEST (active_transactions, vacancy)
.sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub)
.work (*system.work.generate (nano::dev::genesis->hash ())) .work (*system.work.generate (nano::dev::genesis->hash ()))
.build_shared (); .build_shared ();
std::atomic<bool> updated = false;
node.active.vacancy_update = [&updated] () { updated = true; }; node.active.vacancy_update = [&updated] () { updated = true; };
ASSERT_EQ (nano::process_result::progress, node.process (*send).code); ASSERT_EQ (nano::process_result::progress, node.process (*send).code);
ASSERT_EQ (1, node.active.vacancy ()); ASSERT_EQ (1, node.active.vacancy ());
@ -1318,6 +1319,7 @@ TEST (active_transactions, vacancy)
ASSERT_EQ (1, node.active.vacancy ()); ASSERT_EQ (1, node.active.vacancy ());
ASSERT_EQ (0, node.active.size ()); ASSERT_EQ (0, node.active.size ());
} }
}
// Ensure transactions in excess of capacity are removed in fifo order // Ensure transactions in excess of capacity are removed in fifo order
TEST (active_transactions, fifo) TEST (active_transactions, fifo)