mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 20:03:34 -03:00
scripted-diff: Replace ::mempool with m_node.mempool in tests
-BEGIN VERIFY SCRIPT- # tx pool member access (mempool followed by dot) sed --regexp-extended -i -e 's/(::)?\<mempool\>\.([a-zA-Z])/m_node.mempool->\2/g' $(git grep -l mempool ./src/test) # plain global (mempool not preceeded by dot, but followed by comma) sed --regexp-extended -i -e 's/([^\.])(::)?\<mempool\>,/\1*m_node.mempool,/g' $(git grep -l mempool ./src/test) -END VERIFY SCRIPT-
This commit is contained in:
parent
8888ad02e2
commit
fa538813b1
4 changed files with 52 additions and 52 deletions
|
@ -118,19 +118,19 @@ void MinerTestingSetup::TestPackageSelection(const CChainParams& chainparams, co
|
||||||
tx.vout[0].nValue = 5000000000LL - 1000;
|
tx.vout[0].nValue = 5000000000LL - 1000;
|
||||||
// This tx has a low fee: 1000 satoshis
|
// This tx has a low fee: 1000 satoshis
|
||||||
uint256 hashParentTx = tx.GetHash(); // save this txid for later use
|
uint256 hashParentTx = tx.GetHash(); // save this txid for later use
|
||||||
mempool.addUnchecked(entry.Fee(1000).Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
|
m_node.mempool->addUnchecked(entry.Fee(1000).Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
|
||||||
|
|
||||||
// This tx has a medium fee: 10000 satoshis
|
// This tx has a medium fee: 10000 satoshis
|
||||||
tx.vin[0].prevout.hash = txFirst[1]->GetHash();
|
tx.vin[0].prevout.hash = txFirst[1]->GetHash();
|
||||||
tx.vout[0].nValue = 5000000000LL - 10000;
|
tx.vout[0].nValue = 5000000000LL - 10000;
|
||||||
uint256 hashMediumFeeTx = tx.GetHash();
|
uint256 hashMediumFeeTx = tx.GetHash();
|
||||||
mempool.addUnchecked(entry.Fee(10000).Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
|
m_node.mempool->addUnchecked(entry.Fee(10000).Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
|
||||||
|
|
||||||
// This tx has a high fee, but depends on the first transaction
|
// This tx has a high fee, but depends on the first transaction
|
||||||
tx.vin[0].prevout.hash = hashParentTx;
|
tx.vin[0].prevout.hash = hashParentTx;
|
||||||
tx.vout[0].nValue = 5000000000LL - 1000 - 50000; // 50k satoshi fee
|
tx.vout[0].nValue = 5000000000LL - 1000 - 50000; // 50k satoshi fee
|
||||||
uint256 hashHighFeeTx = tx.GetHash();
|
uint256 hashHighFeeTx = tx.GetHash();
|
||||||
mempool.addUnchecked(entry.Fee(50000).Time(GetTime()).SpendsCoinbase(false).FromTx(tx));
|
m_node.mempool->addUnchecked(entry.Fee(50000).Time(GetTime()).SpendsCoinbase(false).FromTx(tx));
|
||||||
|
|
||||||
std::unique_ptr<CBlockTemplate> pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey);
|
std::unique_ptr<CBlockTemplate> pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey);
|
||||||
BOOST_CHECK(pblocktemplate->block.vtx[1]->GetHash() == hashParentTx);
|
BOOST_CHECK(pblocktemplate->block.vtx[1]->GetHash() == hashParentTx);
|
||||||
|
@ -141,7 +141,7 @@ void MinerTestingSetup::TestPackageSelection(const CChainParams& chainparams, co
|
||||||
tx.vin[0].prevout.hash = hashHighFeeTx;
|
tx.vin[0].prevout.hash = hashHighFeeTx;
|
||||||
tx.vout[0].nValue = 5000000000LL - 1000 - 50000; // 0 fee
|
tx.vout[0].nValue = 5000000000LL - 1000 - 50000; // 0 fee
|
||||||
uint256 hashFreeTx = tx.GetHash();
|
uint256 hashFreeTx = tx.GetHash();
|
||||||
mempool.addUnchecked(entry.Fee(0).FromTx(tx));
|
m_node.mempool->addUnchecked(entry.Fee(0).FromTx(tx));
|
||||||
size_t freeTxSize = ::GetSerializeSize(tx, PROTOCOL_VERSION);
|
size_t freeTxSize = ::GetSerializeSize(tx, PROTOCOL_VERSION);
|
||||||
|
|
||||||
// Calculate a fee on child transaction that will put the package just
|
// Calculate a fee on child transaction that will put the package just
|
||||||
|
@ -151,7 +151,7 @@ void MinerTestingSetup::TestPackageSelection(const CChainParams& chainparams, co
|
||||||
tx.vin[0].prevout.hash = hashFreeTx;
|
tx.vin[0].prevout.hash = hashFreeTx;
|
||||||
tx.vout[0].nValue = 5000000000LL - 1000 - 50000 - feeToUse;
|
tx.vout[0].nValue = 5000000000LL - 1000 - 50000 - feeToUse;
|
||||||
uint256 hashLowFeeTx = tx.GetHash();
|
uint256 hashLowFeeTx = tx.GetHash();
|
||||||
mempool.addUnchecked(entry.Fee(feeToUse).FromTx(tx));
|
m_node.mempool->addUnchecked(entry.Fee(feeToUse).FromTx(tx));
|
||||||
pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey);
|
pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey);
|
||||||
// Verify that the free tx and the low fee tx didn't get selected
|
// Verify that the free tx and the low fee tx didn't get selected
|
||||||
for (size_t i=0; i<pblocktemplate->block.vtx.size(); ++i) {
|
for (size_t i=0; i<pblocktemplate->block.vtx.size(); ++i) {
|
||||||
|
@ -162,10 +162,10 @@ void MinerTestingSetup::TestPackageSelection(const CChainParams& chainparams, co
|
||||||
// Test that packages above the min relay fee do get included, even if one
|
// Test that packages above the min relay fee do get included, even if one
|
||||||
// of the transactions is below the min relay fee
|
// of the transactions is below the min relay fee
|
||||||
// Remove the low fee transaction and replace with a higher fee transaction
|
// Remove the low fee transaction and replace with a higher fee transaction
|
||||||
mempool.removeRecursive(CTransaction(tx), MemPoolRemovalReason::REPLACED);
|
m_node.mempool->removeRecursive(CTransaction(tx), MemPoolRemovalReason::REPLACED);
|
||||||
tx.vout[0].nValue -= 2; // Now we should be just over the min relay fee
|
tx.vout[0].nValue -= 2; // Now we should be just over the min relay fee
|
||||||
hashLowFeeTx = tx.GetHash();
|
hashLowFeeTx = tx.GetHash();
|
||||||
mempool.addUnchecked(entry.Fee(feeToUse+2).FromTx(tx));
|
m_node.mempool->addUnchecked(entry.Fee(feeToUse+2).FromTx(tx));
|
||||||
pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey);
|
pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey);
|
||||||
BOOST_CHECK(pblocktemplate->block.vtx[4]->GetHash() == hashFreeTx);
|
BOOST_CHECK(pblocktemplate->block.vtx[4]->GetHash() == hashFreeTx);
|
||||||
BOOST_CHECK(pblocktemplate->block.vtx[5]->GetHash() == hashLowFeeTx);
|
BOOST_CHECK(pblocktemplate->block.vtx[5]->GetHash() == hashLowFeeTx);
|
||||||
|
@ -178,7 +178,7 @@ void MinerTestingSetup::TestPackageSelection(const CChainParams& chainparams, co
|
||||||
tx.vout[0].nValue = 5000000000LL - 100000000;
|
tx.vout[0].nValue = 5000000000LL - 100000000;
|
||||||
tx.vout[1].nValue = 100000000; // 1BTC output
|
tx.vout[1].nValue = 100000000; // 1BTC output
|
||||||
uint256 hashFreeTx2 = tx.GetHash();
|
uint256 hashFreeTx2 = tx.GetHash();
|
||||||
mempool.addUnchecked(entry.Fee(0).SpendsCoinbase(true).FromTx(tx));
|
m_node.mempool->addUnchecked(entry.Fee(0).SpendsCoinbase(true).FromTx(tx));
|
||||||
|
|
||||||
// This tx can't be mined by itself
|
// This tx can't be mined by itself
|
||||||
tx.vin[0].prevout.hash = hashFreeTx2;
|
tx.vin[0].prevout.hash = hashFreeTx2;
|
||||||
|
@ -186,7 +186,7 @@ void MinerTestingSetup::TestPackageSelection(const CChainParams& chainparams, co
|
||||||
feeToUse = blockMinFeeRate.GetFee(freeTxSize);
|
feeToUse = blockMinFeeRate.GetFee(freeTxSize);
|
||||||
tx.vout[0].nValue = 5000000000LL - 100000000 - feeToUse;
|
tx.vout[0].nValue = 5000000000LL - 100000000 - feeToUse;
|
||||||
uint256 hashLowFeeTx2 = tx.GetHash();
|
uint256 hashLowFeeTx2 = tx.GetHash();
|
||||||
mempool.addUnchecked(entry.Fee(feeToUse).SpendsCoinbase(false).FromTx(tx));
|
m_node.mempool->addUnchecked(entry.Fee(feeToUse).SpendsCoinbase(false).FromTx(tx));
|
||||||
pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey);
|
pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey);
|
||||||
|
|
||||||
// Verify that this tx isn't selected.
|
// Verify that this tx isn't selected.
|
||||||
|
@ -199,7 +199,7 @@ void MinerTestingSetup::TestPackageSelection(const CChainParams& chainparams, co
|
||||||
// as well.
|
// as well.
|
||||||
tx.vin[0].prevout.n = 1;
|
tx.vin[0].prevout.n = 1;
|
||||||
tx.vout[0].nValue = 100000000 - 10000; // 10k satoshi fee
|
tx.vout[0].nValue = 100000000 - 10000; // 10k satoshi fee
|
||||||
mempool.addUnchecked(entry.Fee(10000).FromTx(tx));
|
m_node.mempool->addUnchecked(entry.Fee(10000).FromTx(tx));
|
||||||
pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey);
|
pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey);
|
||||||
BOOST_CHECK(pblocktemplate->block.vtx[8]->GetHash() == hashLowFeeTx2);
|
BOOST_CHECK(pblocktemplate->block.vtx[8]->GetHash() == hashLowFeeTx2);
|
||||||
}
|
}
|
||||||
|
@ -256,7 +256,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
||||||
}
|
}
|
||||||
|
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
LOCK(::mempool.cs);
|
LOCK(m_node.mempool->cs);
|
||||||
|
|
||||||
// Just to make sure we can still make simple blocks
|
// Just to make sure we can still make simple blocks
|
||||||
BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey));
|
BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey));
|
||||||
|
@ -280,12 +280,12 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
||||||
hash = tx.GetHash();
|
hash = tx.GetHash();
|
||||||
bool spendsCoinbase = i == 0; // only first tx spends coinbase
|
bool spendsCoinbase = i == 0; // only first tx spends coinbase
|
||||||
// If we don't set the # of sig ops in the CTxMemPoolEntry, template creation fails
|
// If we don't set the # of sig ops in the CTxMemPoolEntry, template creation fails
|
||||||
mempool.addUnchecked(entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(spendsCoinbase).FromTx(tx));
|
m_node.mempool->addUnchecked(entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(spendsCoinbase).FromTx(tx));
|
||||||
tx.vin[0].prevout.hash = hash;
|
tx.vin[0].prevout.hash = hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_CHECK_EXCEPTION(AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey), std::runtime_error, HasReason("bad-blk-sigops"));
|
BOOST_CHECK_EXCEPTION(AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey), std::runtime_error, HasReason("bad-blk-sigops"));
|
||||||
mempool.clear();
|
m_node.mempool->clear();
|
||||||
|
|
||||||
tx.vin[0].prevout.hash = txFirst[0]->GetHash();
|
tx.vin[0].prevout.hash = txFirst[0]->GetHash();
|
||||||
tx.vout[0].nValue = BLOCKSUBSIDY;
|
tx.vout[0].nValue = BLOCKSUBSIDY;
|
||||||
|
@ -295,11 +295,11 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
||||||
hash = tx.GetHash();
|
hash = tx.GetHash();
|
||||||
bool spendsCoinbase = i == 0; // only first tx spends coinbase
|
bool spendsCoinbase = i == 0; // only first tx spends coinbase
|
||||||
// If we do set the # of sig ops in the CTxMemPoolEntry, template creation passes
|
// If we do set the # of sig ops in the CTxMemPoolEntry, template creation passes
|
||||||
mempool.addUnchecked(entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(spendsCoinbase).SigOpsCost(80).FromTx(tx));
|
m_node.mempool->addUnchecked(entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(spendsCoinbase).SigOpsCost(80).FromTx(tx));
|
||||||
tx.vin[0].prevout.hash = hash;
|
tx.vin[0].prevout.hash = hash;
|
||||||
}
|
}
|
||||||
BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey));
|
BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey));
|
||||||
mempool.clear();
|
m_node.mempool->clear();
|
||||||
|
|
||||||
// block size > limit
|
// block size > limit
|
||||||
tx.vin[0].scriptSig = CScript();
|
tx.vin[0].scriptSig = CScript();
|
||||||
|
@ -315,24 +315,24 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
||||||
tx.vout[0].nValue -= LOWFEE;
|
tx.vout[0].nValue -= LOWFEE;
|
||||||
hash = tx.GetHash();
|
hash = tx.GetHash();
|
||||||
bool spendsCoinbase = i == 0; // only first tx spends coinbase
|
bool spendsCoinbase = i == 0; // only first tx spends coinbase
|
||||||
mempool.addUnchecked(entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(spendsCoinbase).FromTx(tx));
|
m_node.mempool->addUnchecked(entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(spendsCoinbase).FromTx(tx));
|
||||||
tx.vin[0].prevout.hash = hash;
|
tx.vin[0].prevout.hash = hash;
|
||||||
}
|
}
|
||||||
BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey));
|
BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey));
|
||||||
mempool.clear();
|
m_node.mempool->clear();
|
||||||
|
|
||||||
// orphan in mempool, template creation fails
|
// orphan in *m_node.mempool, template creation fails
|
||||||
hash = tx.GetHash();
|
hash = tx.GetHash();
|
||||||
mempool.addUnchecked(entry.Fee(LOWFEE).Time(GetTime()).FromTx(tx));
|
m_node.mempool->addUnchecked(entry.Fee(LOWFEE).Time(GetTime()).FromTx(tx));
|
||||||
BOOST_CHECK_EXCEPTION(AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey), std::runtime_error, HasReason("bad-txns-inputs-missingorspent"));
|
BOOST_CHECK_EXCEPTION(AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey), std::runtime_error, HasReason("bad-txns-inputs-missingorspent"));
|
||||||
mempool.clear();
|
m_node.mempool->clear();
|
||||||
|
|
||||||
// child with higher feerate than parent
|
// child with higher feerate than parent
|
||||||
tx.vin[0].scriptSig = CScript() << OP_1;
|
tx.vin[0].scriptSig = CScript() << OP_1;
|
||||||
tx.vin[0].prevout.hash = txFirst[1]->GetHash();
|
tx.vin[0].prevout.hash = txFirst[1]->GetHash();
|
||||||
tx.vout[0].nValue = BLOCKSUBSIDY-HIGHFEE;
|
tx.vout[0].nValue = BLOCKSUBSIDY-HIGHFEE;
|
||||||
hash = tx.GetHash();
|
hash = tx.GetHash();
|
||||||
mempool.addUnchecked(entry.Fee(HIGHFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
|
m_node.mempool->addUnchecked(entry.Fee(HIGHFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
|
||||||
tx.vin[0].prevout.hash = hash;
|
tx.vin[0].prevout.hash = hash;
|
||||||
tx.vin.resize(2);
|
tx.vin.resize(2);
|
||||||
tx.vin[1].scriptSig = CScript() << OP_1;
|
tx.vin[1].scriptSig = CScript() << OP_1;
|
||||||
|
@ -340,34 +340,34 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
||||||
tx.vin[1].prevout.n = 0;
|
tx.vin[1].prevout.n = 0;
|
||||||
tx.vout[0].nValue = tx.vout[0].nValue+BLOCKSUBSIDY-HIGHERFEE; //First txn output + fresh coinbase - new txn fee
|
tx.vout[0].nValue = tx.vout[0].nValue+BLOCKSUBSIDY-HIGHERFEE; //First txn output + fresh coinbase - new txn fee
|
||||||
hash = tx.GetHash();
|
hash = tx.GetHash();
|
||||||
mempool.addUnchecked(entry.Fee(HIGHERFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
|
m_node.mempool->addUnchecked(entry.Fee(HIGHERFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
|
||||||
BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey));
|
BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey));
|
||||||
mempool.clear();
|
m_node.mempool->clear();
|
||||||
|
|
||||||
// coinbase in mempool, template creation fails
|
// coinbase in *m_node.mempool, template creation fails
|
||||||
tx.vin.resize(1);
|
tx.vin.resize(1);
|
||||||
tx.vin[0].prevout.SetNull();
|
tx.vin[0].prevout.SetNull();
|
||||||
tx.vin[0].scriptSig = CScript() << OP_0 << OP_1;
|
tx.vin[0].scriptSig = CScript() << OP_0 << OP_1;
|
||||||
tx.vout[0].nValue = 0;
|
tx.vout[0].nValue = 0;
|
||||||
hash = tx.GetHash();
|
hash = tx.GetHash();
|
||||||
// give it a fee so it'll get mined
|
// give it a fee so it'll get mined
|
||||||
mempool.addUnchecked(entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(false).FromTx(tx));
|
m_node.mempool->addUnchecked(entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(false).FromTx(tx));
|
||||||
// Should throw bad-cb-multiple
|
// Should throw bad-cb-multiple
|
||||||
BOOST_CHECK_EXCEPTION(AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey), std::runtime_error, HasReason("bad-cb-multiple"));
|
BOOST_CHECK_EXCEPTION(AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey), std::runtime_error, HasReason("bad-cb-multiple"));
|
||||||
mempool.clear();
|
m_node.mempool->clear();
|
||||||
|
|
||||||
// double spend txn pair in mempool, template creation fails
|
// double spend txn pair in *m_node.mempool, template creation fails
|
||||||
tx.vin[0].prevout.hash = txFirst[0]->GetHash();
|
tx.vin[0].prevout.hash = txFirst[0]->GetHash();
|
||||||
tx.vin[0].scriptSig = CScript() << OP_1;
|
tx.vin[0].scriptSig = CScript() << OP_1;
|
||||||
tx.vout[0].nValue = BLOCKSUBSIDY-HIGHFEE;
|
tx.vout[0].nValue = BLOCKSUBSIDY-HIGHFEE;
|
||||||
tx.vout[0].scriptPubKey = CScript() << OP_1;
|
tx.vout[0].scriptPubKey = CScript() << OP_1;
|
||||||
hash = tx.GetHash();
|
hash = tx.GetHash();
|
||||||
mempool.addUnchecked(entry.Fee(HIGHFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
|
m_node.mempool->addUnchecked(entry.Fee(HIGHFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
|
||||||
tx.vout[0].scriptPubKey = CScript() << OP_2;
|
tx.vout[0].scriptPubKey = CScript() << OP_2;
|
||||||
hash = tx.GetHash();
|
hash = tx.GetHash();
|
||||||
mempool.addUnchecked(entry.Fee(HIGHFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
|
m_node.mempool->addUnchecked(entry.Fee(HIGHFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
|
||||||
BOOST_CHECK_EXCEPTION(AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey), std::runtime_error, HasReason("bad-txns-inputs-missingorspent"));
|
BOOST_CHECK_EXCEPTION(AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey), std::runtime_error, HasReason("bad-txns-inputs-missingorspent"));
|
||||||
mempool.clear();
|
m_node.mempool->clear();
|
||||||
|
|
||||||
// subsidy changing
|
// subsidy changing
|
||||||
int nHeight = ::ChainActive().Height();
|
int nHeight = ::ChainActive().Height();
|
||||||
|
@ -396,7 +396,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
||||||
}
|
}
|
||||||
BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey));
|
BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey));
|
||||||
|
|
||||||
// invalid p2sh txn in mempool, template creation fails
|
// invalid p2sh txn in *m_node.mempool, template creation fails
|
||||||
tx.vin[0].prevout.hash = txFirst[0]->GetHash();
|
tx.vin[0].prevout.hash = txFirst[0]->GetHash();
|
||||||
tx.vin[0].prevout.n = 0;
|
tx.vin[0].prevout.n = 0;
|
||||||
tx.vin[0].scriptSig = CScript() << OP_1;
|
tx.vin[0].scriptSig = CScript() << OP_1;
|
||||||
|
@ -404,15 +404,15 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
||||||
script = CScript() << OP_0;
|
script = CScript() << OP_0;
|
||||||
tx.vout[0].scriptPubKey = GetScriptForDestination(ScriptHash(script));
|
tx.vout[0].scriptPubKey = GetScriptForDestination(ScriptHash(script));
|
||||||
hash = tx.GetHash();
|
hash = tx.GetHash();
|
||||||
mempool.addUnchecked(entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
|
m_node.mempool->addUnchecked(entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
|
||||||
tx.vin[0].prevout.hash = hash;
|
tx.vin[0].prevout.hash = hash;
|
||||||
tx.vin[0].scriptSig = CScript() << std::vector<unsigned char>(script.begin(), script.end());
|
tx.vin[0].scriptSig = CScript() << std::vector<unsigned char>(script.begin(), script.end());
|
||||||
tx.vout[0].nValue -= LOWFEE;
|
tx.vout[0].nValue -= LOWFEE;
|
||||||
hash = tx.GetHash();
|
hash = tx.GetHash();
|
||||||
mempool.addUnchecked(entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(false).FromTx(tx));
|
m_node.mempool->addUnchecked(entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(false).FromTx(tx));
|
||||||
// Should throw block-validation-failed
|
// Should throw block-validation-failed
|
||||||
BOOST_CHECK_EXCEPTION(AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey), std::runtime_error, HasReason("block-validation-failed"));
|
BOOST_CHECK_EXCEPTION(AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey), std::runtime_error, HasReason("block-validation-failed"));
|
||||||
mempool.clear();
|
m_node.mempool->clear();
|
||||||
|
|
||||||
// Delete the dummy blocks again.
|
// Delete the dummy blocks again.
|
||||||
while (::ChainActive().Tip()->nHeight > nHeight) {
|
while (::ChainActive().Tip()->nHeight > nHeight) {
|
||||||
|
@ -443,7 +443,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
||||||
tx.vout[0].scriptPubKey = CScript() << OP_1;
|
tx.vout[0].scriptPubKey = CScript() << OP_1;
|
||||||
tx.nLockTime = 0;
|
tx.nLockTime = 0;
|
||||||
hash = tx.GetHash();
|
hash = tx.GetHash();
|
||||||
mempool.addUnchecked(entry.Fee(HIGHFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
|
m_node.mempool->addUnchecked(entry.Fee(HIGHFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
|
||||||
BOOST_CHECK(CheckFinalTx(CTransaction(tx), flags)); // Locktime passes
|
BOOST_CHECK(CheckFinalTx(CTransaction(tx), flags)); // Locktime passes
|
||||||
BOOST_CHECK(!TestSequenceLocks(CTransaction(tx), flags)); // Sequence locks fail
|
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
|
BOOST_CHECK(SequenceLocks(CTransaction(tx), flags, &prevheights, CreateBlockIndex(::ChainActive().Tip()->nHeight + 2))); // Sequence locks pass on 2nd block
|
||||||
|
@ -453,7 +453,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
||||||
tx.vin[0].nSequence = CTxIn::SEQUENCE_LOCKTIME_TYPE_FLAG | (((::ChainActive().Tip()->GetMedianTimePast()+1-::ChainActive()[1]->GetMedianTimePast()) >> CTxIn::SEQUENCE_LOCKTIME_GRANULARITY) + 1); // txFirst[1] is the 3rd block
|
tx.vin[0].nSequence = CTxIn::SEQUENCE_LOCKTIME_TYPE_FLAG | (((::ChainActive().Tip()->GetMedianTimePast()+1-::ChainActive()[1]->GetMedianTimePast()) >> CTxIn::SEQUENCE_LOCKTIME_GRANULARITY) + 1); // txFirst[1] is the 3rd block
|
||||||
prevheights[0] = baseheight + 2;
|
prevheights[0] = baseheight + 2;
|
||||||
hash = tx.GetHash();
|
hash = tx.GetHash();
|
||||||
mempool.addUnchecked(entry.Time(GetTime()).FromTx(tx));
|
m_node.mempool->addUnchecked(entry.Time(GetTime()).FromTx(tx));
|
||||||
BOOST_CHECK(CheckFinalTx(CTransaction(tx), flags)); // Locktime passes
|
BOOST_CHECK(CheckFinalTx(CTransaction(tx), flags)); // Locktime passes
|
||||||
BOOST_CHECK(!TestSequenceLocks(CTransaction(tx), flags)); // Sequence locks fail
|
BOOST_CHECK(!TestSequenceLocks(CTransaction(tx), flags)); // Sequence locks fail
|
||||||
|
|
||||||
|
@ -469,7 +469,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
||||||
prevheights[0] = baseheight + 3;
|
prevheights[0] = baseheight + 3;
|
||||||
tx.nLockTime = ::ChainActive().Tip()->nHeight + 1;
|
tx.nLockTime = ::ChainActive().Tip()->nHeight + 1;
|
||||||
hash = tx.GetHash();
|
hash = tx.GetHash();
|
||||||
mempool.addUnchecked(entry.Time(GetTime()).FromTx(tx));
|
m_node.mempool->addUnchecked(entry.Time(GetTime()).FromTx(tx));
|
||||||
BOOST_CHECK(!CheckFinalTx(CTransaction(tx), flags)); // Locktime fails
|
BOOST_CHECK(!CheckFinalTx(CTransaction(tx), flags)); // Locktime fails
|
||||||
BOOST_CHECK(TestSequenceLocks(CTransaction(tx), flags)); // Sequence locks pass
|
BOOST_CHECK(TestSequenceLocks(CTransaction(tx), flags)); // Sequence locks pass
|
||||||
BOOST_CHECK(IsFinalTx(CTransaction(tx), ::ChainActive().Tip()->nHeight + 2, ::ChainActive().Tip()->GetMedianTimePast())); // Locktime passes on 2nd block
|
BOOST_CHECK(IsFinalTx(CTransaction(tx), ::ChainActive().Tip()->nHeight + 2, ::ChainActive().Tip()->GetMedianTimePast())); // Locktime passes on 2nd block
|
||||||
|
@ -480,7 +480,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
||||||
prevheights.resize(1);
|
prevheights.resize(1);
|
||||||
prevheights[0] = baseheight + 4;
|
prevheights[0] = baseheight + 4;
|
||||||
hash = tx.GetHash();
|
hash = tx.GetHash();
|
||||||
mempool.addUnchecked(entry.Time(GetTime()).FromTx(tx));
|
m_node.mempool->addUnchecked(entry.Time(GetTime()).FromTx(tx));
|
||||||
BOOST_CHECK(!CheckFinalTx(CTransaction(tx), flags)); // Locktime fails
|
BOOST_CHECK(!CheckFinalTx(CTransaction(tx), flags)); // Locktime fails
|
||||||
BOOST_CHECK(TestSequenceLocks(CTransaction(tx), flags)); // Sequence locks pass
|
BOOST_CHECK(TestSequenceLocks(CTransaction(tx), flags)); // Sequence locks pass
|
||||||
BOOST_CHECK(IsFinalTx(CTransaction(tx), ::ChainActive().Tip()->nHeight + 2, ::ChainActive().Tip()->GetMedianTimePast() + 1)); // Locktime passes 1 second later
|
BOOST_CHECK(IsFinalTx(CTransaction(tx), ::ChainActive().Tip()->nHeight + 2, ::ChainActive().Tip()->GetMedianTimePast() + 1)); // Locktime passes 1 second later
|
||||||
|
@ -517,7 +517,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
||||||
|
|
||||||
::ChainActive().Tip()->nHeight--;
|
::ChainActive().Tip()->nHeight--;
|
||||||
SetMockTime(0);
|
SetMockTime(0);
|
||||||
mempool.clear();
|
m_node.mempool->clear();
|
||||||
|
|
||||||
TestPackageSelection(chainparams, scriptPubKey, txFirst);
|
TestPackageSelection(chainparams, scriptPubKey, txFirst);
|
||||||
|
|
||||||
|
|
|
@ -34,17 +34,17 @@ BOOST_FIXTURE_TEST_CASE(tx_mempool_reject_coinbase, TestChain100Setup)
|
||||||
|
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
|
|
||||||
unsigned int initialPoolSize = mempool.size();
|
unsigned int initialPoolSize = m_node.mempool->size();
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL(
|
BOOST_CHECK_EQUAL(
|
||||||
false,
|
false,
|
||||||
AcceptToMemoryPool(mempool, state, MakeTransactionRef(coinbaseTx),
|
AcceptToMemoryPool(*m_node.mempool, state, MakeTransactionRef(coinbaseTx),
|
||||||
nullptr /* plTxnReplaced */,
|
nullptr /* plTxnReplaced */,
|
||||||
true /* bypass_limits */,
|
true /* bypass_limits */,
|
||||||
0 /* nAbsurdFee */));
|
0 /* nAbsurdFee */));
|
||||||
|
|
||||||
// Check that the transaction hasn't been added to mempool.
|
// Check that the transaction hasn't been added to mempool.
|
||||||
BOOST_CHECK_EQUAL(mempool.size(), initialPoolSize);
|
BOOST_CHECK_EQUAL(m_node.mempool->size(), initialPoolSize);
|
||||||
|
|
||||||
// Check that the validation state reflects the unsuccessful attempt.
|
// Check that the validation state reflects the unsuccessful attempt.
|
||||||
BOOST_CHECK(state.IsInvalid());
|
BOOST_CHECK(state.IsInvalid());
|
||||||
|
|
|
@ -70,7 +70,7 @@ BOOST_FIXTURE_TEST_CASE(tx_mempool_block_doublespend, TestChain100Setup)
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
BOOST_CHECK(::ChainActive().Tip()->GetBlockHash() != block.GetHash());
|
BOOST_CHECK(::ChainActive().Tip()->GetBlockHash() != block.GetHash());
|
||||||
}
|
}
|
||||||
mempool.clear();
|
m_node.mempool->clear();
|
||||||
|
|
||||||
// Test 3: ... and should be rejected if spend2 is in the memory pool
|
// Test 3: ... and should be rejected if spend2 is in the memory pool
|
||||||
BOOST_CHECK(ToMemPool(spends[1]));
|
BOOST_CHECK(ToMemPool(spends[1]));
|
||||||
|
@ -79,9 +79,9 @@ BOOST_FIXTURE_TEST_CASE(tx_mempool_block_doublespend, TestChain100Setup)
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
BOOST_CHECK(::ChainActive().Tip()->GetBlockHash() != block.GetHash());
|
BOOST_CHECK(::ChainActive().Tip()->GetBlockHash() != block.GetHash());
|
||||||
}
|
}
|
||||||
mempool.clear();
|
m_node.mempool->clear();
|
||||||
|
|
||||||
// Final sanity test: first spend in mempool, second in block, that's OK:
|
// Final sanity test: first spend in *m_node.mempool, second in block, that's OK:
|
||||||
std::vector<CMutableTransaction> oneSpend;
|
std::vector<CMutableTransaction> oneSpend;
|
||||||
oneSpend.push_back(spends[0]);
|
oneSpend.push_back(spends[0]);
|
||||||
BOOST_CHECK(ToMemPool(spends[1]));
|
BOOST_CHECK(ToMemPool(spends[1]));
|
||||||
|
@ -92,7 +92,7 @@ BOOST_FIXTURE_TEST_CASE(tx_mempool_block_doublespend, TestChain100Setup)
|
||||||
}
|
}
|
||||||
// spends[1] should have been removed from the mempool when the
|
// spends[1] should have been removed from the mempool when the
|
||||||
// block with spends[0] is accepted:
|
// block with spends[0] is accepted:
|
||||||
BOOST_CHECK_EQUAL(mempool.size(), 0U);
|
BOOST_CHECK_EQUAL(m_node.mempool->size(), 0U);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run CheckInputs (using CoinsTip()) on the given transaction, for all script
|
// Run CheckInputs (using CoinsTip()) on the given transaction, for all script
|
||||||
|
|
|
@ -278,7 +278,7 @@ BOOST_AUTO_TEST_CASE(mempool_locks_reorg)
|
||||||
std::list<CTransactionRef> plTxnReplaced;
|
std::list<CTransactionRef> plTxnReplaced;
|
||||||
for (const auto& tx : txs) {
|
for (const auto& tx : txs) {
|
||||||
BOOST_REQUIRE(AcceptToMemoryPool(
|
BOOST_REQUIRE(AcceptToMemoryPool(
|
||||||
::mempool,
|
*m_node.mempool,
|
||||||
state,
|
state,
|
||||||
tx,
|
tx,
|
||||||
&plTxnReplaced,
|
&plTxnReplaced,
|
||||||
|
@ -289,8 +289,8 @@ BOOST_AUTO_TEST_CASE(mempool_locks_reorg)
|
||||||
|
|
||||||
// Check that all txs are in the pool
|
// Check that all txs are in the pool
|
||||||
{
|
{
|
||||||
LOCK(::mempool.cs);
|
LOCK(m_node.mempool->cs);
|
||||||
BOOST_CHECK_EQUAL(::mempool.mapTx.size(), txs.size());
|
BOOST_CHECK_EQUAL(m_node.mempool->mapTx.size(), txs.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run a thread that simulates an RPC caller that is polling while
|
// Run a thread that simulates an RPC caller that is polling while
|
||||||
|
@ -300,8 +300,8 @@ BOOST_AUTO_TEST_CASE(mempool_locks_reorg)
|
||||||
// the transactions invalidated by the reorg, or none of them, and
|
// the transactions invalidated by the reorg, or none of them, and
|
||||||
// not some intermediate amount.
|
// not some intermediate amount.
|
||||||
while (true) {
|
while (true) {
|
||||||
LOCK(::mempool.cs);
|
LOCK(m_node.mempool->cs);
|
||||||
if (::mempool.mapTx.size() == 0) {
|
if (m_node.mempool->mapTx.size() == 0) {
|
||||||
// We are done with the reorg
|
// We are done with the reorg
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -310,7 +310,7 @@ BOOST_AUTO_TEST_CASE(mempool_locks_reorg)
|
||||||
// be atomic. So the caller assumes that the returned mempool
|
// be atomic. So the caller assumes that the returned mempool
|
||||||
// is consistent. That is, it has all txs that were there
|
// is consistent. That is, it has all txs that were there
|
||||||
// before the reorg.
|
// before the reorg.
|
||||||
assert(::mempool.mapTx.size() == txs.size());
|
assert(m_node.mempool->mapTx.size() == txs.size());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
|
|
Loading…
Reference in a new issue