mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 07:04:22 +01:00
pyln: add context manager to simpify filter use.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-Added: pyln: LightningRpc has new `reply_filter` context manager for reducing output of RPC commands.
This commit is contained in:
@@ -2823,6 +2823,11 @@ def test_field_filter(node_factory, chainparams):
|
||||
dec = l1.rpc.call('decodepay', {'bolt11': inv['bolt11']}, filter={"currency": True})
|
||||
assert dec == {"currency": chainparams['bip173_prefix']}
|
||||
|
||||
# Use context manager:
|
||||
with l1.rpc.reply_filter({"currency": True}):
|
||||
dec = l1.rpc.decodepay(bolt11=inv['bolt11'])
|
||||
assert dec == {"currency": chainparams['bip173_prefix']}
|
||||
|
||||
# Two fields
|
||||
dec = l1.rpc.call('decodepay', {'bolt11': inv['bolt11']}, filter={"currency": True, "payment_hash": True})
|
||||
assert dec == {"currency": chainparams['bip173_prefix'],
|
||||
|
||||
Reference in New Issue
Block a user