message: test/miner_tests: Pass in chain tip to CreateBlockIndex
diff: @@ -79,11 +79,11 @@ constexpr static struct {
  {2, 0xbbbeb305}, {2, 0xfe1c810a},
  };
  -static CBlockIndex CreateBlockIndex(int nHeight) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
  +static CBlockIndex CreateBlockIndex(int nHeight, CBlockIndex* active_chain_tip) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
  {
  CBlockIndex index;
  index.nHeight = nHeight;
  - index.pprev = ::ChainActive().Tip();
  + index.pprev = active_chain_tip;
  return index;
  }
  @@ -437,7 +437,11 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
  m_node.mempool->addUnchecked(entry.Fee(HIGHFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
  BOOST_CHECK(CheckFinalTx(::ChainActive().Tip(), CTransaction(tx), flags)); // Locktime passes
  BOOST_CHECK(!TestSequenceLocks(CTransaction(tx), flags)); // Sequence locks fail
  - BOOST_CHECK(SequenceLocks(CTransaction(tx), flags, prevheights, CreateBlockIndex(::ChainActive().Tip()->nHeight + 2))); // Sequence locks pass on 2nd block
  +
  + {
  + CBlockIndex* active_chain_tip = m_node.chainman->ActiveChain().Tip();
  + BOOST_CHECK(SequenceLocks(CTransaction(tx), flags, prevheights, CreateBlockIndex(active_chain_tip->nHeight + 2, active_chain_tip))); // Sequence locks pass on 2nd block
  + }
  // relative time locked
  tx.vin[0].prevout.hash = txFirst[1]->GetHash();
  @@ -449,8 +453,13 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
  BOOST_CHECK(!TestSequenceLocks(CTransaction(tx), flags)); // Sequence locks fail
  for (int i = 0; i < CBlockIndex::nMedianTimeSpan; i++)
  - ::ChainActive().Tip()->GetAncestor(::ChainActive().Tip()->nHeight - i)->nTime += 512; //Trick the MedianTimePast
  - BOOST_CHECK(SequenceLocks(CTransaction(tx), flags, prevheights, CreateBlockIndex(::ChainActive().Tip()->nHeight + 1))); // Sequence locks pass 512 seconds later
  + m_node.chainman->ActiveChain().Tip()->GetAncestor(m_node.chainman->ActiveChain().Tip()->nHeight - i)->nTime += 512; //Trick the MedianTimePast
  +
  + {
  + CBlockIndex* active_chain_tip = m_node.chainman->ActiveChain().Tip();
  + BOOST_CHECK(SequenceLocks(CTransaction(tx), flags, prevheights, CreateBlockIndex(active_chain_tip->nHeight + 1, active_chain_tip))); // Sequence locks pass 512 seconds later
  + }
  +
  for (int i = 0; i < CBlockIndex::nMedianTimeSpan; i++)
  ::ChainActive().Tip()->GetAncestor(::ChainActive().Tip()->nHeight - i)->nTime -= 512; //undo tricked MTP
  