Skip to content

Commit 6e67754

Browse files
committed
Merge #12436: [rpc] Adds a functional test to validate the transaction version number in the RPC output
09b30db Asserts that the tx version number is a signed 32-bit integer. (251) Pull request description: This PR attempts to resolve #11561 by addressing the feedback from @MarcoFalke; and @gmaxwell in #12430. Commit 30e9d24 adds a functional test to `rpc_rawtransaction.py` to assert that the transaction version number in the RPC output is a signed 32-bit integer. The functional test uses the raw transaction data from Mainnet transaction `c659729a7fea5071361c2c1a68551ca2bf77679b27086cc415adeeb03852e369`. Tree-SHA512: d78f3120b9aa04537561ab5584769a838b25e162c5caa6e1543256fb27538aa4c708c939fb5ba93ccb3fa676c2d92ce8eb9cc78869f80ac96be64a7bec7bebd0
2 parents 34dd1a6 + 09b30db commit 6e67754

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

test/functional/rpc_rawtransaction.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,10 @@
1414

1515
from collections import OrderedDict
1616
from io import BytesIO
17+
from test_framework.messages import CTransaction, ToHex
1718
from test_framework.test_framework import BitcoinTestFramework
18-
from test_framework.messages import (
19-
CTransaction,
20-
)
2119
from test_framework.util import *
2220

23-
2421
class multidict(dict):
2522
"""Dictionary that allows duplicate keys.
2623
@@ -363,5 +360,23 @@ def run_test(self):
363360
decrawtx= self.nodes[0].decoderawtransaction(rawtx)
364361
assert_equal(decrawtx['vin'][0]['sequence'], 4294967294)
365362

363+
####################################
364+
# TRANSACTION VERSION NUMBER TESTS #
365+
####################################
366+
367+
# Test the minimum transaction version number that fits in a signed 32-bit integer.
368+
tx = CTransaction()
369+
tx.nVersion = -0x80000000
370+
rawtx = ToHex(tx)
371+
decrawtx = self.nodes[0].decoderawtransaction(rawtx)
372+
assert_equal(decrawtx['version'], -0x80000000)
373+
374+
# Test the maximum transaction version number that fits in a signed 32-bit integer.
375+
tx = CTransaction()
376+
tx.nVersion = 0x7fffffff
377+
rawtx = ToHex(tx)
378+
decrawtx = self.nodes[0].decoderawtransaction(rawtx)
379+
assert_equal(decrawtx['version'], 0x7fffffff)
380+
366381
if __name__ == '__main__':
367382
RawTransactionsTest().main()

0 commit comments

Comments
 (0)