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

Function test_reconnect_no_update

tests/test_connection.py:683–722  ·  view source on GitHub ↗

Test that channel_ready is retransmitted on reconnect if new channel This tests if the `channel_ready` is sent if we receive a `channel_reestablish` message with `next_commitment_number` == 1 and our `next_commitment_number` == 1. This test makes extensive use of disconnects follow

(node_factory, executor, bitcoind)

Source from the content-addressed store, hash-verified

681@pytest.mark.openchannel('v1')
682@pytest.mark.openchannel('v2')
683def test_reconnect_no_update(node_factory, executor, bitcoind):
684 """Test that channel_ready is retransmitted on reconnect if new channel
685
686 This tests if the `channel_ready` is sent if we receive a
687 `channel_reestablish` message with `next_commitment_number` == 1
688 and our `next_commitment_number` == 1.
689
690 This test makes extensive use of disconnects followed by automatic
691 reconnects. See comments for details.
692
693 """
694 disconnects = ["-WIRE_CHANNEL_READY", "-WIRE_SHUTDOWN"]
695 # Allow bad gossip because it might receive WIRE_CHANNEL_UPDATE before
696 # announcement of the disconnection
697 l1 = node_factory.get_node(may_reconnect=True, allow_bad_gossip=True)
698 l2 = node_factory.get_node(disconnect=disconnects, may_reconnect=True)
699
700 # For channeld reconnection
701 l1.rpc.connect(l2.info["id"], "localhost", l2.port)
702
703 # LightningNode.fundchannel will fund the channel and generate a
704 # block. The block triggers the channel_ready message, which
705 # causes a disconnect. The retransmission is then caused by the
706 # automatic retry.
707 fundchannel_exec = executor.submit(l1.fundchannel, l2, 10**6, False)
708 if l1.config('experimental-dual-fund'):
709 l1.daemon.wait_for_log(r"dualopend.* Retransmitting channel_ready for channel")
710 else:
711 l1.daemon.wait_for_log(r"channeld.* Retransmitting channel_ready for channel")
712 sync_blockheight(bitcoind, [l1, l2])
713 fundchannel_exec.result()
714 l1.stop()
715
716 # For closingd reconnection
717 l1.daemon.start()
718 # Close will trigger the -WIRE_SHUTDOWN and we then wait for the
719 # automatic reconnection to trigger the retransmission.
720 l1.rpc.close(l2.info['id'], 0)
721 l2.daemon.wait_for_log(r"channeld.* Retransmitting channel_ready for channel")
722 l1.daemon.wait_for_log(r"CLOSINGD_COMPLETE")
723
724
725@pytest.mark.developer

Callers

nothing calls this directly

Calls 8

sync_blockheightFunction · 0.90
configMethod · 0.80
wait_for_logMethod · 0.80
get_nodeMethod · 0.45
connectMethod · 0.45
stopMethod · 0.45
startMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected