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

Function main

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

Source from the content-addressed store, hash-verified

171}
172
173int main(int argc, char *argv[])
174{
175 struct node_id a, b, c, d;
176 struct gossmap_node *a_node, *b_node, *c_node, *d_node;
177 const struct dijkstra *dij;
178 struct route_hop *route;
179 int store_fd;
180 struct gossmap *gossmap;
181 const double riskfactor = 1.0;
182 char gossip_version = 10;
183 char *gossipfilename;
184
185 common_setup(argv[0]);
186 node_id_from_hexstr("03c173897878996287a8100469f954dd820fcd8941daed91c327f168f3329be0bf",
187 strlen("03c173897878996287a8100469f954dd820fcd8941daed91c327f168f3329be0bf"),
188 &a);
189 node_id_from_hexstr("0230ad0e74ea03976b28fda587bb75bdd357a1938af4424156a18265167f5e40ae",
190 strlen("0230ad0e74ea03976b28fda587bb75bdd357a1938af4424156a18265167f5e40ae"),
191 &b);
192 node_id_from_hexstr("02ea622d5c8d6143f15ed3ce1d501dd0d3d09d3b1c83a44d0034949f8a9ab60f06",
193 strlen("02ea622d5c8d6143f15ed3ce1d501dd0d3d09d3b1c83a44d0034949f8a9ab60f06"),
194 &c);
195 node_id_from_hexstr("02cca6c5c966fcf61d121e3a70e03a1cd9eeeea024b26ea666ce974d43b242e636",
196 strlen("02cca6c5c966fcf61d121e3a70e03a1cd9eeeea024b26ea666ce974d43b242e636"),
197 &d);
198
199 chainparams = chainparams_for_network("regtest");
200
201 store_fd = tmpdir_mkstemp(tmpctx, "run-route-specific-gossipstore.XXXXXX", &gossipfilename);
202 assert(write(store_fd, &gossip_version, sizeof(gossip_version))
203 == sizeof(gossip_version));
204
205 gossmap = gossmap_load(tmpctx, gossipfilename, NULL);
206
207 /* [{'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}, */
208 add_connection(store_fd, &c, &b, "6990x2x1",
209 AMOUNT_MSAT(0), AMOUNT_MSAT(1000),
210 0, 10, 5);
211
212 /* {'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}, */
213 add_connection(store_fd, &b, &a, "6989x2x1",
214 AMOUNT_MSAT(0), AMOUNT_MSAT(1000),
215 0, 10, 5);
216
217 /* {'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}, */
218 update_connection(store_fd, &b, &c, "6990x2x1",
219 AMOUNT_MSAT(100), AMOUNT_MSAT(1000),
220 0, 10, 5, false);
221
222 /* {'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}]} */
223 update_connection(store_fd, &a, &b, "6989x2x1",
224 AMOUNT_MSAT(0), AMOUNT_MSAT(1000),
225 0, 10, 5, false);
226
227 assert(gossmap_refresh(gossmap, NULL));
228
229 a_node = gossmap_find_node(gossmap, &a);
230 b_node = gossmap_find_node(gossmap, &b);

Callers

nothing calls this directly

Calls 13

common_setupFunction · 0.85
chainparams_for_networkFunction · 0.85
tmpdir_mkstempFunction · 0.85
gossmap_loadFunction · 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

Tested by

no test coverage detected