Skip to content

Commit c4203e7

Browse files
committed
pyln-client: allow 'msat' fields to be 'null'
This happens with deprecated-apis and listconfigs, breaking some python plugins! Fixes: #5546 Fixes: #5563 Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent ea41432 commit c4203e7

File tree

2 files changed

+26
-21
lines changed

2 files changed

+26
-21
lines changed

contrib/pyln-client/pyln/client/lightning.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,11 @@ def replace_amounts(obj):
455455
if k.endswith('msat'):
456456
if isinstance(v, list):
457457
obj[k] = [Millisatoshi(e) for e in v]
458+
# FIXME: Deprecated "listconfigs" gives two 'null' fields:
459+
# "lease-fee-base-msat": null,
460+
# "channel-fee-max-base-msat": null,
461+
elif v is None:
462+
obj[k] = None
458463
else:
459464
obj[k] = Millisatoshi(v)
460465
else:

tests/test_misc.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -725,29 +725,29 @@ def test_address(node_factory):
725725
l2.rpc.connect(l1.info['id'], l1.daemon.opts['addr'])
726726

727727

728-
@unittest.skipIf(DEPRECATED_APIS, "Tests the --allow-deprecated-apis config")
729728
def test_listconfigs(node_factory, bitcoind, chainparams):
730729
# Make extremely long entry, check it works
731-
l1 = node_factory.get_node(options={'log-prefix': 'lightning1-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'})
732-
733-
configs = l1.rpc.listconfigs()
734-
# See utils.py
735-
assert configs['allow-deprecated-apis'] is False
736-
assert configs['network'] == chainparams['name']
737-
assert configs['ignore-fee-limits'] is False
738-
assert configs['ignore-fee-limits'] is False
739-
assert configs['log-prefix'] == 'lightning1-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...'
740-
741-
# These are aliases, but we don't print the (unofficial!) wumbo.
742-
assert 'wumbo' not in configs
743-
assert configs['large-channels'] is False
744-
745-
# Test one at a time.
746-
for c in configs.keys():
747-
if c.startswith('#') or c.startswith('plugins') or c == 'important-plugins':
748-
continue
749-
oneconfig = l1.rpc.listconfigs(config=c)
750-
assert(oneconfig[c] == configs[c])
730+
for deprecated in (True, False):
731+
l1 = node_factory.get_node(options={'log-prefix': 'lightning1-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
732+
'allow-deprecated-apis': deprecated})
733+
734+
configs = l1.rpc.listconfigs()
735+
# See utils.py
736+
assert configs['allow-deprecated-apis'] == deprecated
737+
assert configs['network'] == chainparams['name']
738+
assert configs['ignore-fee-limits'] is False
739+
assert configs['log-prefix'] == 'lightning1-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...'
740+
741+
# These are aliases, but we don't print the (unofficial!) wumbo.
742+
assert 'wumbo' not in configs
743+
assert configs['large-channels'] is False
744+
745+
# Test one at a time.
746+
for c in configs.keys():
747+
if c.startswith('#') or c.startswith('plugins') or c == 'important-plugins':
748+
continue
749+
oneconfig = l1.rpc.listconfigs(config=c)
750+
assert(oneconfig[c] == configs[c])
751751

752752

753753
def test_listconfigs_plugins(node_factory, bitcoind, chainparams):

0 commit comments

Comments
 (0)