test: Add SyncWithValidationInterfaceQueue to mockscheduler RPC #28118

pull maflcko wants to merge 2 commits into bitcoin:master from maflcko:2307-test-mock-sync- changing 1 files +6 −9
  1. maflcko commented at 1:10 PM on July 21, 2023: member

    There should be no risk or downside in adding a call to SyncWithValidationInterfaceQueue here. In fact, it will make tests less brittle. For example,

  2. test: Add SyncWithValidationInterfaceQueue to mockscheduler RPC
    This makes existing tests less brittle, see
    https://github.com/bitcoin/bitcoin/pull/28108/files#r1268966663
    fa1640617e
  3. refactor: Use EnsureAnyNodeContext
    node_context is never null, but if it was, it would lead to a nullptr
    dereference in node_context->scheduler. Just use EnsureAnyNodeContext
    everywhere for more robust, consistent, and correct code.
    fabef121b0
  4. DrahtBot commented at 1:10 PM on July 21, 2023: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK TheCharlatan, furszy

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

  5. DrahtBot added the label Tests on Jul 21, 2023
  6. DrahtBot added the label CI failed on Jul 25, 2023
  7. DrahtBot removed the label CI failed on Jul 25, 2023
  8. TheCharlatan approved
  9. TheCharlatan commented at 9:55 AM on July 28, 2023: contributor

    ACK fabef121b0cdfac6ec1985f6c08c5685a886ba5a

    Seems like the correct thing to do here anyway. Also reproduced the feature_fee_estimation behavior change.

  10. furszy commented at 1:59 PM on July 28, 2023: member

    Little topic, mainly to not mix RPC commands responsibilities.

    Why not implementing this on the test framework instead?

    Could add a proxy function mockscheduler to test_node.py that calls to the real mockscheduler and, subsequently to syncwithvalidationinterfacequeue.

  11. maflcko commented at 2:17 PM on July 28, 2023: member

    Why not implementing this on the test framework instead?

    That just seems brittle, and bloated, for no reason? It is brittle because one may miss to implement a proxy, as they'll have to be done for the bitcoin-cli utility and the python rpc wrapper, and devs can still accidentally sidestep it. It is bloated because it will be more than one line of code.

  12. furszy commented at 2:45 PM on July 28, 2023: member

    That just seems brittle, and bloated, for no reason? It is brittle because one may miss to implement a proxy, as they'll have to be done for the bitcoin-cli utility and the python rpc wrapper, and devs can still accidentally sidestep it. It is bloated because it will be more than one line of code.

    I'm not really strong here but It just seems a bit error-prone to always call to the syncwithvalidationinterfacequeue internally after bumping the scheduler timeout and not before. Existing callbacks using the node's time to operate could be affected and perform differently (sometimes we might want this, some others we might not?). And thought that it would be easier to change/adapt when calls are done outside of the RPC command.

    About the tests bloat, it should just be a:

    def mockscheduler(self, time):
        self.__getattr__('mockscheduler')(time)
        self.__getattr__('syncwithvalidationinterfacequeue')()
    

    But it is just a gut feeling. All good either way.

  13. maflcko commented at 2:55 PM on July 28, 2023: member

    Existing callbacks using the node's time to operate could be affected and perform differently

    No, they shouldn't be affected by this change. The scheduler thread is already free to behave at any time as-if syncwithvalidationinterfacequeue was just called.

    This will only reduce intermittent test failure rates where the test assumed that the scheduler thread behaved as-if syncwithvalidationinterfacequeue was called and that it must happen within a specific time. As explained in the description there are tests with this assumption. This pull request fixes those tests, and all other cases of the same kind in all current and future tests.

  14. furszy approved
  15. furszy commented at 3:07 PM on July 28, 2023: member

    Code review ACK fabef121. Convinced by checking all current tests usages. Thanks Marco.

  16. fanquake merged this on Jul 30, 2023
  17. fanquake closed this on Jul 30, 2023

  18. maflcko deleted the branch on Jul 30, 2023
  19. sidhujag referenced this in commit 0b441ee07c on Aug 9, 2023
  20. bitcoin locked this on Jul 29, 2024

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:13 UTC

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