test: split interface_ipc.py #34452

pull Sjors wants to merge 4 commits into bitcoin:master from Sjors:2026/01/split-ipc-test changing 4 files +474 −347
  1. Sjors commented at 7:08 pm on January 29, 2026: member

    This test has been growing too large, making it difficult to maintain. Especially when multiple pull requests change it.

    • move helper functions to ipc_util.py
    • move mining test to interface_ipc_mining.py, keeping only an interface sanity check in interface_ipc.py
    • split the tests in interface_ipc_mining.py
    • misc tweaks (to reduce churn in the above commits)

    Review hint:

    0git show --color-moved=dimmed-zebra --color-moved-ws=ignore-space-change
    
  2. DrahtBot added the label Tests on Jan 29, 2026
  3. DrahtBot commented at 7:09 pm on January 29, 2026: contributor

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

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK janb84, fjahr, l0rinc, sedited
    Stale ACK ryanofsky, ismaelsadeeq

    If your review is incorrectly listed, please copy-paste <!–meta-tag:bot-skip–> into the comment that the bot should ignore.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #34422 (Update libmultiprocess subtree to be more stable with rust IPC client by ryanofsky)
    • #34284 (ipc, test: Add tests for unclean disconnect and thread busy behavior by ryanofsky)
    • #34184 (mining: add cooldown to createNewBlock() immediately after IBD by Sjors)
    • #33965 (mining: fix -blockreservedweight shadows IPC option by Sjors)
    • #33922 (mining: add getMemoryLoad() and track template non-mempool memory footprint by Sjors)
    • #30437 (ipc: add bitcoin-mine test program by ryanofsky)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  4. Sjors force-pushed on Jan 29, 2026
  5. DrahtBot added the label CI failed on Jan 29, 2026
  6. in test/functional/test_framework/ipc_util.py:118 in 766c008920
    113+    ctx = capnp_modules['proxy'].Context()
    114+    ctx.thread = thread
    115+    return ctx, init
    116+
    117+
    118+async def parse_and_deserialize_block(block_template, ctx):
    


    ryanofsky commented at 7:44 pm on January 29, 2026:

    In commit “test: move helpers to ipc_util.py” (766c008920c2d45516065e502a826b60d9e8f5f1)

    Not important, but as long as these function signatures are being changed anyway (dropping self parameters) it would be nice to improve their current naming, which I think is misleading as have mentioned, and inconsistent with the names of the remote methods they call:

    • parse_and_deserialize_block -> get_block
    • parse_and_deserialize_coinbase_tx -> get_coinbase_raw_tx
    • parse_and_deserialize_coinbase -> get_coinbase_tx
  7. in test/functional/test_framework/ipc_util.py:45 in 766c008920
    40+        yield obj
    41+    finally:
    42+        await obj.destroy(ctx)
    43+
    44+
    45+async def create_block_template(mining, stack, ctx, opts):
    


    ryanofsky commented at 7:51 pm on January 29, 2026:

    In commit “test: move helpers to ipc_util.py” (766c008920c2d45516065e502a826b60d9e8f5f1)

    May be good to move create_block_template and wait_next_template below near parse_and_deserialize_block so the mining functions are grouped together and the file is organized with generic async functions at the top, followed by capnproto functions, followed by mining functions.

  8. in test/functional/interface_ipc_mining.py:297 in 9f80bd7c39 outdated
    289@@ -266,7 +290,15 @@ async def wait_for_block():
    290         asyncio.run(capnp.run(async_routine()))
    291 
    292     def run_test(self):
    293+        self.miniwallet = MiniWallet(self.nodes[0])
    


    ryanofsky commented at 8:00 pm on January 29, 2026:

    In commit “test: split interface_ipc_mining.py” (9f80bd7c390409cc1713a0ccc58018bd801758a0)

    Seems good to use a shared miniwallet variable like the shared opts variable, but also inconsistent to pass one as a parameter and attach other to self. It would seem better to pass them both as parameters so it’s clear which tests are using them.

  9. ryanofsky approved
  10. ryanofsky commented at 8:02 pm on January 29, 2026: contributor
    Code review ACK 9f80bd7c390409cc1713a0ccc58018bd801758a0. Thanks for the PR! Should make working with this test easier.
  11. ismaelsadeeq commented at 8:19 pm on January 29, 2026: member
    Concept ACK
  12. DrahtBot removed the label CI failed on Jan 29, 2026
  13. Sjors force-pushed on Jan 30, 2026
  14. Sjors commented at 11:14 am on January 30, 2026: member
    Applied suggestions from @ryanofsky.
  15. DrahtBot added the label CI failed on Jan 30, 2026
  16. fanquake commented at 12:16 pm on January 30, 2026: member
    The Windows CI failure is (#34354).
  17. ryanofsky approved
  18. ryanofsky commented at 2:31 pm on January 30, 2026: contributor
    Code review ACK 836ed1fb88ed66bd966b35eb4aec69fb195a0f77. Thanks for the updates! Just some suggested renames and moves since last review
  19. DrahtBot requested review from ismaelsadeeq on Jan 30, 2026
  20. DrahtBot removed the label CI failed on Jan 30, 2026
  21. sedited approved
  22. sedited commented at 8:47 pm on January 30, 2026: contributor

    ACK 836ed1fb88ed66bd966b35eb4aec69fb195a0f77

    Nit: The commit messages could be a bit more descriptive.

  23. DrahtBot added the label Needs rebase on Feb 2, 2026
  24. Sjors force-pushed on Feb 3, 2026
  25. Sjors commented at 3:20 pm on February 3, 2026: member

    Rebased after #32420. @sedited I expanded the commit messages a bit.

    This is more tedious to rebase than I thought, so would prefer if it’s merged before any other PR that touches this test.

  26. DrahtBot removed the label Needs rebase on Feb 3, 2026
  27. in test/functional/interface_ipc.py:63 in 6ce4c3183e
    106-            blockRewardRemaining=int(template_capnp.blockRewardRemaining),
    107-            requiredOutputs=[bytes(output) for output in template_capnp.requiredOutputs],
    108-            lockTime=int(template_capnp.lockTime),
    109-        )
    110+        src_dir = Path(self.config['environment']['SRCDIR']) / "src"
    111+        self.capnp_modules = load_capnp_modules(src_dir, ["proxy", "init", "echo", "mining"])
    


    ryanofsky commented at 4:59 pm on February 3, 2026:

    In commit “test: move IPC helpers to ipc_util.py” (6ce4c3183e1be9d9f6af9c10d8a24734d16b61f8)

    Not important, but it seems kludgy that load_capnp_modules caller is now responsible for listing the modules, but the list of modules also needs to be maintained inside the function. Also how the caller is responsible for figuring out the beginning of src_dir paths but the function is responsible for figuring out the end.

    Would suggest reverting all changes to load_capnp_modules except giving it a config argument and calling load_capnp_modules(config) instead of self.load_capnp_modules()

    Current implementation is also fine if preferred, though, just a suggestion


    Sjors commented at 10:44 am on February 4, 2026:
    Good idea, done. It also reduces the diff.
  28. ryanofsky approved
  29. ryanofsky commented at 5:05 pm on February 3, 2026: contributor
    Code review ACK 6a60ad0c451cbfb4722552dc6a7ba0d75753ac5b
  30. DrahtBot requested review from sedited on Feb 3, 2026
  31. Sjors force-pushed on Feb 4, 2026
  32. DrahtBot added the label CI failed on Feb 4, 2026
  33. Sjors commented at 3:33 pm on February 4, 2026: member
    Test mempool_limit.py failure seems spurious.
  34. ryanofsky approved
  35. ryanofsky commented at 4:30 pm on February 4, 2026: contributor
    Code review ACK 18b297c8aedc1923a3e6869406958afc372b2653, just simplifying load_capnp_modules a little since last review
  36. ryanofsky commented at 4:34 pm on February 4, 2026: contributor

    Test mempool_limit.py failure seems spurious.

    There’s also a message “error: cannot rebase: Your index contains uncommitted changes.” that seem unexpected, but maybe it’s part of the “6 ancestors commits” expected output

  37. DrahtBot removed the label CI failed on Feb 4, 2026
  38. in test/functional/interface_ipc_mining.py:134 in 18b297c8ae
    129+
    130+        async def async_routine():
    131+            ctx, mining = await self.make_mining_ctx()
    132+            blockref = await mining.getTip(ctx)
    133+            current_block_height = self.nodes[0].getchaintips()[0]["height"]
    134+            assert blockref.result.height == current_block_height
    


    l0rinc commented at 10:57 am on February 6, 2026:

    I understand it’s move-only, but some people prefer

    0            assert_equal(blockref.result.height, current_block_height)
    

    ismaelsadeeq commented at 1:07 pm on February 6, 2026:
    I think you contradict yourself here @l0rinc. You mentioned you prefer clean move-only and also suggested changes here https://github.com/bitcoin/bitcoin/pull/34452/changes/63434b1b26eb32f06b112a473a5e3259d1659daa#r2773665264. So this seems to be out of scope? Changing asserts to assert_equal for better error message?

    l0rinc commented at 1:46 pm on February 6, 2026:

    You mentioned you prefer clean move-only and also suggested changes here https://github.com/bitcoin/bitcoin/commit/63434b1b26eb32f06b112a473a5e3259d1659daa#r2773665264.

    I prefer separating refactors from commits introducing behavioral changes. I also prefer code moves be separated from everything else to simplify code review comparisons. There’s no contradiction - except that I personally don’t like assert_equal, but I know other do so I mentioned it here :)


    Sjors commented at 2:05 pm on February 6, 2026:
    Done
  39. in test/functional/interface_ipc_mining.py:168 in 18b297c8ae outdated
    163+
    164+                self.log.debug("Test some inspectors of Template")
    165+                header = (await template.getBlockHeader(ctx)).result
    166+                assert_equal(len(header), block_header_size)
    167+                block = await get_block(template, ctx)
    168+                assert_equal(ser_uint256(block.hashPrevBlock), blockref.result.hash)
    


    l0rinc commented at 10:58 am on February 6, 2026:

    how come we’ve changes this from

    0                assert_equal(ser_uint256(block.hashPrevBlock), newblockref.hash)
    

    is it a result of a subtest split? Can we do these in separate commits to clarify?


    Sjors commented at 3:02 pm on February 6, 2026:
    Addressed in the commit message now.
  40. in test/functional/test_framework/ipc_util.py:94 in 3b47cc33fc
    89+        "echo": capnp.load(str(src_dir / "ipc" / "capnp" / "echo.capnp"), imports=imports),
    90+        "mining": capnp.load(str(src_dir / "ipc" / "capnp" / "mining.capnp"), imports=imports),
    91+    }
    92+
    93+
    94+async def make_capnp_init_ctx(node, capnp_modules):
    


    l0rinc commented at 11:12 am on February 6, 2026:
    we’re moving async def make_capnp_init_ctx(self): and changing it - can we do these in separate commit, it makes review a lot harder

    Sjors commented at 2:04 pm on February 6, 2026:
    It got rid of the churn.
  41. in test/functional/test_framework/ipc_util.py:1 in 3b47cc33fc outdated


    l0rinc commented at 11:14 am on February 6, 2026:

    3b47cc33fca2de2e2a4f684a0dec50c2c4a85435

    parse_and_deserialize_coinbase_tx -> get_coinbase_raw_tx

    But we already had a get_coinbase_raw_tx before


    fjahr commented at 11:58 am on February 6, 2026:
    nit: Adding to that some of these names like get_block are close to RPCs so I would have preferred names that are easier to distinguish

    ryanofsky commented at 12:58 pm on February 6, 2026:

    nit: Adding to that some of these names like get_block are close to RPCs so I would have preferred names that are easier to distinguish

    Makes sense now that they are global to add a mining_ prefix. Alternately, it could make sense to do import ipc_util and call ipc_util.get_block, ipc_util.get_coinbase_tx etc, but our current test style seems prefer global imports.


    Sjors commented at 1:15 pm on February 6, 2026:
    That was also included in #32420, forgot to adjust the comment after rebase.

    Sjors commented at 2:47 pm on February 6, 2026:
    I added a mining_ prefix.

    l0rinc commented at 5:07 pm on February 6, 2026:
    4e49fa2a68846f04cec0beb64c80ba53d3163528 nit: minor typo in commit message: insector

    l0rinc commented at 5:08 pm on February 6, 2026:
    01a1ae889e5aa71d9ae4a76000265572ffcae99f nit: commit message claims parse_and_deserialize_coinbase_tx was renamed here, but the code indicates it was parse_and_deserialize_coinbase (no _tx suffix)

    l0rinc commented at 5:12 pm on February 6, 2026:
    nit: we usually end all with a comma, to avoid touching this next time we edit the list

    l0rinc commented at 5:15 pm on February 6, 2026:
    nit: the PR description still refers to ipc_mining.py

    Sjors commented at 5:50 pm on February 6, 2026:
    Fixed

    Sjors commented at 5:51 pm on February 6, 2026:
    Fortunately the raw transaction variant is deprecated and should go away after #34184, so that should stop confusing people including me.

    Sjors commented at 11:08 am on February 12, 2026:
    I’ll fix this in #33966 along with a few other nits in other PRs.
  42. in test/functional/interface_ipc_mining.py:132 in 63434b1b26 outdated
    124+
    125+        async def async_routine():
    126+            ctx, init = await make_capnp_init_ctx(self.nodes[0], self.capnp_modules)
    127+            self.log.debug("Create Mining proxy object")
    128+            mining = init.makeMining(ctx).result
    129+            blockref = await mining.getTip(ctx)
    


    l0rinc commented at 11:24 am on February 6, 2026:

    in the original we had a few more assertions:

    0            self.log.debug("Test simple inspectors")
    1            assert (await mining.isTestChain(ctx)).result
    2            assert not (await mining.isInitialBlockDownload(ctx)).result
    3            blockref = await mining.getTip(ctx)
    4            assert blockref.hasResult
    5            assert_equal(len(blockref.result.hash), block_hash_size)
    

    Is this just moved elsewhere and we’re just avoiding duplication?


    We’re mixing refactors here, makes review more difficult than it should be - could you split low-risk refactors from riskier or slightly more involved changes and explain the non-trivial changes in the commit message?


    Sjors commented at 1:24 pm on February 6, 2026:

    The simple inspector checks remain in interface_ipc.py, so they’re not moved.

    I think the dimmed_zebra diff is more clear this way then if I were to temporariliy duplicate the code:

    I’ll make this more clear in the commit message.

  43. in test/functional/interface_ipc_mining.py:125 in 18b297c8ae
    122+        return ctx, mining
    123+
    124     def run_mining_interface_test(self):
    125-        """Test Mining interface methods: waitTipChanged, createNewBlock, checkBlock."""
    126-        self.log.info("Running mining test")
    127+        """Test Mining interface methods: getTip, waitTipChanged, checkBlock."""
    


    l0rinc commented at 11:28 am on February 6, 2026:
    isn’t checkBlock tested in run_coinbase_and_submission_test only?

    Sjors commented at 2:04 pm on February 6, 2026:
    I got rid of these lists, too tedious to maintain.
  44. l0rinc changes_requested
  45. l0rinc commented at 11:45 am on February 6, 2026: contributor
    Code review 18b297c8aedc1923a3e6869406958afc372b2653. I find the current refactors mixed with new changes harder to review that I think it needs to be. Could we split out strict move-only changes (formatting and imports are fine) from adjusting method signatures and changing assertions and renaming, etc.
  46. Sjors commented at 11:55 am on February 6, 2026: member

    I find the current refactors mixed with new changes harder to review that I think it needs to be.

    Initially my idea was to change things if the line was touched anyway, e.g. going from self.some_method_with_ugly_name to some_method_with_pretty_name, but I agree it’s too noisy and some other lines are touched too. Let me try to split out another commit.

  47. ryanofsky commented at 12:45 pm on February 6, 2026: contributor

    re: #34452#pullrequestreview-3762378213

    Could we split out strict move-only changes (formatting and imports are fine) from adjusting method signatures and changing assertions and renaming, etc.

    Seems good to make this PR easier to review, but I will say I’m surprised by these comments. I’d agree commit messages should be more accurate and tell reviewers what’s changing so they know exactly what to expect and to be surprised if they see any other changes. But the commits themselves seem fine.

    In the main commit 3b47cc33fca2de2e2a4f684a0dec50c2c4a85435 every single line is shown as move-only by git except for import statements and 5 changed signatures:

    0load_capnp_modules(self)                                  -> load_capnp_modules(config)
    1make_capnp_init_ctx(self)                                 -> make_capnp_init_ctx(node, capnp_modules)
    2parse_and_deserialize_block(self, block_template, ctx)    -> get_block(block_template, ctx)
    3get_coinbase_raw_tx(self, block_template, ctx)            -> get_coinbase_raw_tx(block_template, ctx)
    4parse_and_deserialize_coinbase(self, block_template, ctx) -> get_coinbase_tx(block_template, ctx)
    

    So reviewing the commit feels completely trivial to me, it’s just a matter of making sure all the lines are move only, and the only lines that aren’t move-only are the simple substitutions above. I think I only spent 1-2 minutes reviewing it myself.

    That said, it would be nice to split up, maybe by using @staticmethod to get rid of the self arguments and by defining global aliases load_capnp_modules = IPCInterfaceTest.load_capnp_modules so the signatures can change once in an initial commit and the followup commit can be 100% move-only.

  48. fjahr commented at 12:49 pm on February 6, 2026: contributor

    Code review ACK 18b297c8aedc1923a3e6869406958afc372b2653

    Maybe the changes could have been made a bit easier to review but I’ve seen much worse too. I couldn’t find any issues that I would consider a blocker.

  49. l0rinc commented at 1:12 pm on February 6, 2026: contributor

    So reviewing the commit feels completely trivial to me, it’s just a matter of making sure all the lines are move only

    Since I expected others to review it like that, I did it differently, I have re-moved it in reverse and check what differences I got - which definitely wasn’t trivial, especially since the renames resulted in some duplicates that don’t translate back cleanly.

  50. ismaelsadeeq commented at 1:20 pm on February 6, 2026: member

    utACK 18b297c8aedc1923a3e6869406958afc372b2653

    Maybe the changes could have been made a bit easier to review but I’ve seen much worse too. I couldn’t find any issues that I would consider a blocker.

    I agree this is good as is, but I also agree with @l0rinc on untangling move-only commits from commits that make changes, even if the author doesn’t apply it this time. I think we should still point out specific improvements personally; those comments have improved me as a PR author. I’ve used them as a standard for subsequent PRs, so in a way, they ensure we maintain review standards and set the tone for what we accept.

  51. janb84 commented at 2:06 pm on February 6, 2026: contributor

    crACK 18b297c8aedc1923a3e6869406958afc372b2653

    I agree with @l0rinc about splitting move changes from the refactors changes in separate commits, on principle. I also agree with @fjahr that in this case it should not be a blocker. I do not see major issues.

  52. Sjors commented at 2:13 pm on February 6, 2026: member
    I’m almost done with the cleanup, so might as well, just a minute…
  53. test: move IPC helpers to ipc_util.py
    Move IPC helpers into ipc_util.py and update interface_ipc.py
    to use them.
    
    Rename some helpers for clarity:
    - parse_and_deserialize_block -> mining_get_block
    - parse_and_deserialize_coinbase_tx -> mining_get_coinbase_tx
    - get_coinbase_raw_tx -> mining_get_coinbase_raw_tx
    - wait_next_template -> mining_wait_next_template
    01a1ae889e
  54. test: add interface_ipc_mining.py
    Split Mining interface tests into interface_ipc_mining.py and keep
    interface_ipc.py for echo + simple inspectors.
    
    Register the new test in test_runner.py.
    
    The setup code around "Create Mining proxy object" is duplicated
    in the new test file, but the simple insector checks below it
    are not moved.
    4e49fa2a68
  55. test: split interface_ipc_mining.py into subtests
    Split the Mining interface test into focused subtests.
    
    Keep the initial tip-change pre-mine check in run_mining_interface_test.
    As a result run_block_template_test no longer has newblockref.
    52ccd9215e
  56. test: misc interface_ipc_mining.py improvements
    - share miniwallet and block create options between tests
    - documentation fixes
    - use assert_equal instead of assert ==
    633d183119
  57. Sjors force-pushed on Feb 6, 2026
  58. Sjors commented at 2:48 pm on February 6, 2026: member
    Rebased and pushed cleanups. There’s now a fourth commit that takes some of the churn out of earlier ones.
  59. Sjors commented at 3:01 pm on February 6, 2026: member

    @ryanofsky wrote:

    That said, it would be nice to split up, maybe by using @staticmethod to get rid of the self arguments and by defining global aliases load_capnp_modules = IPCInterfaceTest.load_capnp_modules so the signatures can change once in an initial commit and the followup commit can be 100% move-only

    I missed this and leaving it for a followup, unless I have to make other more invasive changes.

  60. janb84 commented at 3:22 pm on February 6, 2026: contributor

    re ACK 633d1831199a2ca6ca31b97312130419328d5479

    Thanks @Sjors for the cleanup, this makes it easier to review and see what has been changed. lgtm

  61. DrahtBot requested review from ryanofsky on Feb 6, 2026
  62. DrahtBot requested review from fjahr on Feb 6, 2026
  63. in test/functional/interface_ipc_mining.py:30 in 633d183119
    25+    assert_not_equal
    26+)
    27+from test_framework.wallet import MiniWallet
    28+from test_framework.ipc_util import (
    29+    destroying,
    30+    mining_create_block_template,
    


    fjahr commented at 3:32 pm on February 6, 2026:
    micro-nit: ordering

    Sjors commented at 11:09 am on February 12, 2026:
    Fixing in #33966
  64. fjahr commented at 3:33 pm on February 6, 2026: contributor
    reACK 633d1831199a2ca6ca31b97312130419328d5479
  65. l0rinc approved
  66. l0rinc commented at 5:28 pm on February 6, 2026: contributor

    code review ACK 633d1831199a2ca6ca31b97312130419328d5479

    There are still a few nits in commit messages and PR description and in the imports that I would prefer we fix, but based on my understanding of this area of the code, this split seems correct. Since my review, a few interface changes were reverted to simplify review, code splits were simplified, renamed shared IPC mining helpers to mining_*, assertion standardized, docstrings simplified or removed and commit messages were updated to contain additional info. Tests are skipped for me locally but the rest of the build passes after rebase.

  67. sedited approved
  68. sedited commented at 8:42 am on February 7, 2026: contributor
    Re-ACK 633d1831199a2ca6ca31b97312130419328d5479
  69. sedited merged this on Feb 7, 2026
  70. sedited closed this on Feb 7, 2026

  71. Sjors deleted the branch on Feb 7, 2026
  72. Sjors commented at 1:04 pm on February 7, 2026: member
    I rebased the two PR’s that I’d like to see make it into v31: #34184 and #33965. I’ll rebase the others later.
  73. ryanofsky referenced this in commit 0b4cd08fcd on Feb 12, 2026
  74. Sjors referenced this in commit c301ccb0d1 on Feb 12, 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-02-22 18:12 UTC

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