Changeset View
Changeset View
Standalone View
Standalone View
src/test/miner_tests.cpp
Show All 23 Lines | |||||
#include "test/test_bitcoin.h" | #include "test/test_bitcoin.h" | ||||
#include <memory> | #include <memory> | ||||
#include <boost/test/unit_test.hpp> | #include <boost/test/unit_test.hpp> | ||||
BOOST_FIXTURE_TEST_SUITE(miner_tests, TestingSetup) | BOOST_FIXTURE_TEST_SUITE(miner_tests, TestingSetup) | ||||
static CFeeRate blockMinFeeRate = CFeeRate(DEFAULT_BLOCK_MIN_TX_FEE); | static CFeeRate blockMinFeeRate = CFeeRate(DEFAULT_BLOCK_MIN_TX_FEE_PER_KB); | ||||
static struct { | static struct { | ||||
uint8_t extranonce; | uint8_t extranonce; | ||||
uint32_t nonce; | uint32_t nonce; | ||||
} blockinfo[] = { | } blockinfo[] = { | ||||
{4, 0xa4a3e223}, {2, 0x15c32f9e}, {1, 0x0375b547}, {1, 0x7004a8a5}, | {4, 0xa4a3e223}, {2, 0x15c32f9e}, {1, 0x0375b547}, {1, 0x7004a8a5}, | ||||
{2, 0xce440296}, {2, 0x52cfe198}, {1, 0x77a72cd0}, {2, 0xbb5d6f84}, | {2, 0xce440296}, {2, 0x52cfe198}, {1, 0x77a72cd0}, {2, 0xbb5d6f84}, | ||||
{2, 0x83f30c2c}, {1, 0x48a73d5b}, {1, 0xef7dcd01}, {2, 0x6809c6c4}, | {2, 0x83f30c2c}, {1, 0x48a73d5b}, {1, 0xef7dcd01}, {2, 0x6809c6c4}, | ||||
▲ Show 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | void TestPackageSelection(Config &config, CScript scriptPubKey, | ||||
BOOST_CHECK(pblocktemplate->block.vtx[3]->GetId() == mediumFeeTxId); | BOOST_CHECK(pblocktemplate->block.vtx[3]->GetId() == mediumFeeTxId); | ||||
// Test that a package below the block min tx fee doesn't get included | // Test that a package below the block min tx fee doesn't get included | ||||
tx.vin[0].prevout = COutPoint(highFeeTxId, 0); | tx.vin[0].prevout = COutPoint(highFeeTxId, 0); | ||||
// 0 fee. | // 0 fee. | ||||
tx.vout[0].nValue = int64_t(5000000000LL - 1000 - 50000) * SATOSHI; | tx.vout[0].nValue = int64_t(5000000000LL - 1000 - 50000) * SATOSHI; | ||||
TxId freeTxId = tx.GetId(); | TxId freeTxId = tx.GetId(); | ||||
mempool.addUnchecked(freeTxId, entry.Fee(Amount::zero()).FromTx(tx)); | mempool.addUnchecked(freeTxId, entry.Fee(Amount::zero()).FromTx(tx)); | ||||
size_t freeTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); | size_t freeTxSize = CTransaction(tx).GetBillableSize(); | ||||
// 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 block min tx fee (assuming 1 child tx of the same size). | // below the block min tx fee (assuming 1 child tx of the same size). | ||||
Amount feeToUse = blockMinFeeRate.GetFee(2 * freeTxSize) - SATOSHI; | Amount feeToUse = blockMinFeeRate.GetFee(2 * freeTxSize) - SATOSHI; | ||||
tx.vin[0].prevout = COutPoint(freeTxId, 0); | tx.vin[0].prevout = COutPoint(freeTxId, 0); | ||||
tx.vout[0].nValue = | tx.vout[0].nValue = | ||||
int64_t(5000000000LL - 1000 - 50000) * SATOSHI - feeToUse; | int64_t(5000000000LL - 1000 - 50000) * SATOSHI - feeToUse; | ||||
▲ Show 20 Lines • Show All 616 Lines • Show Last 20 Lines |