test: Fail early on disconnect in mininode.wait_for_* #16470

pull MarcoFalke wants to merge 1 commits into bitcoin:master from MarcoFalke:1907-testMininodeNoWaitOnDisconnect changing 1 files +29 −6
  1. MarcoFalke commented at 8:13 PM on July 26, 2019: member

    The node might crash or disconnect when our mininode waits for data. Due to the crash, the data is guaranteed to never arrive and we can fail early with an assert

  2. test: Fail early on disconnect in mininode.wait_for_* fac2e6a604
  3. MarcoFalke commented at 8:19 PM on July 26, 2019: member

    Example:

    2019-07-26T20:11:22.049000Z TestFramework (INFO): Test a re-org of one week's worth of blocks (1088 blocks)
    [...]
     node0 2019-07-26T20:14:44.224983Z [msghand] UpdateTip: new best=02a38b39fec53caf38302ad6075fb32f1f5dc52737ac36c60dbfbb11849038c4 height=766 version=0x00000004 log2_work=10.583083 tx=12824 date='2019-07-26T20:22:31Z' progress=1.000000 cache=1.6MiB(12000txo) 
     test  2019-07-26T20:14:58.425000Z TestFramework.mininode (DEBUG): Closed connection to: 127.0.0.1:13931 
    [...]
    2019-07-26T20:14:58.552000Z TestFramework (ERROR): Assertion failed
    Traceback (most recent call last):
      File "/root/workspace/bitcoin-core/test/functional/test_framework/test_framework.py", line 193, in main
        self.run_test()
      File "./test/functional/feature_block.py", line 1233, in run_test
        self.send_blocks([block], True, timeout=60*60)
      File "./test/functional/feature_block.py", line 1365, in send_blocks
        self.nodes[0].p2p.send_blocks_and_test(blocks, self.nodes[0], success=success, reject_reason=reject_reason, force_send=force_send, timeout=timeout, expect_disconnect=reconnect)
      File "/root/workspace/bitcoin-core/test/functional/test_framework/mininode.py", line 561, in send_blocks_and_test
        self.sync_with_ping(timeout=timeout)
      File "/root/workspace/bitcoin-core/test/functional/test_framework/mininode.py", line 441, in sync_with_ping
        wait_until(test_function, timeout=timeout, lock=mininode_lock)
      File "/root/workspace/bitcoin-core/test/functional/test_framework/util.py", line 211, in wait_until
        if predicate():
      File "/root/workspace/bitcoin-core/test/functional/test_framework/mininode.py", line 439, in test_function
        assert self.is_connected
    AssertionError
    2019-07-26T20:14:58.723000Z TestFramework (INFO): Stopping nodes
    
  4. DrahtBot added the label Tests on Jul 26, 2019
  5. in test/functional/test_framework/mininode.py:432 in fac2e6a604
     430 | +
     431 |          wait_until(test_function, timeout=timeout, lock=mininode_lock)
     432 |  
     433 |      def wait_for_verack(self, timeout=60):
     434 | -        test_function = lambda: self.message_count["verack"]
     435 | +        def test_function():
    


    promag commented at 10:25 PM on July 28, 2019:

    Could you explain why not assert here?


    MarcoFalke commented at 10:49 PM on July 28, 2019:

    This is called in add_p2p_connection, which establishes the connection async. So the assert will fail on the first try.

  6. promag commented at 10:25 PM on July 28, 2019: member

    Concept ACK, makes sense.

  7. laanwj commented at 1:12 PM on August 1, 2019: member

    ACK fac2e6a6045e4ddd6b473f4f3ddbb69d9d6921f6

  8. laanwj merged this on Aug 1, 2019
  9. laanwj closed this on Aug 1, 2019

  10. laanwj referenced this in commit 79816278e2 on Aug 1, 2019
  11. MarcoFalke deleted the branch on Aug 1, 2019
  12. sidhujag referenced this in commit 3b841f6de9 on Aug 1, 2019
  13. jasonbcox referenced this in commit 8fc318140d on Oct 14, 2020
  14. linuxsh2 referenced this in commit 281e00f1f5 on Aug 11, 2021
  15. DrahtBot locked this on Dec 16, 2021
Labels

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-17 06:14 UTC

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