test: measure rpcwaittimeout floor with monotonic time #36529

pull nervana21 wants to merge 1 commits into bitcoin:master from nervana21:test-rpcwaittimeout-slack changing 1 files +4 −4
  1. nervana21 commented at 8:43 PM on October 14, 2026: contributor

    Previously, interface_bitcoin_cli.py measured the -rpcwaittimeout wait floor with time.time(). bitcoin-cli arms that deadline with std::chrono::steady_clock, so a CI wall-clock step backward can make the elapsed time look short and cause the assert to fail.

    Fix this by using time.monotonic() instead and using -rpcwaittimeout=1. The log line also now says "at least" so it matches the floor assert.

    h/t ViniciusCestarii for suggesting time.monotonic() here.

  2. DrahtBot added the label Tests on Oct 14, 2026
  3. DrahtBot commented at 8:44 PM on October 14, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    External sites

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process.

    Type Reviewers
    ACK maflcko, ViniciusCestarii

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  4. nervana21 marked this as a draft on Oct 14, 2026
  5. in test/functional/interface_bitcoin_cli.py:482 in d12ebf8e6d
     477 | @@ -478,7 +478,8 @@ def run_test(self):
     478 |          self.stop_node(0)  # stop the node so we time out
     479 |          start_time = time.time()
     480 |          assert_raises_process_error(1, "Could not connect to the server", self.nodes[0].cli('-rpcwait', '-rpcwaittimeout=5').echo)
     481 | -        assert_greater_than_or_equal(time.time(), start_time + 5)
     482 | +        # Allow small scheduling slack. rpcwaittimeout is best effort wall clock.
     483 | +        assert_greater_than_or_equal(time.time() + 0.5, start_time + 5)
    


    maflcko commented at 9:01 AM on October 23, 2026:

    seems fine, but the 5 can probably be reduced to 1, to speed up the test

  6. nervana21 force-pushed on Oct 25, 2026
  7. nervana21 marked this as ready for review on Oct 25, 2026
  8. nervana21 commented at 4:13 PM on October 25, 2026: contributor

    Updates:

  9. maflcko commented at 5:00 PM on October 26, 2026: member

    lgtm ACK 7445428eb851ab5314dab2cbe2dbe34fdd58200f

    <!--meta-tag:bot-skip-->
    
  10. fanquake commented at 5:04 PM on October 26, 2026: member
  11. ViniciusCestarii commented at 6:10 PM on October 26, 2026: contributor

    start_time is taken before spawning bitcoin-cli and bitcoin-cli uses monotonic time, so the flake can only come from wall clock adjustment. Wouldn't replacing time.time() with time.monotonic() fix this without the slack?

  12. nervana21 renamed this:
    test: allow slack on rpcwaittimeout wait floor
    test: align rpcwaittimeout floor with steady_clock
    on Oct 26, 2026
  13. maflcko commented at 6:28 AM on October 27, 2026: member

    Good catch, not sure how I missed this. I presume I was confused by the LHS and RHS both doing addition. Maybe it would be clearer to understand and to read the assertion error message, when the LHS was monotonic()-start_time, so that only the duration is printed. Steps to reproduce:

    faketime --exclude-monotonic -f "+0 x0.5" ./bld-cmake/test/functional/interface_bitcoin_cli.py 
    
  14. test: measure rpcwaittimeout floor with monotonic time
    Require the `-rpcwait` command to wait at least the configured timeout
    period before raising a process error. Measure the wait using
    `time.monotonic()` so that wall-clock discrepancies do not cause
    intermittent test failures.
    
    Also, lower the timeout from 5 to 1 second.
    dc27539d42
  15. nervana21 renamed this:
    test: align rpcwaittimeout floor with steady_clock
    test: measure rpcwaittimeout floor with monotonic time
    on Oct 27, 2026
  16. nervana21 force-pushed on Oct 27, 2026
  17. nervana21 closed this on Oct 27, 2026

  18. nervana21 deleted the branch on Oct 27, 2026
  19. nervana21 restored the branch on Oct 27, 2026
  20. nervana21 deleted the branch on Oct 27, 2026
  21. nervana21 restored the branch on Oct 27, 2026
  22. nervana21 reopened this on Oct 27, 2026

  23. DrahtBot added the label CI failed on Oct 27, 2026
  24. nervana21 closed this on Oct 27, 2026

  25. nervana21 deleted the branch on Oct 27, 2026
  26. nervana21 restored the branch on Oct 27, 2026
  27. nervana21 reopened this on Oct 27, 2026

  28. nervana21 commented at 5:04 PM on October 27, 2026: contributor

    Updates:

    • Addressed @ViniciusCestarii's feedback (use time.monotonic())

    • Addressed @maflcko's feedback (assert elapsed duration on the LHS)

  29. maflcko commented at 5:40 PM on October 27, 2026: member

    lgtm ACK dc27539d42bbfc04705d9ae1ea00cf70b046d8fa

  30. ViniciusCestarii commented at 5:53 PM on October 27, 2026: contributor

    ACK dc27539d42bbfc04705d9ae1ea00cf70b046d8fa

  31. DrahtBot removed the label CI failed on Oct 27, 2026
  32. fanquake merged this on Oct 27, 2026
  33. fanquake closed this on Oct 27, 2026

  34. nervana21 deleted the branch on Oct 27, 2026

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-10-29 06:51 UTC

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