mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 07:34:24 +01:00
pytest: make test_forward_event_notification more explicit.
We seem to be getting intermittant failures, but it's hard to disgnose. Simplify it by moving all the test logic into the test itself, and making the plugin dumber. This means we'll see exactly what the differences are if it fails again. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -6,24 +6,6 @@ from lightning import Plugin
|
||||
plugin = Plugin()
|
||||
|
||||
|
||||
def check(forward, dbforward):
|
||||
# After finding the corresponding notification record, this function will
|
||||
# make some changes on mutative fields of this record to make this record
|
||||
# same as the ideal format with given status.
|
||||
record = forward
|
||||
if record['status'] == 'offered':
|
||||
if dbforward['status'] == 'local_failed':
|
||||
record['failcode'] = dbforward['failcode']
|
||||
record['failreason'] = dbforward['failreason']
|
||||
elif dbforward['status'] != 'offered':
|
||||
record['resolved_time'] = dbforward['resolved_time']
|
||||
record['status'] = dbforward['status']
|
||||
if record == dbforward:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
@plugin.init()
|
||||
def init(configuration, options, plugin):
|
||||
plugin.forward_list = []
|
||||
@@ -37,18 +19,9 @@ def notify_warning(plugin, forward_event):
|
||||
plugin.forward_list.append(forward_event)
|
||||
|
||||
|
||||
@plugin.method('recordcheck')
|
||||
def record_lookup(payment_hash, status, dbforward, plugin):
|
||||
# Check if we received all notifications when forward changed.
|
||||
# This check is based on the records of 'listforwards'
|
||||
plugin.log("recordcheck: payment_hash: {}, status: {}".format(payment_hash, status))
|
||||
for forward in plugin.forward_list:
|
||||
if forward['payment_hash'] == payment_hash and forward['status'] == status:
|
||||
plugin.log("record exists")
|
||||
check_result = check(forward, dbforward)
|
||||
return check_result
|
||||
plugin.log("no record")
|
||||
return False
|
||||
@plugin.method('listforwards_plugin')
|
||||
def record_lookup(plugin):
|
||||
return {'forwards': plugin.forward_list}
|
||||
|
||||
|
||||
plugin.run()
|
||||
|
||||
Reference in New Issue
Block a user