|
|
|
@ -335,23 +335,6 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
@@ -335,23 +335,6 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
|
|
|
|
BOOST_CHECK_THROW(AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey), std::runtime_error); |
|
|
|
|
mempool.clear(); |
|
|
|
|
|
|
|
|
|
// invalid (pre-p2sh) txn in mempool, template creation fails
|
|
|
|
|
tx.vin[0].prevout.hash = txFirst[0]->GetHash(); |
|
|
|
|
tx.vin[0].prevout.n = 0; |
|
|
|
|
tx.vin[0].scriptSig = CScript() << OP_1; |
|
|
|
|
tx.vout[0].nValue = BLOCKSUBSIDY-LOWFEE; |
|
|
|
|
script = CScript() << OP_0; |
|
|
|
|
tx.vout[0].scriptPubKey = GetScriptForDestination(CScriptID(script)); |
|
|
|
|
hash = tx.GetHash(); |
|
|
|
|
mempool.addUnchecked(hash, entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx)); |
|
|
|
|
tx.vin[0].prevout.hash = hash; |
|
|
|
|
tx.vin[0].scriptSig = CScript() << std::vector<unsigned char>(script.begin(), script.end()); |
|
|
|
|
tx.vout[0].nValue -= LOWFEE; |
|
|
|
|
hash = tx.GetHash(); |
|
|
|
|
mempool.addUnchecked(hash, entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(false).FromTx(tx)); |
|
|
|
|
BOOST_CHECK_THROW(AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey), std::runtime_error); |
|
|
|
|
mempool.clear(); |
|
|
|
|
|
|
|
|
|
// double spend txn pair in mempool, template creation fails
|
|
|
|
|
tx.vin[0].prevout.hash = txFirst[0]->GetHash(); |
|
|
|
|
tx.vin[0].scriptSig = CScript() << OP_1; |
|
|
|
@ -391,6 +374,24 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
@@ -391,6 +374,24 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
|
|
|
|
chainActive.SetTip(next); |
|
|
|
|
} |
|
|
|
|
BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey)); |
|
|
|
|
|
|
|
|
|
// invalid p2sh txn in mempool, template creation fails
|
|
|
|
|
tx.vin[0].prevout.hash = txFirst[0]->GetHash(); |
|
|
|
|
tx.vin[0].prevout.n = 0; |
|
|
|
|
tx.vin[0].scriptSig = CScript() << OP_1; |
|
|
|
|
tx.vout[0].nValue = BLOCKSUBSIDY-LOWFEE; |
|
|
|
|
script = CScript() << OP_0; |
|
|
|
|
tx.vout[0].scriptPubKey = GetScriptForDestination(CScriptID(script)); |
|
|
|
|
hash = tx.GetHash(); |
|
|
|
|
mempool.addUnchecked(hash, entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx)); |
|
|
|
|
tx.vin[0].prevout.hash = hash; |
|
|
|
|
tx.vin[0].scriptSig = CScript() << std::vector<unsigned char>(script.begin(), script.end()); |
|
|
|
|
tx.vout[0].nValue -= LOWFEE; |
|
|
|
|
hash = tx.GetHash(); |
|
|
|
|
mempool.addUnchecked(hash, entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(false).FromTx(tx)); |
|
|
|
|
BOOST_CHECK_THROW(AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey), std::runtime_error); |
|
|
|
|
mempool.clear(); |
|
|
|
|
|
|
|
|
|
// Delete the dummy blocks again.
|
|
|
|
|
while (chainActive.Tip()->nHeight > nHeight) { |
|
|
|
|
CBlockIndex* del = chainActive.Tip(); |
|
|
|
|