|
|
@ -62,7 +62,8 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) |
|
|
|
Checkpoints::fEnabled = false; |
|
|
|
Checkpoints::fEnabled = false; |
|
|
|
|
|
|
|
|
|
|
|
// Simple block creation, nothing special yet:
|
|
|
|
// Simple block creation, nothing special yet:
|
|
|
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey)); |
|
|
|
CBlockIndex* pindexPrev; |
|
|
|
|
|
|
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey, pindexPrev)); |
|
|
|
|
|
|
|
|
|
|
|
// 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 :)
|
|
|
@ -90,7 +91,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) |
|
|
|
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(scriptPubKey, pindexPrev)); |
|
|
|
delete pblocktemplate; |
|
|
|
delete pblocktemplate; |
|
|
|
|
|
|
|
|
|
|
|
// block sigops > limit: 1000 CHECKMULTISIG + 1
|
|
|
|
// block sigops > limit: 1000 CHECKMULTISIG + 1
|
|
|
@ -108,7 +109,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(scriptPubKey, pindexPrev)); |
|
|
|
delete pblocktemplate; |
|
|
|
delete pblocktemplate; |
|
|
|
mempool.clear(); |
|
|
|
mempool.clear(); |
|
|
|
|
|
|
|
|
|
|
@ -128,14 +129,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(scriptPubKey, pindexPrev)); |
|
|
|
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(scriptPubKey, pindexPrev)); |
|
|
|
delete pblocktemplate; |
|
|
|
delete pblocktemplate; |
|
|
|
mempool.clear(); |
|
|
|
mempool.clear(); |
|
|
|
|
|
|
|
|
|
|
@ -153,7 +154,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(scriptPubKey, pindexPrev)); |
|
|
|
delete pblocktemplate; |
|
|
|
delete pblocktemplate; |
|
|
|
mempool.clear(); |
|
|
|
mempool.clear(); |
|
|
|
|
|
|
|
|
|
|
@ -164,7 +165,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(scriptPubKey, pindexPrev)); |
|
|
|
delete pblocktemplate; |
|
|
|
delete pblocktemplate; |
|
|
|
mempool.clear(); |
|
|
|
mempool.clear(); |
|
|
|
|
|
|
|
|
|
|
@ -182,7 +183,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(scriptPubKey, pindexPrev)); |
|
|
|
delete pblocktemplate; |
|
|
|
delete pblocktemplate; |
|
|
|
mempool.clear(); |
|
|
|
mempool.clear(); |
|
|
|
|
|
|
|
|
|
|
@ -196,17 +197,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(scriptPubKey, pindexPrev)); |
|
|
|
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(scriptPubKey, pindexPrev)); |
|
|
|
delete pblocktemplate; |
|
|
|
delete pblocktemplate; |
|
|
|
chainActive.Tip()->nHeight = 210000; |
|
|
|
chainActive.Tip()->nHeight = 210000; |
|
|
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey)); |
|
|
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey, pindexPrev)); |
|
|
|
delete pblocktemplate; |
|
|
|
delete pblocktemplate; |
|
|
|
chainActive.Tip()->nHeight = nHeight; |
|
|
|
chainActive.Tip()->nHeight = nHeight; |
|
|
|
|
|
|
|
|
|
|
@ -238,7 +239,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(!IsFinalTx(tx2)); |
|
|
|
BOOST_CHECK(!IsFinalTx(tx2)); |
|
|
|
|
|
|
|
|
|
|
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey)); |
|
|
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey, pindexPrev)); |
|
|
|
|
|
|
|
|
|
|
|
// 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); |
|
|
@ -251,7 +252,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) |
|
|
|
BOOST_CHECK(IsFinalTx(tx, chainActive.Tip()->nHeight + 1)); |
|
|
|
BOOST_CHECK(IsFinalTx(tx, chainActive.Tip()->nHeight + 1)); |
|
|
|
BOOST_CHECK(IsFinalTx(tx2)); |
|
|
|
BOOST_CHECK(IsFinalTx(tx2)); |
|
|
|
|
|
|
|
|
|
|
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey)); |
|
|
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey, pindexPrev)); |
|
|
|
BOOST_CHECK_EQUAL(pblocktemplate->block.vtx.size(), 3); |
|
|
|
BOOST_CHECK_EQUAL(pblocktemplate->block.vtx.size(), 3); |
|
|
|
delete pblocktemplate; |
|
|
|
delete pblocktemplate; |
|
|
|
|
|
|
|
|
|
|
|