From d04597cbb68ea14755c9ddcffa7519fcbb7cb8f8 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 14 Oct 2020 16:11:17 +1030 Subject: [PATCH] pytest: add test for HTLC ordering. [ Includes tidyups by Christian Decker ] Signed-off-by: Rusty Russell --- tests/test_connection.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/test_connection.py b/tests/test_connection.py index 89bf2db99..64a036f80 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -2661,3 +2661,39 @@ def test_connection_timeout(node_factory): with pytest.raises(RpcError, match=r'(reset by peer|peer closed connection)'): l2.rpc.connect(l1.info['id'], 'localhost', port=l1.port) l1.daemon.wait_for_log('conn timed out') + + +@unittest.skip("Broken") +@unittest.skipIf(not DEVELOPER, "needs --dev-disconnect") +def test_htlc_retransmit_order(node_factory, executor): + NUM_HTLCS = 10 + l1, l2 = node_factory.line_graph(2, + opts=[{'may_reconnect': True, + 'feerates': (7500, 7500, 7500, 7500), + 'disconnect': ['=WIRE_UPDATE_ADD_HTLC-nocommit', + '=WIRE_UPDATE_ADD_HTLC*' + str(NUM_HTLCS - 1), + '-WIRE_COMMITMENT_SIGNED']}, + {'may_reconnect': True}]) + payment_hashes = [l2.rpc.invoice(1000, str(x), str(x))['payment_hash'] for x in range(NUM_HTLCS)] + + routestep = { + 'msatoshi': 1000, + 'id': l2.info['id'], + 'delay': 5, + 'channel': '1x1x1' # note: can be bogus for 1-hop direct payments + } + for p in payment_hashes: + executor.submit(l1.rpc.sendpay, [routestep], p) + + l1.daemon.wait_for_logs(['dev_disconnect'] * 2) + l1.rpc.call('dev-reenable-commit', [l2.info['id']]) + l1.daemon.wait_for_log('dev_disconnect') + + # Now reconnect. + l1.rpc.connect(l2.info['id'], 'localhost', port=l2.port) + + for p in payment_hashes: + result = l1.rpc.waitsendpay(p) + assert(result['status'] == 'complete') + + # If order was wrong, we'll get a LOG_BROKEN and fixtures will complain.