diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-09-13 16:30:11 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-09-13 16:38:33 -0400 |
commit | 874eca6a8c318c6a8a913520299e36a2757aa490 (patch) | |
tree | f369aa865378aaba90501c50d7c52064095d977a /src/test/test_bridges.c | |
parent | 97419210945c3430d079f31d15ae55e1b9cd1fcc (diff) | |
download | tor-874eca6a8c318c6a8a913520299e36a2757aa490.tar.gz tor-874eca6a8c318c6a8a913520299e36a2757aa490.zip |
Add a test case with a matching ip but mismatched identity.
Diffstat (limited to 'src/test/test_bridges.c')
-rw-r--r-- | src/test/test_bridges.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/test/test_bridges.c b/src/test/test_bridges.c index 6fcb6fbbb2..1cad5445f4 100644 --- a/src/test/test_bridges.c +++ b/src/test/test_bridges.c @@ -623,13 +623,25 @@ test_bridges_node_is_a_configured_bridge(void *arg) base16_decode(node_with_digest.identity, DIGEST_LEN, fingerprint, HEX_DIGEST_LEN); - tt_assert(node_is_a_configured_bridge(&node_with_digest)); - node_t node_ri_ipv4 = { .ri = &ri_ipv4 }; base16_decode(node_ri_ipv4.identity, DIGEST_LEN, fingerprint2, HEX_DIGEST_LEN); tt_assert(node_is_a_configured_bridge(&node_ri_ipv4)); + /* This will still match bridge0, since bridge0 has no digest set. */ + memset(node_ri_ipv4.identity, 0x3f, DIGEST_LEN); + tt_assert(node_is_a_configured_bridge(&node_ri_ipv4)); + + /* It won't match bridge1, though, since bridge1 has a digest, and this + isn't it! */ + node_ri_ipv4.ri->addr = 0x06060607; + node_ri_ipv4.ri->or_port = 6667; + tt_assert(! node_is_a_configured_bridge(&node_ri_ipv4)); + /* If we set the fingerprint right, though, it will match. */ + base16_decode(node_ri_ipv4.identity, DIGEST_LEN, + "A10C4F666D27364036B562823E5830BC448E046A", HEX_DIGEST_LEN); + tt_assert(node_is_a_configured_bridge(&node_ri_ipv4)); + node_t node_rs_ipv4 = { .rs = &rs_ipv4 }; base16_decode(node_rs_ipv4.identity, DIGEST_LEN, fingerprint2, HEX_DIGEST_LEN); |