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

Function test_reconnect_no_update

tests/test_connection.py:734–773  ·  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

732@pytest.mark.openchannel('v1')
733@pytest.mark.openchannel('v2')
734def test_reconnect_no_update(node_factory, executor, bitcoind):
735 """Test that channel_ready is retransmitted on reconnect if new channel
736
737 This tests if the `channel_ready` is sent if we receive a
738 `channel_reestablish` message with `next_commitment_number` == 1
739 and our `next_commitment_number` == 1.
740
741 This test makes extensive use of disconnects followed by automatic
742 reconnects. See comments for details.
743
744 """
745 disconnects = ["-WIRE_CHANNEL_READY", "-WIRE_SHUTDOWN"]
746 # Allow bad gossip because it might receive WIRE_CHANNEL_UPDATE before
747 # announcement of the disconnection
748 l1 = node_factory.get_node(may_reconnect=True, allow_bad_gossip=True)
749 l2 = node_factory.get_node(disconnect=disconnects, may_reconnect=True)
750
751 # For channeld reconnection
752 l1.rpc.connect(l2.info["id"], "localhost", l2.port)
753
754 # LightningNode.fundchannel will fund the channel and generate a
755 # block. The block triggers the channel_ready message, which
756 # causes a disconnect. The retransmission is then caused by the
757 # automatic retry.
758 fundchannel_exec = executor.submit(l1.fundchannel, l2, 10**6, False)
759 if l1.config('experimental-dual-fund'):
760 l1.daemon.wait_for_log(r"dualopend.* Retransmitting channel_ready for channel")
761 else:
762 l1.daemon.wait_for_log(r"channeld.* Retransmitting channel_ready for channel")
763 sync_blockheight(bitcoind, [l1, l2])
764 fundchannel_exec.result()
765 l1.stop()
766
767 # For closingd reconnection
768 l1.daemon.start()
769 # Close will trigger the -WIRE_SHUTDOWN and we then wait for the
770 # automatic reconnection to trigger the retransmission.
771 l1.rpc.close(l2.info['id'], 0)
772 l2.daemon.wait_for_log(r"channeld.* Retransmitting channel_ready for channel")
773 l1.daemon.wait_for_log(r"CLOSINGD_COMPLETE")
774
775
776@pytest.mark.openchannel('v1')

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