Skip to content

Commit 2eb5175

Browse files
committed
test: fix StopIteration exception in p2p_node_network_limited.py
The `next()` call throws an exception if the default parameter is omitted and the iterator is exhausted. Fix it by providing a default value. The failure can be tested by commenting out lines 90 and 91 in the test (the `self.connect_nodes(2, 0)``). Since there is no connection, the node in question retrieves a single element in the 'getchaintips()' call. This scenario without the fix, aborts the test right away, throwing an StopIteration exception, and with the fix, the test properly waits until the timeout (wait_until() call).
1 parent 28f2ca6 commit 2eb5175

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

test/functional/p2p_node_network_limited.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ def test_avoid_requesting_historical_blocks(self):
9292

9393
# Wait until the full_node is headers-wise sync
9494
best_block_hash = pruned_node.getbestblockhash()
95-
self.wait_until(lambda: next(filter(lambda x: x['hash'] == best_block_hash, full_node.getchaintips()))['status'] == "headers-only")
95+
default_value = {'status': ''} # No status
96+
self.wait_until(lambda: next(filter(lambda x: x['hash'] == best_block_hash, full_node.getchaintips()), default_value)['status'] == "headers-only")
9697

9798
# Now, since the node aims to download a window of 1024 blocks,
9899
# ensure it requests the blocks below the threshold only (with a

0 commit comments

Comments
 (0)