From 673d81adde82c3ace453daa6d12f36b25078fa28 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 31 Jul 2023 21:01:22 +0930 Subject: [PATCH] pytest: test for bad 'tx' result from close. We print it without the witness! Reported-by: https://github.com/wtogami Signed-off-by: Rusty Russell --- tests/test_closing.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/test_closing.py b/tests/test_closing.py index 2ef88d66f..f9cedfafb 100644 --- a/tests/test_closing.py +++ b/tests/test_closing.py @@ -3870,3 +3870,32 @@ def test_htlc_no_force_close(node_factory, bitcoind, anchors): sync_blockheight(bitcoind, [l1, l2, l3]) # FIXME: l2 should complain! + + +@pytest.mark.xfail(strict=True) +@pytest.mark.developer("needs dev-no-reconnect") +def test_closing_tx_valid(node_factory, bitcoind): + l1, l2 = node_factory.line_graph(2, opts={'may_reconnect': True, + 'dev-no-reconnect': None}) + + # First, mutual close. + close = l1.rpc.close(l2.info['id']) + + wait_for(lambda: len(bitcoind.rpc.getrawmempool()) == 1) + assert only_one(bitcoind.rpc.getrawmempool()) == close['txid'] + assert bitcoind.rpc.getrawtransaction(close['txid']) == close['tx'] + bitcoind.generate_block(1) + # Change output and the closed channel output. + wait_for(lambda: len(l1.rpc.listfunds()['outputs']) == 2) + + # Now, unilateral close. + l1.rpc.connect(l2.info['id'], 'localhost', l2.port) + l1.rpc.fundchannel(l2.info['id'], 10**6) + bitcoind.generate_block(1, wait_for_mempool=1) + + l1.rpc.disconnect(l2.info['id'], force=True) + close = l1.rpc.close(l2.info['id'], 1) + + wait_for(lambda: len(bitcoind.rpc.getrawmempool()) == 1) + assert only_one(bitcoind.rpc.getrawmempool()) == close['txid'] + assert bitcoind.rpc.getrawtransaction(close['txid']) == close['tx']