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: failure in p2p_node_network_limited.py --v2transport #29731

Closed
fanquake opened this issue Mar 26, 2024 · 4 comments · Fixed by #29753
Closed

test: failure in p2p_node_network_limited.py --v2transport #29731

fanquake opened this issue Mar 26, 2024 · 4 comments · Fixed by #29753
Labels

Comments

@fanquake
Copy link
Member

https://cirrus-ci.com/task/5403304943943680?logs=ci#L2801:

 node2 2024-03-25T22:05:25.456671Z [http] [httpserver.cpp:306] [http_request_cb] [http] Received a POST request for / from 127.0.0.1:45080 
 node2 2024-03-25T22:05:25.456751Z [httpworker.3] [rpc/request.cpp:187] [parse] [rpc] ThreadRPCServer method=getchaintips user=__cookie__ 
 test  2024-03-25T22:05:25.457000Z TestFramework (ERROR): Unexpected exception caught during testing 
                                   Traceback (most recent call last):
                                     File "/ci_container_base/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/test/functional/test_framework/test_framework.py", line 132, in main
                                       self.run_test()
                                     File "/ci_container_base/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/test/functional/p2p_node_network_limited.py", line 171, in run_test
                                       self.test_avoid_requesting_historical_blocks()
                                     File "/ci_container_base/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/test/functional/p2p_node_network_limited.py", line 95, in test_avoid_requesting_historical_blocks
                                       self.wait_until(lambda: next(filter(lambda x: x['hash'] == best_block_hash, full_node.getchaintips()))['status'] == "headers-only")
                                     File "/ci_container_base/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/test/functional/test_framework/test_framework.py", line 780, in wait_until
                                       return wait_until_helper_internal(test_function, timeout=timeout, timeout_factor=self.options.timeout_factor)
                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                     File "/ci_container_base/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/test/functional/test_framework/util.py", line 282, in wait_until_helper_internal
                                       if predicate():
                                          ^^^^^^^^^^^
                                     File "/ci_container_base/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/test/functional/p2p_node_network_limited.py", line 95, in <lambda>
                                       self.wait_until(lambda: next(filter(lambda x: x['hash'] == best_block_hash, full_node.getchaintips()))['status'] == "headers-only")
                                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                   StopIteration
 node0 2024-03-25T22:05:25.457757Z [msghand] [net_processing.cpp:3466] [ProcessMessage] [net] received: getheaders (677 bytes) peer=5 
 node0 2024-03-25T22:05:25.457809Z [msghand] [net_processing.cpp:4258] [ProcessMessage] [net] getheaders 303 to end from peer=5 
 node0 2024-03-25T22:05:25.458742Z [msghand] [net.cpp:3738] [PushMessage] [net] sending headers (24384 bytes) peer=5 
 test  2024-03-25T22:05:25.459000Z TestFramework (DEBUG): Closing down network thread 

Seen in https://github.com/bitcoin/bitcoin/pull/29723/checks?check_run_id=23066547382.

@fanquake fanquake added the Tests label Mar 26, 2024
@mzumsande
Copy link
Contributor

FYI @furszy

@mzumsande
Copy link
Contributor

Looks like the next(filter(...) construction throws an exception if getchaintips returns just one element.

@furszy
Copy link
Member

furszy commented Mar 27, 2024

Looks like the next(filter(...) construction throws an exception if getchaintips returns just one element.

Hmm yeah @mzumsande. Thanks for the ping. Just checked the next() docs: "If the default parameter is omitted and the iterator is exhausted, it raises the StopIteration exception."
So, solution is to provide a default value:

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

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

Try to run it there. Will push the PR later today.

@furszy
Copy link
Member

furszy commented Mar 27, 2024

#29753

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 a pull request may close this issue.

3 participants