Changeset View
Changeset View
Standalone View
Standalone View
test/functional/rpc_rawtransaction.py
Show All 10 Lines | Test the following RPCs: | ||||
- decoderawtransaction | - decoderawtransaction | ||||
- getrawtransaction | - getrawtransaction | ||||
""" | """ | ||||
from decimal import Decimal | from decimal import Decimal | ||||
from collections import OrderedDict | from collections import OrderedDict | ||||
from io import BytesIO | from io import BytesIO | ||||
from test_framework.messages import CTransaction, ToHex | |||||
from test_framework.test_framework import BitcoinTestFramework | from test_framework.test_framework import BitcoinTestFramework | ||||
from test_framework.txtools import pad_raw_tx | from test_framework.txtools import pad_raw_tx | ||||
from test_framework.util import ( | from test_framework.util import ( | ||||
assert_equal, | assert_equal, | ||||
assert_greater_than, | assert_greater_than, | ||||
assert_raises_rpc_error, | assert_raises_rpc_error, | ||||
connect_nodes_bi, | connect_nodes_bi, | ||||
hex_str_to_bytes, | hex_str_to_bytes, | ||||
bytes_to_hex_str, | bytes_to_hex_str, | ||||
) | ) | ||||
from test_framework.messages import ( | |||||
CTransaction, | |||||
) | |||||
class multidict(dict): | class multidict(dict): | ||||
"""Dictionary that allows duplicate keys. | """Dictionary that allows duplicate keys. | ||||
Constructed with a list of (key, value) tuples. When dumped by the json module, | Constructed with a list of (key, value) tuples. When dumped by the json module, | ||||
will output invalid json with repeated keys, eg: | will output invalid json with repeated keys, eg: | ||||
>>> json.dumps(multidict([(1,2),(1,2)]) | >>> json.dumps(multidict([(1,2),(1,2)]) | ||||
'{"1": 2, "1": 2}' | '{"1": 2, "1": 2}' | ||||
▲ Show 20 Lines • Show All 431 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
-8, 'Invalid parameter, sequence number is out of range', | -8, 'Invalid parameter, sequence number is out of range', | ||||
self.nodes[0].createrawtransaction, inputs, outputs) | self.nodes[0].createrawtransaction, inputs, outputs) | ||||
inputs[0]['sequence'] = 4294967294 | inputs[0]['sequence'] = 4294967294 | ||||
rawtx = self.nodes[0].createrawtransaction(inputs, outputs) | rawtx = self.nodes[0].createrawtransaction(inputs, outputs) | ||||
decrawtx = self.nodes[0].decoderawtransaction(rawtx) | decrawtx = self.nodes[0].decoderawtransaction(rawtx) | ||||
assert_equal(decrawtx['vin'][0]['sequence'], 4294967294) | 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__': | if __name__ == '__main__': | ||||
RawTransactionsTest().main() | RawTransactionsTest().main() |