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

Function main

common/test/run-gossmap_local.c:289–503  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

287}
288
289int main(int argc, char *argv[])
290{
291 int fd;
292 char *gossfile;
293 struct gossmap *map;
294 struct node_id l1, l2, l3, l4;
295 struct short_channel_id scid23, scid12, scid_local;
296 struct gossmap_chan *chan;
297 struct gossmap_localmods *mods;
298 struct amount_sat capacity;
299 u32 timestamp, fee_base_msat, fee_proportional_millionths;
300 u8 message_flags, channel_flags;
301 struct amount_msat htlc_minimum_msat, htlc_maximum_msat;
302 u8 *cann, *nann;
303
304 common_setup(argv[0]);
305
306 fd = tmpdir_mkstemp(tmpctx, "run-gossip_local.XXXXXX", &gossfile);
307 assert(write_all(fd, canned_map, sizeof(canned_map)));
308
309 map = gossmap_load(tmpctx, gossfile, NULL);
310 assert(map);
311
312 /* There is a public channel 2<->3 (103x1x0), and private
313 * 1<->2 (110x1x1). */
314 assert(node_id_from_hexstr("0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518", 66, &l1));
315 assert(node_id_from_hexstr("022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59", 66, &l2));
316 assert(node_id_from_hexstr("035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d", 66, &l3));
317 assert(gossmap_find_node(map, &l1));
318 assert(gossmap_find_node(map, &l2));
319 assert(gossmap_find_node(map, &l3));
320
321 assert(short_channel_id_from_str("103x1x0", 7, &scid23));
322 assert(short_channel_id_from_str("110x1x1", 7, &scid12));
323 assert(gossmap_find_chan(map, &scid23));
324 assert(!gossmap_find_chan(map, &scid23)->private);
325 assert(gossmap_find_chan(map, &scid12));
326 assert(gossmap_find_chan(map, &scid12)->private);
327 assert(gossmap_chan_get_capacity(map, gossmap_find_chan(map, &scid23),
328 &capacity));
329 assert(amount_sat_eq(capacity, AMOUNT_SAT(1000000)));
330 assert(gossmap_chan_get_capacity(map, gossmap_find_chan(map, &scid12),
331 &capacity));
332 assert(amount_sat_eq(capacity, AMOUNT_SAT(1000000)));
333
334 gossmap_chan_get_update_details(map, gossmap_find_chan(map, &scid23),
335 0,
336 &timestamp,
337 &message_flags,
338 &channel_flags,
339 &fee_base_msat,
340 &fee_proportional_millionths,
341 &htlc_minimum_msat,
342 &htlc_maximum_msat);
343 assert(timestamp == 1612141433);
344 assert(message_flags == 1);
345 assert(channel_flags == 0);
346 assert(fee_base_msat == 20);

Callers

nothing calls this directly

Calls 15

common_setupFunction · 0.85
tmpdir_mkstempFunction · 0.85
gossmap_loadFunction · 0.85
gossmap_find_nodeFunction · 0.85
gossmap_find_chanFunction · 0.85
tal_bytelenFunction · 0.85

Tested by

no test coverage detected