@@ -82,11 +82,11 @@ constexpr static struct {
82
82
{2 , 0xbbbeb305 }, {2 , 0xfe1c810a },
83
83
};
84
84
85
- static CBlockIndex CreateBlockIndex (int nHeight) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
85
+ static CBlockIndex CreateBlockIndex (int nHeight, CBlockIndex* active_chain_tip ) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
86
86
{
87
87
CBlockIndex index;
88
88
index.nHeight = nHeight;
89
- index.pprev = :: ChainActive (). Tip () ;
89
+ index.pprev = active_chain_tip ;
90
90
return index;
91
91
}
92
92
@@ -440,7 +440,11 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
440
440
m_node.mempool ->addUnchecked (entry.Fee (HIGHFEE).Time (GetTime ()).SpendsCoinbase (true ).FromTx (tx));
441
441
BOOST_CHECK (CheckFinalTx (::ChainActive ().Tip (), CTransaction (tx), flags)); // Locktime passes
442
442
BOOST_CHECK (!TestSequenceLocks (CTransaction (tx), flags)); // Sequence locks fail
443
- BOOST_CHECK (SequenceLocks (CTransaction (tx), flags, prevheights, CreateBlockIndex (::ChainActive ().Tip ()->nHeight + 2 ))); // Sequence locks pass on 2nd block
443
+
444
+ {
445
+ CBlockIndex* active_chain_tip = m_node.chainman ->ActiveChain ().Tip ();
446
+ BOOST_CHECK (SequenceLocks (CTransaction (tx), flags, prevheights, CreateBlockIndex (active_chain_tip->nHeight + 2 , active_chain_tip))); // Sequence locks pass on 2nd block
447
+ }
444
448
445
449
// relative time locked
446
450
tx.vin [0 ].prevout .hash = txFirst[1 ]->GetHash ();
@@ -452,8 +456,13 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
452
456
BOOST_CHECK (!TestSequenceLocks (CTransaction (tx), flags)); // Sequence locks fail
453
457
454
458
for (int i = 0 ; i < CBlockIndex::nMedianTimeSpan; i++)
455
- ::ChainActive ().Tip()->GetAncestor(::ChainActive().Tip()->nHeight - i)->nTime += 512; // Trick the MedianTimePast
456
- BOOST_CHECK (SequenceLocks (CTransaction (tx), flags, prevheights, CreateBlockIndex (::ChainActive ().Tip ()->nHeight + 1 ))); // Sequence locks pass 512 seconds later
459
+ m_node.chainman ->ActiveChain ().Tip ()->GetAncestor (m_node.chainman ->ActiveChain ().Tip ()->nHeight - i)->nTime += 512 ; // Trick the MedianTimePast
460
+
461
+ {
462
+ CBlockIndex* active_chain_tip = m_node.chainman ->ActiveChain ().Tip ();
463
+ BOOST_CHECK (SequenceLocks (CTransaction (tx), flags, prevheights, CreateBlockIndex (active_chain_tip->nHeight + 1 , active_chain_tip))); // Sequence locks pass 512 seconds later
464
+ }
465
+
457
466
for (int i = 0 ; i < CBlockIndex::nMedianTimeSpan; i++)
458
467
::ChainActive ().Tip()->GetAncestor(::ChainActive().Tip()->nHeight - i)->nTime -= 512; // undo tricked MTP
459
468
0 commit comments