@@ -820,35 +820,30 @@ BOOST_FIXTURE_TEST_CASE(ZapSelectTx, TestChain100Setup)
820820 context.args = &gArgs ;
821821 context.chain = m_node.chain .get ();
822822 auto wallet = TestLoadWallet (context);
823- AddKey (*wallet, coinbaseKey);
823+ CKey key;
824+ key.MakeNewKey (true );
825+ AddKey (*wallet, key);
824826
825- // rescan to ensure coinbase transactions from test fixture are picked up by the wallet
826- {
827- WalletRescanReserver reserver (*wallet);
828- reserver.reserve ();
829- wallet->ScanForWalletTransactions (m_node.chain ->getBlockHash (0 ), 0 , /* max height= */ {}, reserver, /* update= */ true );
830- }
831- // create one more block to get the first block coinbase to maturity
827+ std::string error;
832828 m_coinbase_txns.push_back (CreateAndProcessBlock ({}, GetScriptForRawPubKey (coinbaseKey.GetPubKey ())).vtx [0 ]);
833- // spend first coinbase tx
834- auto spend_tx = TestSimpleSpend (*m_coinbase_txns[0 ], 0 , coinbaseKey, GetScriptForRawPubKey (coinbaseKey.GetPubKey ()));
835- CreateAndProcessBlock ({spend_tx}, GetScriptForRawPubKey (coinbaseKey.GetPubKey ()));
829+ auto block_tx = TestSimpleSpend (*m_coinbase_txns[0 ], 0 , coinbaseKey, GetScriptForRawPubKey (key.GetPubKey ()));
830+ CreateAndProcessBlock ({block_tx}, GetScriptForRawPubKey (coinbaseKey.GetPubKey ()));
836831
837832 SyncWithValidationInterfaceQueue ();
838833
839834 {
840- auto spend_tx_hash = spend_tx .GetHash ();
835+ auto block_hash = block_tx .GetHash ();
841836 auto prev_hash = m_coinbase_txns[0 ]->GetHash ();
842837
843838 LOCK (wallet->cs_wallet );
844839 BOOST_CHECK (wallet->HasWalletSpend (prev_hash));
845- BOOST_CHECK_EQUAL (wallet->mapWallet .count (spend_tx_hash ), 1u );
840+ BOOST_CHECK_EQUAL (wallet->mapWallet .count (block_hash ), 1u );
846841
847- std::vector<uint256> vHashIn{spend_tx_hash }, vHashOut;
842+ std::vector<uint256> vHashIn{ block_hash }, vHashOut;
848843 BOOST_CHECK_EQUAL (wallet->ZapSelectTx (vHashIn, vHashOut), DBErrors::LOAD_OK);
849844
850845 BOOST_CHECK (!wallet->HasWalletSpend (prev_hash));
851- BOOST_CHECK_EQUAL (wallet->mapWallet .count (spend_tx_hash ), 0u );
846+ BOOST_CHECK_EQUAL (wallet->mapWallet .count (block_hash ), 0u );
852847 }
853848
854849 TestUnloadWallet (std::move (wallet));
0 commit comments