Skip to content

Commit aaaa8eb

Browse files
author
MarcoFalke
committed
test: consensus: Check that final transactions are valid
1 parent fae3617 commit aaaa8eb

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

test/functional/mempool_accept.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from io import BytesIO
88
import math
9+
910
from test_framework.test_framework import BitcoinTestFramework
1011
from test_framework.messages import (
1112
BIP125_SEQUENCE_NUMBER,
@@ -71,6 +72,7 @@ def run_test(self):
7172
))['hex']
7273
txid_in_block = node.sendrawtransaction(hexstring=raw_tx_in_block, allowhighfees=True)
7374
node.generate(1)
75+
self.mempool_size = 0
7476
self.check_mempool_result(
7577
result_expected=[{'txid': txid_in_block, 'allowed': False, 'reject-reason': '18: txn-already-known'}],
7678
rawtxs=[raw_tx_in_block],
@@ -90,9 +92,25 @@ def run_test(self):
9092
rawtxs=[raw_tx_0],
9193
)
9294

95+
self.log.info('A final transaction not in the mempool')
96+
coin = node.listunspent()[0] # Pick a random coin(base) to spend
97+
raw_tx_final = node.signrawtransactionwithwallet(node.createrawtransaction(
98+
inputs=[{'txid': coin['txid'], 'vout': coin['vout'], "sequence": 0xffffffff}], # SEQUENCE_FINAL
99+
outputs=[{node.getnewaddress(): 0.025}],
100+
locktime=node.getblockcount() + 2000, # Can be anything
101+
))['hex']
102+
tx.deserialize(BytesIO(hex_str_to_bytes(raw_tx_final)))
103+
self.check_mempool_result(
104+
result_expected=[{'txid': tx.rehash(), 'allowed': True}],
105+
rawtxs=[bytes_to_hex_str(tx.serialize())],
106+
allowhighfees=True,
107+
)
108+
node.sendrawtransaction(hexstring=raw_tx_final, allowhighfees=True)
109+
self.mempool_size += 1
110+
93111
self.log.info('A transaction in the mempool')
94112
node.sendrawtransaction(hexstring=raw_tx_0)
95-
self.mempool_size = 1
113+
self.mempool_size += 1
96114
self.check_mempool_result(
97115
result_expected=[{'txid': txid_0, 'allowed': False, 'reject-reason': '18: txn-already-in-mempool'}],
98116
rawtxs=[raw_tx_0],

0 commit comments

Comments
 (0)