Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13114945
D1722.id4778.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
16 KB
Subscribers
None
D1722.id4778.diff
View Options
diff --git a/src/test/amount_tests.cpp b/src/test/amount_tests.cpp
--- a/src/test/amount_tests.cpp
+++ b/src/test/amount_tests.cpp
@@ -12,7 +12,7 @@
BOOST_FIXTURE_TEST_SUITE(amount_tests, BasicTestingSetup)
static void CheckAmounts(int64_t aval, int64_t bval) {
- Amount a(aval), b(bval);
+ Amount a(aval * SATOSHI), b(bval * SATOSHI);
// Equality
BOOST_CHECK_EQUAL(a == b, aval == bval);
@@ -35,44 +35,45 @@
BOOST_CHECK_EQUAL(b >= a, bval >= aval);
// Unary minus
- BOOST_CHECK_EQUAL(-a, Amount(-aval));
- BOOST_CHECK_EQUAL(-b, Amount(-bval));
+ BOOST_CHECK_EQUAL(-a, -aval * SATOSHI);
+ BOOST_CHECK_EQUAL(-b, -bval * SATOSHI);
// Addition and subtraction.
BOOST_CHECK_EQUAL(a + b, b + a);
- BOOST_CHECK_EQUAL(a + b, Amount(aval + bval));
+ BOOST_CHECK_EQUAL(a + b, (aval + bval) * SATOSHI);
BOOST_CHECK_EQUAL(a - b, -(b - a));
- BOOST_CHECK_EQUAL(a - b, Amount(aval - bval));
+ BOOST_CHECK_EQUAL(a - b, (aval - bval) * SATOSHI);
// Multiplication
BOOST_CHECK_EQUAL(aval * b, bval * a);
- BOOST_CHECK_EQUAL(aval * b, Amount(aval * bval));
+ BOOST_CHECK_EQUAL(aval * b, (aval * bval) * SATOSHI);
// Division
if (b != Amount::zero()) {
BOOST_CHECK_EQUAL(a / b, aval / bval);
- BOOST_CHECK_EQUAL(a / bval, Amount(a / b));
+ BOOST_CHECK_EQUAL(a / bval, (a / b) * SATOSHI);
}
if (a != Amount::zero()) {
BOOST_CHECK_EQUAL(b / a, bval / aval);
- BOOST_CHECK_EQUAL(b / aval, Amount(b / a));
+ BOOST_CHECK_EQUAL(b / aval, (b / a) * SATOSHI);
}
// Modulus
if (b != Amount::zero()) {
BOOST_CHECK_EQUAL(a % b, a % bval);
- BOOST_CHECK_EQUAL(a % b, Amount(aval % bval));
+ BOOST_CHECK_EQUAL(a % b, (aval % bval) * SATOSHI);
}
if (a != Amount::zero()) {
BOOST_CHECK_EQUAL(b % a, b % aval);
- BOOST_CHECK_EQUAL(b % a, Amount(bval % aval));
+ BOOST_CHECK_EQUAL(b % a, (bval % aval) * SATOSHI);
}
// OpAssign
- Amount v(0);
+ Amount v;
+ BOOST_CHECK_EQUAL(v, Amount::zero());
v += a;
BOOST_CHECK_EQUAL(v, a);
v += b;
diff --git a/src/test/coins_tests.cpp b/src/test/coins_tests.cpp
--- a/src/test/coins_tests.cpp
+++ b/src/test/coins_tests.cpp
@@ -155,7 +155,7 @@
if (InsecureRandRange(5) == 0 || coin.IsSpent()) {
CTxOut txout;
- txout.nValue = Amount(int64_t(insecure_rand()));
+ txout.nValue = int64_t(insecure_rand()) * SATOSHI;
if (InsecureRandRange(16) == 0 && coin.IsSpent()) {
txout.scriptPubKey.assign(1 + InsecureRandBits(6),
OP_RETURN);
@@ -303,7 +303,7 @@
tx.vin.resize(1);
tx.vout.resize(1);
// Keep txs unique unless intended to duplicate.
- tx.vout[0].nValue = Amount(i);
+ tx.vout[0].nValue = i * SATOSHI;
// Random sizes so we can test memory usage accounting
tx.vout[0].scriptPubKey.assign(insecure_rand() & 0x3F, 0);
unsigned int height = insecure_rand();
@@ -551,12 +551,12 @@
}
static const COutPoint OUTPOINT;
-static const Amount PRUNED(-1);
-static const Amount ABSENT(-2);
-static const Amount FAIL(-3);
-static const Amount VALUE1(100);
-static const Amount VALUE2(200);
-static const Amount VALUE3(300);
+static const Amount PRUNED(-1 * SATOSHI);
+static const Amount ABSENT(-2 * SATOSHI);
+static const Amount FAIL(-3 * SATOSHI);
+static const Amount VALUE1(100 * SATOSHI);
+static const Amount VALUE2(200 * SATOSHI);
+static const Amount VALUE3(300 * SATOSHI);
static const char DIRTY = CCoinsCacheEntry::DIRTY;
static const char FRESH = CCoinsCacheEntry::FRESH;
static const char NO_ENTRY = -1;
diff --git a/src/test/compress_tests.cpp b/src/test/compress_tests.cpp
--- a/src/test/compress_tests.cpp
+++ b/src/test/compress_tests.cpp
@@ -48,7 +48,7 @@
BOOST_CHECK(TestPair(21000000 * COIN, 0x1406f40));
for (int64_t i = 1; i <= NUM_MULTIPLES_UNIT; i++) {
- BOOST_CHECK(TestEncode(Amount(i)));
+ BOOST_CHECK(TestEncode(i * SATOSHI));
}
for (int64_t i = 1; i <= NUM_MULTIPLES_CENT; i++) {
diff --git a/src/test/feerate_tests.cpp b/src/test/feerate_tests.cpp
--- a/src/test/feerate_tests.cpp
+++ b/src/test/feerate_tests.cpp
@@ -28,14 +28,14 @@
BOOST_CHECK_EQUAL(feeRate.GetFee(1000), 1000 * SATOSHI);
BOOST_CHECK_EQUAL(feeRate.GetFee(9000), 9000 * SATOSHI);
- feeRate = CFeeRate(Amount(-1000));
+ feeRate = CFeeRate(-1000 * SATOSHI);
// Must always just return -1 * arg
BOOST_CHECK_EQUAL(feeRate.GetFee(0), Amount::zero());
BOOST_CHECK_EQUAL(feeRate.GetFee(1), -SATOSHI);
- BOOST_CHECK_EQUAL(feeRate.GetFee(121), Amount(-121));
- BOOST_CHECK_EQUAL(feeRate.GetFee(999), Amount(-999));
- BOOST_CHECK_EQUAL(feeRate.GetFee(1000), Amount(-1000));
- BOOST_CHECK_EQUAL(feeRate.GetFee(9000), Amount(-9000));
+ BOOST_CHECK_EQUAL(feeRate.GetFee(121), -121 * SATOSHI);
+ BOOST_CHECK_EQUAL(feeRate.GetFee(999), -999 * SATOSHI);
+ BOOST_CHECK_EQUAL(feeRate.GetFee(1000), -1000 * SATOSHI);
+ BOOST_CHECK_EQUAL(feeRate.GetFee(9000), -9000 * SATOSHI);
feeRate = CFeeRate(123 * SATOSHI);
// Truncates the result, if not integer
@@ -49,7 +49,7 @@
BOOST_CHECK_EQUAL(feeRate.GetFee(1000), 123 * SATOSHI);
BOOST_CHECK_EQUAL(feeRate.GetFee(9000), 1107 * SATOSHI);
- feeRate = CFeeRate(Amount(-123));
+ feeRate = CFeeRate(-123 * SATOSHI);
// Truncates the result, if not integer
BOOST_CHECK_EQUAL(feeRate.GetFee(0), Amount::zero());
// Special case: returns -1 instead of 0
diff --git a/src/test/main_tests.cpp b/src/test/main_tests.cpp
--- a/src/test/main_tests.cpp
+++ b/src/test/main_tests.cpp
@@ -47,14 +47,14 @@
BOOST_AUTO_TEST_CASE(subsidy_limit_test) {
const auto chainParams = CreateChainParams(CBaseChainParams::MAIN);
- Amount nSum(0);
+ Amount nSum = Amount::zero();
for (int nHeight = 0; nHeight < 14000000; nHeight += 1000) {
Amount nSubsidy = GetBlockSubsidy(nHeight, chainParams->GetConsensus());
BOOST_CHECK(nSubsidy <= 50 * COIN);
nSum += 1000 * nSubsidy;
BOOST_CHECK(MoneyRange(nSum));
}
- BOOST_CHECK_EQUAL(nSum, Amount(2099999997690000ULL));
+ BOOST_CHECK_EQUAL(nSum, int64_t(2099999997690000LL) * SATOSHI);
}
bool ReturnFalse() {
diff --git a/src/test/mempool_tests.cpp b/src/test/mempool_tests.cpp
--- a/src/test/mempool_tests.cpp
+++ b/src/test/mempool_tests.cpp
@@ -463,7 +463,7 @@
uint64_t tx7Size = CTransaction(tx7).GetTotalSize();
/* set the fee to just below tx2's feerate when including ancestor */
- Amount fee((20000 / tx2Size) * (tx7Size + tx6Size) - 1);
+ Amount fee = int64_t((20000 / tx2Size) * (tx7Size + tx6Size) - 1) * SATOSHI;
// CTxMemPoolEntry entry7(tx7, fee, 2, 10.0, 1, true);
pool.addUnchecked(tx7.GetId(), entry.Fee(Amount(fee)).FromTx(tx7));
@@ -479,10 +479,11 @@
sortedOrder.erase(sortedOrder.begin() + 1);
// Ties are broken by hash
- if (tx3.GetId() < tx6.GetId())
+ if (tx3.GetId() < tx6.GetId()) {
sortedOrder.pop_back();
- else
+ } else {
sortedOrder.erase(sortedOrder.end() - 2);
+ }
sortedOrder.insert(sortedOrder.begin(), tx7.GetId().ToString());
CheckSort<ancestor_score>(pool, sortedOrder,
"MempoolAncestorIndexingTest4");
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
@@ -95,7 +95,7 @@
tx.vin[0].scriptSig = CScript() << OP_1;
tx.vin[0].prevout = COutPoint(txFirst[0]->GetId(), 0);
tx.vout.resize(1);
- tx.vout[0].nValue = Amount(5000000000LL - 1000);
+ tx.vout[0].nValue = int64_t(5000000000LL - 1000) * SATOSHI;
// This tx has a low fee: 1000 satoshis.
// Save this txid for later use.
TxId parentTxId = tx.GetId();
@@ -107,7 +107,7 @@
// This tx has a medium fee: 10000 satoshis.
tx.vin[0].prevout = COutPoint(txFirst[1]->GetId(), 0);
- tx.vout[0].nValue = Amount(5000000000LL - 10000);
+ tx.vout[0].nValue = int64_t(5000000000LL - 10000) * SATOSHI;
TxId mediumFeeTxId = tx.GetId();
mempool.addUnchecked(mediumFeeTxId,
entry.Fee(10000 * SATOSHI)
@@ -118,7 +118,7 @@
// This tx has a high fee, but depends on the first transaction.
tx.vin[0].prevout = COutPoint(parentTxId, 0);
// 50k satoshi fee.
- tx.vout[0].nValue = Amount(5000000000LL - 1000 - 50000);
+ tx.vout[0].nValue = int64_t(5000000000LL - 1000 - 50000) * SATOSHI;
TxId highFeeTxId = tx.GetId();
mempool.addUnchecked(highFeeTxId,
entry.Fee(50000 * SATOSHI)
@@ -135,7 +135,7 @@
// Test that a package below the block min tx fee doesn't get included
tx.vin[0].prevout = COutPoint(highFeeTxId, 0);
// 0 fee.
- tx.vout[0].nValue = Amount(5000000000LL - 1000 - 50000);
+ tx.vout[0].nValue = int64_t(5000000000LL - 1000 - 50000) * SATOSHI;
TxId freeTxId = tx.GetId();
mempool.addUnchecked(freeTxId, entry.Fee(Amount::zero()).FromTx(tx));
size_t freeTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION);
@@ -145,7 +145,8 @@
Amount feeToUse = blockMinFeeRate.GetFee(2 * freeTxSize) - SATOSHI;
tx.vin[0].prevout = COutPoint(freeTxId, 0);
- tx.vout[0].nValue = Amount(5000000000LL - 1000 - 50000) - feeToUse;
+ tx.vout[0].nValue =
+ int64_t(5000000000LL - 1000 - 50000) * SATOSHI - feeToUse;
TxId lowFeeTxId = tx.GetId();
mempool.addUnchecked(lowFeeTxId, entry.Fee(feeToUse).FromTx(tx));
pblocktemplate = BlockAssembler(config).CreateNewBlock(scriptPubKey);
@@ -173,7 +174,7 @@
// 0-fee transaction that has 2 outputs.
tx.vin[0].prevout = COutPoint(txFirst[2]->GetId(), 0);
tx.vout.resize(2);
- tx.vout[0].nValue = Amount(5000000000LL - 100000000);
+ tx.vout[0].nValue = int64_t(5000000000LL - 100000000) * SATOSHI;
// 1BCC output.
tx.vout[1].nValue = 100000000 * SATOSHI;
TxId freeTxId2 = tx.GetId();
@@ -184,7 +185,7 @@
tx.vin[0].prevout = COutPoint(freeTxId2, 0);
tx.vout.resize(1);
feeToUse = blockMinFeeRate.GetFee(freeTxSize);
- tx.vout[0].nValue = 5000000000 * SATOSHI - 100000000 * SATOSHI - feeToUse;
+ tx.vout[0].nValue = int64_t(5000000000LL - 100000000) * SATOSHI - feeToUse;
TxId lowFeeTxId2 = tx.GetId();
mempool.addUnchecked(lowFeeTxId2,
entry.Fee(feeToUse).SpendsCoinbase(false).FromTx(tx));
@@ -200,7 +201,7 @@
// well.
tx.vin[0].prevout = COutPoint(freeTxId2, 1);
// 10k satoshi fee.
- tx.vout[0].nValue = Amount(100000000 - 10000);
+ tx.vout[0].nValue = (100000000 - 10000) * SATOSHI;
mempool.addUnchecked(tx.GetId(), entry.Fee(10000 * SATOSHI).FromTx(tx));
pblocktemplate = BlockAssembler(config).CreateNewBlock(scriptPubKey);
BOOST_CHECK(pblocktemplate->block.vtx[8]->GetId() == lowFeeTxId2);
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
@@ -42,7 +42,7 @@
ScriptError err;
CKey key[4];
- Amount amount(0);
+ Amount amount = Amount::zero();
for (int i = 0; i < 4; i++) {
key[i].MakeNewKey(true);
}
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
@@ -17,8 +17,8 @@
BOOST_AUTO_TEST_CASE(BlockPolicyEstimates) {
CTxMemPool mpool;
TestMemPoolEntryHelper entry;
- Amount basefee(2000);
- Amount deltaFee(100);
+ Amount basefee = 2000 * SATOSHI;
+ Amount deltaFee = 100 * SATOSHI;
std::vector<Amount> feeV;
// Populate vectors of increasing fees
diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp
--- a/src/test/script_tests.cpp
+++ b/src/test/script_tests.cpp
@@ -1087,7 +1087,7 @@
.PushSig(keys.key0)
.PushRedeem());
- static const Amount TEST_AMOUNT(12345000000000);
+ static const Amount TEST_AMOUNT(12345000000000 * SATOSHI);
tests.push_back(
TestBuilder(CScript() << ToByteVector(keys.pubkey0) << OP_CHECKSIG,
"P2PK FORKID", SCRIPT_ENABLE_SIGHASH_FORKID, false,
@@ -1353,7 +1353,7 @@
for (unsigned int idx = 0; idx < tests.size(); idx++) {
UniValue test = tests[idx];
std::string strTest = test.write();
- Amount nValue(0);
+ Amount nValue = Amount::zero();
unsigned int pos = 0;
if (test.size() > 0 && test[pos].isArray()) {
nValue = AmountFromValue(test[pos][0]);
@@ -1619,7 +1619,7 @@
BOOST_AUTO_TEST_CASE(script_combineSigs) {
// Test the CombineSignatures function
- Amount amount(0);
+ Amount amount = Amount::zero();
CBasicKeyStore keystore;
std::vector<CKey> keys;
std::vector<CPubKey> pubkeys;
diff --git a/src/test/sighash_tests.cpp b/src/test/sighash_tests.cpp
--- a/src/test/sighash_tests.cpp
+++ b/src/test/sighash_tests.cpp
@@ -116,7 +116,7 @@
for (int out = 0; out < outs; out++) {
tx.vout.push_back(CTxOut());
CTxOut &txout = tx.vout.back();
- txout.nValue = Amount(int64_t(insecure_rand()) % 100000000);
+ txout.nValue = (int64_t(insecure_rand()) % 100000000) * SATOSHI;
RandomScript(txout.scriptPubKey);
}
}
diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp
--- a/src/test/transaction_tests.cpp
+++ b/src/test/transaction_tests.cpp
@@ -81,7 +81,8 @@
mapprevOutScriptPubKeys[outpoint] =
ParseScript(vinput[2].get_str());
if (vinput.size() >= 4) {
- mapprevOutValues[outpoint] = Amount(vinput[3].get_int64());
+ mapprevOutValues[outpoint] =
+ vinput[3].get_int64() * SATOSHI;
}
}
if (!fValid) {
@@ -108,9 +109,9 @@
break;
}
- Amount amount(0);
+ Amount amount = Amount::zero();
if (mapprevOutValues.count(tx.vin[i].prevout)) {
- amount = Amount(mapprevOutValues[tx.vin[i].prevout]);
+ amount = mapprevOutValues[tx.vin[i].prevout];
}
uint32_t verify_flags = ParseScriptFlags(test[2].get_str());
@@ -172,7 +173,8 @@
mapprevOutScriptPubKeys[outpoint] =
ParseScript(vinput[2].get_str());
if (vinput.size() >= 4) {
- mapprevOutValues[outpoint] = Amount(vinput[3].get_int64());
+ mapprevOutValues[outpoint] =
+ vinput[3].get_int64() * SATOSHI;
}
}
if (!fValid) {
@@ -195,7 +197,7 @@
break;
}
- Amount amount(0);
+ Amount amount = Amount::zero();
if (0 != mapprevOutValues.count(tx.vin[i].prevout)) {
amount = mapprevOutValues[tx.vin[i].prevout];
}
@@ -638,7 +640,7 @@
// nDustThreshold = 182 * 1234 / 1000 * 3
dustRelayFee = CFeeRate(1234 * SATOSHI);
// dust:
- t.vout[0].nValue = Amount(672 - 1);
+ t.vout[0].nValue = (672 - 1) * SATOSHI;
BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
// not dust:
t.vout[0].nValue = 672 * SATOSHI;
diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp
--- a/src/test/util_tests.cpp
+++ b/src/test/util_tests.cpp
@@ -190,7 +190,7 @@
}
BOOST_AUTO_TEST_CASE(util_ParseMoney) {
- Amount ret(0);
+ Amount ret = Amount::zero();
BOOST_CHECK(ParseMoney("0.0", ret));
BOOST_CHECK_EQUAL(ret, Amount::zero());
diff --git a/src/wallet/test/accounting_tests.cpp b/src/wallet/test/accounting_tests.cpp
--- a/src/wallet/test/accounting_tests.cpp
+++ b/src/wallet/test/accounting_tests.cpp
@@ -21,7 +21,7 @@
BOOST_CHECK(pwalletMain->ReorderTransactions() == DB_LOAD_OK);
pwalletMain->ListAccountCreditDebit("", aes);
for (CAccountingEntry &ae : aes) {
- results[Amount(ae.nOrderPos)] = ae;
+ results[ae.nOrderPos * SATOSHI] = ae;
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 1, 08:49 (12 m, 5 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5187127
Default Alt Text
D1722.id4778.diff (16 KB)
Attached To
D1722: Do not use Amount constructor taking satoshi as aprameter in the test code.
Event Timeline
Log In to Comment