Skip to content

Conversation

promag
Copy link
Contributor

@promag promag commented Dec 12, 2017

This was motivated by the Invalid parameter, duplicated address test.

Credit to @laanwj for multidict implementation.

@promag
Copy link
Contributor Author

promag commented Dec 12, 2017

Relates to #11872 (#11872 (comment)).

assert_raises_rpc_error(-5, "Invalid Bitcoin address", self.nodes[0].createrawtransaction, [], {'foo': 0})
assert_raises_rpc_error(-3, "Invalid amount", self.nodes[0].createrawtransaction, [], {address: 'foo'})
assert_raises_rpc_error(-3, "Amount out of range", self.nodes[0].createrawtransaction, [], {address: -1})
assert_raises_rpc_error(-8, "Invalid parameter, duplicated address: %s" % address, self.nodes[0].createrawtransaction, [], multidict([(address, 1), (address, 1)]))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So there is already a check for duplicated address?
That's great!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, createrawtransaction and sendmany RPC's check for duplicated address.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed! I hadn't expected a check here because passing this is tricky in JSON object format.

@laanwj
Copy link
Member

laanwj commented Dec 12, 2017

utACK 0df137b

@laanwj laanwj added the Tests label Dec 12, 2017
Copy link
Contributor

@jonasschnelli jonasschnelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK 0df137b8c719a904c792240a0e373ca38c334443

Copy link
Contributor

@jnewbery jnewbery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested ACK. Great coverage - thanks @promag . One request for an additional comment.

@@ -15,6 +15,16 @@
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *


class multidict(dict):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment for this please? Something like:

"""Dictionary that allows duplicate keys.

Constructed with a list of (key, value) tuples. When dumped by the json module, will output invalid json with repeated keys, eg:
>>> json.dumps(multidict([(1,2),(1,2)])
'{"1": 2, "1": 2}'

Used to test calls to rpc methods with invalid repeated keys in the json object."""

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah submitting JSON objects in deterministic order and with potentially duplicated keys is the only thing it's good for, it's not quite a traditional multidict implementation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

assert_raises_rpc_error(-1, "createrawtransaction", self.nodes[0].createrawtransaction, [])

# Test `createrawtransaction` invalid extra parameters
assert_raises_rpc_error(-1, "createrawtransaction", self.nodes[0].createrawtransaction, [], {}, 0, False, 'foo')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: My personal style preference is to use named args when passing unnamed parameters. Not sure what others think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case I'm not sure, because that will throw Unknown named parameter. But for other cases you mean?

assert_raises_rpc_error(-1, "createrawtransaction", self.nodes[0].createrawtransaction, inputs=[], outputs={}, locktime=0, replaceable=False)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, right. Won't work in this case.

@maflcko
Copy link
Member

maflcko commented Dec 13, 2017

Concept ACK.

@promag promag force-pushed the 2017-12-createrawtransaction branch from 0df137b to 88af502 Compare December 13, 2017 14:52
@maflcko
Copy link
Member

maflcko commented Dec 13, 2017

According to what others reviewed, only change should be adding a comment, so trivial to re-ACK. (ping @jnewbery )

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

utACK 88af5028ad3de71c8b86b50cb1c6bdd57c1ba6e5
-----BEGIN PGP SIGNATURE-----

iQIcBAEBCgAGBQJaMUWGAAoJENLqSFDnUoslcNUP/Ar1eK4SOmsoA/SvpfhbpwHE
4jMFEqkKhef4F1AYQIDaJAvh4HKUpyTX2o8IA9XRvrHLjTJz0vFMd/jMMuKbnB7M
6Ie1mmykyNRmFg3qvYJDa4XD6FdLEpR7Nwk4YYlAJemBm9+G24vAY1jL6r3Devle
g6z90/2iYBYOam6ihkhfd7luRMEFKcIi8fjIVsPXK+g8TLOlS4M9wTjRqQ+6RvC4
npkANcAsaHcF3f3d3VOggij3TrEUq40fiir5dtW/ViU27fT03YFZKJKfuSRjFxCf
NRGL1IDlgw4HFKnBLdC/Boq25Lx3f5w7PDUBU4C60YL/j6n5CehxjA3TAOHzDvh+
l2wGjk3y9TGTnrknZGmwmP7GRbM1a3bVPN0UsZoaKMBzwGnAe+UMpf/rkR+jxjhO
Ge73jZyowtpv0hPJotVb89kGcWCBaWWOXE6Btr1t8bc/NJB7UYJdjh5/uCHRpeOn
VeZOZAxS839xUphtgf9yaBF/sjM7lLO/TFIg5OTZBQd/Rs1aV8wijy/P3IeSn+zd
ZFAmBcqUYep9JQorRDNHzav4a0KIeL10kEJ3BYWezmJSPIkpdXJHX+f/vS8sbkNA
FMyJi1htT2dwffLal6YleHHEOmpkO2RF0WSzsV0Hs8f3tEImu/5Tgk47gTxo5Nvy
FqUd3vncrAM1cc5IyU4G
=IryX
-----END PGP SIGNATURE-----

@jnewbery
Copy link
Contributor

Tested ACK 88af502. Comment looks good 🙂

