Page MenuHomePhabricator

Improve the p2p_inv_download test by using a mocked time

Authored by Fabien on Thu, Jul 22, 10:17.


Group Reviewers
Restricted Project
rABC3cca01825bf8: Improve the p2p_inv_download test by using a mocked time

The test_inv_block from test case has a few flaws:

  • The name does not reflect the content (it does not test any block inventory)
  • The test relies on some event to occur within some timeout, which is unlikely to fail but is not guaranteed, and in case of failure makes it not obvious what the problem is
  • It takes an absurd amount of time

This diff addresses all these points. It uses mocktime to both improve the robustness and make the test more easy to debug in case a failure occurs. The test duration is reduced by x2 on my machine (from ~120s to ~60s).

Test Plan
./test/functional/ p2p_inv_download

Diff Detail

rABC Bitcoin ABC
Lint Not Applicable
Tests Not Applicable

Event Timeline

Fabien requested review of this revision.Thu, Jul 22, 10:17
This revision is now accepted and ready to land.Thu, Jul 22, 13:40

Failed tests logs:

====== Bitcoin ABC extended functional tests: ======

------- Stdout: -------
2021-07-22T13:52:36.006000Z TestFramework (INFO): Initializing test directory /work/abc-ci-builds/build-master/test/tmp/test_runner_₿₵_  _20210722_135114/feature_block_5
2021-07-22T13:52:37.118000Z TestFramework (INFO): Reject block with invalid tx: OutputMissing
2021-07-22T13:52:39.132000Z TestFramework.utils (ERROR): wait_until() failed. Predicate: ''''
        def test_function():
            if check_connected:
                assert self.is_connected
            return test_function_in()
2021-07-22T13:52:42.838000Z TestFramework (ERROR): Assertion failed
Traceback (most recent call last):
  File "/work/test/functional/test_framework/", line 127, in main
  File "/work/test/functional/", line 164, in run_test
    reconnect=True, timeout=2)
  File "/work/test/functional/", line 1297, in send_blocks
    reject_reason=reject_reason, force_send=force_send, timeout=timeout, expect_disconnect=reconnect)
  File "/work/test/functional/test_framework/", line 722, in send_blocks_and_test
  File "/work/test/functional/test_framework/", line 710, in test
  File "/work/test/functional/test_framework/", line 485, in wait_for_disconnect
    self.wait_until(test_function, timeout=timeout, check_connected=False)
  File "/work/test/functional/test_framework/", line 481, in wait_until
  File "/work/test/functional/test_framework/", line 278, in wait_until
    "Predicate {} not true after {} seconds".format(predicate_source, timeout))
AssertionError: Predicate ''''
        def test_function():
            if check_connected:
                assert self.is_connected
            return test_function_in()
''' not true after 2.0 seconds
2021-07-22T13:52:42.889000Z TestFramework (INFO): Stopping nodes
2021-07-22T13:52:43.191000Z TestFramework (WARNING): Not cleaning up dir /work/abc-ci-builds/build-master/test/tmp/test_runner_₿₵_  _20210722_135114/feature_block_5
2021-07-22T13:52:43.191000Z TestFramework (ERROR): Test failed. Test logging available at /work/abc-ci-builds/build-master/test/tmp/test_runner_₿₵_  _20210722_135114/feature_block_5/test_framework.log
2021-07-22T13:52:43.191000Z TestFramework (ERROR): 
2021-07-22T13:52:43.191000Z TestFramework (ERROR): Hint: Call /work/test/functional/ '/work/abc-ci-builds/build-master/test/tmp/test_runner_₿₵_  _20210722_135114/feature_block_5' to consolidate all logs
2021-07-22T13:52:43.191000Z TestFramework (ERROR): 
2021-07-22T13:52:43.191000Z TestFramework (ERROR): If this failure happened unexpectedly or intermittently, please file a bug and provide a link or upload of the combined log.
2021-07-22T13:52:43.191000Z TestFramework (ERROR):
2021-07-22T13:52:43.191000Z TestFramework (ERROR):

Each failure log is accessible here:
Bitcoin ABC extended functional tests: