From 4517435810f2ab8409f953b7eeca5b77fb326ac7 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 29 Jul 2020 13:51:09 +0930 Subject: [PATCH] pytest: fix flake in tests/test_pay.py::test_pay_exclude_node ``` # Excludes channel, then ignores routehint which includes that, then # it excludes other channel. > assert len(status) == 2 E assert 1 == 2 E -1 E +2 ``` The invoice we use at the end has a routehint: 50% of the time it's to l2 (which fails), 50% to l5 (which succeeds). Change it to create invoice before channel with l5 so it does the retry like we expect here. Signed-off-by: Rusty Russell --- tests/test_pay.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/test_pay.py b/tests/test_pay.py index 3b787d64e..8d22f8658 100644 --- a/tests/test_pay.py +++ b/tests/test_pay.py @@ -161,6 +161,11 @@ def test_pay_exclude_node(node_factory, bitcoind): assert status[0]['failure']['data']['failcodename'] == 'WIRE_TEMPORARY_NODE_FAILURE' assert 'failure' in status[1] + # Get a fresh invoice, but do it before other routes exist, so routehint + # will be via l2. + inv = l3.rpc.invoice(amount, "test2", 'description')['bolt11'] + assert only_one(l1.rpc.decodepay(inv)['routes'])[0]['pubkey'] == l2.info['id'] + # l1->l4->l5->l3 is the longer route. This makes sure this route won't be # tried for the first pay attempt. Just to be sure we also raise the fees # that l4 leverages. @@ -187,8 +192,6 @@ def test_pay_exclude_node(node_factory, bitcoind): r'update for channel {}/1 now ACTIVE' .format(scid53)]) - inv = l3.rpc.invoice(amount, "test2", 'description')['bolt11'] - # This `pay` will work l1.rpc.pay(inv)