MCPcopy Create free account
hub / github.com/ElementsProject/lightning / test_feerate_ceiling

Function test_feerate_ceiling

tests/test_misc.py:1952–1977  ·  view source on GitHub ↗

A broken fee source can't feed absurd feerates into the daemon.

(node_factory)

Source from the content-addressed store, hash-verified

1950
1951@unittest.skipIf(TEST_NETWORK == 'liquid-regtest', "Fees on elements are different")
1952def test_feerate_ceiling(node_factory):
1953 """A broken fee source can't feed absurd feerates into the daemon."""
1954 l1 = node_factory.get_node()
1955
1956 # bcli trims anything wider than a u32 of perkb down to exactly
1957 # 0xFFFFFFFF. That is also the interesting value for the conversion:
1958 # (0xFFFFFFFF + 3) / 4 wraps to 0 on a u32, so before the conversion was
1959 # widened this arrived as 0perkw and was quietly raised to the floor,
1960 # i.e. an absurd fee source produced an absurdly *low* feerate and the
1961 # ceiling never saw it.
1962 def absurd_feerate(r):
1963 return {'id': r['id'], 'error': None,
1964 'result': {'feerate': Decimal(900000)}}
1965
1966 l1.daemon.rpcproxy.mock_rpc('estimatesmartfee', absurd_feerate)
1967 l1.restart()
1968
1969 l1.daemon.wait_for_log(r'is above sanity ceiling \(1000000\): clamping!')
1970
1971 feerates = l1.rpc.feerates('perkw')['perkw']
1972 assert [e['feerate'] for e in feerates['estimates']] == [1000000] * 4
1973 # max_fee_multiplier can't carry max_acceptable past the ceiling either.
1974 assert feerates['max_acceptable'] == 1000000
1975 # And what we're prepared to pay ourselves stays well under it.
1976 assert feerates['opening'] <= 100000
1977 assert feerates['splice'] <= 100000
1978
1979
1980def test_logging(node_factory):

Callers

nothing calls this directly

Calls 5

mock_rpcMethod · 0.80
restartMethod · 0.80
wait_for_logMethod · 0.80
get_nodeMethod · 0.45
feeratesMethod · 0.45

Tested by

no test coverage detected