@@ -42,26 +42,6 @@ static_assert(WALLET_INCREMENTAL_RELAY_FEE >= DEFAULT_INCREMENTAL_RELAY_FEE, "wa
4242
4343BOOST_FIXTURE_TEST_SUITE (wallet_tests, WalletTestingSetup)
4444
45- static std::shared_ptr<CWallet> TestLoadWallet (WalletContext& context)
46- {
47- DatabaseOptions options;
48- options.create_flags = WALLET_FLAG_DESCRIPTORS;
49- DatabaseStatus status;
50- bilingual_str error;
51- std::vector<bilingual_str> warnings;
52- auto database = MakeWalletDatabase (" " , options, status, error);
53- auto wallet = CWallet::Create (context, " " , std::move (database), options.create_flags , error, warnings);
54- NotifyWalletLoaded (context, wallet);
55- return wallet;
56- }
57-
58- static void TestUnloadWallet (std::shared_ptr<CWallet>&& wallet)
59- {
60- SyncWithValidationInterfaceQueue ();
61- wallet->m_chain_notifications_handler .reset ();
62- UnloadWallet (std::move (wallet));
63- }
64-
6545static CMutableTransaction TestSimpleSpend (const CTransaction& from, uint32_t index, const CKey& key, const CScript& pubkey)
6646{
6747 CMutableTransaction mtx;
@@ -845,10 +825,11 @@ BOOST_FIXTURE_TEST_CASE(CreateWallet, TestChain100Setup)
845825
846826 // Reload wallet and make sure new transactions are detected despite events
847827 // being blocked
828+ // Loading will also ask for current mempool transactions
848829 wallet = TestLoadWallet (context);
849830 BOOST_CHECK (rescan_completed);
850- // AddToWallet events for block_tx and mempool_tx
851- BOOST_CHECK_EQUAL (addtx_count, 2 );
831+ // AddToWallet events for block_tx and mempool_tx (x2)
832+ BOOST_CHECK_EQUAL (addtx_count, 3 );
852833 {
853834 LOCK (wallet->cs_wallet );
854835 BOOST_CHECK_EQUAL (wallet->mapWallet .count (block_tx.GetHash ()), 1U );
@@ -862,7 +843,7 @@ BOOST_FIXTURE_TEST_CASE(CreateWallet, TestChain100Setup)
862843 SyncWithValidationInterfaceQueue ();
863844 // AddToWallet events for block_tx and mempool_tx events are counted a
864845 // second time as the notification queue is processed
865- BOOST_CHECK_EQUAL (addtx_count, 4 );
846+ BOOST_CHECK_EQUAL (addtx_count, 5 );
866847
867848
868849 TestUnloadWallet (std::move (wallet));
@@ -885,7 +866,9 @@ BOOST_FIXTURE_TEST_CASE(CreateWallet, TestChain100Setup)
885866 SyncWithValidationInterfaceQueue ();
886867 });
887868 wallet = TestLoadWallet (context);
888- BOOST_CHECK_EQUAL (addtx_count, 2 );
869+ // Since mempool transactions are requested at the end of loading, there will
870+ // be 2 additional AddToWallet calls, one from the previous test, and a duplicate for mempool_tx
871+ BOOST_CHECK_EQUAL (addtx_count, 2 + 2 );
889872 {
890873 LOCK (wallet->cs_wallet );
891874 BOOST_CHECK_EQUAL (wallet->mapWallet .count (block_tx.GetHash ()), 1U );
0 commit comments