| 63 | static void remove_file(char *fname) { assert(!remove(fname)); } |
| 64 | |
| 65 | int main(int argc, char *argv[]) |
| 66 | { |
| 67 | int fd; |
| 68 | char *gossfile; |
| 69 | struct gossmap *gossmap; |
| 70 | struct node_id nodes[NUM_NODES]; |
| 71 | |
| 72 | common_setup(argv[0]); |
| 73 | chainparams = chainparams_for_network("regtest"); |
| 74 | |
| 75 | fd = tmpdir_mkstemp(tmpctx, "run-bottleneck.XXXXXX", &gossfile); |
| 76 | tal_add_destructor(gossfile, remove_file); |
| 77 | assert(write(fd, empty_map, sizeof(empty_map)) == sizeof(empty_map)); |
| 78 | |
| 79 | gossmap = gossmap_load(tmpctx, gossfile, NULL, NULL); |
| 80 | assert(gossmap); |
| 81 | |
| 82 | for (size_t i = 0; i < NUM_NODES; i++) { |
| 83 | struct privkey tmp; |
| 84 | memset(&tmp, i+1, sizeof(tmp)); |
| 85 | node_id_from_privkey(&tmp, &nodes[i]); |
| 86 | } |
| 87 | |
| 88 | /* We will try a payment from 1 to 8, forcing a payment split between |
| 89 | * two routes 1->2->4->5->6->8 and 1->3->4->5->7->8. |
| 90 | * To force the split the total payment amount will be greater than the |
| 91 | * channel 1-2 and 1-3 capacities. Then channel 4--5 will be a common |
| 92 | * edge in the payment routes. |
| 93 | * |
| 94 | * MCF does not handle fees hence if the capacity of 4--5 is enough to |
| 95 | * let the entire payment pass, we expect that minflow computes two |
| 96 | * routes that are scaled down by get_route algorithm |
| 97 | * to fit for the fee constraints. |
| 98 | * |
| 99 | * +--2--+ +--6--+ |
| 100 | * | | | | |
| 101 | * 1 4---5 8 |
| 102 | * | | | | |
| 103 | * +--3--+ +--7--+ |
| 104 | * |
| 105 | * */ |
| 106 | struct short_channel_id scid; |
| 107 | |
| 108 | assert(mk_short_channel_id(&scid, 1, 2, 0)); |
| 109 | add_connection(fd, &nodes[0], &nodes[1], scid, |
| 110 | AMOUNT_MSAT(0), |
| 111 | AMOUNT_MSAT(60 * 1000 * 1000), |
| 112 | 0, 0, 5, |
| 113 | AMOUNT_SAT(60 * 1000)); |
| 114 | |
| 115 | assert(mk_short_channel_id(&scid, 1, 3, 0)); |
| 116 | add_connection(fd, &nodes[0], &nodes[2], scid, |
| 117 | AMOUNT_MSAT(0), |
| 118 | AMOUNT_MSAT(60 * 1000 * 1000), |
| 119 | 0, 0, 5, |
| 120 | AMOUNT_SAT(60 * 1000)); |
| 121 | |
| 122 | assert(mk_short_channel_id(&scid, 2, 4, 0)); |
nothing calls this directly
no test coverage detected