| 179 | } |
| 180 | |
| 181 | static void test_b11(const char *b11str, |
| 182 | const struct bolt11 *expect_b11, |
| 183 | const char *hashed_desc) |
| 184 | { |
| 185 | struct bolt11 *b11; |
| 186 | const char *fail; |
| 187 | char *reproduce; |
| 188 | struct bolt11_field *b11_extra, *expect_extra; |
| 189 | |
| 190 | b11 = bolt11_decode(tmpctx, b11str, NULL, hashed_desc, |
| 191 | expect_b11->chain, &fail); |
| 192 | if (!b11) |
| 193 | errx(1, "%s:%u:%s", __FILE__, __LINE__, fail); |
| 194 | |
| 195 | assert(b11->chain == expect_b11->chain); |
| 196 | assert(b11->timestamp == expect_b11->timestamp); |
| 197 | if (!b11->msat) |
| 198 | assert(!expect_b11->msat); |
| 199 | else |
| 200 | assert(amount_msat_eq(*b11->msat, *expect_b11->msat)); |
| 201 | assert(sha256_eq(&b11->payment_hash, &expect_b11->payment_hash)); |
| 202 | if (!b11->description) |
| 203 | assert(!expect_b11->description); |
| 204 | else |
| 205 | assert(streq(b11->description, expect_b11->description)); |
| 206 | if (b11->description_hash) |
| 207 | assert(sha256_eq(b11->description_hash, expect_b11->description_hash)); |
| 208 | |
| 209 | if (!b11->payment_secret) |
| 210 | assert(!expect_b11->payment_secret); |
| 211 | else |
| 212 | assert(memeq(b11->payment_secret, sizeof(*b11->payment_secret), |
| 213 | expect_b11->payment_secret, |
| 214 | sizeof(*expect_b11->payment_secret))); |
| 215 | assert(memeq(b11->features, tal_bytelen(b11->features), |
| 216 | expect_b11->features, tal_bytelen(expect_b11->features))); |
| 217 | assert(b11->expiry == expect_b11->expiry); |
| 218 | assert(b11->min_final_cltv_expiry == expect_b11->min_final_cltv_expiry); |
| 219 | |
| 220 | assert(tal_count(b11->fallbacks) == tal_count(expect_b11->fallbacks)); |
| 221 | for (size_t i = 0; i < tal_count(b11->fallbacks); i++) |
| 222 | assert(memeq(b11->fallbacks[i], tal_count(b11->fallbacks[i]), |
| 223 | expect_b11->fallbacks[i], |
| 224 | tal_count(expect_b11->fallbacks[i]))); |
| 225 | |
| 226 | assert(tal_count(b11->routes) == tal_count(expect_b11->routes)); |
| 227 | for (size_t i = 0; i < tal_count(b11->routes); i++) { |
| 228 | assert(tal_count(b11->routes[i]) |
| 229 | == tal_count(expect_b11->routes[i])); |
| 230 | for (size_t j = 0; j < tal_count(b11->routes[i]); j++) { |
| 231 | const struct route_info *r = &b11->routes[i][j], |
| 232 | *er = &expect_b11->routes[i][j]; |
| 233 | assert(node_id_eq(&er->pubkey, &r->pubkey)); |
| 234 | assert(er->cltv_expiry_delta == r->cltv_expiry_delta); |
| 235 | assert(short_channel_id_eq(er->short_channel_id, |
| 236 | r->short_channel_id)); |
| 237 | assert(er->fee_base_msat == r->fee_base_msat); |
| 238 | assert(er->fee_proportional_millionths |
no test coverage detected