mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
merge bitcoin#23210: Replace satoshi_round with int() or Decimal()
This commit is contained in:
parent
739394df18
commit
851dae7b29
@ -21,7 +21,6 @@ from test_framework.util import (
|
||||
assert_equal,
|
||||
assert_greater_than,
|
||||
assert_raises_rpc_error,
|
||||
satoshi_round,
|
||||
softfork_active,
|
||||
)
|
||||
from test_framework.script_util import DUMMY_P2SH_SCRIPT
|
||||
@ -91,7 +90,7 @@ class BIP68Test(BitcoinTestFramework):
|
||||
utxo = utxos[0]
|
||||
|
||||
tx1 = CTransaction()
|
||||
value = int(satoshi_round(utxo["amount"] - self.relayfee)*COIN)
|
||||
value = int((utxo["amount"] - self.relayfee) * COIN)
|
||||
|
||||
# Check that the disable flag disables relative locktime.
|
||||
# If sequence locks were used, this would require 1 block for the
|
||||
|
@ -14,7 +14,6 @@ from test_framework.util import (
|
||||
assert_equal,
|
||||
assert_raises_rpc_error,
|
||||
chain_transaction,
|
||||
satoshi_round,
|
||||
)
|
||||
|
||||
# default limits
|
||||
@ -190,10 +189,10 @@ class MempoolPackagesTest(BitcoinTestFramework):
|
||||
entry = self.nodes[0].getmempoolentry(x)
|
||||
descendant_fees += entry['fee']
|
||||
if (x == chain[-1]):
|
||||
assert_equal(entry['modifiedfee'], entry['fee']+satoshi_round(0.00002))
|
||||
assert_equal(entry['fees']['modified'], entry['fee']+satoshi_round(0.00002))
|
||||
assert_equal(entry['modifiedfee'], entry['fee'] + Decimal("0.00002"))
|
||||
assert_equal(entry['fees']['modified'], entry['fee'] + Decimal("0.00002"))
|
||||
assert_equal(entry['descendantfees'], descendant_fees * COIN + 2000)
|
||||
assert_equal(entry['fees']['descendant'], descendant_fees+satoshi_round(0.00002))
|
||||
assert_equal(entry['fees']['descendant'], descendant_fees + Decimal("0.00002"))
|
||||
|
||||
# Check that node1's mempool is as expected (-> custom ancestor limit)
|
||||
mempool0 = self.nodes[0].getrawmempool(False)
|
||||
@ -289,7 +288,7 @@ class MempoolPackagesTest(BitcoinTestFramework):
|
||||
value = utxo[0]['amount']
|
||||
vout = utxo[0]['vout']
|
||||
|
||||
send_value = satoshi_round((value - fee)/2)
|
||||
send_value = (value - fee) / 2
|
||||
inputs = [ {'txid' : txid, 'vout' : vout} ]
|
||||
outputs = {}
|
||||
for _ in range(2):
|
||||
|
@ -31,7 +31,6 @@ from test_framework.script import (
|
||||
from test_framework.util import (
|
||||
assert_equal,
|
||||
assert_greater_than_or_equal,
|
||||
satoshi_round,
|
||||
)
|
||||
|
||||
DEFAULT_FEE = Decimal("0.0001")
|
||||
@ -162,13 +161,12 @@ class MiniWallet:
|
||||
vsize = Decimal(85) # 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
|
||||
@ -186,7 +184,7 @@ class MiniWallet:
|
||||
assert_equal(mempool_valid, tx_info['allowed'])
|
||||
if mempool_valid:
|
||||
assert_equal(len(tx_hex) // 2, vsize) # 1 byte = 2 character
|
||||
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'], 'hex': tx_hex, 'tx': tx}
|
||||
|
||||
def sendrawtransaction(self, *, from_node, tx_hex):
|
||||
|
Loading…
Reference in New Issue
Block a user