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