Changeset View
Changeset View
Standalone View
Standalone View
src/test/miner_tests.cpp
Show First 20 Lines • Show All 518 Lines • ▼ Show 20 Lines | const Consensus::Params ¶ms = chainparams.GetConsensus(); | ||||
BOOST_CHECK(ContextualCheckTransactionForCurrentBlock( | BOOST_CHECK(ContextualCheckTransactionForCurrentBlock( | ||||
params, CTransaction(tx), state, flags)); | params, CTransaction(tx), state, flags)); | ||||
} | } | ||||
// Sequence locks fail. | // Sequence locks fail. | ||||
BOOST_CHECK(!TestSequenceLocks(CTransaction(tx), flags)); | BOOST_CHECK(!TestSequenceLocks(CTransaction(tx), flags)); | ||||
// Sequence locks pass on 2nd block. | // Sequence locks pass on 2nd block. | ||||
BOOST_CHECK( | BOOST_CHECK( | ||||
SequenceLocks(CTransaction(tx), flags, &prevheights, | SequenceLocks(CTransaction(tx), flags, prevheights, | ||||
CreateBlockIndex(::ChainActive().Tip()->nHeight + 2))); | CreateBlockIndex(::ChainActive().Tip()->nHeight + 2))); | ||||
// Relative time locked. | // Relative time locked. | ||||
tx.vin[0].prevout = COutPoint(txFirst[1]->GetId(), 0); | tx.vin[0].prevout = COutPoint(txFirst[1]->GetId(), 0); | ||||
// txFirst[1] is the 3rd block. | // txFirst[1] is the 3rd block. | ||||
tx.vin[0].nSequence = CTxIn::SEQUENCE_LOCKTIME_TYPE_FLAG | | tx.vin[0].nSequence = CTxIn::SEQUENCE_LOCKTIME_TYPE_FLAG | | ||||
(((::ChainActive().Tip()->GetMedianTimePast() + 1 - | (((::ChainActive().Tip()->GetMedianTimePast() + 1 - | ||||
::ChainActive()[1]->GetMedianTimePast()) >> | ::ChainActive()[1]->GetMedianTimePast()) >> | ||||
Show All 17 Lines | for (int i = 0; i < CBlockIndex::nMedianTimeSpan; i++) { | ||||
// Trick the MedianTimePast. | // Trick the MedianTimePast. | ||||
::ChainActive() | ::ChainActive() | ||||
.Tip() | .Tip() | ||||
->GetAncestor(::ChainActive().Tip()->nHeight - i) | ->GetAncestor(::ChainActive().Tip()->nHeight - i) | ||||
->nTime += 512; | ->nTime += 512; | ||||
} | } | ||||
// Sequence locks pass 512 seconds later. | // Sequence locks pass 512 seconds later. | ||||
BOOST_CHECK( | BOOST_CHECK( | ||||
SequenceLocks(CTransaction(tx), flags, &prevheights, | SequenceLocks(CTransaction(tx), flags, prevheights, | ||||
CreateBlockIndex(::ChainActive().Tip()->nHeight + 1))); | CreateBlockIndex(::ChainActive().Tip()->nHeight + 1))); | ||||
for (int i = 0; i < CBlockIndex::nMedianTimeSpan; i++) { | for (int i = 0; i < CBlockIndex::nMedianTimeSpan; i++) { | ||||
// Undo tricked MTP. | // Undo tricked MTP. | ||||
::ChainActive() | ::ChainActive() | ||||
.Tip() | .Tip() | ||||
->GetAncestor(::ChainActive().Tip()->nHeight - i) | ->GetAncestor(::ChainActive().Tip()->nHeight - i) | ||||
->nTime -= 512; | ->nTime -= 512; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 179 Lines • Show Last 20 Lines |