Skip to content

Commit 76f6967

Browse files
committed
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.
1 parent 19e32d6 commit 76f6967

File tree

4 files changed

+6
-0
lines changed

4 files changed

+6
-0
lines changed

electrum/commands.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,6 +1624,8 @@ async def getfeerate(self):
16241624
async def test_inject_fee_etas(self, fee_est):
16251625
"""
16261626
Inject fee estimates into the network object, as if they were coming from connected servers.
1627+
`setconfig 'test_disable_automatic_fee_eta_update' true` to prevent Network from overriding
1628+
the configured fees.
16271629
Useful on regtest.
16281630
16291631
arg:str:fee_est:dict of ETA-based fee estimates, encoded as str

electrum/network.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,8 @@ def get_fee_estimates(self):
612612

613613
def update_fee_estimates(self, *, fee_est: Dict[int, int] = None):
614614
if fee_est is None:
615+
if self.config.TEST_DISABLE_AUTOMATIC_FEE_ETA_UPDATE:
616+
return
615617
fee_est = self.get_fee_estimates()
616618
for nblock_target, fee in fee_est.items():
617619
self.fee_estimates.set_data(nblock_target, fee)

electrum/simple_config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,7 @@ def __setattr__(self, name, value):
775775
FEE_POLICY = ConfigVar('fee_policy.default', default='eta:2', type_=str) # exposed to GUI
776776
FEE_POLICY_LIGHTNING = ConfigVar('fee_policy.lnwatcher', default='eta:2', type_=str) # for txbatcher (sweeping)
777777
FEE_POLICY_SWAPS = ConfigVar('fee_policy.swaps', default='eta:2', type_=str) # for txbatcher (sweeping and sending if we are a swapserver)
778+
TEST_DISABLE_AUTOMATIC_FEE_ETA_UPDATE = ConfigVar('test_disable_automatic_fee_eta_update', default=False, type_=bool)
778779

779780
RPC_USERNAME = ConfigVar('rpcuser', default=None, type_=str)
780781
RPC_PASSWORD = ConfigVar('rpcpassword', default=None, type_=str)

tests/regtest/regtest.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ if [[ $1 == "lnwatcher_waits_until_fees_go_down" ]]; then
331331
$alice setconfig test_force_disable_mpp true
332332
$alice setconfig test_force_mpp false
333333
wait_for_balance alice 1
334+
$alice setconfig test_disable_automatic_fee_eta_update true
334335
$alice test_inject_fee_etas "{2:1000}"
335336
$bob test_inject_fee_etas "{2:1000}"
336337
echo "alice opens channel"

0 commit comments

Comments
 (0)