test: cover feeThreshold = MAX_MONEY in interface_ipc_mining.py #35598

Manually merged
Sjors merged 1 commit from 2026/06/max-money into master 2026-11-05 14:54:55 +00:00 AGit
Sjors commented 2026-06-24 19:35:34 +00:00 (Migrated from github.com)

This adds coverage for when BlockWaitOptions's feeThreshold is set to MAX_MONEY. In other words, when the IPC client is only interested in tip updates, not in fee increases.

This tested ended up in #33922 at some point https://github.com/bitcoin/bitcoin/pull/33922#issuecomment-3674495132, but doesn't really belong there.

This adds coverage for when [BlockWaitOptions](https://github.com/bitcoin/bitcoin/blob/master/src/node/mining_types.h#L94-L113)'s `feeThreshold` is set to `MAX_MONEY`. In other words, when the IPC client is only interested in tip updates, not in fee increases. This tested ended up in #33922 at some point https://github.com/bitcoin/bitcoin/pull/33922#issuecomment-3674495132, but doesn't really belong there.
DrahtBot commented 2026-06-24 19:35:48 +00:00 (Migrated from github.com)

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

External sites

Reviews

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

Type Reviewers
ACK davidgumberg, sedited, enirox001
Approach ACK jeanpablojp

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

Conflicts

No conflicts as of last run.

LLM Linter (✨ experimental)

Possible places where comparison-specific test macros should replace generic comparisons:

  • test/functional/interface_ipc_mining.py: assert template3 is None → Prefer assert_equal(template3, None).

2026-10-15 04:12:45

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/35598 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/35598.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/35598#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. | Type | Reviewers | | ---- | --------- | | ACK | [davidgumberg](https://github.com/bitcoin/bitcoin/pull/35598#issuecomment-6648359018), [sedited](https://github.com/bitcoin/bitcoin/pull/35598#pullrequestreview-5786765833), [enirox001](https://github.com/bitcoin/bitcoin/pull/35598#pullrequestreview-5786902735) | | Approach ACK | [jeanpablojp](https://github.com/bitcoin/bitcoin/pull/35598#pullrequestreview-5040791065) | 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. <!--174a7506f384e20aa4161008e828411d--> ### Conflicts No conflicts as of last run. <!--5faf32d7da4f0f540f40219e4f7537a3--> ### LLM Linter (✨ experimental) Possible places where comparison-specific test macros should replace generic comparisons: - `test/functional/interface_ipc_mining.py`: `assert template3 is None` → Prefer `assert_equal(template3, None)`. <sup>2026-10-15 04:12:45</sup>
enirox001 (Migrated from github.com) reviewed 2026-06-26 11:55:43 +00:00
enirox001 (Migrated from github.com) left a comment

ACK 4f74b73

Mostly reviewing this in isolation, as I have not looked at #33922 in depth, it makes sense that this should be a PR on its own

The change updates the functional test to explicitly ignore mempool fee increases while waiting for a tip update, then restores the lower fee threshold for subsequent checks.

These changes look good to me. Left a minor non-blocking suggestion below,

ACK 4f74b73 _Mostly_ reviewing this in isolation, as I have not looked at #33922 in depth, it makes sense that this should be a PR on its own The change updates the functional test to explicitly ignore mempool fee increases while waiting for a tip update, then restores the lower fee threshold for subsequent checks. These changes look good to me. Left a minor non-blocking suggestion below,
enirox001 (Migrated from github.com) commented 2026-06-26 11:55:37 +00:00

In 4f74b73 (test: cover feeThreshold = MAX_MONEY)

Would be nice if there were a comment explaining the assertion here. Something like

If waitNext had returned for the fee increase instead of the tip update,
this template would include the mempool transaction.
In 4f74b73 (_test: cover feeThreshold = MAX_MONEY_) Would be nice if there were a comment explaining the assertion here. Something like ``` If waitNext had returned for the fee increase instead of the tip update, this template would include the mempool transaction. ```
Sjors commented 2026-06-26 12:56:52 +00:00 (Migrated from github.com)

Added the suggested comment.

as I have not looked at https://github.com/bitcoin/bitcoin/pull/33922 in depth, it makes sense that this should be a PR on its own

It's unrelated. That PR is about memory tracking and management, this test is about adding coverages to pre-existing waitNext() behavior. The PR touches the same test file, so it was easy to add. But now that I'm considering alternative approaches for #33922, the test becomes a distraction - and it might be a long time before it lands.

Added the suggested comment. > as I have not looked at https://github.com/bitcoin/bitcoin/pull/33922 in depth, it makes sense that this should be a PR on its own It's unrelated. That PR is about memory tracking and management, this test is about adding coverages to pre-existing `waitNext()` behavior. The PR touches the same test file, so it was easy to add. But now that I'm considering alternative approaches for #33922, the test becomes a distraction - and it might be a long time before it lands.
davidgumberg (Migrated from github.com) reviewed 2026-07-02 00:21:50 +00:00
davidgumberg (Migrated from github.com) commented 2026-07-02 00:21:50 +00:00

https://github.com/bitcoin/bitcoin/pull/35598/changes/bd1771fc0cd248438e87b028b096f59ffc976d18 (test: cover feeThreshold = MAX_MONEY)


The test still passes with waitoptions.feeThreshold = 1

That is because WaitAndCreateNewBlock() checks for a tip update immediately and then goes to sleep waiting for a tip update, only waking up 1 second after being called or at the timeout deadline before checking for a fee-based update:

github.com/bitcoin/bitcoin@a8823c0996/src/node/miner.cpp (L452-L460)

and wait_and_do only sleeps for 0.1s:

github.com/bitcoin/bitcoin@a8823c0996/test/functional/test_framework/ipc_util.py (L59-L67)

so the fee check never even has a chance, since WaitAndCreateNewBlock() is still asleep waiting for a new tip when wait_and_do produces one, returns, and the fee check has never even had a chance..

To fix it, easier shown than explained I think:

-                waitoptions.timeout = self.default_ipc_timeout
+
+                # Temporarily increase the timeout to allow a fee ticks (1s) to
+                # happen before the deadline
+                waitoptions.timeout = 2000
                 # Ignore fee increases, wait only for the tip update
                 waitoptions.feeThreshold = MAX_MONEY
                 self.miniwallet.send_self_transfer(fee_rate=10, from_node=self.nodes[0])
                 template2 = await wait_and_do(
                     mining_wait_next_template(template, stack, ctx, waitoptions),
                     # This mines the transaction, so it won't be in the next template
-                    lambda: self.generate(self.nodes[0], 1))
+                    lambda: self.generate(self.nodes[0], 1),
+                    sleep_time=1.1)

