Skip to content

Commit

Permalink
pytest: fix flake in test_sendpay_grouping
Browse files Browse the repository at this point in the history
Now pay learns, it sometimes learns not to try again:

```
>       assert(len(l1.rpc.listpays()['pays']) == 2)
E       AssertionError: assert 1 == 2
E        +  where 1 = len([{'amount_sent_msat': 0, 'bolt11': 'lnbcrt1pnjj7mysp5tfx8n6nyx7ehszgqn7gqm2r6n079p22u2yddtg797ka3pa9557tspp5f89z6genjqrl3knymvav9ajwcxrm5w7arxux06rrhjux88derjyqdq8v3jhxccxqyjw5qcqp9rzjqgkjyd3q5dv6gllh77kygly9c3kfy0d9xwyjyxsq2nq3c83u5vw4jqqqvuqqqqsqqqqqqqqpqqqqqzsqqc9qxpqysgqcuyr7qlyctf9w96fqg4wetqt7t5v938dagmv0r777n902utjufujzjxl3289r97yngft966zly3ehxfp469dh3lq0hkv6r684snvunqppuyvsl', 'created_at': 1730771812, 'destination': '035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d', ...}])

tests/test_pay.py:5147: AssertionError
```

We fix this by creating a fresh channel, so it will try.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed Nov 5, 2024
1 parent 7aef053 commit b9c718f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tests/test_pay.py
Original file line number Diff line number Diff line change
Expand Up @@ -5134,13 +5134,19 @@ def test_sendpay_grouping(node_factory, bitcoind):
assert(len(l1.db.query("SELECT * FROM payments")) == 0)
assert(len(l1.rpc.listpays()['pays']) == 0)

with pytest.raises(RpcError, match=r'Ran out of routes to try after [0-9]+ attempts'):
with pytest.raises(RpcError, match=r'Ran out of routes to try after [1-9]+ attempts'):
l1.rpc.pay(inv, amount_msat='100002msat')

# After this one invocation we have one entry in `listpays`
assert(len(l1.rpc.listpays()['pays']) == 1)

with pytest.raises(RpcError, match=r'Ran out of routes to try after [0-9]+ attempts'):
# Pay learns, and sometimes now refuses to even attempt. Give it a new channel.
l3.start()
node_factory.join_nodes([l2, l3], wait_for_announce=True)
wait_for(lambda: len(l1.rpc.listchannels()['channels']) == 6)
l3.stop()

with pytest.raises(RpcError, match=r'Ran out of routes to try after [1-9]+ attempts'):
l1.rpc.pay(inv, amount_msat='100001msat')

# Surprise: we should have 2 entries after 2 invocations
Expand Down

0 comments on commit b9c718f

Please sign in to comment.