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 <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2020-07-29 13:51:09 +09:30 committed by Christian Decker
parent 14d08b75cd
commit 4517435810

View File

@ -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)