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

Function main

plugins/test/run-route-calc.c:239–450  ·  view source on GitHub ↗

A -> B -> C -> D -> E * * Each node has two channels with the next, one has worse characteristics. */

Source from the content-addressed store, hash-verified

237 * Each node has two channels with the next, one has worse characteristics.
238 */
239int main(int argc, char *argv[])
240{
241 struct payment *p;
242 struct payment_modifier **mods;
243 struct channel_hint_set *hints;
244
245 common_setup(argv[0]);
246 chainparams = chainparams_for_network("regtest");
247 hints = channel_hint_set_new(tmpctx);
248
249 mods = tal_arrz(tmpctx, struct payment_modifier *, 1);
250 p = payment_new(mods, tal(tmpctx, struct command), NULL, hints, mods);
251
252 /* We want to permute order of channels between each node, to
253 * avoid "it works because it chooses the first one!" */
254 for (size_t i = 0; i < 2; i++) {
255 const char gossip_version = 10;
256 struct gossmap *gossmap;
257 char *gossipfilename;
258 int store_fd;
259 struct short_channel_id_dir scids[2], path[4];
260 struct route_hop *r;
261 struct node_id src, dst;
262 const struct dijkstra *dij;
263 const char *errmsg;
264 u32 risk_factor = 10;
265
266 store_fd = tmpdir_mkstemp(tmpctx, "run-route-calc.XXXXXX",
267 &gossipfilename);
268 assert(write(store_fd, &gossip_version, sizeof(gossip_version))
269 == sizeof(gossip_version));
270
271 /* Cheap base vs expensive base */
272 scids[0] = add_connection(store_fd, 'A', 'B',
273 1000 * !i,
274 100,
275 1,
276 AMOUNT_SAT(100000000));
277 scids[1] = add_connection(store_fd, 'A', 'B',
278 1000 * !!i,
279 100,
280 1,
281 AMOUNT_SAT(100000000));
282 path[0] = scids[!i];
283
284 /* Cheap proportion vs expensive proportion */
285 scids[0] = add_connection(store_fd, 'B', 'C',
286 1000,
287 100 * !i,
288 1,
289 AMOUNT_SAT(100000000));
290 scids[1] = add_connection(store_fd, 'B', 'C',
291 1000,
292 100 * !!i,
293 1,
294 AMOUNT_SAT(100000000));
295 path[1] = scids[!i];
296

Callers

nothing calls this directly

Calls 15

common_setupFunction · 0.85
chainparams_for_networkFunction · 0.85
channel_hint_set_newFunction · 0.85
tmpdir_mkstempFunction · 0.85
gossmap_find_nodeFunction · 0.85
short_channel_id_eqFunction · 0.85
dijkstra_distanceFunction · 0.85
amount_msat_add_feeFunction · 0.85
amount_msat_feeFunction · 0.85
risk_priceFunction · 0.85
gossmap_find_chanFunction · 0.85
gossmap_refreshFunction · 0.85

Tested by

no test coverage detected