plugins/topology: add direction field to listchannels.

It's a core concept in the spec which isn't directly exposed.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Added: JSON-RPC: `listchannels` added a `direction` field (0 or 1) as per gossip specification.
This commit is contained in:
Rusty Russell
2023-01-30 16:37:03 +10:30
committed by Alex Myers
parent 611795beee
commit 9ab488fc41
9 changed files with 21 additions and 1 deletions

View File

@@ -425,6 +425,10 @@ def test_gossip_jsonrpc(node_factory):
channels2 = l2.rpc.listchannels(source=l1.info['id'])['channels']
assert only_one(channels1)['source'] == l1.info['id']
assert only_one(channels1)['destination'] == l2.info['id']
if l1.info['id'] > l2.info['id']:
assert only_one(channels1)['direction'] == 1
else:
assert only_one(channels1)['direction'] == 0
assert channels1 == channels2
# Test listchannels-by-destination
@@ -432,6 +436,10 @@ def test_gossip_jsonrpc(node_factory):
channels2 = l2.rpc.listchannels(destination=l1.info['id'])['channels']
assert only_one(channels1)['destination'] == l1.info['id']
assert only_one(channels1)['source'] == l2.info['id']
if l2.info['id'] > l1.info['id']:
assert only_one(channels1)['direction'] == 1
else:
assert only_one(channels1)['direction'] == 0
assert channels1 == channels2
# Test only one of short_channel_id, source or destination can be supplied