aboutsummaryrefslogtreecommitdiff
path: root/src/mesh/test_mesh_path_api.c
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/test_mesh_path_api.c
parent64d5a91798af32dd3a5183ee5e9ddafcbc376ead (diff)
downloadgnunet-0de13c19d7966293b6b7f493c08baaeecb188b02.tar.gz
gnunet-0de13c19d7966293b6b7f493c08baaeecb188b02.zip
WiP
Diffstat (limited to 'src/mesh/test_mesh_path_api.c')
-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)
75 struct GNUNET_PeerIdentity *pi; 75 struct GNUNET_PeerIdentity *pi;
76 76
77 pi = GNUNET_malloc(sizeof(struct GNUNET_PeerIdentity)); 77 pi = GNUNET_malloc(sizeof(struct GNUNET_PeerIdentity));
78 pi->hashPubKey.bits[0] = id; 78 pi->hashPubKey.bits[0] = id + 1;
79 return pi; 79 return pi;
80} 80}
81 81
@@ -108,20 +108,19 @@ main (int argc, char *argv[])
108 tree = GNUNET_malloc(sizeof(struct MeshTunnelTree)); 108 tree = GNUNET_malloc(sizeof(struct MeshTunnelTree));
109 tree->first_hops = GNUNET_CONTAINER_multihashmap_create(32); 109 tree->first_hops = GNUNET_CONTAINER_multihashmap_create(32);
110 tree->root = GNUNET_malloc(sizeof(struct MeshTunnelTreeNode)); 110 tree->root = GNUNET_malloc(sizeof(struct MeshTunnelTreeNode));
111 tree->root->peer = 0; 111 tree->root->peer = 1;
112 tree->me = tree->root; 112 tree->me = tree->root;
113 path = GNUNET_malloc(sizeof(struct MeshPeerPath)); 113 path = path_new (4);
114 path->peers = GNUNET_malloc(sizeof(GNUNET_PEER_Id) * 4); 114 path->peers[0] = 1;
115 path->peers[0] = 0; 115 path->peers[1] = 2;
116 path->peers[1] = 1; 116 path->peers[2] = 3;
117 path->peers[2] = 2; 117 path->peers[3] = 4;
118 path->peers[3] = 3;
119 path->length = 4; 118 path->length = 4;
120 119
121 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "test: Adding first path: 0 1 2 3\n"); 120 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "test: Adding first path: 1 2 3 4\n");
122 tree_add_path(tree, path, &cb); 121 tree_add_path(tree, path, &cb);
123 tree_debug(tree); 122 tree_debug(tree);
124 path1 = tree_get_path_to_peer(tree, 3); 123 path1 = tree_get_path_to_peer(tree, 4);
125 if (path->length != path1->length || 124 if (path->length != path1->length ||
126 memcmp(path->peers, path1->peers, path->length) != 0) 125 memcmp(path->peers, path1->peers, path->length) != 0)
127 { 126 {
@@ -129,8 +128,8 @@ main (int argc, char *argv[])
129 failed++; 128 failed++;
130 } 129 }
131 path_destroy(path1); 130 path_destroy(path1);
132 node = tree_find_peer(tree->root, 3); 131 node = tree_find_peer(tree->root, 4);
133 if (node->peer != 3) 132 if (node->peer != 4)
134 { 133 {
135 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer != original\n"); 134 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer != original\n");
136 failed++; 135 failed++;
@@ -140,14 +139,14 @@ main (int argc, char *argv[])
140 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong status!\n"); 139 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong status!\n");
141 failed++; 140 failed++;
142 } 141 }
143 if (GNUNET_PEER_search(path_get_first_hop(tree, 3)) != 1) 142 if (GNUNET_PEER_search(path_get_first_hop(tree, 4)) != 2)
144 { 143 {
145 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Wrong first hop!\n"); 144 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Wrong first hop!\n");
146 failed++; 145 failed++;
147 } 146 }
148 147
149 node = tree_find_peer(tree->root, 2); 148 node = tree_find_peer(tree->root, 3);
150 if (node->peer != 2) 149 if (node->peer != 3)
151 { 150 {
152 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer != original\n"); 151 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer != original\n");
153 failed++; 152 failed++;
@@ -162,14 +161,14 @@ main (int argc, char *argv[])
162 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong nchildren!\n"); 161 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong nchildren!\n");
163 failed++; 162 failed++;
164 } 163 }
165 if (GNUNET_PEER_search(path_get_first_hop(tree, 3)) != 1) 164 if (GNUNET_PEER_search(path_get_first_hop(tree, 3)) != 2)
166 { 165 {
167 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Wrong first hop!\n"); 166 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Wrong first hop!\n");
168 failed++; 167 failed++;
169 } 168 }
170 169
171 node = tree_find_peer(tree->root, 1); 170 node = tree_find_peer(tree->root, 2);
172 if (node->peer != 1) 171 if (node->peer != 2)
173 { 172 {
174 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer != original\n"); 173 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer != original\n");
175 failed++; 174 failed++;
@@ -185,13 +184,13 @@ main (int argc, char *argv[])
185 failed++; 184 failed++;
186 } 185 }
187 186
188 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "test: Adding second path: 0 1 2\n"); 187 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "test: Adding second path: 1 2 3\n");
189 path->length--; 188 path->length--;
190 tree_add_path(tree, path, &cb); 189 tree_add_path(tree, path, &cb);
191 tree_debug(tree); 190 tree_debug(tree);
192 191
193 node = tree_find_peer(tree->root, 2); 192 node = tree_find_peer(tree->root, 4);
194 if (node->peer != 2) 193 if (node->peer != 4)
195 { 194 {
196 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer != original\n"); 195 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer != original\n");
197 failed++; 196 failed++;
@@ -206,21 +205,21 @@ main (int argc, char *argv[])
206 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong nchildren!\n"); 205 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong nchildren!\n");
207 failed++; 206 failed++;
208 } 207 }
209 if (GNUNET_PEER_search(path_get_first_hop(tree, 3)) != 1) 208 if (GNUNET_PEER_search(path_get_first_hop(tree, 4)) != 2)
210 { 209 {
211 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Wrong first hop!\n"); 210 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Wrong first hop!\n");
212 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "3 GOT: %u\n", GNUNET_PEER_search(path_get_first_hop(tree, 3))); 211 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "4 GOT: %u\n", GNUNET_PEER_search(path_get_first_hop(tree, 4)));
213 failed++; 212 failed++;
214 } 213 }
215 if (GNUNET_PEER_search(path_get_first_hop(tree, 2)) != 1) 214 if (GNUNET_PEER_search(path_get_first_hop(tree, 3)) != 2)
216 { 215 {
217 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Wrong first hop!\n"); 216 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Wrong first hop!\n");
218 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "2 GOT: %u\n", GNUNET_PEER_search(path_get_first_hop(tree, 2))); 217 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "3 GOT: %u\n", GNUNET_PEER_search(path_get_first_hop(tree, 3)));
219 failed++; 218 failed++;
220 } 219 }
221 220
222 node = tree_find_peer(tree->root, 1); 221 node = tree_find_peer(tree->root, 2);
223 if (node->peer != 1) 222 if (node->peer != 2)
224 { 223 {
225 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer != original\n"); 224 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer != original\n");
226 failed++; 225 failed++;
@@ -238,12 +237,12 @@ main (int argc, char *argv[])
238 237
239 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "test: Adding third path...\n"); 238 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "test: Adding third path...\n");
240 path->length++; 239 path->length++;
241 path->peers[3] = 4; 240 path->peers[3] = 5;
242 tree_add_path(tree, path, &cb); 241 tree_add_path(tree, path, &cb);
243 tree_debug(tree); 242 tree_debug(tree);
244 243
245 node = tree_find_peer(tree->root, 2); 244 node = tree_find_peer(tree->root, 3);
246 if (node->peer != 2) 245 if (node->peer != 3)
247 { 246 {
248 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer != original\n"); 247 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer != original\n");
249 failed++; 248 failed++;
@@ -258,19 +257,19 @@ main (int argc, char *argv[])
258 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong nchildren!\n"); 257 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong nchildren!\n");
259 failed++; 258 failed++;
260 } 259 }
261 if (GNUNET_PEER_search(path_get_first_hop(tree, 3)) != 1) 260 if (GNUNET_PEER_search(path_get_first_hop(tree, 3)) != 2)
262 { 261 {
263 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Wrong first hop!\n"); 262 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Wrong first hop!\n");
264 failed++; 263 failed++;
265 } 264 }
266 if (GNUNET_PEER_search(path_get_first_hop(tree, 4)) != 1) 265 if (GNUNET_PEER_search(path_get_first_hop(tree, 4)) != 2)
267 { 266 {
268 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Wrong first hop!\n"); 267 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Wrong first hop!\n");
269 failed++; 268 failed++;
270 } 269 }
271 270
272 node = tree_find_peer(tree->root, 1); 271 node = tree_find_peer(tree->root, 2);
273 if (node->peer != 1) 272 if (node->peer != 2)
274 { 273 {
275 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer != original\n"); 274 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer != original\n");
276 failed++; 275 failed++;
@@ -286,8 +285,8 @@ main (int argc, char *argv[])
286 failed++; 285 failed++;
287 } 286 }
288 287
289 node = tree_find_peer(tree->root, 4); 288 node = tree_find_peer(tree->root, 5);
290 if (node->peer != 4) 289 if (node->peer != 5)
291 { 290 {
292 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer != original\n"); 291 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer != original\n");
293 failed++; 292 failed++;
@@ -296,21 +295,21 @@ main (int argc, char *argv[])
296 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "test: Deleting third path...\n"); 295 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "test: Deleting third path...\n");
297 node->status = MESH_PEER_READY; 296 node->status = MESH_PEER_READY;
298 cb_call = 1; 297 cb_call = 1;
299 node2 = tree_del_path(tree, 4, &cb); 298 node2 = tree_del_path(tree, 5, &cb);
300 tree_debug(tree); 299 tree_debug(tree);
301 if (cb_call != 0) 300 if (cb_call != 0)
302 { 301 {
303 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "%u callbacks missed!\n", cb_call); 302 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "%u callbacks missed!\n", cb_call);
304 failed++; 303 failed++;
305 } 304 }
306 if (node2->peer != 4) 305 if (node2->peer != 5)
307 { 306 {
308 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer != original\n"); 307 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer != original\n");
309 failed++; 308 failed++;
310 } 309 }
311 310
312 node = tree_find_peer(tree->root, 2); 311 node = tree_find_peer(tree->root, 3);
313 if (node->peer != 2) 312 if (node->peer != 3)
314 { 313 {
315 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer != original\n"); 314 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer != original\n");
316 failed++; 315 failed++;