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

Function test_getroutes_maxdelay

tests/test_askrene.py:1129–1182  ·  view source on GitHub ↗
(node_factory)

Source from the content-addressed store, hash-verified

1127
1128
1129def test_getroutes_maxdelay(node_factory):
1130 gsfile, nodemap = generate_gossip_store([GenChannel(0, 1, forward=GenChannel.Half(propfee=10000, delay=80)),
1131 GenChannel(0, 1, forward=GenChannel.Half(propfee=20000, delay=40))])
1132
1133 # Set up l1 with this as the gossip_store
1134 l1 = node_factory.get_node(gossip_store_file=gsfile.name)
1135
1136 # Should prefer the cheaper channel
1137 dir01 = direction(nodemap[0], nodemap[1])
1138 assert l1.rpc.getroutes(source=nodemap[0],
1139 destination=nodemap[1],
1140 amount_msat=1000,
1141 layers=[],
1142 maxfee_msat=1000,
1143 final_cltv=99) == {'probability_ppm': 999999,
1144 'routes': [{'probability_ppm': 999999,
1145 'final_cltv': 99,
1146 'amount_msat': 1000,
1147 'path': [{'short_channel_id_dir': f'0x1x0/{dir01}',
1148 'node_id_in': nodemap[0],
1149 'node_id_out': nodemap[1],
1150 'amount_in_msat': 1010,
1151 'amount_out_msat': 1000,
1152 'cltv_in': 179,
1153 'cltv_out': 99}]}]}
1154
1155 # But use the channel with lower delay when needed
1156 assert l1.rpc.getroutes(source=nodemap[0],
1157 destination=nodemap[1],
1158 amount_msat=1000,
1159 layers=[],
1160 maxfee_msat=2000,
1161 final_cltv=99,
1162 maxdelay=170) == {'probability_ppm': 999999,
1163 'routes': [{'probability_ppm': 999999,
1164 'final_cltv': 99,
1165 'amount_msat': 1000,
1166 'path': [{'short_channel_id_dir': f'1x1x1/{dir01}',
1167 'node_id_in': nodemap[0],
1168 'node_id_out': nodemap[1],
1169 'amount_in_msat': 1020,
1170 'amount_out_msat': 1000,
1171 'cltv_in': 139,
1172 'cltv_out': 99}]}]}
1173
1174 # Excessive maxdelay parameter
1175 with pytest.raises(RpcError, match="maximum delay allowed is 2016"):
1176 l1.rpc.getroutes(source=nodemap[0],
1177 destination=nodemap[1],
1178 amount_msat=100000,
1179 layers=[],
1180 maxfee_msat=100,
1181 final_cltv=99,
1182 maxdelay=2017)
1183
1184
1185def test_getroutes_auto_localchans(node_factory):

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