Skip to content

Commit a4dbd6e

Browse files
rustyrussellcdecker
authored andcommitted
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 <[email protected]>
1 parent 3746ea3 commit a4dbd6e

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

tests/test_closing.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -630,17 +630,15 @@ def test_onchain_dust_out(node_factory, bitcoind, executor):
630630
assert only_one(l2.rpc.listinvoices('onchain_dust_out')['invoices'])['status'] == 'unpaid'
631631

632632

633+
@pytest.mark.xfail(strict=True)
633634
@unittest.skipIf(not DEVELOPER, "needs DEVELOPER=1")
634635
def test_onchain_timeout(node_factory, bitcoind, executor):
635636
"""Onchain handling of outgoing failed htlcs"""
636637
# HTLC 1->2, 1 fails just after it's irrevocably committed
637-
disconnects = ['+WIRE_REVOKE_AND_ACK', 'permfail']
638+
disconnects = ['+WIRE_REVOKE_AND_ACK*3', 'permfail']
638639
# Feerates identical so we don't get gratuitous commit to update them
639640
l1 = node_factory.get_node(disconnect=disconnects, feerates=(7500, 7500, 7500))
640641
l2 = node_factory.get_node()
641-
l2 = node_factory.get_node()
642-
643-
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
644642

645643
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
646644
l1.fund_channel(l2, 10**6)
@@ -654,6 +652,15 @@ def test_onchain_timeout(node_factory, bitcoind, executor):
654652
'channel': '1:1:1'
655653
}
656654

655+
l1.rpc.sendpay([routestep], rhash)
656+
with pytest.raises(RpcError):
657+
l1.rpc.waitsendpay(rhash)
658+
659+
# Make sure CLTVs are different, in case it confuses onchaind.
660+
bitcoind.generate_block(1)
661+
sync_blockheight(bitcoind, [l1])
662+
663+
# Second one will cause drop to chain.
657664
l1.rpc.sendpay([routestep], rhash)
658665
payfuture = executor.submit(l1.rpc.waitsendpay, rhash)
659666

0 commit comments

Comments
 (0)