This was motivated by the Invalid parameter, duplicated address
test.
Credit to @laanwj for multidict
implementation.
72+ assert_raises_rpc_error(-3, "Expected type object", self.nodes[0].createrawtransaction, [], 'foo')
73+ assert_raises_rpc_error(-8, "Data must be hexadecimal string", self.nodes[0].createrawtransaction, [], {'data': 'foo'})
74+ assert_raises_rpc_error(-5, "Invalid Bitcoin address", self.nodes[0].createrawtransaction, [], {'foo': 0})
75+ assert_raises_rpc_error(-3, "Invalid amount", self.nodes[0].createrawtransaction, [], {address: 'foo'})
76+ assert_raises_rpc_error(-3, "Amount out of range", self.nodes[0].createrawtransaction, [], {address: -1})
77+ assert_raises_rpc_error(-8, "Invalid parameter, duplicated address: %s" % address, self.nodes[0].createrawtransaction, [], multidict([(address, 1), (address, 1)]))
createrawtransaction
and sendmany
RPC’s check for duplicated address.
14@@ -15,6 +15,16 @@
15 from test_framework.test_framework import BitcoinTestFramework
16 from test_framework.util import *
17
18+
19+class multidict(dict):
Can you add a comment for this please? Something like:
0"""Dictionary that allows duplicate keys.
1
2Constructed with a list of (key, value) tuples. When dumped by the json module, will output invalid json with repeated keys, eg:
3>>> json.dumps(multidict([(1,2),(1,2)])
4'{"1": 2, "1": 2}'
5
6Used to test calls to rpc methods with invalid repeated keys in the json object."""
48@@ -39,6 +49,41 @@ def run_test(self):
49 self.nodes[0].generate(5)
50 self.sync_all()
51
52+ # Test `createrawtransaction` required parameters
53+ assert_raises_rpc_error(-1, "createrawtransaction", self.nodes[0].createrawtransaction)
54+ assert_raises_rpc_error(-1, "createrawtransaction", self.nodes[0].createrawtransaction, [])
55+
56+ # Test `createrawtransaction` invalid extra parameters
57+ assert_raises_rpc_error(-1, "createrawtransaction", self.nodes[0].createrawtransaction, [], {}, 0, False, 'foo')
In this case I’m not sure, because that will throw Unknown named parameter
. But for other cases you mean?
0assert_raises_rpc_error(-1, "createrawtransaction", self.nodes[0].createrawtransaction, inputs=[], outputs={}, locktime=0, replaceable=False)
According to what others reviewed, only change should be adding a comment, so trivial to re-ACK. (ping @jnewbery )
0-----BEGIN PGP SIGNED MESSAGE-----
1Hash: SHA512
2
3utACK 88af5028ad3de71c8b86b50cb1c6bdd57c1ba6e5
4-----BEGIN PGP SIGNATURE-----
5
6iQIcBAEBCgAGBQJaMUWGAAoJENLqSFDnUoslcNUP/Ar1eK4SOmsoA/SvpfhbpwHE
74jMFEqkKhef4F1AYQIDaJAvh4HKUpyTX2o8IA9XRvrHLjTJz0vFMd/jMMuKbnB7M
86Ie1mmykyNRmFg3qvYJDa4XD6FdLEpR7Nwk4YYlAJemBm9+G24vAY1jL6r3Devle
9g6z90/2iYBYOam6ihkhfd7luRMEFKcIi8fjIVsPXK+g8TLOlS4M9wTjRqQ+6RvC4
10npkANcAsaHcF3f3d3VOggij3TrEUq40fiir5dtW/ViU27fT03YFZKJKfuSRjFxCf
11NRGL1IDlgw4HFKnBLdC/Boq25Lx3f5w7PDUBU4C60YL/j6n5CehxjA3TAOHzDvh+
12l2wGjk3y9TGTnrknZGmwmP7GRbM1a3bVPN0UsZoaKMBzwGnAe+UMpf/rkR+jxjhO
13Ge73jZyowtpv0hPJotVb89kGcWCBaWWOXE6Btr1t8bc/NJB7UYJdjh5/uCHRpeOn
14VeZOZAxS839xUphtgf9yaBF/sjM7lLO/TFIg5OTZBQd/Rs1aV8wijy/P3IeSn+zd
15ZFAmBcqUYep9JQorRDNHzav4a0KIeL10kEJ3BYWezmJSPIkpdXJHX+f/vS8sbkNA
16FMyJi1htT2dwffLal6YleHHEOmpkO2RF0WSzsV0Hs8f3tEImu/5Tgk47gTxo5Nvy
17FqUd3vncrAM1cc5IyU4G
18=IryX
19-----END PGP SIGNATURE-----
promag
laanwj
jonasschnelli
jnewbery
MarcoFalke
Labels
Tests