#include "config.h" #include #include #include #include #include #include #include #include #include #include #include "../flow.c" #include "../mcf.c" /* AUTOGENERATED MOCKS START */ /* Generated stub for sciddir_or_pubkey_from_node_id */ bool sciddir_or_pubkey_from_node_id(struct sciddir_or_pubkey *sciddpk UNNEEDED, const struct node_id *node_id UNNEEDED) { fprintf(stderr, "sciddir_or_pubkey_from_node_id called!\n"); abort(); } /* AUTOGENERATED MOCKS END */ int main(int argc, char *argv[]) { bool dual; u32 part; int chandir; u32 chanidx; common_setup(argv[0]); for (int i = 0; i < 32; i++) { for (int j = 0; j < 32; j++) { for (int k = 0; k < 32; k++) { struct arc a, a2; a.idx = (1U << i) | (1U << j) | (1U << k); arc_to_parts(a, &chanidx, &chandir, &part, &dual); a2 = arc_from_parts(chanidx, chandir, part, dual); assert(a.idx == a2.idx); } } } /* Test all chanidx */ for (int i = 0; i < (1U << ARC_CHANIDX_BITS); i++) { struct arc a = arc_from_parts(i, chandir, part, dual); arc_to_parts(a, &chanidx, NULL, NULL, NULL); assert(chanidx == i); } /* Test both chandir */ for (int i = 0; i < 2; i++) { struct arc a = arc_from_parts(chanidx, i, part, dual); arc_to_parts(a, NULL, &chandir, NULL, NULL); assert(chandir == i); } /* Test all parts */ for (int i = 0; i < CHANNEL_PARTS; i++) { struct arc a = arc_from_parts(chanidx, chandir, i, dual); arc_to_parts(a, NULL, NULL, &part, NULL); assert(part == i); } /* Test both dual */ for (int i = 0; i < 2; i++) { struct arc a = arc_from_parts(chanidx, chandir, part, i); arc_to_parts(a, NULL, NULL, NULL, &dual); assert(dual == i); assert(arc_is_dual(a) == dual); a = arc_dual(a); arc_to_parts(a, NULL, NULL, NULL, &dual); assert(dual == !i); assert(arc_is_dual(a) == dual); } common_shutdown(); }