(because of my other suggestion I've omitted setting waitoptions.timeout back to self.default_ipc_timeout in this diff but that needs to be done at some point)

and adding an arg to wait_and_do:

--- a/test/functional/test_framework/ipc_util.py
+++ b/test/functional/test_framework/ipc_util.py
@@ -45,7 +45,7 @@ async def destroying(obj, ctx):
         await obj.destroy(ctx)


-async def wait_and_do(wait_fn, do_fn):
+async def wait_and_do(wait_fn, do_fn, sleep_time=0.1):
     """Call wait_fn, then sleep, then call do_fn in a parallel task. Wait for
     both tasks to complete."""
     wait_started = asyncio.Event()
@@ -58,7 +58,7 @@ async def wait_and_do(wait_fn, do_fn):

     async def do():
         await wait_started.wait()
-        await asyncio.sleep(0.1)
+        await asyncio.sleep(sleep_time)
         # Let do_fn be either a callable or an awaitable object
         if inspect.isawaitable(do_fn):
             await do_fn
https://github.com/bitcoin/bitcoin/pull/35598/changes/bd1771fc0cd248438e87b028b096f59ffc976d18 (_test: cover feeThreshold = MAX_MONEY_) --- The test still passes with `waitoptions.feeThreshold = 1` That is because `WaitAndCreateNewBlock()` checks for a tip update immediately and then goes to sleep waiting for a tip update, only waking up 1 second after being called or at the timeout deadline before checking for a fee-based update: https://github.com/bitcoin/bitcoin/blob/a8823c099618559fdf6116fe17c9afd311e88890/src/node/miner.cpp#L452-L460 and `wait_and_do` only sleeps for 0.1s: https://github.com/bitcoin/bitcoin/blob/a8823c099618559fdf6116fe17c9afd311e88890/test/functional/test_framework/ipc_util.py#L59-L67 so the fee check never even has a chance, since `WaitAndCreateNewBlock()` is still asleep waiting for a new tip when `wait_and_do` produces one, returns, and the fee check has never even had a chance.. To fix it, easier shown than explained I think: ```diff - waitoptions.timeout = self.default_ipc_timeout + + # Temporarily increase the timeout to allow a fee ticks (1s) to + # happen before the deadline + waitoptions.timeout = 2000 # Ignore fee increases, wait only for the tip update waitoptions.feeThreshold = MAX_MONEY self.miniwallet.send_self_transfer(fee_rate=10, from_node=self.nodes[0]) template2 = await wait_and_do( mining_wait_next_template(template, stack, ctx, waitoptions), # This mines the transaction, so it won't be in the next template - lambda: self.generate(self.nodes[0], 1)) + lambda: self.generate(self.nodes[0], 1), + sleep_time=1.1) ``` > _(because of my other suggestion I've omitted setting waitoptions.timeout back to `self.default_ipc_timeout` in this diff but that needs to be done at some point)_ and adding an arg to `wait_and_do`: ```diff --- a/test/functional/test_framework/ipc_util.py +++ b/test/functional/test_framework/ipc_util.py @@ -45,7 +45,7 @@ async def destroying(obj, ctx): await obj.destroy(ctx) -async def wait_and_do(wait_fn, do_fn): +async def wait_and_do(wait_fn, do_fn, sleep_time=0.1): """Call wait_fn, then sleep, then call do_fn in a parallel task. Wait for both tasks to complete.""" wait_started = asyncio.Event() @@ -58,7 +58,7 @@ async def wait_and_do(wait_fn, do_fn): async def do(): await wait_started.wait() - await asyncio.sleep(0.1) + await asyncio.sleep(sleep_time) # Let do_fn be either a callable or an awaitable object if inspect.isawaitable(do_fn): await do_fn ```
davidgumberg (Migrated from github.com) reviewed 2026-07-02 00:25:44 +00:00
davidgumberg (Migrated from github.com) commented 2026-07-02 00:25:44 +00:00

https://github.com/bitcoin/bitcoin/pull/35598/changes/bd1771fc0cd248438e87b028b096f59ffc976d18 (test: cover feeThreshold = MAX_MONEY)


(see comment above: https://github.com/bitcoin/bitcoin/pull/35598/changes/bd1771fc0cd248438e87b028b096f59ffc976d18#r3509745119)

Should probably add a transaction here to check in another way that MAX_MONEY works to prevent fee-based template updates:

@@ -280,9 +284,14 @@ class IPCMiningTest(BitcoinTestFramework):
                 assert_equal(len(block2.vtx), 1)

                 self.log.debug("Wait for another, but time out")
+                # Temporarily decrease the timeout since we want to hit the
+                # deadline and perform a fee check and see what happens.
+                waitoptions.timeout = 100
+                self.miniwallet.send_self_transfer(fee_rate=10, from_node=self.nodes[0])
                 template3 = await mining_wait_next_template(template2, stack, ctx, waitoptions)
                 assert template3 is None

+                waitoptions.timeout = self.default_ipc_timeout
                 self.log.debug("Wait for another, get one after increase in fees in the mempool")
                 waitoptions.feeThreshold = 1
                 template4 = await wait_and_do(
@@ -290,14 +299,14 @@ class IPCMiningTest(BitcoinTestFramework):
                     lambda: self.miniwallet.send_self_transfer(fee_rate=10, from_node=self.nodes[0]))
                 assert template4 is not None
                 block3 = await mining_get_block(template4, ctx)
-                assert_equal(len(block3.vtx), 2)
+                assert_equal(len(block3.vtx), 3)

                 self.log.debug("Wait again, this should return the same template, since the fee threshold is zero")
                 waitoptions.feeThreshold = 0
                 template5 = await mining_wait_next_template(template4, stack, ctx, waitoptions)
                 assert template5 is not None
                 block4 = await mining_get_block(template5, ctx)
-                assert_equal(len(block4.vtx), 2)
+                assert_equal(len(block4.vtx), 3)
                 waitoptions.feeThreshold = 1

                 self.log.debug("Wait for another, get one after increase in fees in the mempool")
@@ -306,7 +315,7 @@ class IPCMiningTest(BitcoinTestFramework):
                     lambda: self.miniwallet.send_self_transfer(fee_rate=10, from_node=self.nodes[0]))
                 assert template6 is not None
                 block4 = await mining_get_block(template6, ctx)
-                assert_equal(len(block4.vtx), 3)
+                assert_equal(len(block4.vtx), 4)

                 self.log.debug("Wait for another, but time out, since the fee threshold is set now")
                 template7 = await mining_wait_next_template(template6, stack, ctx, waitoptions)
https://github.com/bitcoin/bitcoin/pull/35598/changes/bd1771fc0cd248438e87b028b096f59ffc976d18 (_test: cover feeThreshold = MAX_MONEY_) --- (see comment above: https://github.com/bitcoin/bitcoin/pull/35598/changes/bd1771fc0cd248438e87b028b096f59ffc976d18#r3509745119) Should probably add a transaction here to check in another way that MAX_MONEY works to prevent fee-based template updates: ```diff @@ -280,9 +284,14 @@ class IPCMiningTest(BitcoinTestFramework): assert_equal(len(block2.vtx), 1) self.log.debug("Wait for another, but time out") + # Temporarily decrease the timeout since we want to hit the + # deadline and perform a fee check and see what happens. + waitoptions.timeout = 100 + self.miniwallet.send_self_transfer(fee_rate=10, from_node=self.nodes[0]) template3 = await mining_wait_next_template(template2, stack, ctx, waitoptions) assert template3 is None + waitoptions.timeout = self.default_ipc_timeout self.log.debug("Wait for another, get one after increase in fees in the mempool") waitoptions.feeThreshold = 1 template4 = await wait_and_do( @@ -290,14 +299,14 @@ class IPCMiningTest(BitcoinTestFramework): lambda: self.miniwallet.send_self_transfer(fee_rate=10, from_node=self.nodes[0])) assert template4 is not None block3 = await mining_get_block(template4, ctx) - assert_equal(len(block3.vtx), 2) + assert_equal(len(block3.vtx), 3) self.log.debug("Wait again, this should return the same template, since the fee threshold is zero") waitoptions.feeThreshold = 0 template5 = await mining_wait_next_template(template4, stack, ctx, waitoptions) assert template5 is not None block4 = await mining_get_block(template5, ctx) - assert_equal(len(block4.vtx), 2) + assert_equal(len(block4.vtx), 3) waitoptions.feeThreshold = 1 self.log.debug("Wait for another, get one after increase in fees in the mempool") @@ -306,7 +315,7 @@ class IPCMiningTest(BitcoinTestFramework): lambda: self.miniwallet.send_self_transfer(fee_rate=10, from_node=self.nodes[0])) assert template6 is not None block4 = await mining_get_block(template6, ctx) - assert_equal(len(block4.vtx), 3) + assert_equal(len(block4.vtx), 4) self.log.debug("Wait for another, but time out, since the fee threshold is set now") template7 = await mining_wait_next_template(template6, stack, ctx, waitoptions) ```
Sjors (Migrated from github.com) reviewed 2026-07-02 11:54:47 +00:00
Sjors (Migrated from github.com) commented 2026-07-02 11:54:47 +00:00

Ah oops. The counter intuitive thing here is that waitNext() will ignore fee changes in the first second. This might change with cluster mempool when we get rid of the internal tick mechanism, see https://github.com/bitcoin/bitcoin/pull/35581. But the adjusted test should continue to work.

Took your suggestion with some adjustments.

Ah oops. The counter intuitive thing here is that `waitNext()` will ignore fee changes in the first second. This might change with cluster mempool when we get rid of the internal tick mechanism, see https://github.com/bitcoin/bitcoin/pull/35581. But the adjusted test should continue to work. Took your suggestion with some adjustments.
Sjors (Migrated from github.com) reviewed 2026-07-02 11:55:08 +00:00
Sjors (Migrated from github.com) commented 2026-07-02 11:55:08 +00:00

Also taken

Also taken
Sjors commented 2026-07-02 11:55:31 +00:00 (Migrated from github.com)
Turns out it was a a good idea to make this a separate PR. Fixed https://github.com/bitcoin/bitcoin/pull/35598#discussion_r3509745119
jeanpablojp (Migrated from github.com) reviewed 2026-08-27 12:33:12 +00:00
jeanpablojp (Migrated from github.com) left a comment

Approach ACK

Left two comments.

Approach ACK Left two comments.
jeanpablojp (Migrated from github.com) commented 2026-08-27 12:33:12 +00:00

Nit, feel free to ignore. With feeThreshold at MAX_MONEY the fee block in WaitAndCreateNewBlock is skipped, so nothing is checked at the deadline either. The assert is right, the comment isn't.

Nit, feel free to ignore. With `feeThreshold` at MAX_MONEY the fee block in `WaitAndCreateNewBlock` is skipped, so nothing is checked at the deadline either. The assert is right, the comment isn't.
jeanpablojp (Migrated from github.com) commented 2026-08-27 12:33:12 +00:00

mining_types.h describes MAX_MONEY as an optimization, and no fee delta can reach it, so the MAX_MONEY half of that guard only exists to skip building the template. Dropping it, and the Assume it makes true, leaves the test green in both release and debug builds. With the wrap below it fails. What do you think about covering that here too?

                # MAX_MONEY is documented as an optimization, so waitNext()
                # should not build a template at all here.
                with self.nodes[0].assert_debug_log(expected_msgs=[], unexpected_msgs=["CreateNewBlock()"]):
                    template3 = await mining_wait_next_template(template2, stack, ctx, waitoptions)
`mining_types.h` describes MAX_MONEY as an optimization, and no fee delta can reach it, so the MAX_MONEY half of that guard only exists to skip building the template. Dropping it, and the `Assume` it makes true, leaves the test green in both release and debug builds. With the wrap below it fails. What do you think about covering that here too? ```suggestion # MAX_MONEY is documented as an optimization, so waitNext() # should not build a template at all here. with self.nodes[0].assert_debug_log(expected_msgs=[], unexpected_msgs=["CreateNewBlock()"]): template3 = await mining_wait_next_template(template2, stack, ctx, waitoptions) ```
enirox001 (Migrated from github.com) reviewed 2026-08-28 09:44:44 +00:00
enirox001 (Migrated from github.com) left a comment

reACK https://github.com/bitcoin/bitcoin/pull/35598/changes/0de7c2bf7912d5632c33195b7764e06c46e5f7b0

Changes look good to me. It is useful to have this coverage, and it makes sense as a standalone pr. Left non-blocking comment

reACK https://github.com/bitcoin/bitcoin/pull/35598/changes/0de7c2bf7912d5632c33195b7764e06c46e5f7b0 Changes look good to me. It is useful to have this coverage, and it makes sense as a standalone pr. Left non-blocking comment
enirox001 (Migrated from github.com) reviewed 2026-08-28 09:46:57 +00:00
enirox001 (Migrated from github.com) commented 2026-08-28 09:46:40 +00:00

In https://github.com/bitcoin/bitcoin/pull/35598/changes/0de7c2bf7912d5632c33195b7764e06c46e5f7b0: test: cover feeThreshold = MAX_MONEY

non_blocking nit

Looking at this again, my understanding is that the transaction added above is intentionally kept in the mempool to verify that feeThreshold = MAX_MONEY ignores a fee increase and still times out. That part makes sense.

After the timeout, however, that transaction remains in the mempool and is not included in template2. Therefore, once feeThreshold is changed to 1, it already satisfies the threshold before this second wait starts. waitNext is allowed to return without waiting for the transaction added by this lambda.

Verified this by delaying the lambda

index 85a7b8bf11..fe5b861614 100755
--- a/test/functional/interface_ipc_mining.py
+++ b/test/functional/interface_ipc_mining.py
@@ -299,7 +299,8 @@ class IPCMiningTest(BitcoinTestFramework):
                 waitoptions.feeThreshold = 1
                 template4 = await wait_and_do(
                     mining_wait_next_template(template2, stack, ctx, waitoptions),
-                    lambda: self.miniwallet.send_self_transfer(fee_rate=10, from_node=self.nodes[0]))
+                    lambda: self.miniwallet.send_self_transfer(fee_rate=10, from_node=self.nodes[0]),
+                    sleep_time=1.1 * self.options.timeout_factor)
                 assert template4 is not None
                 block3 = await mining_get_block(template4, ctx)
                 assert_equal(len(block3.vtx), 3)

