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

issue fanquake opened this issue on March 26, 2024
  1. fanquake commented at 9:34 AM on March 26, 2024: 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.

  2. fanquake added the label Tests on Mar 26, 2024
  3. mzumsande commented at 3:43 PM on March 26, 2024: contributor

    FYI @furszy

  4. mzumsande commented at 3:56 PM on March 26, 2024: contributor

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

  5. furszy commented at 2:08 PM on March 27, 2024: member

    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.

  6. furszy commented at 7:38 PM on March 27, 2024: member
  7. fanquake closed this on Apr 1, 2024

  8. fanquake referenced this in commit 23ba39470c on Apr 1, 2024
  9. bitcoin locked this on Apr 1, 2025

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-16 03:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me