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

Function test_getroutes_auto_localchans

tests/test_askrene.py:1138–1184  ·  view source on GitHub ↗

Test getroutes call with auto.localchans layer

(node_factory)

Source from the content-addressed store, hash-verified

1136
1137
1138def test_getroutes_auto_localchans(node_factory):
1139 """Test getroutes call with auto.localchans layer"""
1140 l1 = node_factory.get_node()
1141 gsfile, nodemap = generate_gossip_store([GenChannel(0, 1, forward=GenChannel.Half(propfee=10000)),
1142 GenChannel(1, 2, forward=GenChannel.Half(propfee=10000))],
1143 nodemap={0: l1.info['id']})
1144
1145 # We get bad signature warnings, since our gossip is made up!
1146 l2 = node_factory.get_node(allow_warning=True, gossip_store_file=gsfile.name)
1147
1148 # Now l2 believes l1 has an entire network behind it.
1149 scid12, _ = l2.fundchannel(l1, 10**6, announce_channel=False)
1150
1151 # Cannot find a route unless we use local hints.
1152 with pytest.raises(RpcError, match="Unknown source node {}".format(l2.info['id'])):
1153 l2.rpc.getroutes(source=l2.info['id'],
1154 destination=nodemap[2],
1155 amount_msat=100000,
1156 layers=[],
1157 maxfee_msat=100000,
1158 final_cltv=99)
1159
1160 # This should work
1161 scid21dir = f"{scid12}/{direction(l2.info['id'], l1.info['id'])}"
1162 # Calculate directions dynamically based on node IDs
1163 dir01 = direction(nodemap[0], nodemap[1])
1164 dir12 = direction(nodemap[1], nodemap[2])
1165 check_getroute_paths(l2,
1166 l2.info['id'],
1167 nodemap[2],
1168 100000,
1169 maxfee_msat=100000,
1170 layers=['auto.localchans'],
1171 paths=[[{'short_channel_id_dir': scid21dir, 'amount_in_msat': 102012, 'cltv_in': 99 + 6 + 6 + 6},
1172 {'short_channel_id_dir': f'0x1x0/{dir01}', 'amount_in_msat': 102010, 'cltv_in': 99 + 6 + 6},
1173 {'short_channel_id_dir': f'2x2x1/{dir12}', 'amount_in_msat': 101000, 'cltv_in': 99 + 6}]])
1174
1175 # This should get self-discount correct
1176 check_getroute_paths(l2,
1177 l2.info['id'],
1178 nodemap[2],
1179 100000,
1180 maxfee_msat=100000,
1181 layers=['auto.localchans', 'auto.sourcefree'],
1182 paths=[[{'short_channel_id_dir': scid21dir, 'amount_in_msat': 102010, 'cltv_in': 99 + 6 + 6},
1183 {'short_channel_id_dir': f'0x1x0/{dir01}', 'amount_in_msat': 102010, 'cltv_in': 99 + 6 + 6},
1184 {'short_channel_id_dir': f'2x2x1/{dir12}', 'amount_in_msat': 101000, 'cltv_in': 99 + 6}]])
1185
1186
1187def test_fees_dont_exceed_constraints(node_factory):

Callers

nothing calls this directly

Calls 7

generate_gossip_storeFunction · 0.90
GenChannelClass · 0.90
check_getroute_pathsFunction · 0.85
getroutesMethod · 0.80
directionFunction · 0.70
get_nodeMethod · 0.45
fundchannelMethod · 0.45

Tested by

no test coverage detected