diff options
author | Joao Fonseca <jpdf.fonseca@gmail.com> | 2016-04-19 12:22:11 +0100 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2016-04-19 16:37:14 +0200 |
commit | 6862627ce6bc04e68801f026629932987c3ab424 (patch) | |
tree | cbac56de6ad52eebe40e23048a8e3293c6f2ad9d /qa/rpc-tests/test_framework/util.py | |
parent | 28ba22c20209c88a6a903729d3935e836ed0cf1a (diff) | |
download | bitcoin-6862627ce6bc04e68801f026629932987c3ab424.tar.xz |
Add listunspent() test for spendable/unspendable UTXO
Github-Pull: #7822
Rebased-From: fa942c755ab513829dcab27487ba1e7ab5a806ee 5d217decc1145823a3c126658c82c60cf7dbfec8
Diffstat (limited to 'qa/rpc-tests/test_framework/util.py')
-rw-r--r-- | qa/rpc-tests/test_framework/util.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/qa/rpc-tests/test_framework/util.py b/qa/rpc-tests/test_framework/util.py index eb29fea312..51e7e021f7 100644 --- a/qa/rpc-tests/test_framework/util.py +++ b/qa/rpc-tests/test_framework/util.py @@ -437,6 +437,35 @@ def assert_is_hash_string(string, length=64): raise AssertionError( "String %r contains invalid characters for a hash." % string) +def assert_array_result(object_array, to_match, expected, should_not_find = False): + """ + Pass in array of JSON objects, a dictionary with key/value pairs + to match against, and another dictionary with expected key/value + pairs. + If the should_not_find flag is true, to_match should not be found + in object_array + """ + if should_not_find == True: + expected = { } + num_matched = 0 + for item in object_array: + all_match = True + for key,value in to_match.items(): + if item[key] != value: + all_match = False + if not all_match: + continue + elif should_not_find == True: + num_matched = num_matched+1 + for key,value in expected.items(): + if item[key] != value: + raise AssertionError("%s : expected %s=%s"%(str(item), str(key), str(value))) + num_matched = num_matched+1 + if num_matched == 0 and should_not_find != True: + raise AssertionError("No objects matched %s"%(str(to_match))) + if num_matched > 0 and should_not_find == True: + raise AssertionError("Objects were found %s"%(str(to_match))) + def satoshi_round(amount): return Decimal(amount).quantize(Decimal('0.00000001'), rounding=ROUND_DOWN) |