Implement helper class for CTxMemPoolEntry constructor
This is only for unit tests.
This commit is contained in:
@@ -143,6 +143,10 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
||||
CMutableTransaction tx,tx2;
|
||||
CScript script;
|
||||
uint256 hash;
|
||||
TestMemPoolEntryHelper entry;
|
||||
entry.nFee = 11;
|
||||
entry.dPriority = 111.0;
|
||||
entry.nHeight = 11;
|
||||
|
||||
LOCK(cs_main);
|
||||
fCheckpointsEnabled = false;
|
||||
@@ -281,7 +285,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
||||
{
|
||||
tx.vout[0].nValue -= 10;
|
||||
hash = tx.GetHash();
|
||||
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
|
||||
mempool.addUnchecked(hash, entry.Time(GetTime()).FromTx(tx));
|
||||
tx.vin[0].prevout.hash = hash;
|
||||
}
|
||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
|
||||
@@ -301,7 +305,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
||||
{
|
||||
tx.vout[0].nValue -= 350;
|
||||
hash = tx.GetHash();
|
||||
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
|
||||
mempool.addUnchecked(hash, entry.Time(GetTime()).FromTx(tx));
|
||||
tx.vin[0].prevout.hash = hash;
|
||||
}
|
||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
|
||||
@@ -310,7 +314,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
||||
|
||||
// orphan in mempool
|
||||
hash = tx.GetHash();
|
||||
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
|
||||
mempool.addUnchecked(hash, entry.Time(GetTime()).FromTx(tx));
|
||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
|
||||
delete pblocktemplate;
|
||||
mempool.clear();
|
||||
@@ -320,7 +324,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
||||
tx.vin[0].prevout.hash = txFirst[1]->GetHash();
|
||||
tx.vout[0].nValue = 39000LL;
|
||||
hash = tx.GetHash();
|
||||
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
|
||||
mempool.addUnchecked(hash, entry.Time(GetTime()).FromTx(tx));
|
||||
tx.vin[0].prevout.hash = hash;
|
||||
tx.vin.resize(2);
|
||||
tx.vin[1].scriptSig = CScript() << OP_1;
|
||||
@@ -328,7 +332,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
||||
tx.vin[1].prevout.n = 0;
|
||||
tx.vout[0].nValue = 49000LL;
|
||||
hash = tx.GetHash();
|
||||
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
|
||||
mempool.addUnchecked(hash, entry.Time(GetTime()).FromTx(tx));
|
||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
|
||||
delete pblocktemplate;
|
||||
mempool.clear();
|
||||
@@ -339,7 +343,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
||||
tx.vin[0].scriptSig = CScript() << OP_0 << OP_1;
|
||||
tx.vout[0].nValue = 0;
|
||||
hash = tx.GetHash();
|
||||
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
|
||||
mempool.addUnchecked(hash, entry.Time(GetTime()).FromTx(tx));
|
||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
|
||||
delete pblocktemplate;
|
||||
mempool.clear();
|
||||
@@ -352,12 +356,12 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
||||
script = CScript() << OP_0;
|
||||
tx.vout[0].scriptPubKey = GetScriptForDestination(CScriptID(script));
|
||||
hash = tx.GetHash();
|
||||
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
|
||||
mempool.addUnchecked(hash, entry.Time(GetTime()).FromTx(tx));
|
||||
tx.vin[0].prevout.hash = hash;
|
||||
tx.vin[0].scriptSig = CScript() << (std::vector<unsigned char>)script;
|
||||
tx.vout[0].nValue -= 10000;
|
||||
hash = tx.GetHash();
|
||||
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
|
||||
mempool.addUnchecked(hash, entry.Time(GetTime()).FromTx(tx));
|
||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
|
||||
delete pblocktemplate;
|
||||
mempool.clear();
|
||||
@@ -368,10 +372,10 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
||||
tx.vout[0].nValue = 49000LL;
|
||||
tx.vout[0].scriptPubKey = CScript() << OP_1;
|
||||
hash = tx.GetHash();
|
||||
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
|
||||
mempool.addUnchecked(hash, entry.Time(GetTime()).FromTx(tx));
|
||||
tx.vout[0].scriptPubKey = CScript() << OP_2;
|
||||
hash = tx.GetHash();
|
||||
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
|
||||
mempool.addUnchecked(hash, entry.Time(GetTime()).FromTx(tx));
|
||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
|
||||
delete pblocktemplate;
|
||||
mempool.clear();
|
||||
@@ -397,7 +401,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
||||
tx.vout[0].scriptPubKey = CScript() << OP_1;
|
||||
tx.nLockTime = chainActive.Tip()->nHeight+1;
|
||||
hash = tx.GetHash();
|
||||
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
|
||||
mempool.addUnchecked(hash, entry.Time(GetTime()).FromTx(tx));
|
||||
BOOST_CHECK(!CheckFinalTx(tx, LOCKTIME_MEDIAN_TIME_PAST));
|
||||
|
||||
// time locked
|
||||
@@ -411,7 +415,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
||||
tx2.vout[0].scriptPubKey = CScript() << OP_1;
|
||||
tx2.nLockTime = chainActive.Tip()->GetMedianTimePast()+1;
|
||||
hash = tx2.GetHash();
|
||||
mempool.addUnchecked(hash, CTxMemPoolEntry(tx2, 11, GetTime(), 111.0, 11));
|
||||
mempool.addUnchecked(hash, entry.Time(GetTime()).FromTx(tx2));
|
||||
BOOST_CHECK(!CheckFinalTx(tx2, LOCKTIME_MEDIAN_TIME_PAST));
|
||||
|
||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
|
||||
|
||||
Reference in New Issue
Block a user