mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-23 07:15:29 +01:00
Convert amounts from float to decimal
+ fee, fee_expected, output_amount + Using value of coin['amount'] as decimal and removed 'int' + Removed unnecessary parentheses + Remove str() and use quotes
This commit is contained in:
parent
de4b7f25ac
commit
5aadd4be18
1 changed files with 8 additions and 8 deletions
|
@ -83,31 +83,31 @@ class MempoolAcceptanceTest(BitcoinTestFramework):
|
||||||
)
|
)
|
||||||
|
|
||||||
self.log.info('A transaction not in the mempool')
|
self.log.info('A transaction not in the mempool')
|
||||||
fee = 0.00000700
|
fee = Decimal('0.000007')
|
||||||
raw_tx_0 = node.signrawtransactionwithwallet(node.createrawtransaction(
|
raw_tx_0 = node.signrawtransactionwithwallet(node.createrawtransaction(
|
||||||
inputs=[{"txid": txid_in_block, "vout": 0, "sequence": BIP125_SEQUENCE_NUMBER}], # RBF is used later
|
inputs=[{"txid": txid_in_block, "vout": 0, "sequence": BIP125_SEQUENCE_NUMBER}], # RBF is used later
|
||||||
outputs=[{node.getnewaddress(): 0.3 - fee}],
|
outputs=[{node.getnewaddress(): Decimal('0.3') - fee}],
|
||||||
))['hex']
|
))['hex']
|
||||||
tx = CTransaction()
|
tx = CTransaction()
|
||||||
tx.deserialize(BytesIO(hex_str_to_bytes(raw_tx_0)))
|
tx.deserialize(BytesIO(hex_str_to_bytes(raw_tx_0)))
|
||||||
txid_0 = tx.rehash()
|
txid_0 = tx.rehash()
|
||||||
self.check_mempool_result(
|
self.check_mempool_result(
|
||||||
result_expected=[{'txid': txid_0, 'allowed': True, 'vsize': tx.get_vsize(), 'fees': {'base': Decimal(str(fee))}}],
|
result_expected=[{'txid': txid_0, 'allowed': True, 'vsize': tx.get_vsize(), 'fees': {'base': fee}}],
|
||||||
rawtxs=[raw_tx_0],
|
rawtxs=[raw_tx_0],
|
||||||
)
|
)
|
||||||
|
|
||||||
self.log.info('A final transaction not in the mempool')
|
self.log.info('A final transaction not in the mempool')
|
||||||
coin = coins.pop() # Pick a random coin(base) to spend
|
coin = coins.pop() # Pick a random coin(base) to spend
|
||||||
output_amount = 0.025
|
output_amount = Decimal('0.025')
|
||||||
raw_tx_final = node.signrawtransactionwithwallet(node.createrawtransaction(
|
raw_tx_final = node.signrawtransactionwithwallet(node.createrawtransaction(
|
||||||
inputs=[{'txid': coin['txid'], 'vout': coin['vout'], "sequence": 0xffffffff}], # SEQUENCE_FINAL
|
inputs=[{'txid': coin['txid'], 'vout': coin['vout'], "sequence": 0xffffffff}], # SEQUENCE_FINAL
|
||||||
outputs=[{node.getnewaddress(): output_amount}],
|
outputs=[{node.getnewaddress(): output_amount}],
|
||||||
locktime=node.getblockcount() + 2000, # Can be anything
|
locktime=node.getblockcount() + 2000, # Can be anything
|
||||||
))['hex']
|
))['hex']
|
||||||
tx.deserialize(BytesIO(hex_str_to_bytes(raw_tx_final)))
|
tx.deserialize(BytesIO(hex_str_to_bytes(raw_tx_final)))
|
||||||
fee_expected = int(coin['amount']) - output_amount
|
fee_expected = coin['amount'] - output_amount
|
||||||
self.check_mempool_result(
|
self.check_mempool_result(
|
||||||
result_expected=[{'txid': tx.rehash(), 'allowed': True, 'vsize': tx.get_vsize(), 'fees': {'base': Decimal(str(fee_expected))}}],
|
result_expected=[{'txid': tx.rehash(), 'allowed': True, 'vsize': tx.get_vsize(), 'fees': {'base': fee_expected}}],
|
||||||
rawtxs=[tx.serialize().hex()],
|
rawtxs=[tx.serialize().hex()],
|
||||||
maxfeerate=0,
|
maxfeerate=0,
|
||||||
)
|
)
|
||||||
|
@ -130,7 +130,7 @@ class MempoolAcceptanceTest(BitcoinTestFramework):
|
||||||
tx.deserialize(BytesIO(hex_str_to_bytes(raw_tx_0)))
|
tx.deserialize(BytesIO(hex_str_to_bytes(raw_tx_0)))
|
||||||
txid_0 = tx.rehash()
|
txid_0 = tx.rehash()
|
||||||
self.check_mempool_result(
|
self.check_mempool_result(
|
||||||
result_expected=[{'txid': txid_0, 'allowed': True, 'vsize': tx.get_vsize(), 'fees': {'base': Decimal(str(2 * fee))}}],
|
result_expected=[{'txid': txid_0, 'allowed': True, 'vsize': tx.get_vsize(), 'fees': {'base': (2 * fee)}}],
|
||||||
rawtxs=[raw_tx_0],
|
rawtxs=[raw_tx_0],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ class MempoolAcceptanceTest(BitcoinTestFramework):
|
||||||
tx.deserialize(BytesIO(hex_str_to_bytes(raw_tx_reference)))
|
tx.deserialize(BytesIO(hex_str_to_bytes(raw_tx_reference)))
|
||||||
# Reference tx should be valid on itself
|
# Reference tx should be valid on itself
|
||||||
self.check_mempool_result(
|
self.check_mempool_result(
|
||||||
result_expected=[{'txid': tx.rehash(), 'allowed': True, 'vsize': tx.get_vsize(), 'fees': { 'base': Decimal(str(0.1 - 0.05))}}],
|
result_expected=[{'txid': tx.rehash(), 'allowed': True, 'vsize': tx.get_vsize(), 'fees': { 'base': Decimal('0.1') - Decimal('0.05')}}],
|
||||||
rawtxs=[tx.serialize().hex()],
|
rawtxs=[tx.serialize().hex()],
|
||||||
maxfeerate=0,
|
maxfeerate=0,
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue