From 76f69676d3e917d5cb609e12b3abf3b27baeec30 Mon Sep 17 00:00:00 2001 From: f321x Date: Fri, 31 Oct 2025 13:31:10 +0100 Subject: [PATCH] config/regtest: add config to disable automatic fee updates Some regtest tests depend on manual fee injection to simulate certain mempool conditions (e.g. lnwatcher_waits_until_fees_go_down). This is done by manually injecting fee estimates into the `Network` object using the `test_inject_fee_etas` cli command. However it can still happen that the Network automatically updates its fee estimates from the connected electrum server in the time between injecting the fee and the actual tested logic making decisions based on the fee. This causes the test to fail sometimes. By setting the `test_disable_automatic_fee_eta_update` true the Network will stop automatically updating the fee estimates and the test will behave as expected. --- electrum/commands.py | 2 ++ electrum/network.py | 2 ++ electrum/simple_config.py | 1 + tests/regtest/regtest.sh | 1 + 4 files changed, 6 insertions(+) diff --git a/electrum/commands.py b/electrum/commands.py index 8e350def0..217f5aba7 100644 --- a/electrum/commands.py +++ b/electrum/commands.py @@ -1624,6 +1624,8 @@ class Commands(Logger): async def test_inject_fee_etas(self, fee_est): """ Inject fee estimates into the network object, as if they were coming from connected servers. + `setconfig 'test_disable_automatic_fee_eta_update' true` to prevent Network from overriding + the configured fees. Useful on regtest. arg:str:fee_est:dict of ETA-based fee estimates, encoded as str diff --git a/electrum/network.py b/electrum/network.py index ea38ef04e..c49b48f9c 100644 --- a/electrum/network.py +++ b/electrum/network.py @@ -612,6 +612,8 @@ class Network(Logger, NetworkRetryManager[ServerAddr]): def update_fee_estimates(self, *, fee_est: Dict[int, int] = None): if fee_est is None: + if self.config.TEST_DISABLE_AUTOMATIC_FEE_ETA_UPDATE: + return fee_est = self.get_fee_estimates() for nblock_target, fee in fee_est.items(): self.fee_estimates.set_data(nblock_target, fee) diff --git a/electrum/simple_config.py b/electrum/simple_config.py index f356f2696..b545d899b 100644 --- a/electrum/simple_config.py +++ b/electrum/simple_config.py @@ -775,6 +775,7 @@ Warning: setting this to too low will result in lots of payment failures."""), FEE_POLICY = ConfigVar('fee_policy.default', default='eta:2', type_=str) # exposed to GUI FEE_POLICY_LIGHTNING = ConfigVar('fee_policy.lnwatcher', default='eta:2', type_=str) # for txbatcher (sweeping) FEE_POLICY_SWAPS = ConfigVar('fee_policy.swaps', default='eta:2', type_=str) # for txbatcher (sweeping and sending if we are a swapserver) + TEST_DISABLE_AUTOMATIC_FEE_ETA_UPDATE = ConfigVar('test_disable_automatic_fee_eta_update', default=False, type_=bool) RPC_USERNAME = ConfigVar('rpcuser', default=None, type_=str) RPC_PASSWORD = ConfigVar('rpcpassword', default=None, type_=str) diff --git a/tests/regtest/regtest.sh b/tests/regtest/regtest.sh index 0473c6577..c2c8301cb 100755 --- a/tests/regtest/regtest.sh +++ b/tests/regtest/regtest.sh @@ -331,6 +331,7 @@ if [[ $1 == "lnwatcher_waits_until_fees_go_down" ]]; then $alice setconfig test_force_disable_mpp true $alice setconfig test_force_mpp false wait_for_balance alice 1 + $alice setconfig test_disable_automatic_fee_eta_update true $alice test_inject_fee_etas "{2:1000}" $bob test_inject_fee_etas "{2:1000}" echo "alice opens channel"