From 27c6199373093bff194f996bca0a85ed52088790 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jo=C3=A3o=20Barbosa?= Date: Tue, 12 Dec 2017 14:55:00 +0000 Subject: [PATCH] test: Add multidict to support dictionary with duplicate key (laanwj) --- test/functional/rawtransactions.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/functional/rawtransactions.py b/test/functional/rawtransactions.py index 79f2a2834..1495bc375 100755 --- a/test/functional/rawtransactions.py +++ b/test/functional/rawtransactions.py @@ -15,6 +15,25 @@ Test the following RPCs: from test_framework.test_framework import BitcoinTestFramework from test_framework.util import * + +class multidict(dict): + """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 repeated keys in the json object.""" + + def __init__(self, x): + dict.__init__(self, x) + self.x = x + + def items(self): + return self.x + + # Create one-input, one-output, no-fee transaction: class RawTransactionsTest(BitcoinTestFramework): def set_test_params(self): -- 2.11.4.GIT