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

Function test_feerates

tests/test_misc.py:1794–1948  ·  view source on GitHub ↗
(node_factory, anchors)

Source from the content-addressed store, hash-verified

1792@unittest.skipIf(TEST_NETWORK == 'liquid-regtest', "Fees on elements are different")
1793@pytest.mark.parametrize("anchors", [False, True])
1794def test_feerates(node_factory, anchors):
1795 opts = {'log-level': 'io',
1796 'dev-no-fake-fees': True}
1797 if anchors is False:
1798 opts['dev-force-features'] = "-23"
1799
1800 l1 = node_factory.get_node(options=opts, start=False)
1801 l1.daemon.rpcproxy.mock_rpc('estimatesmartfee', {
1802 'error': {"errors": ["Insufficient data or no feerate found"], "blocks": 0}
1803 })
1804 l1.start()
1805
1806 # All estimation types
1807 types = ["opening", "mutual_close", "unilateral_close", "penalty"]
1808
1809 # Try parsing the feerates, won't work because can't estimate
1810 for t in types:
1811 with pytest.raises(RpcError, match=r'Cannot estimate fees'):
1812 feerate = l1.rpc.parsefeerate(t)
1813
1814 # Query feerates (shouldn't give any!)
1815 wait_for(lambda: len(l1.rpc.feerates('perkw')['perkw']) == 4)
1816 feerates = l1.rpc.feerates('perkw')
1817 assert feerates['warning_missing_feerates'] == 'Some fee estimates unavailable: bitcoind startup?'
1818 assert 'perkb' not in feerates
1819 # No estimates: falls back to the ceiling, as min falls back to the floor.
1820 assert feerates['perkw']['max_acceptable'] == 1000000
1821 assert feerates['perkw']['min_acceptable'] == 253
1822 assert feerates['perkw']['min_acceptable'] == 253
1823 assert feerates['perkw']['floor'] == 253
1824 assert feerates['perkw']['estimates'] == []
1825 for t in types:
1826 assert t not in feerates['perkw']
1827
1828 feerates = l1.rpc.feerates('perkb')
1829 assert feerates['warning_missing_feerates'] == 'Some fee estimates unavailable: bitcoind startup?'
1830 assert 'perkw' not in feerates
1831 assert feerates['perkb']['max_acceptable'] == 1000000 * 4
1832 assert feerates['perkb']['min_acceptable'] == 253 * 4
1833 # Note: This is floored at the FEERATE_FLOOR constant (253)
1834 assert feerates['perkb']['floor'] == 1012
1835 assert feerates['perkb']['estimates'] == []
1836 for t in types:
1837 assert t not in feerates['perkb']
1838
1839 # Now try setting them, one at a time.
1840 # Set CONSERVATIVE/2 feerate, for max
1841 l1.set_feerates((15000, 0, 0, 0), True)
1842 # Make sure it's digested the bcli plugin results.
1843 wait_for(lambda: len(l1.rpc.feerates('perkw')['perkw']['estimates']) == 1)
1844 feerates = l1.rpc.feerates('perkw')
1845 # We only get the warning if *no* feerates are avail.
1846 assert 'warning_missing_feerates' not in feerates
1847 assert 'perkb' not in feerates
1848 assert feerates['perkw']['max_acceptable'] == 15000 * 10
1849
1850 # With only one data point, this is a terrible guess!
1851 assert feerates['perkw']['min_acceptable'] == 15000 // 2

Callers

nothing calls this directly

Calls 6

wait_forFunction · 0.90
mock_rpcMethod · 0.80
set_feeratesMethod · 0.80
get_nodeMethod · 0.45
startMethod · 0.45
feeratesMethod · 0.45

Tested by

no test coverage detected