The test fails when asserting the transaction count because it only contains 2 transactions. Would it be clearer to consume the existing fee increase directly here?

index 85a7b8bf11..57c1b60b98 100755
--- a/test/functional/interface_ipc_mining.py
+++ b/test/functional/interface_ipc_mining.py
@@ -295,21 +295,19 @@ class IPCMiningTest(BitcoinTestFramework):
                 assert template3 is None

                 waitoptions.timeout = self.default_ipc_timeout
-                self.log.debug("Wait for another, get one after increase in fees in the mempool")
+                self.log.debug("Wait for another, get one for the fees already in the mempool")
                 waitoptions.feeThreshold = 1
-                template4 = await wait_and_do(
-                    mining_wait_next_template(template2, stack, ctx, waitoptions),
-                    lambda: self.miniwallet.send_self_transfer(fee_rate=10, from_node=self.nodes[0]))
+                template4 = await mining_wait_next_template(template2, stack, ctx, waitoptions)
                 assert template4 is not None
                 block3 = await mining_get_block(template4, ctx)
-                assert_equal(len(block3.vtx), 3)
+                assert_equal(len(block3.vtx), 2)

                 self.log.debug("Wait again, this should return the same template, since the fee threshold is zero")
                 waitoptions.feeThreshold = 0
                 template5 = await mining_wait_next_template(template4, stack, ctx, waitoptions)
                 assert template5 is not None
                 block4 = await mining_get_block(template5, ctx)
