aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorfurszy <matiasfurszyfer@protonmail.com>2024-03-27 16:32:08 -0300
committerfurszy <matiasfurszyfer@protonmail.com>2024-03-27 16:37:36 -0300
commit2eb5175de87c798af328de3f2147aac7879eaa10 (patch)
treee614b09959380d73a7a5fca69b33bfa8a17a26df /test
parent28f2ca675f89a764e1ec8eb5671b35357b8677f3 (diff)
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).
Diffstat (limited to 'test')
-rwxr-xr-xtest/functional/p2p_node_network_limited.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/test/functional/p2p_node_network_limited.py b/test/functional/p2p_node_network_limited.py
index 467bbad09c..8f145b954a 100755
--- a/test/functional/p2p_node_network_limited.py
+++ b/test/functional/p2p_node_network_limited.py
@@ -92,7 +92,8 @@ class NodeNetworkLimitedTest(BitcoinTestFramework):
# Wait until the full_node is headers-wise sync
best_block_hash = pruned_node.getbestblockhash()
- self.wait_until(lambda: next(filter(lambda x: x['hash'] == best_block_hash, full_node.getchaintips()))['status'] == "headers-only")
+ default_value = {'status': ''} # No status
+ self.wait_until(lambda: next(filter(lambda x: x['hash'] == best_block_hash, full_node.getchaintips()), default_value)['status'] == "headers-only")
# Now, since the node aims to download a window of 1024 blocks,
# ensure it requests the blocks below the threshold only (with a