Skip to content

Commit

Permalink
pytest: test for transient "failed" status during ongoing payment.
Browse files Browse the repository at this point in the history
Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed May 22, 2019
1 parent 71460ac commit 18d2506
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion tests/test_pay.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@


import copy
import concurrent.futures
import pytest
import random
import re
Expand Down Expand Up @@ -1412,6 +1413,7 @@ def test_pay_variants(node_factory):
l1.rpc.pay(b11)


@pytest.mark.xfail(strict=True)
@unittest.skipIf(not DEVELOPER, "gossip without DEVELOPER=1 is slow")
def test_pay_retry(node_factory, bitcoind):
"""Make sure pay command retries properly. """
Expand Down Expand Up @@ -1459,8 +1461,26 @@ def exhaust_channel(funder, fundee, scid, already_spent=0):
exhaust_channel(l2, l5, scid25)
exhaust_channel(l3, l5, scid35)

def listpays_nofail(b11):
while True:
pays = l1.rpc.listpays(b11)['pays']
if len(pays) != 0:
if only_one(pays)['status'] == 'complete':
return
assert only_one(pays)['status'] != 'failed'

inv = l5.rpc.invoice(10**8, 'test_retry', 'test_retry')

# Make sure listpays doesn't transiently show failure while pay
# is retrying.
executor = concurrent.futures.ThreadPoolExecutor()
fut = executor.submit(listpays_nofail, inv['bolt11'])

# Pay l1->l5 should succeed via straight line (eventually)
l1.rpc.pay(l5.rpc.invoice(10**8, 'test_retry', 'test_retry')['bolt11'])
l1.rpc.pay(inv['bolt11'])

# This should be OK.
fut.result()

# This should make it fail.
exhaust_channel(l4, l5, scid45, 10**8)
Expand Down

0 comments on commit 18d2506

Please sign in to comment.