Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix StopIteration exception in p2p_node_network_limited.py #29753

Merged

Conversation

furszy
Copy link
Member

@furszy furszy commented Mar 27, 2024

Fixes #29731

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).

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).
@DrahtBot
Copy link
Contributor

DrahtBot commented Mar 27, 2024

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage

For detailed information about the code coverage, see the test coverage report.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK maflcko, brunoerg, BrandonOdiwuor, tdb3

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

@maflcko
Copy link
Member

maflcko commented Mar 27, 2024

review ACK 2eb5175

Copy link
Contributor

@brunoerg brunoerg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

crACK 2eb5175

Copy link
Contributor

@BrandonOdiwuor BrandonOdiwuor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

crACK 2eb5175

Copy link
Contributor

@tdb3 tdb3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested ACK for 2eb5175.
Pulled, built, ran all unit and functional tests (all passed).
Comment out lines 90 and 91 of p2p_node_network_limited.py as discussed in the intro. The test properly waited for the 60 timeout and failed as expected instead of encountering StopIteration.

@fanquake fanquake merged commit 23ba394 into bitcoin:master Apr 1, 2024
16 checks passed
@furszy furszy deleted the 2024_test_fix_p2p_node_network_failure branch April 1, 2024 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

test: failure in p2p_node_network_limited.py --v2transport
7 participants