fix test_fail_pending_htlcs_on_shutdown: poll number of htlcs
This commit is contained in:
@@ -1234,19 +1234,17 @@ class TestPeer(TestCaseForTestnet):
|
|||||||
graph.workers['bob'].enable_htlc_forwarding = False # Bob will hold forwarded HTLCs
|
graph.workers['bob'].enable_htlc_forwarding = False # Bob will hold forwarded HTLCs
|
||||||
assert graph.workers['alice'].network.channel_db is not None
|
assert graph.workers['alice'].network.channel_db is not None
|
||||||
lnaddr, pay_req = self.prepare_invoice(graph.workers['dave'], include_routing_hints=True, amount_msat=amount_to_pay)
|
lnaddr, pay_req = self.prepare_invoice(graph.workers['dave'], include_routing_hints=True, amount_msat=amount_to_pay)
|
||||||
try:
|
result, log = await graph.workers['alice'].pay_invoice(pay_req, attempts=1)
|
||||||
async with timeout_after(0.5):
|
async def stop():
|
||||||
result, log = await graph.workers['alice'].pay_invoice(pay_req, attempts=1)
|
hm = graph.channels[('dave', 'carol')].hm
|
||||||
except TaskTimeout:
|
while len(hm.htlcs(LOCAL)) == 0 or len(hm.htlcs(REMOTE)) == 0:
|
||||||
# by now Dave hopefully received some HTLCs:
|
await asyncio.sleep(0.1)
|
||||||
self.assertTrue(len(graph.channels[('dave', 'carol')].hm.htlcs(LOCAL)) > 0)
|
self.assertTrue(len(hm.htlcs(LOCAL)) > 0)
|
||||||
self.assertTrue(len(graph.channels[('dave', 'carol')].hm.htlcs(REMOTE)) > 0)
|
self.assertTrue(len(hm.htlcs(REMOTE)) > 0)
|
||||||
else:
|
|
||||||
self.fail(f"pay_invoice finished but was not supposed to. result={result}")
|
|
||||||
await graph.workers['dave'].stop()
|
await graph.workers['dave'].stop()
|
||||||
# Dave is supposed to have failed the pending incomplete MPP HTLCs
|
# Dave is supposed to have failed the pending incomplete MPP HTLCs
|
||||||
self.assertEqual(0, len(graph.channels[('dave', 'carol')].hm.htlcs(LOCAL)))
|
self.assertEqual(0, len(hm.htlcs(LOCAL)))
|
||||||
self.assertEqual(0, len(graph.channels[('dave', 'carol')].hm.htlcs(REMOTE)))
|
self.assertEqual(0, len(hm.htlcs(REMOTE)))
|
||||||
raise SuccessfulTest()
|
raise SuccessfulTest()
|
||||||
|
|
||||||
async def f():
|
async def f():
|
||||||
@@ -1256,6 +1254,7 @@ class TestPeer(TestCaseForTestnet):
|
|||||||
await group.spawn(peer.htlc_switch())
|
await group.spawn(peer.htlc_switch())
|
||||||
await asyncio.sleep(0.2)
|
await asyncio.sleep(0.2)
|
||||||
await group.spawn(pay())
|
await group.spawn(pay())
|
||||||
|
await group.spawn(stop())
|
||||||
|
|
||||||
with self.assertRaises(SuccessfulTest):
|
with self.assertRaises(SuccessfulTest):
|
||||||
run(f())
|
run(f())
|
||||||
|
|||||||
Reference in New Issue
Block a user