aboutsummaryrefslogtreecommitdiff
path: root/test/functional/rpc_getblockfrompeer.py
diff options
context:
space:
mode:
authorMacroFake <falke.marco@gmail.com>2022-07-12 17:28:23 +0200
committerMacroFake <falke.marco@gmail.com>2022-07-12 17:28:26 +0200
commit46fcb52cb19462c74dceb085b8ca727c47a6ad32 (patch)
tree51b68471dc9ee06da7579d4b01ca54a49678a858 /test/functional/rpc_getblockfrompeer.py
parent7d258ee8bc3bff439881064dd6234f7b04982783 (diff)
parent2ef5294a5bb68ceb3797d2638567a172cc21699f (diff)
Merge bitcoin/bitcoin#24944: rpc: add getblockfrompeer RPCTypeCheck and invalid input test coverage
2ef5294a5bb68ceb3797d2638567a172cc21699f rpc: add RPCTypeCheck for getblockfrompeer inputs (Jon Atack) 734b9669ff7b2f5e2820993443a6f868f6b0b20a test: add getblockfrompeer coverage of invalid inputs (Jon Atack) Pull request description: The new getblockfrompeer RPC lacks test coverage for invalid arguments, and its error messages are not harmonized with the existing RPCs. Fix all issues. ACKs for top commit: brunoerg: ACK 2ef5294a5bb68ceb3797d2638567a172cc21699f Tree-SHA512: 454782cf6a44fd0e05483bb152153667ef5c8021358385ddcf89724fbbbd35e187362bdff757e00c99319527bc4c0b20c7187f67241d4585d767a29787142f25
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 a7628b5591..41e430d87e 100755
--- a/test/functional/rpc_getblockfrompeer.py
+++ b/test/functional/rpc_getblockfrompeer.py
@@ -54,14 +54,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(-3, "Expected type string, got number", self.nodes[0].getblockfrompeer, 1234, peer_0_peer_1_id)
+ assert_raises_rpc_error(-3, "Expected type number, got string", 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("Fetching from pre-segwit peer generates error")
self.nodes[0].add_p2p_connection(P2PInterface(), services=P2P_SERVICES & ~NODE_WITNESS)