| 235 | } |
| 236 | |
| 237 | int main(int argc, char *argv[]) |
| 238 | { |
| 239 | int fd; |
| 240 | char *gossfile; |
| 241 | struct gossmap *map; |
| 242 | struct node_id l1, l2, l3, l4; |
| 243 | struct short_channel_id scid23, scid12, scid_local, scid_nonexisting; |
| 244 | struct gossmap_chan *chan; |
| 245 | struct gossmap_localmods *mods; |
| 246 | struct amount_msat capacity; |
| 247 | u32 timestamp, fee_base_msat, fee_proportional_millionths; |
| 248 | u16 cltv_expiry_delta; |
| 249 | u8 message_flags, channel_flags; |
| 250 | struct amount_msat htlc_minimum_msat, htlc_maximum_msat; |
| 251 | u8 *cann, *nann; |
| 252 | |
| 253 | common_setup(argv[0]); |
| 254 | |
| 255 | fd = tmpdir_mkstemp(tmpctx, "run-gossip_local.XXXXXX", &gossfile); |
| 256 | assert(write_all(fd, canned_map, sizeof(canned_map))); |
| 257 | |
| 258 | map = gossmap_load(tmpctx, gossfile, NULL, NULL); |
| 259 | assert(map); |
| 260 | |
| 261 | /* There is a public channel 2<->3 (103x1x0), and private |
| 262 | * 1<->2 (110x1x1). */ |
| 263 | assert(node_id_from_hexstr("0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518", 66, &l1)); |
| 264 | assert(node_id_from_hexstr("022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59", 66, &l2)); |
| 265 | assert(node_id_from_hexstr("035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d", 66, &l3)); |
| 266 | assert(gossmap_find_node(map, &l1)); |
| 267 | assert(gossmap_find_node(map, &l2)); |
| 268 | assert(gossmap_find_node(map, &l3)); |
| 269 | |
| 270 | assert(short_channel_id_from_str("103x1x0", 7, &scid23)); |
| 271 | assert(short_channel_id_from_str("110x1x0", 7, &scid12)); |
| 272 | assert(gossmap_find_chan(map, &scid23)); |
| 273 | assert(!gossmap_chan_is_localmod(map, gossmap_find_chan(map, &scid23))); |
| 274 | assert(gossmap_find_chan(map, &scid12)); |
| 275 | assert(!gossmap_chan_is_localmod(map, gossmap_find_chan(map, &scid12))); |
| 276 | capacity = gossmap_chan_get_capacity(map, gossmap_find_chan(map, &scid23)); |
| 277 | assert(amount_msat_eq_sat(capacity, AMOUNT_SAT(1000000))); |
| 278 | capacity = gossmap_chan_get_capacity(map, gossmap_find_chan(map, &scid12)); |
| 279 | assert(amount_msat_eq_sat(capacity, AMOUNT_SAT(1000000))); |
| 280 | |
| 281 | gossmap_chan_get_update_details(map, gossmap_find_chan(map, &scid23), |
| 282 | 0, |
| 283 | ×tamp, |
| 284 | &message_flags, |
| 285 | &channel_flags, |
| 286 | &cltv_expiry_delta, |
| 287 | &fee_base_msat, |
| 288 | &fee_proportional_millionths, |
| 289 | &htlc_minimum_msat, |
| 290 | &htlc_maximum_msat); |
| 291 | assert(timestamp == 1700115301); |
| 292 | assert(message_flags == 1); |
| 293 | assert(channel_flags == 0); |
| 294 | assert(cltv_expiry_delta == 6); |
nothing calls this directly
no test coverage detected