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

Function main

common/test/run-route-specific.c:187–313  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

185}
186
187int main(int argc, char *argv[])
188{
189 struct node_id a, b, c, d;
190 struct gossmap_node *a_node, *b_node, *c_node, *d_node;
191 const struct dijkstra *dij;
192 struct route_hop *route;
193 int store_fd;
194 struct gossmap *gossmap;
195 const double riskfactor = 1.0;
196 char gossip_version = 10;
197 char *gossipfilename;
198
199 common_setup(argv[0]);
200 node_id_from_hexstr("03c173897878996287a8100469f954dd820fcd8941daed91c327f168f3329be0bf",
201 strlen("03c173897878996287a8100469f954dd820fcd8941daed91c327f168f3329be0bf"),
202 &a);
203 node_id_from_hexstr("0230ad0e74ea03976b28fda587bb75bdd357a1938af4424156a18265167f5e40ae",
204 strlen("0230ad0e74ea03976b28fda587bb75bdd357a1938af4424156a18265167f5e40ae"),
205 &b);
206 node_id_from_hexstr("02ea622d5c8d6143f15ed3ce1d501dd0d3d09d3b1c83a44d0034949f8a9ab60f06",
207 strlen("02ea622d5c8d6143f15ed3ce1d501dd0d3d09d3b1c83a44d0034949f8a9ab60f06"),
208 &c);
209 node_id_from_hexstr("02cca6c5c966fcf61d121e3a70e03a1cd9eeeea024b26ea666ce974d43b242e636",
210 strlen("02cca6c5c966fcf61d121e3a70e03a1cd9eeeea024b26ea666ce974d43b242e636"),
211 &d);
212
213 chainparams = chainparams_for_network("regtest");
214
215 store_fd = tmpdir_mkstemp(tmpctx, "run-route-specific-gossipstore.XXXXXX", &gossipfilename);
216 assert(write(store_fd, &gossip_version, sizeof(gossip_version))
217 == sizeof(gossip_version));
218
219 gossmap = gossmap_load(tmpctx, gossipfilename, NULL, NULL);
220
221 /* [{'active': True, 'short_id': '6990:2:1/1', 'fee_per_kw': 10, 'delay': 5, 'message_flags': 0, 'channel_flags': 1, 'destination': '0230ad0e74ea03976b28fda587bb75bdd357a1938af4424156a18265167f5e40ae', 'source': '02ea622d5c8d6143f15ed3ce1d501dd0d3d09d3b1c83a44d0034949f8a9ab60f06', 'last_update': 1504064344}, */
222 add_connection(store_fd, &c, &b, "6990x2x1",
223 AMOUNT_MSAT(0), AMOUNT_MSAT(1000),
224 0, 10, 5);
225
226 /* {'active': True, 'short_id': '6989:2:1/0', 'fee_per_kw': 10, 'delay': 5, 'message_flags': 0, 'channel_flags': 0, 'destination': '03c173897878996287a8100469f954dd820fcd8941daed91c327f168f3329be0bf', 'source': '0230ad0e74ea03976b28fda587bb75bdd357a1938af4424156a18265167f5e40ae', 'last_update': 1504064344}, */
227 add_connection(store_fd, &b, &a, "6989x2x1",
228 AMOUNT_MSAT(0), AMOUNT_MSAT(1000),
229 0, 10, 5);
230
231 /* {'active': True, 'short_id': '6990:2:1/0', 'fee_per_kw': 10, 'delay': 5, 'message_flags': 0, 'channel_flags': 0, 'destination': '02ea622d5c8d6143f15ed3ce1d501dd0d3d09d3b1c83a44d0034949f8a9ab60f06', 'source': '0230ad0e74ea03976b28fda587bb75bdd357a1938af4424156a18265167f5e40ae', 'last_update': 1504064344}, */
232 update_connection(store_fd, &b, &c, "6990x2x1",
233 AMOUNT_MSAT(100), AMOUNT_MSAT(1000),
234 0, 10, 5, false);
235
236 /* {'active': True, 'short_id': '6989:2:1/1', 'fee_per_kw': 10, 'delay': 5, 'message_flags': 0, 'channel_flags': 1, 'destination': '0230ad0e74ea03976b28fda587bb75bdd357a1938af4424156a18265167f5e40ae', 'source': '03c173897878996287a8100469f954dd820fcd8941daed91c327f168f3329be0bf', 'last_update': 1504064344}]} */
237 update_connection(store_fd, &a, &b, "6989x2x1",
238 AMOUNT_MSAT(0), AMOUNT_MSAT(1000),
239 0, 10, 5, false);
240
241 assert(gossmap_refresh(gossmap));
242
243 a_node = gossmap_find_node(gossmap, &a);
244 b_node = gossmap_find_node(gossmap, &b);

Callers

nothing calls this directly

Calls 12

common_setupFunction · 0.85
chainparams_for_networkFunction · 0.85
tmpdir_mkstempFunction · 0.85
gossmap_refreshFunction · 0.85
gossmap_find_nodeFunction · 0.85
route_from_dijkstraFunction · 0.85
common_shutdownFunction · 0.85
node_id_from_hexstrFunction · 0.70
add_connectionFunction · 0.70
update_connectionFunction · 0.70
dijkstraClass · 0.70
channel_is_betweenFunction · 0.70

Tested by

no test coverage detected