|
|
@ -59,6 +59,7 @@ struct { |
|
|
|
// NOTE: These tests rely on CreateNewBlock doing its own self-validation!
|
|
|
|
// NOTE: These tests rely on CreateNewBlock doing its own self-validation!
|
|
|
|
BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) |
|
|
|
BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
const CChainParams& chainparams = Params(CBaseChainParams::MAIN); |
|
|
|
CScript scriptPubKey = CScript() << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG; |
|
|
|
CScript scriptPubKey = CScript() << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG; |
|
|
|
CBlockTemplate *pblocktemplate; |
|
|
|
CBlockTemplate *pblocktemplate; |
|
|
|
CMutableTransaction tx,tx2; |
|
|
|
CMutableTransaction tx,tx2; |
|
|
@ -69,7 +70,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) |
|
|
|
fCheckpointsEnabled = false; |
|
|
|
fCheckpointsEnabled = false; |
|
|
|
|
|
|
|
|
|
|
|
// Simple block creation, nothing special yet:
|
|
|
|
// Simple block creation, nothing special yet:
|
|
|
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey)); |
|
|
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(chainparams, scriptPubKey)); |
|
|
|
|
|
|
|
|
|
|
|
// We can't make transactions until we have inputs
|
|
|
|
// We can't make transactions until we have inputs
|
|
|
|
// Therefore, load 100 blocks :)
|
|
|
|
// Therefore, load 100 blocks :)
|
|
|
@ -91,14 +92,14 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) |
|
|
|
pblock->hashMerkleRoot = pblock->ComputeMerkleRoot(); |
|
|
|
pblock->hashMerkleRoot = pblock->ComputeMerkleRoot(); |
|
|
|
pblock->nNonce = blockinfo[i].nonce; |
|
|
|
pblock->nNonce = blockinfo[i].nonce; |
|
|
|
CValidationState state; |
|
|
|
CValidationState state; |
|
|
|
BOOST_CHECK(ProcessNewBlock(state, NULL, pblock, true, NULL)); |
|
|
|
BOOST_CHECK(ProcessNewBlock(state, chainparams, NULL, pblock, true, NULL)); |
|
|
|
BOOST_CHECK(state.IsValid()); |
|
|
|
BOOST_CHECK(state.IsValid()); |
|
|
|
pblock->hashPrevBlock = pblock->GetHash(); |
|
|
|
pblock->hashPrevBlock = pblock->GetHash(); |
|
|
|
} |
|
|
|
} |
|
|
|
delete pblocktemplate; |
|
|
|
delete pblocktemplate; |
|
|
|
|
|
|
|
|
|
|
|
// Just to make sure we can still make simple blocks
|
|
|
|
// Just to make sure we can still make simple blocks
|
|
|
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey)); |
|
|
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(chainparams, scriptPubKey)); |
|
|
|
delete pblocktemplate; |
|
|
|
delete pblocktemplate; |
|
|
|
|
|
|
|
|
|
|
|
// block sigops > limit: 1000 CHECKMULTISIG + 1
|
|
|
|
// block sigops > limit: 1000 CHECKMULTISIG + 1
|
|
|
@ -116,7 +117,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) |
|
|
|
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11)); |
|
|
|
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11)); |
|
|
|
tx.vin[0].prevout.hash = hash; |
|
|
|
tx.vin[0].prevout.hash = hash; |
|
|
|
} |
|
|
|
} |
|
|
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey)); |
|
|
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(chainparams, scriptPubKey)); |
|
|
|
delete pblocktemplate; |
|
|
|
delete pblocktemplate; |
|
|
|
mempool.clear(); |
|
|
|
mempool.clear(); |
|
|
|
|
|
|
|
|
|
|
@ -136,14 +137,14 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) |
|
|
|
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11)); |
|
|
|
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11)); |
|
|
|
tx.vin[0].prevout.hash = hash; |
|
|
|
tx.vin[0].prevout.hash = hash; |
|
|
|
} |
|
|
|
} |
|
|
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey)); |
|
|
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(chainparams, scriptPubKey)); |
|
|
|
delete pblocktemplate; |
|
|
|
delete pblocktemplate; |
|
|
|
mempool.clear(); |
|
|
|
mempool.clear(); |
|
|
|
|
|
|
|
|
|
|
|
// orphan in mempool
|
|
|
|
// orphan in mempool
|
|
|
|
hash = tx.GetHash(); |
|
|
|
hash = tx.GetHash(); |
|
|
|
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11)); |
|
|
|
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11)); |
|
|
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey)); |
|
|
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(chainparams, scriptPubKey)); |
|
|
|
delete pblocktemplate; |
|
|
|
delete pblocktemplate; |
|
|
|
mempool.clear(); |
|
|
|
mempool.clear(); |
|
|
|
|
|
|
|
|
|
|
@ -161,7 +162,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) |
|
|
|
tx.vout[0].nValue = 5900000000LL; |
|
|
|
tx.vout[0].nValue = 5900000000LL; |
|
|
|
hash = tx.GetHash(); |
|
|
|
hash = tx.GetHash(); |
|
|
|
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11)); |
|
|
|
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11)); |
|
|
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey)); |
|
|
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(chainparams, scriptPubKey)); |
|
|
|
delete pblocktemplate; |
|
|
|
delete pblocktemplate; |
|
|
|
mempool.clear(); |
|
|
|
mempool.clear(); |
|
|
|
|
|
|
|
|
|
|
@ -172,7 +173,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) |
|
|
|
tx.vout[0].nValue = 0; |
|
|
|
tx.vout[0].nValue = 0; |
|
|
|
hash = tx.GetHash(); |
|
|
|
hash = tx.GetHash(); |
|
|
|
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11)); |
|
|
|
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11)); |
|
|
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey)); |
|
|
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(chainparams, scriptPubKey)); |
|
|
|
delete pblocktemplate; |
|
|
|
delete pblocktemplate; |
|
|
|
mempool.clear(); |
|
|
|
mempool.clear(); |
|
|
|
|
|
|
|
|
|
|
@ -190,7 +191,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) |
|
|
|
tx.vout[0].nValue -= 1000000; |
|
|
|
tx.vout[0].nValue -= 1000000; |
|
|
|
hash = tx.GetHash(); |
|
|
|
hash = tx.GetHash(); |
|
|
|
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11)); |
|
|
|
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11)); |
|
|
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey)); |
|
|
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(chainparams, scriptPubKey)); |
|
|
|
delete pblocktemplate; |
|
|
|
delete pblocktemplate; |
|
|
|
mempool.clear(); |
|
|
|
mempool.clear(); |
|
|
|
|
|
|
|
|
|
|
@ -204,17 +205,17 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) |
|
|
|
tx.vout[0].scriptPubKey = CScript() << OP_2; |
|
|
|
tx.vout[0].scriptPubKey = CScript() << OP_2; |
|
|
|
hash = tx.GetHash(); |
|
|
|
hash = tx.GetHash(); |
|
|
|
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11)); |
|
|
|
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11)); |
|
|
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey)); |
|
|
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(chainparams, scriptPubKey)); |
|
|
|
delete pblocktemplate; |
|
|
|
delete pblocktemplate; |
|
|
|
mempool.clear(); |
|
|
|
mempool.clear(); |
|
|
|
|
|
|
|
|
|
|
|
// subsidy changing
|
|
|
|
// subsidy changing
|
|
|
|
int nHeight = chainActive.Height(); |
|
|
|
int nHeight = chainActive.Height(); |
|
|
|
chainActive.Tip()->nHeight = 209999; |
|
|
|
chainActive.Tip()->nHeight = 209999; |
|
|
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey)); |
|
|
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(chainparams, scriptPubKey)); |
|
|
|
delete pblocktemplate; |
|
|
|
delete pblocktemplate; |
|
|
|
chainActive.Tip()->nHeight = 210000; |
|
|
|
chainActive.Tip()->nHeight = 210000; |
|
|
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey)); |
|
|
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(chainparams, scriptPubKey)); |
|
|
|
delete pblocktemplate; |
|
|
|
delete pblocktemplate; |
|
|
|
chainActive.Tip()->nHeight = nHeight; |
|
|
|
chainActive.Tip()->nHeight = nHeight; |
|
|
|
|
|
|
|
|
|
|
@ -246,7 +247,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) |
|
|
|
mempool.addUnchecked(hash, CTxMemPoolEntry(tx2, 11, GetTime(), 111.0, 11)); |
|
|
|
mempool.addUnchecked(hash, CTxMemPoolEntry(tx2, 11, GetTime(), 111.0, 11)); |
|
|
|
BOOST_CHECK(!CheckFinalTx(tx2, LOCKTIME_MEDIAN_TIME_PAST)); |
|
|
|
BOOST_CHECK(!CheckFinalTx(tx2, LOCKTIME_MEDIAN_TIME_PAST)); |
|
|
|
|
|
|
|
|
|
|
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey)); |
|
|
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(chainparams, scriptPubKey)); |
|
|
|
|
|
|
|
|
|
|
|
// Neither tx should have make it into the template.
|
|
|
|
// Neither tx should have make it into the template.
|
|
|
|
BOOST_CHECK_EQUAL(pblocktemplate->block.vtx.size(), 1); |
|
|
|
BOOST_CHECK_EQUAL(pblocktemplate->block.vtx.size(), 1); |
|
|
@ -261,7 +262,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) |
|
|
|
//BOOST_CHECK(CheckFinalTx(tx));
|
|
|
|
//BOOST_CHECK(CheckFinalTx(tx));
|
|
|
|
//BOOST_CHECK(CheckFinalTx(tx2));
|
|
|
|
//BOOST_CHECK(CheckFinalTx(tx2));
|
|
|
|
|
|
|
|
|
|
|
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey)); |
|
|
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(chainparams, scriptPubKey)); |
|
|
|
BOOST_CHECK_EQUAL(pblocktemplate->block.vtx.size(), 2); |
|
|
|
BOOST_CHECK_EQUAL(pblocktemplate->block.vtx.size(), 2); |
|
|
|
delete pblocktemplate; |
|
|
|
delete pblocktemplate; |
|
|
|
|
|
|
|
|
|
|
|