| 44 | } |
| 45 | |
| 46 | static void test_b11(const char *b11str, |
| 47 | const struct bolt11 *expect_b11, |
| 48 | const char *hashed_desc) |
| 49 | { |
| 50 | struct bolt11 *b11; |
| 51 | char *fail; |
| 52 | struct bolt11_field *b11_extra, *expect_extra; |
| 53 | |
| 54 | b11 = bolt11_decode(tmpctx, b11str, NULL, hashed_desc, |
| 55 | expect_b11->chain, &fail); |
| 56 | if (!b11) |
| 57 | errx(1, "%s:%u:%s", __FILE__, __LINE__, fail); |
| 58 | |
| 59 | assert(b11->chain == expect_b11->chain); |
| 60 | assert(b11->timestamp == expect_b11->timestamp); |
| 61 | if (!b11->msat) |
| 62 | assert(!expect_b11->msat); |
| 63 | else |
| 64 | assert(amount_msat_eq(*b11->msat, *expect_b11->msat)); |
| 65 | assert(sha256_eq(&b11->payment_hash, &expect_b11->payment_hash)); |
| 66 | if (!b11->description) |
| 67 | assert(!expect_b11->description); |
| 68 | else |
| 69 | assert(streq(b11->description, expect_b11->description)); |
| 70 | |
| 71 | if (!b11->payment_secret) |
| 72 | assert(!expect_b11->payment_secret); |
| 73 | else |
| 74 | assert(memeq(b11->payment_secret, sizeof(*b11->payment_secret), |
| 75 | expect_b11->payment_secret, |
| 76 | sizeof(*expect_b11->payment_secret))); |
| 77 | assert(memeq(b11->features, tal_bytelen(b11->features), |
| 78 | expect_b11->features, tal_bytelen(expect_b11->features))); |
| 79 | assert(b11->expiry == expect_b11->expiry); |
| 80 | assert(b11->min_final_cltv_expiry == expect_b11->min_final_cltv_expiry); |
| 81 | |
| 82 | assert(tal_count(b11->fallbacks) == tal_count(expect_b11->fallbacks)); |
| 83 | for (size_t i = 0; i < tal_count(b11->fallbacks); i++) |
| 84 | assert(memeq(b11->fallbacks[i], tal_count(b11->fallbacks[i]), |
| 85 | expect_b11->fallbacks[i], |
| 86 | tal_count(expect_b11->fallbacks[i]))); |
| 87 | |
| 88 | assert(tal_count(b11->routes) == tal_count(expect_b11->routes)); |
| 89 | for (size_t i = 0; i < tal_count(b11->routes); i++) { |
| 90 | assert(tal_count(b11->routes[i]) |
| 91 | == tal_count(expect_b11->routes[i])); |
| 92 | for (size_t j = 0; j < tal_count(b11->routes[i]); j++) { |
| 93 | const struct route_info *r = &b11->routes[i][j], |
| 94 | *er = &expect_b11->routes[i][j]; |
| 95 | assert(node_id_eq(&er->pubkey, &r->pubkey)); |
| 96 | assert(er->cltv_expiry_delta == r->cltv_expiry_delta); |
| 97 | assert(short_channel_id_eq(&er->short_channel_id, |
| 98 | &r->short_channel_id)); |
| 99 | assert(er->fee_base_msat == r->fee_base_msat); |
| 100 | assert(er->fee_proportional_millionths |
| 101 | == r->fee_proportional_millionths); |
| 102 | } |
| 103 | } |
no test coverage detected