Skip to content

Commit

Permalink
partial bitcoin#14926: test: consensus: Check that final transactions…
Browse files Browse the repository at this point in the history
… are valid

Does not include commit (fae3617) that makes a change to code introduced here:
	330b0f3 [qa] p2p segwit tests (Merge bitcoin#8149: Segregated witness rebased)
which I don't think is in Dash

aaaa8eb test: consensus: Check that final transactions are valid (MarcoFalke)
fae3617 test: Correctly deserialize without witness (MarcoFalke)

Pull request description:

  There is no check that checks that final transactions are valid, i.e. the consensus rules could be changed (accidentally) with none of the tests failing.

Tree-SHA512: 48f4c24bfcc525ddbc1bfe8c37131953b464823428c1f7a278ba6d98b98827b6b84a8eb2b33396bfb5b8cc4012b7cc1cd771637f405ea20beddae001c22aa290
  • Loading branch information
laanwj authored and christiancfifi committed Aug 24, 2021
1 parent f41004a commit 6590ec9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion test/functional/mempool_accept.py
Expand Up @@ -6,6 +6,7 @@

from io import BytesIO
import math

from test_framework.test_framework import BitcoinTestFramework
from test_framework.messages import (
BIP125_SEQUENCE_NUMBER,
Expand Down Expand Up @@ -69,6 +70,7 @@ def run_test(self):
))['hex']
txid_in_block = node.sendrawtransaction(hexstring=raw_tx_in_block, allowhighfees=True)
node.generate(1)
self.mempool_size = 0
self.check_mempool_result(
result_expected=[{'txid': txid_in_block, 'allowed': False, 'reject-reason': '18: txn-already-known'}],
rawtxs=[raw_tx_in_block],
Expand All @@ -88,9 +90,25 @@ def run_test(self):
rawtxs=[raw_tx_0],
)

self.log.info('A final transaction not in the mempool')
coin = node.listunspent()[0] # Pick a random coin(base) to spend
raw_tx_final = node.signrawtransactionwithwallet(node.createrawtransaction(
inputs=[{'txid': coin['txid'], 'vout': coin['vout'], "sequence": 0xffffffff}], # SEQUENCE_FINAL
outputs=[{node.getnewaddress(): 0.025}],
locktime=node.getblockcount() + 2000, # Can be anything
))['hex']
tx.deserialize(BytesIO(hex_str_to_bytes(raw_tx_final)))
self.check_mempool_result(
result_expected=[{'txid': tx.rehash(), 'allowed': True}],
rawtxs=[bytes_to_hex_str(tx.serialize())],
allowhighfees=True,
)
node.sendrawtransaction(hexstring=raw_tx_final, allowhighfees=True)
self.mempool_size += 1

self.log.info('A transaction in the mempool')
node.sendrawtransaction(hexstring=raw_tx_0)
self.mempool_size = 1
self.mempool_size += 1
self.check_mempool_result(
result_expected=[{'txid': txid_0, 'allowed': False, 'reject-reason': '18: txn-already-in-mempool'}],
rawtxs=[raw_tx_0],
Expand Down
Empty file modified test/functional/test_framework/messages.py 100755 → 100644
Empty file.

0 comments on commit 6590ec9

Please sign in to comment.