-                assert_equal(len(block4.vtx), 3)
+                assert_equal(len(block4.vtx), 2)
                 waitoptions.feeThreshold = 1

                 self.log.debug("Wait for another, get one after increase in fees in the mempool")
@@ -318,7 +316,7 @@ class IPCMiningTest(BitcoinTestFramework):
                     lambda: self.miniwallet.send_self_transfer(fee_rate=10, from_node=self.nodes[0]))
                 assert template6 is not None
                 block4 = await mining_get_block(template6, ctx)
-                assert_equal(len(block4.vtx), 4)
+                assert_equal(len(block4.vtx), 3)

                 self.log.debug("Wait for another, but time out, since the fee threshold is set now")
                 template7 = await mining_wait_next_template(template6, stack, ctx, waitoptions)

Later on template6 would still test adding a transaction while waitNext is active, verifying that a new template is returned

In https://github.com/bitcoin/bitcoin/pull/35598/changes/0de7c2bf7912d5632c33195b7764e06c46e5f7b0: _test: cover feeThreshold = MAX_MONEY_ non_blocking nit Looking at this again, my understanding is that the transaction added above is intentionally kept in the mempool to verify that `feeThreshold = MAX_MONEY` ignores a fee increase and still times out. That part makes sense. After the timeout, however, that transaction remains in the mempool and is not included in `template2`. Therefore, once `feeThreshold` is changed to 1, it already satisfies the threshold before this second wait starts. `waitNext` is allowed to return without waiting for the transaction added by this lambda. Verified this by delaying the lambda ```diff --git a/test/functional/interface_ipc_mining.py b/test/functional/interface_ipc_mining.py index 85a7b8bf11..fe5b861614 100755 --- a/test/functional/interface_ipc_mining.py +++ b/test/functional/interface_ipc_mining.py @@ -299,7 +299,8 @@ class IPCMiningTest(BitcoinTestFramework): waitoptions.feeThreshold = 1 template4 = await wait_and_do( mining_wait_next_template(template2, stack, ctx, waitoptions), - lambda: self.miniwallet.send_self_transfer(fee_rate=10, from_node=self.nodes[0])) + lambda: self.miniwallet.send_self_transfer(fee_rate=10, from_node=self.nodes[0]), + sleep_time=1.1 * self.options.timeout_factor) assert template4 is not None block3 = await mining_get_block(template4, ctx) assert_equal(len(block3.vtx), 3) ``` The test fails when asserting the transaction count because it only contains 2 transactions. Would it be clearer to consume the existing fee increase directly here? ```diff --git a/test/functional/interface_ipc_mining.py b/test/functional/interface_ipc_mining.py index 85a7b8bf11..57c1b60b98 100755 --- a/test/functional/interface_ipc_mining.py +++ b/test/functional/interface_ipc_mining.py @@ -295,21 +295,19 @@ class IPCMiningTest(BitcoinTestFramework): assert template3 is None waitoptions.timeout = self.default_ipc_timeout - self.log.debug("Wait for another, get one after increase in fees in the mempool") + self.log.debug("Wait for another, get one for the fees already in the mempool") waitoptions.feeThreshold = 1 - template4 = await wait_and_do( - mining_wait_next_template(template2, stack, ctx, waitoptions), - lambda: self.miniwallet.send_self_transfer(fee_rate=10, from_node=self.nodes[0])) + template4 = await mining_wait_next_template(template2, stack, ctx, waitoptions) assert template4 is not None block3 = await mining_get_block(template4, ctx) - assert_equal(len(block3.vtx), 3) + assert_equal(len(block3.vtx), 2) self.log.debug("Wait again, this should return the same template, since the fee threshold is zero") waitoptions.feeThreshold = 0 template5 = await mining_wait_next_template(template4, stack, ctx, waitoptions) assert template5 is not None block4 = await mining_get_block(template5, ctx) - assert_equal(len(block4.vtx), 3) + assert_equal(len(block4.vtx), 2) waitoptions.feeThreshold = 1 self.log.debug("Wait for another, get one after increase in fees in the mempool") @@ -318,7 +316,7 @@ class IPCMiningTest(BitcoinTestFramework): lambda: self.miniwallet.send_self_transfer(fee_rate=10, from_node=self.nodes[0])) assert template6 is not None block4 = await mining_get_block(template6, ctx) - assert_equal(len(block4.vtx), 4) + assert_equal(len(block4.vtx), 3) self.log.debug("Wait for another, but time out, since the fee threshold is set now") template7 = await mining_wait_next_template(template6, stack, ctx, waitoptions) ``` Later on `template6` would still test adding a transaction while `waitNext` is active, verifying that a new template is returned
Sjors commented 2026-08-28 12:53:32 +00:00 (Migrated from github.com)

