From 321e5cecf1e17980942dc8f830c743a66498cd5a Mon Sep 17 00:00:00 2001 From: Michael Schmoock Date: Fri, 25 Jun 2021 11:22:46 +0200 Subject: [PATCH] monitor: fix flakyness Sometimes a channels funding allocation was not yet readable via listpeers which is why this plugin test was flaky. Also makes use of funding_msat instead of deprecated fields. --- monitor/monitor.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/monitor/monitor.py b/monitor/monitor.py index f8d97fe..04828ce 100755 --- a/monitor/monitor.py +++ b/monitor/monitor.py @@ -41,11 +41,17 @@ def monitor(plugin): else: states[state] = 1 connected = 'connected' if p['connected'] else 'disconnected' - funding = c['funding_allocation_msat'] - our_funding = funding[nid] - fees = "our fees" - if int(our_funding) == 0: - fees = "their fees" + fees = "unknown onchain fees" + funding = c.get('funding_msat', None) + if funding is not None: + our_funding = funding[nid] + their_funding = funding[p['id']] + if int(our_funding) == 0: + fees = "their onchain fees" + elif int(their_funding) == 0: + fees = "our onchain fees" + else: + fees = "shared onchain fees" total = int(c['total_msat']) ours = int(c['our_reserve_msat']) + int(c['spendable_msat']) our_fraction = '{:4.2f}% owned by us'.format(ours * 100 / total)