mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 07:34:24 +01:00
Assert our parse_wireaddr assumptions in run-ip_port_parsing.c
We assume that the parse_wireaddr(...) calls return true. Otherwise addr.port will be uninitialized.
This commit is contained in:
committed by
Christian Decker
parent
b2f7e9af4a
commit
0eff28c80f
@@ -73,17 +73,17 @@ int main(void)
|
|||||||
assert(!separate_address_and_port(tmpctx, "[::1]:http", &ip, &port));
|
assert(!separate_address_and_port(tmpctx, "[::1]:http", &ip, &port));
|
||||||
|
|
||||||
// localhost hostnames for backward compat
|
// localhost hostnames for backward compat
|
||||||
parse_wireaddr("localhost", &addr, 200, NULL);
|
assert(parse_wireaddr("localhost", &addr, 200, NULL));
|
||||||
assert(addr.port == 200);
|
assert(addr.port == 200);
|
||||||
|
|
||||||
// string should win the port battle
|
// string should win the port battle
|
||||||
parse_wireaddr("[::1]:9735", &addr, 500, NULL);
|
assert(parse_wireaddr("[::1]:9735", &addr, 500, NULL));
|
||||||
assert(addr.port == 9735);
|
assert(addr.port == 9735);
|
||||||
ip = fmt_wireaddr(tmpctx, &addr);
|
ip = fmt_wireaddr(tmpctx, &addr);
|
||||||
assert(streq(ip, "[::1]:9735"));
|
assert(streq(ip, "[::1]:9735"));
|
||||||
|
|
||||||
// should use argument if we have no port in string
|
// should use argument if we have no port in string
|
||||||
parse_wireaddr("2001:db8:85a3::8a2e:370:7334", &addr, 9777, NULL);
|
assert(parse_wireaddr("2001:db8:85a3::8a2e:370:7334", &addr, 9777, NULL));
|
||||||
assert(addr.port == 9777);
|
assert(addr.port == 9777);
|
||||||
|
|
||||||
ip = fmt_wireaddr(tmpctx, &addr);
|
ip = fmt_wireaddr(tmpctx, &addr);
|
||||||
|
|||||||
Reference in New Issue
Block a user