test: remove wallet context from write_wallet_settings_concurrently
This commit is contained in:
1 file changed
+7
-8
@@ -334,12 +334,11 @@ BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain100Setup)
|
|||||||
// concurrently, ensuring no race conditions occur during either process.
|
// concurrently, ensuring no race conditions occur during either process.
|
||||||
BOOST_FIXTURE_TEST_CASE(write_wallet_settings_concurrently, TestingSetup)
|
BOOST_FIXTURE_TEST_CASE(write_wallet_settings_concurrently, TestingSetup)
|
||||||
{
|
{
|
||||||
WalletContext context;
|
auto chain = m_node.chain.get();
|
||||||
context.chain = m_node.chain.get();
|
|
||||||
const auto NUM_WALLETS{5};
|
const auto NUM_WALLETS{5};
|
||||||
|
|
||||||
// Since we're counting the number of wallets, ensure we start without any.
|
// Since we're counting the number of wallets, ensure we start without any.
|
||||||
BOOST_REQUIRE(context.chain->getRwSetting("wallet").isNull());
|
BOOST_REQUIRE(chain->getRwSetting("wallet").isNull());
|
||||||
|
|
||||||
const auto& check_concurrent_wallet = [&](const auto& settings_function, int num_expected_wallets) {
|
const auto& check_concurrent_wallet = [&](const auto& settings_function, int num_expected_wallets) {
|
||||||
std::vector<std::thread> threads;
|
std::vector<std::thread> threads;
|
||||||
@@ -347,19 +346,19 @@ BOOST_FIXTURE_TEST_CASE(write_wallet_settings_concurrently, TestingSetup)
|
|||||||
for (auto i{0}; i < NUM_WALLETS; ++i) threads.emplace_back(settings_function, i);
|
for (auto i{0}; i < NUM_WALLETS; ++i) threads.emplace_back(settings_function, i);
|
||||||
for (auto& t : threads) t.join();
|
for (auto& t : threads) t.join();
|
||||||
|
|
||||||
auto wallets = context.chain->getRwSetting("wallet");
|
auto wallets = chain->getRwSetting("wallet");
|
||||||
BOOST_CHECK_EQUAL(wallets.getValues().size(), num_expected_wallets);
|
BOOST_CHECK_EQUAL(wallets.getValues().size(), num_expected_wallets);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Add NUM_WALLETS wallets concurrently, ensure we end up with NUM_WALLETS stored.
|
// Add NUM_WALLETS wallets concurrently, ensure we end up with NUM_WALLETS stored.
|
||||||
check_concurrent_wallet([&context](int i) {
|
check_concurrent_wallet([&chain](int i) {
|
||||||
Assert(AddWalletSetting(*context.chain, strprintf("wallet_%d", i)));
|
Assert(AddWalletSetting(*chain, strprintf("wallet_%d", i)));
|
||||||
},
|
},
|
||||||
/*num_expected_wallets=*/NUM_WALLETS);
|
/*num_expected_wallets=*/NUM_WALLETS);
|
||||||
|
|
||||||
// Remove NUM_WALLETS wallets concurrently, ensure we end up with 0 wallets.
|
// Remove NUM_WALLETS wallets concurrently, ensure we end up with 0 wallets.
|
||||||
check_concurrent_wallet([&context](int i) {
|
check_concurrent_wallet([&chain](int i) {
|
||||||
Assert(RemoveWalletSetting(*context.chain, strprintf("wallet_%d", i)));
|
Assert(RemoveWalletSetting(*chain, strprintf("wallet_%d", i)));
|
||||||
},
|
},
|
||||||
/*num_expected_wallets=*/0);
|
/*num_expected_wallets=*/0);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user