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

Function test_update_fee_reconnect

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

Source from the content-addressed store, hash-verified

2634
2635
2636def test_update_fee_reconnect(node_factory, bitcoind):
2637 # Disconnect after commitsig for fee update.
2638 disconnects = ['+WIRE_COMMITMENT_SIGNED*3']
2639 # Feerates identical so we don't get gratuitous commit to update them
2640 l1 = node_factory.get_node(disconnect=disconnects, may_reconnect=True,
2641 feerates=(15000, 15000, 15000, 3750))
2642 # We match l2's later feerate, so we agree on same closing tx for simplicity.
2643 l2 = node_factory.get_node(may_reconnect=True,
2644 feerates=(14000, 15000, 14000, 3750))
2645 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
2646 chan, _ = l1.fundchannel(l2, 10**6)
2647
2648 # Make an HTLC just to get us to do feechanges.
2649 l1.pay(l2, 1000)
2650
2651 # Make l1 send out feechange; triggers disconnect/reconnect.
2652 # (Note: < 10% change, so no smoothing here!)
2653 l1.set_feerates((14000, 14000, 14000, 14000))
2654 l1.daemon.wait_for_log('Setting REMOTE feerate to 14005')
2655 l2.daemon.wait_for_log('Setting LOCAL feerate to 14005')
2656 l1.daemon.wait_for_log(r'dev_disconnect: \+WIRE_COMMITMENT_SIGNED')
2657
2658 # Wait for reconnect....
2659 l1.daemon.wait_for_log('Feerate:.*LOCAL now 14005')
2660
2661 l1.pay(l2, 200000000)
2662 l2.pay(l1, 100000000)
2663
2664 # They should both have gotten commits with correct feerate.
2665 assert l1.daemon.is_in_log('got commitsig [0-9]*: feerate 14005')
2666 assert l2.daemon.is_in_log('got commitsig [0-9]*: feerate 14005')
2667
2668 # Now shutdown cleanly. (Make sure l1 has raised min_acceptable: if it
2669 # changes while it negotiates, it may reject the result and unilaterally close!)
2670 wait_for(lambda: l1.rpc.feerates(style='perkw')['perkw']['min_acceptable'] == 7000)
2671 l1.rpc.close(chan)
2672
2673 # And should put closing into mempool.
2674 l1.wait_for_channel_onchain(l2.info['id'])
2675 l2.wait_for_channel_onchain(l1.info['id'])
2676
2677 bitcoind.generate_block(1)
2678 l1.daemon.wait_for_log(' to ONCHAIN')
2679 l2.daemon.wait_for_log(' to ONCHAIN')
2680
2681 bitcoind.generate_block(99)
2682 l1.daemon.wait_for_log('onchaind complete, forgetting peer')
2683 l2.daemon.wait_for_log('onchaind complete, forgetting peer')
2684
2685
2686def test_multiple_channels(node_factory):

Callers

nothing calls this directly

Calls 12

wait_forFunction · 0.90
set_feeratesMethod · 0.80
wait_for_logMethod · 0.80
is_in_logMethod · 0.80
generate_blockMethod · 0.80
get_nodeMethod · 0.45
connectMethod · 0.45
fundchannelMethod · 0.45
payMethod · 0.45
feeratesMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected