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

Function test_getroutes_maxdelay

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

Source from the content-addressed store, hash-verified

1080
1081
1082def test_getroutes_maxdelay(node_factory):
1083 gsfile, nodemap = generate_gossip_store([GenChannel(0, 1, forward=GenChannel.Half(propfee=10000, delay=80)),
1084 GenChannel(0, 1, forward=GenChannel.Half(propfee=20000, delay=40))])
1085
1086 # Set up l1 with this as the gossip_store
1087 l1 = node_factory.get_node(gossip_store_file=gsfile.name)
1088
1089 # Should prefer the cheaper channel
1090 dir01 = direction(nodemap[0], nodemap[1])
1091 assert l1.rpc.getroutes(source=nodemap[0],
1092 destination=nodemap[1],
1093 amount_msat=1000,
1094 layers=[],
1095 maxfee_msat=1000,
1096 final_cltv=99) == {'probability_ppm': 999999,
1097 'routes': [{'probability_ppm': 999999,
1098 'final_cltv': 99,
1099 'amount_msat': 1000,
1100 'path': [{'short_channel_id_dir': f'0x1x0/{dir01}',
1101 'node_id_in': nodemap[0],
1102 'node_id_out': nodemap[1],
1103 'amount_in_msat': 1010,
1104 'amount_out_msat': 1000,
1105 'cltv_in': 179,
1106 'cltv_out': 99}]}]}
1107
1108 # But use the channel with lower delay when needed
1109 assert l1.rpc.getroutes(source=nodemap[0],
1110 destination=nodemap[1],
1111 amount_msat=1000,
1112 layers=[],
1113 maxfee_msat=2000,
1114 final_cltv=99,
1115 maxdelay=170) == {'probability_ppm': 999999,
1116 'routes': [{'probability_ppm': 999999,
1117 'final_cltv': 99,
1118 'amount_msat': 1000,
1119 'path': [{'short_channel_id_dir': f'1x1x1/{dir01}',
1120 'node_id_in': nodemap[0],
1121 'node_id_out': nodemap[1],
1122 'amount_in_msat': 1020,
1123 'amount_out_msat': 1000,
1124 'cltv_in': 139,
1125 'cltv_out': 99}]}]}
1126
1127 # Excessive maxdelay parameter
1128 with pytest.raises(RpcError, match="maximum delay allowed is 2016"):
1129 l1.rpc.getroutes(source=nodemap[0],
1130 destination=nodemap[1],
1131 amount_msat=100000,
1132 layers=[],
1133 maxfee_msat=100,
1134 final_cltv=99,
1135 maxdelay=2017)
1136
1137
1138def 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