Fix to have miner test aware of new separate block min tx fee

This commit is contained in:
Alex Morcos 2017-01-19 21:02:54 -05:00
parent de6400de5d
commit 6b331e6cf9

View file

@ -9,6 +9,7 @@
#include "consensus/validation.h" #include "consensus/validation.h"
#include "validation.h" #include "validation.h"
#include "miner.h" #include "miner.h"
#include "policy/policy.h"
#include "pubkey.h" #include "pubkey.h"
#include "script/standard.h" #include "script/standard.h"
#include "txmempool.h" #include "txmempool.h"
@ -24,6 +25,8 @@
BOOST_FIXTURE_TEST_SUITE(miner_tests, TestingSetup) BOOST_FIXTURE_TEST_SUITE(miner_tests, TestingSetup)
static CFeeRate blockMinFeeRate = CFeeRate(DEFAULT_BLOCK_MIN_TX_FEE);
static static
struct { struct {
unsigned char extranonce; unsigned char extranonce;
@ -112,7 +115,7 @@ void TestPackageSelection(const CChainParams& chainparams, CScript scriptPubKey,
BOOST_CHECK(pblocktemplate->block.vtx[2]->GetHash() == hashHighFeeTx); BOOST_CHECK(pblocktemplate->block.vtx[2]->GetHash() == hashHighFeeTx);
BOOST_CHECK(pblocktemplate->block.vtx[3]->GetHash() == hashMediumFeeTx); BOOST_CHECK(pblocktemplate->block.vtx[3]->GetHash() == hashMediumFeeTx);
// Test that a package below the min relay fee doesn't get included // Test that a package below the block min tx fee doesn't get included
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();
@ -120,8 +123,8 @@ void TestPackageSelection(const CChainParams& chainparams, CScript scriptPubKey,
size_t freeTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); size_t freeTxSize = ::GetSerializeSize(tx, SER_NETWORK, 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
// below the min relay fee (assuming 1 child tx of the same size). // below the block min tx fee (assuming 1 child tx of the same size).
CAmount feeToUse = minRelayTxFee.GetFee(2*freeTxSize) - 1; CAmount feeToUse = blockMinFeeRate.GetFee(2*freeTxSize) - 1;
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;
@ -158,7 +161,7 @@ void TestPackageSelection(const CChainParams& chainparams, CScript scriptPubKey,
// 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;
tx.vout.resize(1); tx.vout.resize(1);
feeToUse = minRelayTxFee.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(hashLowFeeTx2, entry.Fee(feeToUse).SpendsCoinbase(false).FromTx(tx)); mempool.addUnchecked(hashLowFeeTx2, entry.Fee(feeToUse).SpendsCoinbase(false).FromTx(tx));