@@ -51,32 +51,6 @@ static_assert(DEFAULT_TRANSACTION_MINFEE >= DEFAULT_MIN_RELAY_TX_FEE, "wallet mi
5151
5252BOOST_FIXTURE_TEST_SUITE (wallet_tests, WalletTestingSetup)
5353
54- static std::shared_ptr<CWallet> TestLoadWallet (WalletContext& context)
55- {
56- DatabaseOptions options;
57- options.create_flags = WALLET_FLAG_DESCRIPTORS ;
58- DatabaseStatus status;
59- bilingual_str error;
60- std::vector<bilingual_str> warnings;
61- auto database = MakeWalletDatabase (" " , options, status, error);
62- auto wallet = CWallet::Create (context, " " , std::move (database), options.create_flags , error, warnings);
63- if (context.coinjoin_loader ) {
64- // TODO: see CreateWalletWithoutChain
65- AddWallet (context, wallet);
66- }
67- NotifyWalletLoaded (context, wallet);
68- return wallet;
69- }
70-
71- static void TestUnloadWallet (WalletContext& context, std::shared_ptr<CWallet>&& wallet)
72- {
73- std::vector<bilingual_str> warnings;
74- SyncWithValidationInterfaceQueue ();
75- wallet->m_chain_notifications_handler .reset ();
76- RemoveWallet (context, wallet, /* load_on_start=*/ std::nullopt , warnings);
77- UnloadWallet (std::move (wallet));
78- }
79-
8054static CMutableTransaction TestSimpleSpend (const CTransaction& from, uint32_t index, const CKey& key, const CScript& pubkey)
8155{
8256 CMutableTransaction mtx;
@@ -820,8 +794,9 @@ BOOST_FIXTURE_TEST_CASE(CreateWallet, TestChain100Setup)
820794 // being blocked
821795 wallet = TestLoadWallet (context);
822796 BOOST_CHECK (rescan_completed);
823- // AddToWallet events for block_tx and mempool_tx
824- BOOST_CHECK_EQUAL (addtx_count, 2 );
797+ // Loading will also ask for current mempool transactions
798+ // AddToWallet events for block_tx and mempool_tx (x2)
799+ BOOST_CHECK_EQUAL (addtx_count, 3 );
825800 {
826801 LOCK (wallet->cs_wallet );
827802 BOOST_CHECK_EQUAL (wallet->mapWallet .count (block_tx.GetHash ()), 1U );
@@ -835,7 +810,7 @@ BOOST_FIXTURE_TEST_CASE(CreateWallet, TestChain100Setup)
835810 SyncWithValidationInterfaceQueue ();
836811 // AddToWallet events for block_tx and mempool_tx events are counted a
837812 // second time as the notification queue is processed
838- BOOST_CHECK_EQUAL (addtx_count, 4 );
813+ BOOST_CHECK_EQUAL (addtx_count, 5 );
839814
840815 TestUnloadWallet (context, std::move (wallet));
841816
@@ -857,7 +832,9 @@ BOOST_FIXTURE_TEST_CASE(CreateWallet, TestChain100Setup)
857832 SyncWithValidationInterfaceQueue ();
858833 });
859834 wallet = TestLoadWallet (context);
860- BOOST_CHECK_EQUAL (addtx_count, 2 );
835+ // Since mempool transactions are requested at the end of loading, there will
836+ // be 2 additional AddToWallet calls, one from the previous test, and a duplicate for mempool_tx
837+ BOOST_CHECK_EQUAL (addtx_count, 2 + 2 );
861838 {
862839 LOCK (wallet->cs_wallet );
863840 BOOST_CHECK_EQUAL (wallet->mapWallet .count (block_tx.GetHash ()), 1U );
0 commit comments