QA: rpc_getblockfrompeer: Test specific error for trying to fetch from peer twice

This commit is contained in:
Luke Dashjr 2023-07-09 00:41:44 +00:00
parent d7e08d408c
commit 017ab85cec
1 changed files with 8 additions and 0 deletions

View File

@ -84,6 +84,14 @@ class GetBlockFromPeerTest(BitcoinTestFramework):
presegwit_peer_id = peers[1]["id"]
assert_raises_rpc_error(-1, "Pre-SegWit peer", self.nodes[0].getblockfrompeer, short_tip, presegwit_peer_id)
self.log.info("Fetching from same peer twice generates error")
self.nodes[0].add_p2p_connection(P2PInterface())
peers = self.nodes[0].getpeerinfo()
assert_equal(len(peers), 3)
slow_peer_id = peers[2]["id"]
assert_equal(self.nodes[0].getblockfrompeer(short_tip, slow_peer_id), {})
assert_raises_rpc_error(-1, "Already requested from this peer", self.nodes[0].getblockfrompeer, short_tip, slow_peer_id)
self.log.info("Successful fetch")
result = self.nodes[0].getblockfrompeer(short_tip, peer_0_peer_1_id)
self.wait_until(lambda: self.check_for_block(node=0, hash=short_tip), timeout=1)