We create an arrangement of nodes, each node N connected to N+1 and * to node 1. The cost for each N to N+1 route is 1, for N to 1 is * 2^N. That means it's always cheapest to go the longer route */
| 228 | * to node 1. The cost for each N to N+1 route is 1, for N to 1 is |
| 229 | * 2^N. That means it's always cheapest to go the longer route */ |
| 230 | int main(int argc, char *argv[]) |
| 231 | { |
| 232 | struct node_id ids[NUM_NODES]; |
| 233 | int store_fd; |
| 234 | struct payment *p; |
| 235 | struct payment_modifier **mods; |
| 236 | char gossip_version = 10; |
| 237 | char *gossipfilename; |
| 238 | struct channel_hint_set *hints = channel_hint_set_new(tmpctx); |
| 239 | |
| 240 | common_setup(argv[0]); |
| 241 | chainparams = chainparams_for_network("regtest"); |
| 242 | store_fd = tmpdir_mkstemp(tmpctx, "run-route-overlong.XXXXXX", &gossipfilename); |
| 243 | assert(write(store_fd, &gossip_version, sizeof(gossip_version)) |
| 244 | == sizeof(gossip_version)); |
| 245 | |
| 246 | global_gossmap = gossmap_load(tmpctx, gossipfilename, NULL, NULL); |
| 247 | |
| 248 | for (size_t i = 0; i < NUM_NODES; i++) { |
| 249 | struct privkey tmp; |
| 250 | memset(&tmp, i+1, sizeof(tmp)); |
| 251 | node_id_from_privkey(&tmp, &ids[i]); |
| 252 | } |
| 253 | |
| 254 | mods = tal_arrz(tmpctx, struct payment_modifier *, 1); |
| 255 | p = payment_new(mods, tal(tmpctx, struct command), NULL, hints, mods); |
| 256 | |
| 257 | for (size_t i = 1; i < NUM_NODES; i++) { |
| 258 | struct short_channel_id scid; |
| 259 | |
| 260 | if (!mk_short_channel_id(&scid, i, i-1, 0)) |
| 261 | abort(); |
| 262 | add_connection(store_fd, &ids[i-1], &ids[i], scid, |
| 263 | AMOUNT_MSAT(0), |
| 264 | AMOUNT_MSAT(1000000 * 1000), |
| 265 | 0, 0, 0); |
| 266 | SUPERVERBOSE("Joining %s to %s, fee %u\n", |
| 267 | fmt_node_id(tmpctx, &ids[i-1]), |
| 268 | fmt_node_id(tmpctx, &ids[i]), |
| 269 | 0); |
| 270 | |
| 271 | if (i <= 2) |
| 272 | continue; |
| 273 | if (!mk_short_channel_id(&scid, i, 1, 0)) |
| 274 | abort(); |
| 275 | add_connection(store_fd, &ids[1], &ids[i], scid, |
| 276 | AMOUNT_MSAT(0), |
| 277 | AMOUNT_MSAT(1000000 * 1000), |
| 278 | 1 << i, 0, 0); |
| 279 | SUPERVERBOSE("Joining %s to %s, fee %u\n", |
| 280 | fmt_node_id(tmpctx, &ids[1]), |
| 281 | fmt_node_id(tmpctx, &ids[i]), |
| 282 | 1 << i); |
| 283 | } |
| 284 | |
| 285 | assert(gossmap_refresh(global_gossmap)); |
| 286 | for (size_t i = ROUTING_MAX_HOPS; i > 2; i--) { |
| 287 | struct gossmap_node *dst, *src; |
nothing calls this directly
no test coverage detected