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

Function test_htlc_rexmit_while_closing

tests/test_closing.py:3855–3896  ·  view source on GitHub ↗

Retranmitting an HTLC revocation while shutting down should work

(node_factory, executor)

Source from the content-addressed store, hash-verified

3853
3854@pytest.mark.flaky(reruns=3)
3855def test_htlc_rexmit_while_closing(node_factory, executor):
3856 """Retranmitting an HTLC revocation while shutting down should work"""
3857 # FIXME: This should be in lnprototest! UNRELIABLE.
3858 # l1 disconnects after sending second COMMITMENT_SIGNED.
3859 # Then it stops receiving after sending WIRE_SHUTDOWN (which is before it
3860 # reads the revoke_and_ack).
3861 disconnects = ['+WIRE_COMMITMENT_SIGNED*2',
3862 'xWIRE_SHUTDOWN']
3863
3864 l1, l2 = node_factory.line_graph(2, opts=[{'may_reconnect': True,
3865 'dev-no-reconnect': None,
3866 'disconnect': disconnects},
3867 {'may_reconnect': True,
3868 'dev-no-reconnect': None}])
3869
3870 # Start payment, will disconnect
3871 l1.pay(l2, 200000)
3872 wait_for(lambda: only_one(l1.rpc.listpeers()['peers'])['connected'] is False)
3873
3874 # Tell it to close (will block)
3875 fut = executor.submit(l1.rpc.close, l2.info['id'])
3876
3877 # Original problem was with multiple disconnects, but to simplify we make
3878 # l2 send shutdown too.
3879 fut2 = executor.submit(l2.rpc.close, l1.info['id'])
3880
3881 # Reconnect, shutdown will continue disconnect again
3882 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
3883
3884 # Now l2 should be in CLOSINGD_SIGEXCHANGE, l1 still waiting on
3885 # WIRE_REVOKE_AND_ACK.
3886 wait_for(lambda: only_one(l2.rpc.listpeerchannels()['channels'])['state'] == 'CLOSINGD_SIGEXCHANGE')
3887 assert only_one(l1.rpc.listpeerchannels()['channels'])['state'] == 'CHANNELD_SHUTTING_DOWN'
3888
3889 # They don't realize they're not talking, so disconnect and reconnect.
3890 l1.rpc.disconnect(l2.info['id'], force=True)
3891
3892 # Now it hangs, since l1 is expecting rexmit of revoke-and-ack.
3893 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
3894
3895 fut.result(TIMEOUT)
3896 fut2.result(TIMEOUT)
3897
3898
3899@pytest.mark.openchannel('v1')

Callers

nothing calls this directly

Calls 8

wait_forFunction · 0.90
only_oneFunction · 0.90
line_graphMethod · 0.80
listpeerchannelsMethod · 0.80
payMethod · 0.45
listpeersMethod · 0.45
connectMethod · 0.45
disconnectMethod · 0.45

Tested by

no test coverage detected