aboutsummaryrefslogtreecommitdiff
path: root/test/functional/rpc_scantxoutset.py
diff options
context:
space:
mode:
authorBen Woosley <ben.woosley@gmail.com>2019-04-04 00:39:04 -0700
committerBen Woosley <ben.woosley@gmail.com>2019-04-13 18:52:11 -0700
commit510c6532bae9abc5beda1c126c945923a64680cb (patch)
tree08817bc88ad774370833066ca14714a6f8a2d262 /test/functional/rpc_scantxoutset.py
parentba54342c9dd3f2e5cdeed9ac57f1924f0d885cc6 (diff)
downloadbitcoin-510c6532bae9abc5beda1c126c945923a64680cb.tar.xz
Extract ParseDescriptorRange
So as to be consistently informative when the checks fail, and to protect against unintentional divergence among the checks.
Diffstat (limited to 'test/functional/rpc_scantxoutset.py')
-rwxr-xr-xtest/functional/rpc_scantxoutset.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/test/functional/rpc_scantxoutset.py b/test/functional/rpc_scantxoutset.py
index 6346477922..a1cd33ad54 100755
--- a/test/functional/rpc_scantxoutset.py
+++ b/test/functional/rpc_scantxoutset.py
@@ -4,7 +4,7 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test the scantxoutset rpc call."""
from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import assert_equal
+from test_framework.util import assert_equal, assert_raises_rpc_error
from decimal import Decimal
import shutil
@@ -67,6 +67,13 @@ class ScantxoutsetTest(BitcoinTestFramework):
assert_equal(self.nodes[0].scantxoutset("start", [ "addr(" + addr_P2SH_SEGWIT + ")", "addr(" + addr_LEGACY + ")", "addr(" + addr_BECH32 + ")"])['total_amount'], Decimal("0.007"))
assert_equal(self.nodes[0].scantxoutset("start", [ "addr(" + addr_P2SH_SEGWIT + ")", "addr(" + addr_LEGACY + ")", "combo(" + pubk3 + ")"])['total_amount'], Decimal("0.007"))
+ self.log.info("Test range validation.")
+ assert_raises_rpc_error(-8, "End of range is too high", self.nodes[0].scantxoutset, "start", [ {"desc": "desc", "range": -1}])
+ assert_raises_rpc_error(-8, "Range should be greater or equal than 0", self.nodes[0].scantxoutset, "start", [ {"desc": "desc", "range": [-1, 10]}])
+ assert_raises_rpc_error(-8, "End of range is too high", self.nodes[0].scantxoutset, "start", [ {"desc": "desc", "range": [(2 << 31 + 1) - 1000000, (2 << 31 + 1)]}])
+ assert_raises_rpc_error(-8, "Range specified as [begin,end] must not have begin after end", self.nodes[0].scantxoutset, "start", [ {"desc": "desc", "range": [2, 1]}])
+ assert_raises_rpc_error(-8, "Range is too large", self.nodes[0].scantxoutset, "start", [ {"desc": "desc", "range": [0, 1000001]}])
+
self.log.info("Test extended key derivation.")
# Run various scans, and verify that the sum of the amounts of the matches corresponds to the expected subset.
# Note that all amounts in the UTXO set are powers of 2 multiplied by 0.001 BTC, so each amounts uniquely identifies a subset.