diff --git a/src/test/miner_tests.cpp b/src/test/miner_tests.cpp --- a/src/test/miner_tests.cpp +++ b/src/test/miner_tests.cpp @@ -97,30 +97,33 @@ tx.vin[0].prevout.hash = txFirst[0]->GetId(); tx.vin[0].prevout.n = 0; tx.vout.resize(1); - tx.vout[0].nValue = 5000000000LL - 1000; + tx.vout[0].nValue = Amount(5000000000LL - 1000); // This tx has a low fee: 1000 satoshis. // Save this txid for later use. uint256 hashParentTx = tx.GetId(); - mempool.addUnchecked( - hashParentTx, - entry.Fee(1000).Time(GetTime()).SpendsCoinbase(true).FromTx(tx)); + mempool.addUnchecked(hashParentTx, entry.Fee(Amount(1000)) + .Time(GetTime()) + .SpendsCoinbase(true) + .FromTx(tx)); // This tx has a medium fee: 10000 satoshis. tx.vin[0].prevout.hash = txFirst[1]->GetId(); - tx.vout[0].nValue = 5000000000LL - 10000; + tx.vout[0].nValue = Amount(5000000000LL - 10000); uint256 hashMediumFeeTx = tx.GetId(); - mempool.addUnchecked( - hashMediumFeeTx, - entry.Fee(10000).Time(GetTime()).SpendsCoinbase(true).FromTx(tx)); + mempool.addUnchecked(hashMediumFeeTx, entry.Fee(Amount(10000)) + .Time(GetTime()) + .SpendsCoinbase(true) + .FromTx(tx)); // This tx has a high fee, but depends on the first transaction. tx.vin[0].prevout.hash = hashParentTx; // 50k satoshi fee. - tx.vout[0].nValue = 5000000000LL - 1000 - 50000; + tx.vout[0].nValue = Amount(5000000000LL - 1000 - 50000); uint256 hashHighFeeTx = tx.GetId(); - mempool.addUnchecked( - hashHighFeeTx, - entry.Fee(50000).Time(GetTime()).SpendsCoinbase(false).FromTx(tx)); + mempool.addUnchecked(hashHighFeeTx, entry.Fee(Amount(50000)) + .Time(GetTime()) + .SpendsCoinbase(false) + .FromTx(tx)); std::unique_ptr pblocktemplate = BlockAssembler(config, chainparams).CreateNewBlock(scriptPubKey); @@ -131,9 +134,9 @@ // Test that a package below the block min tx fee doesn't get included tx.vin[0].prevout.hash = hashHighFeeTx; // 0 fee. - tx.vout[0].nValue = 5000000000LL - 1000 - 50000; + tx.vout[0].nValue = Amount(5000000000LL - 1000 - 50000); uint256 hashFreeTx = tx.GetId(); - mempool.addUnchecked(hashFreeTx, entry.Fee(0).FromTx(tx)); + mempool.addUnchecked(hashFreeTx, entry.Fee(Amount(0)).FromTx(tx)); size_t freeTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); // Calculate a fee on child transaction that will put the package just @@ -141,7 +144,7 @@ Amount feeToUse = blockMinFeeRate.GetFee(2 * freeTxSize) - Amount(1); tx.vin[0].prevout.hash = hashFreeTx; - tx.vout[0].nValue = 5000000000LL - 1000 - 50000 - feeToUse; + tx.vout[0].nValue = Amount(5000000000LL - 1000 - 50000) - feeToUse; uint256 hashLowFeeTx = tx.GetId(); mempool.addUnchecked(hashLowFeeTx, entry.Fee(feeToUse).FromTx(tx)); pblocktemplate = @@ -157,9 +160,10 @@ // transaction and replace with a higher fee transaction mempool.removeRecursive(tx); // Now we should be just over the min relay fee. - tx.vout[0].nValue -= 2; + tx.vout[0].nValue -= Amount(2); hashLowFeeTx = tx.GetId(); - mempool.addUnchecked(hashLowFeeTx, entry.Fee(feeToUse + 2).FromTx(tx)); + mempool.addUnchecked(hashLowFeeTx, + entry.Fee(feeToUse + Amount(2)).FromTx(tx)); pblocktemplate = BlockAssembler(config, chainparams).CreateNewBlock(scriptPubKey); BOOST_CHECK(pblocktemplate->block.vtx[4]->GetId() == hashFreeTx); @@ -170,18 +174,18 @@ // 0-fee transaction that has 2 outputs. tx.vin[0].prevout.hash = txFirst[2]->GetId(); tx.vout.resize(2); - tx.vout[0].nValue = 5000000000LL - 100000000; - // 1BCH output. - tx.vout[1].nValue = 100000000; + tx.vout[0].nValue = Amount(5000000000LL - 100000000); + // 1BCC output. + tx.vout[1].nValue = Amount(100000000); uint256 hashFreeTx2 = tx.GetId(); mempool.addUnchecked(hashFreeTx2, - entry.Fee(0).SpendsCoinbase(true).FromTx(tx)); + entry.Fee(Amount(0)).SpendsCoinbase(true).FromTx(tx)); // This tx can't be mined by itself. tx.vin[0].prevout.hash = hashFreeTx2; tx.vout.resize(1); feeToUse = blockMinFeeRate.GetFee(freeTxSize); - tx.vout[0].nValue = 5000000000LL - 100000000 - feeToUse; + tx.vout[0].nValue = Amount(5000000000LL) - Amount(100000000) - feeToUse; uint256 hashLowFeeTx2 = tx.GetId(); mempool.addUnchecked(hashLowFeeTx2, entry.Fee(feeToUse).SpendsCoinbase(false).FromTx(tx)); @@ -198,8 +202,8 @@ // as well. tx.vin[0].prevout.n = 1; // 10k satoshi fee. - tx.vout[0].nValue = 100000000 - 10000; - mempool.addUnchecked(tx.GetId(), entry.Fee(10000).FromTx(tx)); + tx.vout[0].nValue = Amount(100000000 - 10000); + mempool.addUnchecked(tx.GetId(), entry.Fee(Amount(10000)).FromTx(tx)); pblocktemplate = BlockAssembler(config, chainparams).CreateNewBlock(scriptPubKey); BOOST_CHECK(pblocktemplate->block.vtx[8]->GetId() == hashLowFeeTx2); @@ -255,7 +259,7 @@ CScript script; uint256 hash; TestMemPoolEntryHelper entry; - entry.nFee = 11; + entry.nFee = Amount(11); entry.dPriority = 111.0; entry.nHeight = 11; @@ -417,7 +421,7 @@ tx.vin.resize(1); tx.vin[0].prevout.SetNull(); tx.vin[0].scriptSig = CScript() << OP_0 << OP_1; - tx.vout[0].nValue = 0; + tx.vout[0].nValue = Amount(0); hash = tx.GetId(); // Give it a fee so it'll get mined. mempool.addUnchecked( @@ -681,7 +685,7 @@ // into the template because we still check IsFinalTx in CreateNewBlock, but // relative locked txs will if inconsistently added to mempool. For now // these will still generate a valid template until BIP68 soft fork. - BOOST_CHECK_EQUAL(pblocktemplate->block.vtx.size(), 3); + BOOST_CHECK_EQUAL(pblocktemplate->block.vtx.size(), 3UL); // However if we advance height by 1 and time by 512, all of them should be // mined. for (int i = 0; i < CBlockIndex::nMedianTimeSpan; i++) { @@ -695,7 +699,7 @@ BOOST_CHECK( pblocktemplate = BlockAssembler(config, chainparams).CreateNewBlock(scriptPubKey)); - BOOST_CHECK_EQUAL(pblocktemplate->block.vtx.size(), 5); + BOOST_CHECK_EQUAL(pblocktemplate->block.vtx.size(), 5UL); chainActive.Tip()->nHeight--; SetMockTime(0); diff --git a/src/test/multisig_tests.cpp b/src/test/multisig_tests.cpp --- a/src/test/multisig_tests.cpp +++ b/src/test/multisig_tests.cpp @@ -21,8 +21,8 @@ CScript sign_multisig(CScript scriptPubKey, std::vector keys, CTransaction transaction, int whichIn) { - uint256 hash = - SignatureHash(scriptPubKey, transaction, whichIn, SIGHASH_ALL, 0); + uint256 hash = SignatureHash(scriptPubKey, transaction, whichIn, + SIGHASH_ALL, Amount(0)); CScript result; // CHECKMULTISIG bug workaround @@ -72,7 +72,7 @@ txTo[i].vout.resize(1); txTo[i].vin[0].prevout.n = i; txTo[i].vin[0].prevout.hash = txFrom.GetId(); - txTo[i].vout[0].nValue = 1; + txTo[i].vout[0].nValue = Amount(1); } std::vector keys; @@ -346,7 +346,7 @@ txTo[i].vout.resize(1); txTo[i].vin[0].prevout.n = i; txTo[i].vin[0].prevout.hash = txFrom.GetId(); - txTo[i].vout[0].nValue = 1; + txTo[i].vout[0].nValue = Amount(1); } for (int i = 0; i < 3; i++) { diff --git a/src/test/policyestimator_tests.cpp b/src/test/policyestimator_tests.cpp --- a/src/test/policyestimator_tests.cpp +++ b/src/test/policyestimator_tests.cpp @@ -15,7 +15,7 @@ BOOST_FIXTURE_TEST_SUITE(policyestimator_tests, BasicTestingSetup) BOOST_AUTO_TEST_CASE(BlockPolicyEstimates) { - CTxMemPool mpool(CFeeRate(1000)); + CTxMemPool mpool(CFeeRate(Amount(1000))); TestMemPoolEntryHelper entry; Amount basefee(2000); Amount deltaFee(100); @@ -39,7 +39,7 @@ tx.vin.resize(1); tx.vin[0].scriptSig = garbage; tx.vout.resize(1); - tx.vout[0].nValue = 0LL; + tx.vout[0].nValue = Amount(0); CFeeRate baseRate(basefee, GetTransactionSize(tx)); // Create a fake block @@ -83,9 +83,9 @@ // data points. So estimateFee(1,2,3) should fail and estimateFee(4) // should return somewhere around 8*baserate. estimateFee(4) %'s // are 100,100,100,100,90 = average 98% - BOOST_CHECK(mpool.estimateFee(1) == CFeeRate(0)); - BOOST_CHECK(mpool.estimateFee(2) == CFeeRate(0)); - BOOST_CHECK(mpool.estimateFee(3) == CFeeRate(0)); + BOOST_CHECK(mpool.estimateFee(1) == CFeeRate(Amount(0))); + BOOST_CHECK(mpool.estimateFee(2) == CFeeRate(Amount(0))); + BOOST_CHECK(mpool.estimateFee(3) == CFeeRate(Amount(0))); BOOST_CHECK(mpool.estimateFee(4).GetFeePerK() < 8 * baseRate.GetFeePerK() + deltaFee); BOOST_CHECK(mpool.estimateFee(4).GetFeePerK() > @@ -126,7 +126,7 @@ BOOST_CHECK(origFeeEst[i - 1] > mult * baseRate.GetFeePerK() - deltaFee); } else { - BOOST_CHECK(origFeeEst[i - 1] == CFeeRate(0).GetFeePerK()); + BOOST_CHECK(origFeeEst[i - 1] == CFeeRate(Amount(0)).GetFeePerK()); } } @@ -136,7 +136,7 @@ while (blocknum < 250) mpool.removeForBlock(block, ++blocknum); - BOOST_CHECK(mpool.estimateFee(1) == CFeeRate(0)); + BOOST_CHECK(mpool.estimateFee(1) == CFeeRate(Amount(0))); for (int i = 2; i < 10; i++) { BOOST_CHECK(mpool.estimateFee(i).GetFeePerK() < origFeeEst[i - 1] + deltaFee); @@ -166,7 +166,7 @@ int answerFound; for (int i = 1; i < 10; i++) { - BOOST_CHECK(mpool.estimateFee(i) == CFeeRate(0) || + BOOST_CHECK(mpool.estimateFee(i) == CFeeRate(Amount(0)) || mpool.estimateFee(i).GetFeePerK() > origFeeEst[i - 1] - deltaFee); Amount a1 = mpool.estimateSmartFee(i, &answerFound).GetFeePerK(); @@ -185,7 +185,7 @@ } mpool.removeForBlock(block, 265); block.clear(); - BOOST_CHECK(mpool.estimateFee(1) == CFeeRate(0)); + BOOST_CHECK(mpool.estimateFee(1) == CFeeRate(Amount(0))); for (int i = 2; i < 10; i++) { BOOST_CHECK(mpool.estimateFee(i).GetFeePerK() > origFeeEst[i - 1] - deltaFee); @@ -212,7 +212,7 @@ mpool.removeForBlock(block, ++blocknum); block.clear(); } - BOOST_CHECK(mpool.estimateFee(1) == CFeeRate(0)); + BOOST_CHECK(mpool.estimateFee(1) == CFeeRate(Amount(0))); for (int i = 2; i < 10; i++) { BOOST_CHECK(mpool.estimateFee(i).GetFeePerK() < origFeeEst[i - 1] - deltaFee); diff --git a/src/test/random_tests.cpp b/src/test/random_tests.cpp --- a/src/test/random_tests.cpp +++ b/src/test/random_tests.cpp @@ -40,7 +40,7 @@ for (int bits = 0; bits < 63; ++bits) { for (int j = 0; j < 1000; ++j) { uint64_t rangebits = ctx1.randbits(bits); - BOOST_CHECK_EQUAL(rangebits >> bits, 0); + BOOST_CHECK_EQUAL(rangebits >> bits, uint64_t(0)); uint64_t range = uint64_t(1) << bits | rangebits; uint64_t rand = ctx2.randrange(range); BOOST_CHECK(rand < range);