@laanwj laanwj merged commit 88af502 into bitcoin:master Dec 13, 2017
laanwj added a commit that referenced this pull request Dec 13, 2017
88af502 test: Add createrawtransaction functional tests (João Barbosa)
27c6199 test: Add multidict to support dictionary with duplicate key (laanwj) (João Barbosa)
320669a rpc: Validate replaceable type in createrawtransaction (João Barbosa)

Pull request description:

  This was motivated by the `Invalid parameter, duplicated address` test.

  Credit to @laanwj for `multidict` implementation.

Tree-SHA512: a87139ae11004b73b467db1e8a072b75e23a0622b173a5668eed383b3575d8abc709817ddd2dfdc53f55afc90750fb61331199ad5de38c1ef6d482f2bc220f74
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 17, 2020
88af502 test: Add createrawtransaction functional tests (João Barbosa)
27c6199 test: Add multidict to support dictionary with duplicate key (laanwj) (João Barbosa)
320669a rpc: Validate replaceable type in createrawtransaction (João Barbosa)

Pull request description:

  This was motivated by the `Invalid parameter, duplicated address` test.

  Credit to @laanwj for `multidict` implementation.

Tree-SHA512: a87139ae11004b73b467db1e8a072b75e23a0622b173a5668eed383b3575d8abc709817ddd2dfdc53f55afc90750fb61331199ad5de38c1ef6d482f2bc220f74
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 22, 2020
88af502 test: Add createrawtransaction functional tests (João Barbosa)
27c6199 test: Add multidict to support dictionary with duplicate key (laanwj) (João Barbosa)
320669a rpc: Validate replaceable type in createrawtransaction (João Barbosa)

Pull request description:

  This was motivated by the `Invalid parameter, duplicated address` test.

  Credit to @laanwj for `multidict` implementation.

Tree-SHA512: a87139ae11004b73b467db1e8a072b75e23a0622b173a5668eed383b3575d8abc709817ddd2dfdc53f55afc90750fb61331199ad5de38c1ef6d482f2bc220f74
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 22, 2020
88af502 test: Add createrawtransaction functional tests (João Barbosa)
27c6199 test: Add multidict to support dictionary with duplicate key (laanwj) (João Barbosa)
320669a rpc: Validate replaceable type in createrawtransaction (João Barbosa)

Pull request description:

  This was motivated by the `Invalid parameter, duplicated address` test.

  Credit to @laanwj for `multidict` implementation.

Tree-SHA512: a87139ae11004b73b467db1e8a072b75e23a0622b173a5668eed383b3575d8abc709817ddd2dfdc53f55afc90750fb61331199ad5de38c1ef6d482f2bc220f74
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 29, 2020
88af502 test: Add createrawtransaction functional tests (João Barbosa)
27c6199 test: Add multidict to support dictionary with duplicate key (laanwj) (João Barbosa)
320669a rpc: Validate replaceable type in createrawtransaction (João Barbosa)

Pull request description:

  This was motivated by the `Invalid parameter, duplicated address` test.

  Credit to @laanwj for `multidict` implementation.

Tree-SHA512: a87139ae11004b73b467db1e8a072b75e23a0622b173a5668eed383b3575d8abc709817ddd2dfdc53f55afc90750fb61331199ad5de38c1ef6d482f2bc220f74
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 29, 2020
88af502 test: Add createrawtransaction functional tests (João Barbosa)
27c6199 test: Add multidict to support dictionary with duplicate key (laanwj) (João Barbosa)
320669a rpc: Validate replaceable type in createrawtransaction (João Barbosa)

Pull request description:

  This was motivated by the `Invalid parameter, duplicated address` test.

  Credit to @laanwj for `multidict` implementation.

Tree-SHA512: a87139ae11004b73b467db1e8a072b75e23a0622b173a5668eed383b3575d8abc709817ddd2dfdc53f55afc90750fb61331199ad5de38c1ef6d482f2bc220f74
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 29, 2020
88af502 test: Add createrawtransaction functional tests (João Barbosa)
27c6199 test: Add multidict to support dictionary with duplicate key (laanwj) (João Barbosa)
320669a rpc: Validate replaceable type in createrawtransaction (João Barbosa)

Pull request description:

  This was motivated by the `Invalid parameter, duplicated address` test.

  Credit to @laanwj for `multidict` implementation.

Tree-SHA512: a87139ae11004b73b467db1e8a072b75e23a0622b173a5668eed383b3575d8abc709817ddd2dfdc53f55afc90750fb61331199ad5de38c1ef6d482f2bc220f74
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 31, 2020
88af502 test: Add createrawtransaction functional tests (João Barbosa)
27c6199 test: Add multidict to support dictionary with duplicate key (laanwj) (João Barbosa)
320669a rpc: Validate replaceable type in createrawtransaction (João Barbosa)

Pull request description:

  This was motivated by the `Invalid parameter, duplicated address` test.

  Credit to @laanwj for `multidict` implementation.

Tree-SHA512: a87139ae11004b73b467db1e8a072b75e23a0622b173a5668eed383b3575d8abc709817ddd2dfdc53f55afc90750fb61331199ad5de38c1ef6d482f2bc220f74
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants