aboutsummaryrefslogtreecommitdiff
path: root/test/functional
diff options
context:
space:
mode:
authorJon Atack <jon@atack.com>2021-07-12 14:48:54 +0200
committerJon Atack <jon@atack.com>2021-08-31 20:51:20 +0200
commit8c19d1329f1f28000ca32d826cecf04680c6be69 (patch)
tree098151cbe21c50edfb24269564d168b9b35f5424 /test/functional
parent7f073594c9f5b518dc1fb66dfb0189e8803e3545 (diff)
refactor: dedup/reorg createrawtransaction sequence number tests
Diffstat (limited to 'test/functional')
-rwxr-xr-xtest/functional/rpc_rawtransaction.py36
1 files changed, 13 insertions, 23 deletions
diff --git a/test/functional/rpc_rawtransaction.py b/test/functional/rpc_rawtransaction.py
index 4c3dcac046..deb2a668af 100755
--- a/test/functional/rpc_rawtransaction.py
+++ b/test/functional/rpc_rawtransaction.py
@@ -105,7 +105,19 @@ class RawTransactionsTest(BitcoinTestFramework):
assert_raises_rpc_error(-8, "Invalid parameter, missing vout key", self.nodes[0].createrawtransaction, [{'txid': txid}], {})
assert_raises_rpc_error(-8, "Invalid parameter, missing vout key", self.nodes[0].createrawtransaction, [{'txid': txid, 'vout': 'foo'}], {})
assert_raises_rpc_error(-8, "Invalid parameter, vout cannot be negative", self.nodes[0].createrawtransaction, [{'txid': txid, 'vout': -1}], {})
- assert_raises_rpc_error(-8, "Invalid parameter, sequence number is out of range", self.nodes[0].createrawtransaction, [{'txid': txid, 'vout': 0, 'sequence': -1}], {})
+ # sequence number out of range
+ for invalid_seq in [-1, 4294967296]:
+ inputs = [{'txid': txid, 'vout': 1, 'sequence': invalid_seq}]
+ outputs = {self.nodes[0].getnewaddress(): 1}
+ assert_raises_rpc_error(-8, 'Invalid parameter, sequence number is out of range',
+ self.nodes[0].createrawtransaction, inputs, outputs)
+ # with valid sequence number
+ for valid_seq in [1000, 4294967294]:
+ inputs = [{'txid': txid, 'vout': 1, 'sequence': valid_seq}]
+ outputs = {self.nodes[0].getnewaddress(): 1}
+ rawtx = self.nodes[0].createrawtransaction(inputs, outputs)
+ decrawtx = self.nodes[0].decoderawtransaction(rawtx)
+ assert_equal(decrawtx['vin'][0]['sequence'], valid_seq)
# Test `createrawtransaction` invalid `outputs`
address = self.nodes[0].getnewaddress()
@@ -437,28 +449,6 @@ class RawTransactionsTest(BitcoinTestFramework):
# 8. invalid parameters - supply txid and empty dict
assert_raises_rpc_error(-1, "not a boolean", self.nodes[0].getrawtransaction, txId, {})
- inputs = [ {'txid' : "1d1d4e24ed99057e84c3f80fd8fbec79ed9e1acee37da269356ecea000000000", 'vout' : 1, 'sequence' : 1000}]
- outputs = { self.nodes[0].getnewaddress() : 1 }
- rawtx = self.nodes[0].createrawtransaction(inputs, outputs)
- decrawtx= self.nodes[0].decoderawtransaction(rawtx)
- assert_equal(decrawtx['vin'][0]['sequence'], 1000)
-
- # 9. invalid parameters - sequence number out of range
- inputs = [ {'txid' : "1d1d4e24ed99057e84c3f80fd8fbec79ed9e1acee37da269356ecea000000000", 'vout' : 1, 'sequence' : -1}]
- outputs = { self.nodes[0].getnewaddress() : 1 }
- assert_raises_rpc_error(-8, 'Invalid parameter, sequence number is out of range', self.nodes[0].createrawtransaction, inputs, outputs)
-
- # 10. invalid parameters - sequence number out of range
- inputs = [ {'txid' : "1d1d4e24ed99057e84c3f80fd8fbec79ed9e1acee37da269356ecea000000000", 'vout' : 1, 'sequence' : 4294967296}]
- outputs = { self.nodes[0].getnewaddress() : 1 }
- assert_raises_rpc_error(-8, 'Invalid parameter, sequence number is out of range', self.nodes[0].createrawtransaction, inputs, outputs)
-
- inputs = [ {'txid' : "1d1d4e24ed99057e84c3f80fd8fbec79ed9e1acee37da269356ecea000000000", 'vout' : 1, 'sequence' : 4294967294}]
- outputs = { self.nodes[0].getnewaddress() : 1 }
- rawtx = self.nodes[0].createrawtransaction(inputs, outputs)
- decrawtx= self.nodes[0].decoderawtransaction(rawtx)
- assert_equal(decrawtx['vin'][0]['sequence'], 4294967294)
-
####################################
# TRANSACTION VERSION NUMBER TESTS #
####################################