From f7f9f35f2aad4d4e139ddd4fca1e8bce1d31a527 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Sat, 29 Jan 2022 14:03:06 +1030 Subject: [PATCH] pytest: remove flake in test_upgrade_statickey_onchaind We were relying on the fee update to create an additional tx. That's ugly; do an actual payment and make sure we definitely complete a new tx by waiting for that *then* both revoke_and_ack. (Without this, we could get a unilateral close instead of a penalty). Signed-off-by: Rusty Russell --- tests/test_connection.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/test_connection.py b/tests/test_connection.py index 055551557..18f155592 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -3522,8 +3522,21 @@ def test_upgrade_statickey_onchaind(node_factory, executor, bitcoind): l1.rpc.connect(l2.info['id'], 'localhost', l2.port) l1.daemon.wait_for_log('option_static_remotekey enabled at 1/1') + # Make sure another commitment happens, sending failed payment. + routestep = { + 'msatoshi': 1, + 'id': l2.info['id'], + 'delay': 5, + 'channel': '1x1x1' # note: can be bogus for 1-hop direct payments + } + l1.rpc.sendpay([routestep], '00' * 32, payment_secret='00' * 32) + with pytest.raises(RpcError, match=r'WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS'): + l1.rpc.waitsendpay('00' * 32) + # Make sure l2 gets REVOKE_AND_ACK from previous. + l2.daemon.wait_for_log('peer_in WIRE_UPDATE_ADD_HTLC') l2.daemon.wait_for_log('peer_out WIRE_REVOKE_AND_ACK') + l2.daemon.wait_for_log('peer_in WIRE_REVOKE_AND_ACK') # Pre-statickey penalty works. bitcoind.rpc.sendrawtransaction(tx)