aboutsummaryrefslogtreecommitdiff
path: root/test/functional
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2018-04-24 11:56:32 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2018-04-24 11:57:36 +0200
commit6e67754e481f4072dffca04e9f8cbfb5e29725a3 (patch)
tree526d63e936916d98519bd7740f0af62fc926ff04 /test/functional
parent34dd1a6d5e3610c2cbff76422d6a653b1acf5abc (diff)
parent09b30db2b02aef03d15c2def9181bce93db400bb (diff)
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
Diffstat (limited to 'test/functional')
-rwxr-xr-xtest/functional/rpc_rawtransaction.py23
1 files changed, 19 insertions, 4 deletions
diff --git a/test/functional/rpc_rawtransaction.py b/test/functional/rpc_rawtransaction.py
index 658782e82a..48b4a4a9db 100755
--- a/test/functional/rpc_rawtransaction.py
+++ b/test/functional/rpc_rawtransaction.py
@@ -14,13 +14,10 @@ Test the following RPCs:
from collections import OrderedDict
from io import BytesIO
+from test_framework.messages import CTransaction, ToHex
from test_framework.test_framework import BitcoinTestFramework
-from test_framework.messages import (
- CTransaction,
-)
from test_framework.util import *
-
class multidict(dict):
"""Dictionary that allows duplicate keys.
@@ -363,5 +360,23 @@ class RawTransactionsTest(BitcoinTestFramework):
decrawtx= self.nodes[0].decoderawtransaction(rawtx)
assert_equal(decrawtx['vin'][0]['sequence'], 4294967294)
+ ####################################
+ # TRANSACTION VERSION NUMBER TESTS #
+ ####################################
+
+ # Test the minimum transaction version number that fits in a signed 32-bit integer.
+ tx = CTransaction()
+ tx.nVersion = -0x80000000
+ rawtx = ToHex(tx)
+ decrawtx = self.nodes[0].decoderawtransaction(rawtx)
+ assert_equal(decrawtx['version'], -0x80000000)
+
+ # Test the maximum transaction version number that fits in a signed 32-bit integer.
+ tx = CTransaction()
+ tx.nVersion = 0x7fffffff
+ rawtx = ToHex(tx)
+ decrawtx = self.nodes[0].decoderawtransaction(rawtx)
+ assert_equal(decrawtx['version'], 0x7fffffff)
+
if __name__ == '__main__':
RawTransactionsTest().main()