aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_framework
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2021-10-06 15:19:34 +0200
committerMarcoFalke <falke.marco@gmail.com>2021-10-06 15:16:59 +0200
commitfa2ac5881edf8d0d3f15c43f089f1831348dfae2 (patch)
tree394995de99764ede38e30b9c1c7161bd19f98354 /test/functional/test_framework
parent66d11b14357c474416181227e197406ca8fb5dee (diff)
test: Replace satoshi_round with int() or Decimal()
satoshi_round will round down. To make the code easier to parse use Decimal() where possible, which does not round. Or use int(), which explicitly rounds down.
Diffstat (limited to 'test/functional/test_framework')
-rw-r--r--test/functional/test_framework/wallet.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/test/functional/test_framework/wallet.py b/test/functional/test_framework/wallet.py
index ef27cb3221..f99dc8da0d 100644
--- a/test/functional/test_framework/wallet.py
+++ b/test/functional/test_framework/wallet.py
@@ -32,7 +32,6 @@ from test_framework.script_util import key_to_p2wpkh_script
from test_framework.util import (
assert_equal,
assert_greater_than_or_equal,
- satoshi_round,
)
DEFAULT_FEE = Decimal("0.0001")
@@ -174,13 +173,12 @@ class MiniWallet:
vsize = Decimal(96) # anyone-can-spend
else:
vsize = Decimal(168) # P2PK (73 bytes scriptSig + 35 bytes scriptPubKey + 60 bytes other)
- send_value = satoshi_round(utxo_to_spend['value'] - fee_rate * (vsize / 1000))
- fee = utxo_to_spend['value'] - send_value
+ send_value = int(COIN * (utxo_to_spend['value'] - fee_rate * (vsize / 1000)))
assert send_value > 0
tx = CTransaction()
tx.vin = [CTxIn(COutPoint(int(utxo_to_spend['txid'], 16), utxo_to_spend['vout']), nSequence=sequence)]
- tx.vout = [CTxOut(int(send_value * COIN), self._scriptPubKey)]
+ tx.vout = [CTxOut(send_value, self._scriptPubKey)]
tx.nLockTime = locktime
if not self._address:
# raw script
@@ -199,7 +197,7 @@ class MiniWallet:
assert_equal(mempool_valid, tx_info['allowed'])
if mempool_valid:
assert_equal(tx_info['vsize'], vsize)
- assert_equal(tx_info['fees']['base'], fee)
+ assert_equal(tx_info['fees']['base'], utxo_to_spend['value'] - Decimal(send_value) / COIN)
return {'txid': tx_info['txid'], 'wtxid': tx_info['wtxid'], 'hex': tx_hex, 'tx': tx}
def sendrawtransaction(self, *, from_node, tx_hex):