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

Function test_update_fee_dynamic

tests/test_connection.py:2580–2633  ·  view source on GitHub ↗
(node_factory, bitcoind)

Source from the content-addressed store, hash-verified

2578
2579@unittest.skipIf(TEST_NETWORK != 'regtest', 'Assumes anchors')
2580def test_update_fee_dynamic(node_factory, bitcoind):
2581 # l1 has no fee estimates to start.
2582 l1 = node_factory.get_node(options={'log-level': 'io',
2583 'dev-no-fake-fees': True}, start=False)
2584 l1.daemon.rpcproxy.mock_rpc('estimatesmartfee', {
2585 'error': {"errors": ["Insufficient data or no feerate found"], "blocks": 0}
2586 })
2587 l1.start()
2588 l2 = node_factory.get_node()
2589
2590 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
2591 # Fails due to lack of fee estimate.
2592 with pytest.raises(RpcError, match='Cannot estimate fees'):
2593 l1.fundchannel(l2, 10**6)
2594
2595 # Explicit feerate does not work still (doesn't apply for anchors!)
2596 # We could make it, but we need a separate commitment feerate for
2597 # anchors vs non-anchors, so easier after anchors are compulsory.
2598 with pytest.raises(RpcError, match='Cannot estimate fees'):
2599 l1.fundchannel(l2, 10**6, feerate='10000perkw')
2600
2601 l1.set_feerates((2000, 2000, 2000, 2000))
2602 l1.fundchannel(l2, 10**6)
2603
2604 l1.set_feerates((15000, 11000, 7500, 3750))
2605
2606 # It will send UPDATE_FEE when it tries to send HTLC.
2607 inv = l2.rpc.invoice(5000, 'test_update_fee_dynamic', 'test_update_fee_dynamic')['bolt11']
2608 l1.rpc.xpay(inv)
2609
2610 l2.daemon.wait_for_log('peer_in.*UPDATE_FEE')
2611
2612 # Now we take it away again!
2613 l1.daemon.rpcproxy.mock_rpc('estimatesmartfee', {
2614 'error': {"errors": ["Insufficient data or no feerate found"], "blocks": 0}
2615 })
2616 # Make sure that registers! (--developer means polling every second)
2617 time.sleep(2)
2618
2619 inv = l2.rpc.invoice(5000, 'test_update_fee_dynamic2', 'test_update_fee_dynamic2')['bolt11']
2620 l1.rpc.xpay(inv)
2621
2622 # Won't update fee.
2623 assert not l2.daemon.is_in_log('peer_in.*UPDATE_FEE',
2624 start=l2.daemon.logsearch_start)
2625
2626 # Bring it back.
2627 l1.set_feerates((14000, 10000, 7000, 3000))
2628
2629 # It will send UPDATE_FEE when it tries to send HTLC.
2630 inv = l2.rpc.invoice(5000, 'test_update_fee_dynamic3', 'test_update_fee_dynamic')['bolt11']
2631 l1.rpc.xpay(inv)
2632
2633 l2.daemon.wait_for_log('peer_in.*UPDATE_FEE')
2634
2635
2636def test_update_fee_reconnect(node_factory, bitcoind):

Callers

nothing calls this directly

Calls 10

mock_rpcMethod · 0.80
set_feeratesMethod · 0.80
wait_for_logMethod · 0.80
is_in_logMethod · 0.80
get_nodeMethod · 0.45
startMethod · 0.45
connectMethod · 0.45
fundchannelMethod · 0.45
invoiceMethod · 0.45
xpayMethod · 0.45

Tested by

no test coverage detected