Browse Source

Add a test case with a matching ip but mismatched identity.

Nick Mathewson 5 years ago
parent
commit
874eca6a8c
1 changed files with 14 additions and 2 deletions
  1. 14 2
      src/test/test_bridges.c

+ 14 - 2
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);