summaryrefslogtreecommitdiff
path: root/src/mesh
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2011-10-27 13:06:23 +0000
committerBart Polot <bart@net.in.tum.de>2011-10-27 13:06:23 +0000
commit0de13c19d7966293b6b7f493c08baaeecb188b02 (patch)
treee8bbbf58b8f4247bc65a1c57e6bddd053ea9963e /src/mesh
parent64d5a91798af32dd3a5183ee5e9ddafcbc376ead (diff)
WiP
Diffstat (limited to 'src/mesh')
-rw-r--r--src/mesh/test_mesh_path_api.c79
1 files changed, 39 insertions, 40 deletions
diff --git a/src/mesh/test_mesh_path_api.c b/src/mesh/test_mesh_path_api.c
index 337ce35de..177250901 100644
--- a/src/mesh/test_mesh_path_api.c
+++ b/src/mesh/test_mesh_path_api.c
@@ -75,7 +75,7 @@ get_pi (uint32_t id)
struct GNUNET_PeerIdentity *pi;
pi = GNUNET_malloc(sizeof(struct GNUNET_PeerIdentity));
- pi->hashPubKey.bits[0] = id;
+ pi->hashPubKey.bits[0] = id + 1;
return pi;
}
@@ -108,20 +108,19 @@ main (int argc, char *argv[])
tree = GNUNET_malloc(sizeof(struct MeshTunnelTree));
tree->first_hops = GNUNET_CONTAINER_multihashmap_create(32);
tree->root = GNUNET_malloc(sizeof(struct MeshTunnelTreeNode));
- tree->root->peer = 0;
+ tree->root->peer = 1;
tree->me = tree->root;
- path = GNUNET_malloc(sizeof(struct MeshPeerPath));
- path->peers = GNUNET_malloc(sizeof(GNUNET_PEER_Id) * 4);
- path->peers[0] = 0;
- path->peers[1] = 1;
- path->peers[2] = 2;
- path->peers[3] = 3;
+ path = path_new (4);
+ path->peers[0] = 1;
+ path->peers[1] = 2;
+ path->peers[2] = 3;
+ path->peers[3] = 4;
path->length = 4;
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "test: Adding first path: 0 1 2 3\n");
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "test: Adding first path: 1 2 3 4\n");
tree_add_path(tree, path, &cb);
tree_debug(tree);
- path1 = tree_get_path_to_peer(tree, 3);
+ path1 = tree_get_path_to_peer(tree, 4);
if (path->length != path1->length ||
memcmp(path->peers, path1->peers, path->length) != 0)
{
@@ -129,8 +128,8 @@ main (int argc, char *argv[])
failed++;
}
path_destroy(path1);
- node = tree_find_peer(tree->root, 3);
- if (node->peer != 3)
+ node = tree_find_peer(tree->root, 4);
+ if (node->peer != 4)
{
GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer != original\n");
failed++;
@@ -140,14 +139,14 @@ main (int argc, char *argv[])
GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong status!\n");
failed++;
}
- if (GNUNET_PEER_search(path_get_first_hop(tree, 3)) != 1)
+ if (GNUNET_PEER_search(path_get_first_hop(tree, 4)) != 2)
{
GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Wrong first hop!\n");
failed++;
}
- node = tree_find_peer(tree->root, 2);
- if (node->peer != 2)
+ node = tree_find_peer(tree->root, 3);
+ if (node->peer != 3)
{
GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer != original\n");
failed++;
@@ -162,14 +161,14 @@ main (int argc, char *argv[])
GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong nchildren!\n");
failed++;
}
- if (GNUNET_PEER_search(path_get_first_hop(tree, 3)) != 1)
+ if (GNUNET_PEER_search(path_get_first_hop(tree, 3)) != 2)
{
GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Wrong first hop!\n");
failed++;
}
- node = tree_find_peer(tree->root, 1);
- if (node->peer != 1)
+ node = tree_find_peer(tree->root, 2);
+ if (node->peer != 2)
{
GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer != original\n");
failed++;
@@ -185,13 +184,13 @@ main (int argc, char *argv[])
failed++;
}
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "test: Adding second path: 0 1 2\n");
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "test: Adding second path: 1 2 3\n");
path->length--;
tree_add_path(tree, path, &cb);
tree_debug(tree);
- node = tree_find_peer(tree->root, 2);
- if (node->peer != 2)
+ node = tree_find_peer(tree->root, 4);
+ if (node->peer != 4)
{
GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer != original\n");
failed++;
@@ -206,21 +205,21 @@ main (int argc, char *argv[])
GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong nchildren!\n");
failed++;
}
- if (GNUNET_PEER_search(path_get_first_hop(tree, 3)) != 1)
+ if (GNUNET_PEER_search(path_get_first_hop(tree, 4)) != 2)
{
GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Wrong first hop!\n");
- GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "3 GOT: %u\n", GNUNET_PEER_search(path_get_first_hop(tree, 3)));
+ GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "4 GOT: %u\n", GNUNET_PEER_search(path_get_first_hop(tree, 4)));
failed++;
}
- if (GNUNET_PEER_search(path_get_first_hop(tree, 2)) != 1)
+ if (GNUNET_PEER_search(path_get_first_hop(tree, 3)) != 2)
{
GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Wrong first hop!\n");
- GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "2 GOT: %u\n", GNUNET_PEER_search(path_get_first_hop(tree, 2)));
+ GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "3 GOT: %u\n", GNUNET_PEER_search(path_get_first_hop(tree, 3)));
failed++;
}
- node = tree_find_peer(tree->root, 1);
- if (node->peer != 1)
+ node = tree_find_peer(tree->root, 2);
+ if (node->peer != 2)
{
GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer != original\n");
failed++;
@@ -238,12 +237,12 @@ main (int argc, char *argv[])
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "test: Adding third path...\n");
path->length++;
- path->peers[3] = 4;
+ path->peers[3] = 5;
tree_add_path(tree, path, &cb);
tree_debug(tree);
- node = tree_find_peer(tree->root, 2);
- if (node->peer != 2)
+ node = tree_find_peer(tree->root, 3);
+ if (node->peer != 3)
{
GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer != original\n");
failed++;
@@ -258,19 +257,19 @@ main (int argc, char *argv[])
GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong nchildren!\n");
failed++;
}
- if (GNUNET_PEER_search(path_get_first_hop(tree, 3)) != 1)
+ if (GNUNET_PEER_search(path_get_first_hop(tree, 3)) != 2)
{
GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Wrong first hop!\n");
failed++;
}
- if (GNUNET_PEER_search(path_get_first_hop(tree, 4)) != 1)
+ if (GNUNET_PEER_search(path_get_first_hop(tree, 4)) != 2)
{
GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Wrong first hop!\n");
failed++;
}
- node = tree_find_peer(tree->root, 1);
- if (node->peer != 1)
+ node = tree_find_peer(tree->root, 2);
+ if (node->peer != 2)
{
GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer != original\n");
failed++;
@@ -286,8 +285,8 @@ main (int argc, char *argv[])
failed++;
}
- node = tree_find_peer(tree->root, 4);
- if (node->peer != 4)
+ node = tree_find_peer(tree->root, 5);
+ if (node->peer != 5)
{
GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer != original\n");
failed++;
@@ -296,21 +295,21 @@ main (int argc, char *argv[])
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "test: Deleting third path...\n");
node->status = MESH_PEER_READY;
cb_call = 1;
- node2 = tree_del_path(tree, 4, &cb);
+ node2 = tree_del_path(tree, 5, &cb);
tree_debug(tree);
if (cb_call != 0)
{
GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "%u callbacks missed!\n", cb_call);
failed++;
}
- if (node2->peer != 4)
+ if (node2->peer != 5)
{
GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer != original\n");
failed++;
}
- node = tree_find_peer(tree->root, 2);
- if (node->peer != 2)
+ node = tree_find_peer(tree->root, 3);
+ if (node->peer != 3)
{
GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer != original\n");
failed++;