From 7028493d010db2847a56861f44367143b82ba40c Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 3 Feb 2020 10:09:26 +1030 Subject: [PATCH] common: implement route comparison in run-bolt11. This next test will have route hints. Signed-off-by: Rusty Russell --- common/test/run-bolt11.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/common/test/run-bolt11.c b/common/test/run-bolt11.c index b7c5c8d02..cc52410ed 100644 --- a/common/test/run-bolt11.c +++ b/common/test/run-bolt11.c @@ -117,8 +117,22 @@ static void test_b11(const char *b11str, expect_b11->fallbacks[i], tal_count(expect_b11->fallbacks[i]))); - /* FIXME: compare routes. */ assert(tal_count(b11->routes) == tal_count(expect_b11->routes)); + for (size_t i = 0; i < tal_count(b11->routes); i++) { + assert(tal_count(b11->routes[i]) + == tal_count(expect_b11->routes[i])); + for (size_t j = 0; j < tal_count(b11->routes[i]); j++) { + const struct route_info *r = &b11->routes[i][j], + *er = &expect_b11->routes[i][j]; + assert(node_id_eq(&er->pubkey, &r->pubkey)); + assert(er->cltv_expiry_delta == r->cltv_expiry_delta); + assert(short_channel_id_eq(&er->short_channel_id, + &r->short_channel_id)); + assert(er->fee_base_msat == r->fee_base_msat); + assert(er->fee_proportional_millionths + == r->fee_proportional_millionths); + } + } expect_extra = list_top(&expect_b11->extra_fields, struct bolt11_field, list);