Rebased just in case, and addressed feedback from @jeanpablojp and @enirox001.

Rebased just in case, and addressed feedback from @jeanpablojp and @enirox001.
First-time contributor

Base: 649bc0a645eb127a9b1e6d078f8d129be6380c87
Head: 7dfc7ef17ca33d01b854f63789cd357fee84f22d

I found no actionable issues in this static review.

Full review report

<!-- forgejo-review-bot:bitcoin/bitcoin --> Base: `649bc0a645eb127a9b1e6d078f8d129be6380c87` Head: `7dfc7ef17ca33d01b854f63789cd357fee84f22d` I found no actionable issues in this static review. [Full review report](<https://review.fish.foo/traces/35598-7dfc7ef17ca33d01b854f63789cd357fee84f22d-789-2.html>)
enirox001 (Migrated from github.com) reviewed 2026-10-13 10:55:01 +00:00
enirox001 (Migrated from github.com) left a comment
reACK https://github.com/bitcoin/bitcoin/pull/35598/changes/8fb2dbc0d6e788da43c8e471b6e8027b03b8b6ec Previous feedback has been addressed, Changes LGTM.
DrahtBot commented 2026-10-15 02:04:28 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
Sjors commented 2026-10-15 04:13:00 +00:00 (Migrated from github.com)

Rebased after #36446.

Rebased after #36446.
davidgumberg commented 2026-11-05 02:51:37 +00:00 (Migrated from github.com)

crACK github.com/bitcoin/bitcoin@7dfc7ef17c

(apologies for the delay)

crACK https://github.com/bitcoin/bitcoin/commit/7dfc7ef17ca33d01b854f63789cd357fee84f22d (apologies for the delay)
sedited (Migrated from github.com) approved these changes 2026-11-05 14:44:37 +00:00
sedited (Migrated from github.com) left a comment
ACK 7dfc7ef17ca33d01b854f63789cd357fee84f22d
enirox001 (Migrated from github.com) reviewed 2026-11-05 14:53:05 +00:00
enirox001 (Migrated from github.com) left a comment
reACK https://github.com/bitcoin/bitcoin/pull/35598/changes/7dfc7ef17ca33d01b854f63789cd357fee84f22d
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!35598
No description provided.