mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-23 09:04:22 +01:00
pytest: Use futures to wait for failing sendpays
Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
committed by
Rusty Russell
parent
0b350d2f5f
commit
5029f95066
@@ -538,18 +538,7 @@ class LightningDTests(BaseLightningDTests):
|
|||||||
'channel': '1:1:1'
|
'channel': '1:1:1'
|
||||||
}
|
}
|
||||||
|
|
||||||
q = queue.Queue()
|
payfuture = self.executor.submit(l1.rpc.sendpay, to_json([routestep]), rhash)
|
||||||
|
|
||||||
def try_pay():
|
|
||||||
try:
|
|
||||||
l1.rpc.sendpay(to_json([routestep]), rhash, async=False)
|
|
||||||
q.put(None)
|
|
||||||
except Exception as err:
|
|
||||||
q.put(err)
|
|
||||||
|
|
||||||
t = threading.Thread(target=try_pay)
|
|
||||||
t.daemon = True
|
|
||||||
t.start()
|
|
||||||
|
|
||||||
# l1 will drop to chain.
|
# l1 will drop to chain.
|
||||||
l1.daemon.wait_for_log('permfail')
|
l1.daemon.wait_for_log('permfail')
|
||||||
@@ -562,10 +551,7 @@ class LightningDTests(BaseLightningDTests):
|
|||||||
bitcoind.rpc.generate(3)
|
bitcoind.rpc.generate(3)
|
||||||
|
|
||||||
# It should fail.
|
# It should fail.
|
||||||
err = q.get(timeout = 5)
|
self.assertRaises(ValueError, payfuture.result, 5)
|
||||||
assert type(err) is ValueError
|
|
||||||
t.join(timeout=1)
|
|
||||||
assert not t.isAlive()
|
|
||||||
|
|
||||||
l1.daemon.wait_for_log('WIRE_PERMANENT_CHANNEL_FAILURE: missing in commitment tx')
|
l1.daemon.wait_for_log('WIRE_PERMANENT_CHANNEL_FAILURE: missing in commitment tx')
|
||||||
|
|
||||||
@@ -604,18 +590,7 @@ class LightningDTests(BaseLightningDTests):
|
|||||||
'channel': '1:1:1'
|
'channel': '1:1:1'
|
||||||
}
|
}
|
||||||
|
|
||||||
q = queue.Queue()
|
payfuture = self.executor.submit(l1.rpc.sendpay, to_json([routestep]), rhash)
|
||||||
|
|
||||||
def try_pay():
|
|
||||||
try:
|
|
||||||
l1.rpc.sendpay(to_json([routestep]), rhash, async=False)
|
|
||||||
q.put(None)
|
|
||||||
except Exception as err:
|
|
||||||
q.put(err)
|
|
||||||
|
|
||||||
t = threading.Thread(target=try_pay)
|
|
||||||
t.daemon = True
|
|
||||||
t.start()
|
|
||||||
|
|
||||||
# l1 will drop to chain.
|
# l1 will drop to chain.
|
||||||
l1.daemon.wait_for_log('permfail')
|
l1.daemon.wait_for_log('permfail')
|
||||||
@@ -636,10 +611,7 @@ class LightningDTests(BaseLightningDTests):
|
|||||||
bitcoind.rpc.generate(3)
|
bitcoind.rpc.generate(3)
|
||||||
|
|
||||||
# It should fail.
|
# It should fail.
|
||||||
err = q.get(timeout = 5)
|
self.assertRaises(ValueError, payfuture.result, 5)
|
||||||
assert type(err) is ValueError
|
|
||||||
t.join(timeout=1)
|
|
||||||
assert not t.isAlive()
|
|
||||||
|
|
||||||
l1.daemon.wait_for_log('WIRE_PERMANENT_CHANNEL_FAILURE: timed out')
|
l1.daemon.wait_for_log('WIRE_PERMANENT_CHANNEL_FAILURE: timed out')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user