aboutsummaryrefslogtreecommitdiff
path: root/test/functional/rpc_getblockfrompeer.py
diff options
context:
space:
mode:
authorJon Atack <jon@atack.com>2022-04-22 11:09:45 +0200
committerJon Atack <jon@atack.com>2022-04-22 11:27:15 +0200
commit734b9669ff7b2f5e2820993443a6f868f6b0b20a (patch)
tree0bb69acc12b357d55804f00b631f186c83344e6d /test/functional/rpc_getblockfrompeer.py
parent7a4ac713aad699435cc3175f1c3b6a5d985442a5 (diff)
test: add getblockfrompeer coverage of invalid inputs
Diffstat (limited to 'test/functional/rpc_getblockfrompeer.py')
-rwxr-xr-xtest/functional/rpc_getblockfrompeer.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/test/functional/rpc_getblockfrompeer.py b/test/functional/rpc_getblockfrompeer.py
index b65322d920..cc9ccf3066 100755
--- a/test/functional/rpc_getblockfrompeer.py
+++ b/test/functional/rpc_getblockfrompeer.py
@@ -49,14 +49,17 @@ class GetBlockFromPeerTest(BitcoinTestFramework):
assert_equal(len(peers), 1)
peer_0_peer_1_id = peers[0]["id"]
- self.log.info("Arguments must be sensible")
- assert_raises_rpc_error(-8, "hash must be of length 64 (not 4, for '1234')", self.nodes[0].getblockfrompeer, "1234", 0)
+ self.log.info("Arguments must be valid")
+ assert_raises_rpc_error(-8, "hash must be of length 64 (not 4, for '1234')", self.nodes[0].getblockfrompeer, "1234", peer_0_peer_1_id)
+ assert_raises_rpc_error(-1, "JSON value is not a string as expected", self.nodes[0].getblockfrompeer, 1234, peer_0_peer_1_id)
+ assert_raises_rpc_error(-1, "JSON value is not an integer as expected", self.nodes[0].getblockfrompeer, short_tip, "0")
self.log.info("We must already have the header")
assert_raises_rpc_error(-1, "Block header missing", self.nodes[0].getblockfrompeer, "00" * 32, 0)
self.log.info("Non-existent peer generates error")
- assert_raises_rpc_error(-1, "Peer does not exist", self.nodes[0].getblockfrompeer, short_tip, peer_0_peer_1_id + 1)
+ for peer_id in [-1, peer_0_peer_1_id + 1]:
+ assert_raises_rpc_error(-1, "Peer does not exist", self.nodes[0].getblockfrompeer, short_tip, peer_id)
self.log.info("Successful fetch")
result = self.nodes[0].getblockfrompeer(short_tip, peer_0_peer_1_id)