MCPcopy Create free account
hub / github.com/ElementsProject/lightning / test_getroutes_auto_sourcefree

Function test_getroutes_auto_sourcefree

tests/test_askrene.py:983–1079  ·  view source on GitHub ↗

Test getroutes call with auto.sourcefree layer

(node_factory)

Source from the content-addressed store, hash-verified

981
982
983def test_getroutes_auto_sourcefree(node_factory):
984 """Test getroutes call with auto.sourcefree layer"""
985 gsfile, nodemap = generate_gossip_store([GenChannel(0, 1, forward=GenChannel.Half(propfee=10000)),
986 GenChannel(0, 2, capacity_sats=9000),
987 GenChannel(1, 3, forward=GenChannel.Half(propfee=20000)),
988 GenChannel(0, 2, capacity_sats=10000),
989 GenChannel(2, 4, forward=GenChannel.Half(delay=2000))])
990
991 # Set up l1 with this as the gossip_store
992 l1 = node_factory.get_node(gossip_store_file=gsfile.name)
993
994 # Without sourcefree:
995 dir01 = direction(nodemap[0], nodemap[1])
996 assert l1.rpc.getroutes(source=nodemap[0],
997 destination=nodemap[1],
998 amount_msat=1000,
999 layers=[],
1000 maxfee_msat=1000,
1001 final_cltv=99) == {'probability_ppm': 999999,
1002 'routes': [{'probability_ppm': 999999,
1003 'final_cltv': 99,
1004 'amount_msat': 1000,
1005 'path': [{'short_channel_id_dir': f'0x1x0/{dir01}',
1006 'node_id_in': nodemap[0],
1007 'node_id_out': nodemap[1],
1008 'amount_in_msat': 1010,
1009 'amount_out_msat': 1000,
1010 'cltv_in': 105,
1011 'cltv_out': 99}]}]}
1012
1013 # Start easy
1014 assert l1.rpc.getroutes(source=nodemap[0],
1015 destination=nodemap[1],
1016 amount_msat=1000,
1017 layers=['auto.sourcefree'],
1018 maxfee_msat=1000,
1019 final_cltv=99) == {'probability_ppm': 999999,
1020 'routes': [{'probability_ppm': 999999,
1021 'final_cltv': 99,
1022 'amount_msat': 1000,
1023 'path': [{'short_channel_id_dir': f'0x1x0/{dir01}',
1024 'node_id_in': nodemap[0],
1025 'node_id_out': nodemap[1],
1026 'amount_in_msat': 1000,
1027 'amount_out_msat': 1000,
1028 'cltv_in': 99,
1029 'cltv_out': 99}]}]}
1030 # Two hop, still easy.
1031 dir13 = direction(nodemap[1], nodemap[3])
1032 assert l1.rpc.getroutes(source=nodemap[0],
1033 destination=nodemap[3],
1034 amount_msat=100000,
1035 layers=['auto.sourcefree'],
1036 maxfee_msat=5000,
1037 final_cltv=99) == {'probability_ppm': 999798,
1038 'routes': [{'probability_ppm': 999798,
1039 'final_cltv': 99,
1040 'amount_msat': 100000,

Callers

nothing calls this directly

Calls 5

generate_gossip_storeFunction · 0.90
GenChannelClass · 0.90
getroutesMethod · 0.80
directionFunction · 0.70
get_nodeMethod · 0.45

Tested by

no test coverage detected