diff options
author | Bart Polot <bart@net.in.tum.de> | 2011-10-31 17:12:30 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2011-10-31 17:12:30 +0000 |
commit | 1c468a36db041ad0c0bb0aaf6750f4a6df30d84a (patch) | |
tree | 4639623eebae2fe185826b36263a4a425072ca14 /src/mesh/test_mesh_path_api.c | |
parent | a38370ae1e835d9ad452788ad1fc6424926fe31c (diff) | |
download | gnunet-1c468a36db041ad0c0bb0aaf6750f4a6df30d84a.tar.gz gnunet-1c468a36db041ad0c0bb0aaf6750f4a6df30d84a.zip |
Fixed tree behavior for relay peers, adapted testcase to look for it.
Diffstat (limited to 'src/mesh/test_mesh_path_api.c')
-rw-r--r-- | src/mesh/test_mesh_path_api.c | 48 |
1 files changed, 43 insertions, 5 deletions
diff --git a/src/mesh/test_mesh_path_api.c b/src/mesh/test_mesh_path_api.c index eb3ce57db..e7c2a6fdf 100644 --- a/src/mesh/test_mesh_path_api.c +++ b/src/mesh/test_mesh_path_api.c | |||
@@ -125,7 +125,6 @@ finish(void) | |||
125 | { | 125 | { |
126 | GNUNET_free(pi[i]); | 126 | GNUNET_free(pi[i]); |
127 | } | 127 | } |
128 | tree_destroy(tree); | ||
129 | exit(0); | 128 | exit(0); |
130 | } | 129 | } |
131 | 130 | ||
@@ -244,7 +243,8 @@ main (int argc, char *argv[]) | |||
244 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "test: Destroying node copy...\n"); | 243 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "test: Destroying node copy...\n"); |
245 | GNUNET_free (node2); | 244 | GNUNET_free (node2); |
246 | 245 | ||
247 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "test: Adding new shorter first path...\n"); | 246 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
247 | "test: Adding new shorter first path...\n"); | ||
248 | path->length = 2; | 248 | path->length = 2; |
249 | path->peers[1] = 4; | 249 | path->peers[1] = 4; |
250 | cb_call = 1; | 250 | cb_call = 1; |
@@ -262,15 +262,53 @@ main (int argc, char *argv[]) | |||
262 | test_assert (2, MESH_PEER_RELAY, 1, 0); | 262 | test_assert (2, MESH_PEER_RELAY, 1, 0); |
263 | test_assert (1, MESH_PEER_ROOT, 2, 0); | 263 | test_assert (1, MESH_PEER_ROOT, 2, 0); |
264 | 264 | ||
265 | GNUNET_free (path->peers); | ||
266 | GNUNET_free (path); | ||
267 | tree_destroy (tree); | ||
268 | |||
269 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "test:\n"); | ||
270 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "test: Testing relay trees\n"); | ||
271 | for (i = 0; i < 10; i++) | ||
272 | { | ||
273 | pi[i] = get_pi(i); | ||
274 | GNUNET_break (i + 1 == GNUNET_PEER_intern(pi[i])); | ||
275 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Peer %u: %s\n", | ||
276 | i + 1, | ||
277 | GNUNET_h2s(&pi[i]->hashPubKey)); | ||
278 | } | ||
279 | tree = GNUNET_malloc(sizeof(struct MeshTunnelTree)); | ||
280 | tree->first_hops = GNUNET_CONTAINER_multihashmap_create(32); | ||
281 | tree->root = GNUNET_malloc(sizeof(struct MeshTunnelTreeNode)); | ||
282 | tree->root->peer = 1; | ||
283 | path = path_new (3); | ||
284 | path->peers[0] = 1; | ||
285 | path->peers[1] = 2; | ||
286 | path->peers[2] = 3; | ||
287 | path->length = 3; | ||
288 | |||
289 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "test: Adding first path: 1 2 3\n"); | ||
290 | tree_add_path(tree, path, &cb); | ||
291 | tree_debug(tree); | ||
292 | tree->me = tree_find_peer (tree->root, 2); | ||
293 | |||
294 | test_assert (3, MESH_PEER_SEARCHING, 0, 3); | ||
295 | test_assert (2, MESH_PEER_RELAY, 1, 0); | ||
296 | test_assert (1, MESH_PEER_ROOT, 1, 0); | ||
297 | |||
298 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "test: Adding same path: 1 2 3\n"); | ||
299 | tree_add_path(tree, path, &cb); | ||
300 | |||
301 | GNUNET_free (path->peers); | ||
302 | GNUNET_free (path); | ||
303 | tree_destroy (tree); | ||
304 | |||
265 | if (failed > 0) | 305 | if (failed > 0) |
266 | { | 306 | { |
267 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "%u tests failed\n", failed); | 307 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "%u tests failed\n", failed); |
268 | return 1; | 308 | return 1; |
269 | } | 309 | } |
270 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: OK\n"); | 310 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: OK\n"); |
271 | GNUNET_free (path->peers); | ||
272 | GNUNET_free (path); | ||
273 | finish(); | 311 | finish(); |
274 | 312 | ||
275 | return 0; | 313 | return 0; |
276 | } | 314 | } |