From a4dbd6e0f0b2818e9f54146bc1b3ea6fb1e85744 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 22 Oct 2018 14:52:05 +1030 Subject: [PATCH] pytest: simple addition to test_onchain_timeout to trigger grind failure. Create a second HTLC with a different CTLV but same preimage; onchaind uses the wrong signature and fails to grind it. Reported-by: molz (#c-lightning) Signed-off-by: Rusty Russell --- tests/test_closing.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/test_closing.py b/tests/test_closing.py index 1744839cf..e8e566c02 100644 --- a/tests/test_closing.py +++ b/tests/test_closing.py @@ -630,17 +630,15 @@ def test_onchain_dust_out(node_factory, bitcoind, executor): assert only_one(l2.rpc.listinvoices('onchain_dust_out')['invoices'])['status'] == 'unpaid' +@pytest.mark.xfail(strict=True) @unittest.skipIf(not DEVELOPER, "needs DEVELOPER=1") def test_onchain_timeout(node_factory, bitcoind, executor): """Onchain handling of outgoing failed htlcs""" # HTLC 1->2, 1 fails just after it's irrevocably committed - disconnects = ['+WIRE_REVOKE_AND_ACK', 'permfail'] + disconnects = ['+WIRE_REVOKE_AND_ACK*3', 'permfail'] # Feerates identical so we don't get gratuitous commit to update them l1 = node_factory.get_node(disconnect=disconnects, feerates=(7500, 7500, 7500)) l2 = node_factory.get_node() - l2 = node_factory.get_node() - - l1.rpc.connect(l2.info['id'], 'localhost', l2.port) l1.rpc.connect(l2.info['id'], 'localhost', l2.port) l1.fund_channel(l2, 10**6) @@ -654,6 +652,15 @@ def test_onchain_timeout(node_factory, bitcoind, executor): 'channel': '1:1:1' } + l1.rpc.sendpay([routestep], rhash) + with pytest.raises(RpcError): + l1.rpc.waitsendpay(rhash) + + # Make sure CLTVs are different, in case it confuses onchaind. + bitcoind.generate_block(1) + sync_blockheight(bitcoind, [l1]) + + # Second one will cause drop to chain. l1.rpc.sendpay([routestep], rhash) payfuture = executor.submit(l1.rpc.waitsendpay, rhash)