Skip to content

Commit 27c6199

Browse files
committed
test: Add multidict to support dictionary with duplicate key (laanwj)
1 parent 320669a commit 27c6199

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

test/functional/rawtransactions.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,25 @@
1515
from test_framework.test_framework import BitcoinTestFramework
1616
from test_framework.util import *
1717

18+
19+
class multidict(dict):
20+
"""Dictionary that allows duplicate keys.
21+
22+
Constructed with a list of (key, value) tuples. When dumped by the json module,
23+
will output invalid json with repeated keys, eg:
24+
>>> json.dumps(multidict([(1,2),(1,2)])
25+
'{"1": 2, "1": 2}'
26+
27+
Used to test calls to rpc methods with repeated keys in the json object."""
28+
29+
def __init__(self, x):
30+
dict.__init__(self, x)
31+
self.x = x
32+
33+
def items(self):
34+
return self.x
35+
36+
1837
# Create one-input, one-output, no-fee transaction:
1938
class RawTransactionsTest(BitcoinTestFramework):
2039
def set_test_params(self):

0 commit comments

Comments
 (0)