@@ -337,15 +337,16 @@ BOOST_FIXTURE_TEST_CASE(coin_mark_dirty_immature_credit, TestChain100Setup)
337337 BOOST_CHECK_EQUAL (wtx.GetImmatureCredit ()[CAsset ()], 50 *COIN );
338338}
339339
340- static int64_t AddTx (CWallet& wallet, uint32_t lockTime, int64_t mockTime, int64_t blockTime)
340+ static int64_t AddTx (ChainstateManager& chainman, CWallet& wallet, uint32_t lockTime, int64_t mockTime, int64_t blockTime)
341341{
342342 CMutableTransaction tx;
343343 CWalletTx::Confirmation confirm;
344344 tx.nLockTime = lockTime;
345345 SetMockTime (mockTime);
346346 CBlockIndex* block = nullptr ;
347347 if (blockTime > 0 ) {
348- auto inserted = ::BlockIndex ().emplace (GetRandHash (), new CBlockIndex);
348+ LOCK (cs_main);
349+ auto inserted = chainman.BlockIndex ().emplace (GetRandHash (), new CBlockIndex);
349350 assert (inserted.second );
350351 const uint256& hash = inserted.first ->first ;
351352 block = inserted.first ->second ;
@@ -367,24 +368,24 @@ static int64_t AddTx(CWallet& wallet, uint32_t lockTime, int64_t mockTime, int64
367368BOOST_AUTO_TEST_CASE (ComputeTimeSmart)
368369{
369370 // New transaction should use clock time if lower than block time.
370- BOOST_CHECK_EQUAL (AddTx (m_wallet, 1 , 100 , 120 ), 100 );
371+ BOOST_CHECK_EQUAL (AddTx (*m_node. chainman , m_wallet, 1 , 100 , 120 ), 100 );
371372
372373 // Test that updating existing transaction does not change smart time.
373- BOOST_CHECK_EQUAL (AddTx (m_wallet, 1 , 200 , 220 ), 100 );
374+ BOOST_CHECK_EQUAL (AddTx (*m_node. chainman , m_wallet, 1 , 200 , 220 ), 100 );
374375
375376 // New transaction should use clock time if there's no block time.
376- BOOST_CHECK_EQUAL (AddTx (m_wallet, 2 , 300 , 0 ), 300 );
377+ BOOST_CHECK_EQUAL (AddTx (*m_node. chainman , m_wallet, 2 , 300 , 0 ), 300 );
377378
378379 // New transaction should use block time if lower than clock time.
379- BOOST_CHECK_EQUAL (AddTx (m_wallet, 3 , 420 , 400 ), 400 );
380+ BOOST_CHECK_EQUAL (AddTx (*m_node. chainman , m_wallet, 3 , 420 , 400 ), 400 );
380381
381382 // New transaction should use latest entry time if higher than
382383 // min(block time, clock time).
383- BOOST_CHECK_EQUAL (AddTx (m_wallet, 4 , 500 , 390 ), 400 );
384+ BOOST_CHECK_EQUAL (AddTx (*m_node. chainman , m_wallet, 4 , 500 , 390 ), 400 );
384385
385386 // If there are future entries, new transaction should use time of the
386387 // newest entry that is no more than 300 seconds ahead of the clock time.
387- BOOST_CHECK_EQUAL (AddTx (m_wallet, 5 , 50 , 600 ), 300 );
388+ BOOST_CHECK_EQUAL (AddTx (*m_node. chainman , m_wallet, 5 , 50 , 600 ), 300 );
388389
389390 // Reset mock time for other tests.
390391 SetMockTime (0 );
0 commit comments