Skip to content

Commit

Permalink
pytest: Reproduce waitblockheight timeout issue ElementsProject#4309
Browse files Browse the repository at this point in the history
  • Loading branch information
cdecker authored and vibhaa committed Mar 24, 2021
1 parent 1b6bed5 commit eb757be
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/plugins/endlesswaitblockheight.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env python3
"""Simple plugin to cause a waitblockheight that times out.
We report an error with a future blockheight, which causes the sender
to wait, and ultimately retry, excluding us because we misbehaved.
"""


from pyln.client import Plugin
plugin = Plugin()


@plugin.hook('htlc_accepted')
def on_htlc_accepted(onion, htlc, **kwargs):
return {
'result': "fail",
"failure_message": "400f00000000000000007fffffff", # Bogus error with INT32_MAX as blockheight
}


plugin.run()
19 changes: 19 additions & 0 deletions tests/test_pay.py
Original file line number Diff line number Diff line change
Expand Up @@ -3933,3 +3933,22 @@ def test_fetchinvoice(node_factory, bitcoind):
l1.rpc.call('fetchinvoice', {'offer': offer,
'recurrence_counter': 2,
'recurrence_label': 'test recurrence'})


@pytest.mark.xfail(strict=True)
def test_pay_waitblockheight_timeout(node_factory, bitcoind):
plugin = os.path.join(os.path.dirname(__file__), 'plugins', 'endlesswaitblockheight.py')
l1, l2 = node_factory.line_graph(2, opts=[{}, {'plugin': plugin}])

sync_blockheight(bitcoind, [l1, l2])
inv = l2.rpc.invoice(42, 'lbl', 'desc')['bolt11']

with pytest.raises(RpcError, match=r'WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS'):
l1.rpc.pay(inv)

# Post mortem checks that we tried only once.
status = l1.rpc.paystatus(inv)

# Should have only one attempt that triggered the wait, which then failed.
assert len(status['pay']) == 1
assert len(status['pay'][0]['attempts']) == 1

0 comments on commit eb757be

Please sign in to comment.