diff options
Diffstat (limited to 'src/mesh')
-rw-r--r-- | src/mesh/gnunet-service-mesh.c | 4 | ||||
-rw-r--r-- | src/mesh/mesh_api_new.c | 1 | ||||
-rw-r--r-- | src/mesh/test_mesh_small.c | 240 | ||||
-rw-r--r-- | src/mesh/test_mesh_small.conf | 4 |
4 files changed, 168 insertions, 81 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c index 0f2bbe3cf..8d37ae7ab 100644 --- a/src/mesh/gnunet-service-mesh.c +++ b/src/mesh/gnunet-service-mesh.c | |||
@@ -1238,6 +1238,9 @@ peer_info_connect (struct MeshPeerInfo *peer, struct MeshTunnel *t) | |||
1238 | path_info = GNUNET_malloc(sizeof(struct MeshPathInfo)); | 1238 | path_info = GNUNET_malloc(sizeof(struct MeshPathInfo)); |
1239 | path_info->peer = peer; | 1239 | path_info->peer = peer; |
1240 | path_info->t = t; | 1240 | path_info->t = t; |
1241 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1242 | "MESH: Starting DHT GET for peer %s\n", | ||
1243 | GNUNET_i2s (&id)); | ||
1241 | peer->dhtget = | 1244 | peer->dhtget = |
1242 | GNUNET_DHT_get_start(dht_handle, /* handle */ | 1245 | GNUNET_DHT_get_start(dht_handle, /* handle */ |
1243 | GNUNET_TIME_UNIT_FOREVER_REL, /* timeout */ | 1246 | GNUNET_TIME_UNIT_FOREVER_REL, /* timeout */ |
@@ -1297,6 +1300,7 @@ tunnel_notify_connection_broken (struct MeshTunnel *t, | |||
1297 | struct MeshPeerInfo *peer, GNUNET_PEER_Id p1, | 1300 | struct MeshPeerInfo *peer, GNUNET_PEER_Id p1, |
1298 | GNUNET_PEER_Id p2); | 1301 | GNUNET_PEER_Id p2); |
1299 | 1302 | ||
1303 | |||
1300 | /** | 1304 | /** |
1301 | * Remove all paths that rely on a direct connection between p1 and p2 | 1305 | * Remove all paths that rely on a direct connection between p1 and p2 |
1302 | * from the peer itself and notify all tunnels about it. | 1306 | * from the peer itself and notify all tunnels about it. |
diff --git a/src/mesh/mesh_api_new.c b/src/mesh/mesh_api_new.c index 81933e858..7c45cd7b8 100644 --- a/src/mesh/mesh_api_new.c +++ b/src/mesh/mesh_api_new.c | |||
@@ -1347,6 +1347,7 @@ GNUNET_MESH_peer_request_connect_add (struct GNUNET_MESH_Tunnel *tunnel, | |||
1347 | { | 1347 | { |
1348 | if (tunnel->peers[i]->id == peer_id) | 1348 | if (tunnel->peers[i]->id == peer_id) |
1349 | { | 1349 | { |
1350 | /* Peer already exists in tunnel */ | ||
1350 | GNUNET_PEER_change_rc (peer_id, -1); | 1351 | GNUNET_PEER_change_rc (peer_id, -1); |
1351 | GNUNET_break (0); | 1352 | GNUNET_break (0); |
1352 | return; | 1353 | return; |
diff --git a/src/mesh/test_mesh_small.c b/src/mesh/test_mesh_small.c index 9fe2c1292..1cb9d6181 100644 --- a/src/mesh/test_mesh_small.c +++ b/src/mesh/test_mesh_small.c | |||
@@ -55,7 +55,7 @@ struct StatsContext | |||
55 | /** | 55 | /** |
56 | * Time to wait for stuff that should be rather fast | 56 | * Time to wait for stuff that should be rather fast |
57 | */ | 57 | */ |
58 | #define SHORT_TIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) | 58 | #define SHORT_TIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) |
59 | 59 | ||
60 | /** | 60 | /** |
61 | * DIFFERENT TESTS TO RUN | 61 | * DIFFERENT TESTS TO RUN |
@@ -74,6 +74,10 @@ static int test; | |||
74 | */ | 74 | */ |
75 | static int ok; | 75 | static int ok; |
76 | 76 | ||
77 | static int peers_in_tunnel; | ||
78 | |||
79 | static int peers_responded; | ||
80 | |||
77 | /** | 81 | /** |
78 | * Be verbose | 82 | * Be verbose |
79 | */ | 83 | */ |
@@ -144,14 +148,20 @@ static GNUNET_PEER_Id pid1; | |||
144 | 148 | ||
145 | static struct GNUNET_TESTING_Daemon *d2; | 149 | static struct GNUNET_TESTING_Daemon *d2; |
146 | 150 | ||
151 | static struct GNUNET_TESTING_Daemon *d3; | ||
152 | |||
147 | static struct GNUNET_MESH_Handle *h1; | 153 | static struct GNUNET_MESH_Handle *h1; |
148 | 154 | ||
149 | static struct GNUNET_MESH_Handle *h2; | 155 | static struct GNUNET_MESH_Handle *h2; |
150 | 156 | ||
157 | static struct GNUNET_MESH_Handle *h3; | ||
158 | |||
151 | static struct GNUNET_MESH_Tunnel *t; | 159 | static struct GNUNET_MESH_Tunnel *t; |
152 | 160 | ||
153 | static struct GNUNET_MESH_Tunnel *incoming_t; | 161 | static struct GNUNET_MESH_Tunnel *incoming_t; |
154 | 162 | ||
163 | static struct GNUNET_MESH_Tunnel *incoming_t2; | ||
164 | |||
155 | static uint16_t *mesh_peers; | 165 | static uint16_t *mesh_peers; |
156 | 166 | ||
157 | /** | 167 | /** |
@@ -163,14 +173,14 @@ shutdown_callback (void *cls, const char *emsg) | |||
163 | if (emsg != NULL) | 173 | if (emsg != NULL) |
164 | { | 174 | { |
165 | #if VERBOSE | 175 | #if VERBOSE |
166 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: Shutdown of peers failed!\n"); | 176 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "***************** test: Shutdown of peers failed!\n"); |
167 | #endif | 177 | #endif |
168 | ok--; | 178 | ok--; |
169 | } | 179 | } |
170 | else | 180 | else |
171 | { | 181 | { |
172 | #if VERBOSE | 182 | #if VERBOSE |
173 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: All peers successfully shut down!\n"); | 183 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "***************** test: All peers successfully shut down!\n"); |
174 | #endif | 184 | #endif |
175 | } | 185 | } |
176 | } | 186 | } |
@@ -180,7 +190,7 @@ static void | |||
180 | shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 190 | shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
181 | { | 191 | { |
182 | #if VERBOSE | 192 | #if VERBOSE |
183 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: Ending test.\n"); | 193 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "***************** test: Ending test.\n"); |
184 | #endif | 194 | #endif |
185 | 195 | ||
186 | if (disconnect_task != GNUNET_SCHEDULER_NO_TASK) | 196 | if (disconnect_task != GNUNET_SCHEDULER_NO_TASK) |
@@ -200,12 +210,17 @@ static void | |||
200 | disconnect_mesh_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 210 | disconnect_mesh_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
201 | { | 211 | { |
202 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 212 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
203 | "test: disconnecting mesh service of peers\n"); | 213 | "***************** test: disconnecting mesh service of peers\n"); |
204 | disconnect_task = GNUNET_SCHEDULER_NO_TASK; | 214 | disconnect_task = GNUNET_SCHEDULER_NO_TASK; |
205 | GNUNET_MESH_disconnect(h1); | 215 | GNUNET_MESH_disconnect(h1); |
206 | GNUNET_MESH_disconnect(h2); | 216 | GNUNET_MESH_disconnect(h2); |
207 | GNUNET_SCHEDULER_cancel (shutdown_handle); | 217 | if (test == MULTICAST) |
208 | shutdown_handle = GNUNET_SCHEDULER_add_now(&shutdown_task, NULL); | 218 | GNUNET_MESH_disconnect(h3); |
219 | if (GNUNET_SCHEDULER_NO_TASK != shutdown_handle) | ||
220 | { | ||
221 | GNUNET_SCHEDULER_cancel (shutdown_handle); | ||
222 | shutdown_handle = GNUNET_SCHEDULER_add_now(&shutdown_task, NULL); | ||
223 | } | ||
209 | } | 224 | } |
210 | 225 | ||
211 | 226 | ||
@@ -217,7 +232,7 @@ tmt_rdy (void *cls, size_t size, void *buf) | |||
217 | { | 232 | { |
218 | struct GNUNET_MessageHeader *msg = buf; | 233 | struct GNUNET_MessageHeader *msg = buf; |
219 | 234 | ||
220 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: tmt_rdy called\n"); | 235 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "***************** test: tmt_rdy called\n"); |
221 | if (size < sizeof(struct GNUNET_MessageHeader) || NULL == buf) | 236 | if (size < sizeof(struct GNUNET_MessageHeader) || NULL == buf) |
222 | return 0; | 237 | return 0; |
223 | msg->size = htons (sizeof(struct GNUNET_MessageHeader)); | 238 | msg->size = htons (sizeof(struct GNUNET_MessageHeader)); |
@@ -252,19 +267,27 @@ data_callback (void *cls, | |||
252 | { | 267 | { |
253 | case 1L: | 268 | case 1L: |
254 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 269 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
255 | "test: Origin client got a response!\n"); | 270 | "***************** test: Origin client got a response!\n"); |
256 | ok++; | 271 | ok++; |
257 | GNUNET_MESH_tunnel_destroy (tunnel); | 272 | peers_responded++; |
258 | GNUNET_SCHEDULER_cancel (disconnect_task); | 273 | if (GNUNET_SCHEDULER_NO_TASK != disconnect_task) |
259 | disconnect_task = GNUNET_SCHEDULER_add_delayed(SHORT_TIME, | 274 | { |
275 | GNUNET_SCHEDULER_cancel (disconnect_task); | ||
276 | disconnect_task = GNUNET_SCHEDULER_add_delayed(SHORT_TIME, | ||
260 | &disconnect_mesh_peers, | 277 | &disconnect_mesh_peers, |
261 | NULL); | 278 | NULL); |
279 | } | ||
280 | if (test == MULTICAST && peers_responded < 2) | ||
281 | return GNUNET_OK; | ||
282 | GNUNET_MESH_tunnel_destroy (tunnel); | ||
262 | break; | 283 | break; |
263 | case 2L: | 284 | case 2L: |
285 | case 3L: | ||
264 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 286 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
265 | "test: Destination client got a message \n"); | 287 | "***************** test: Destination client %u got a message.\n", |
288 | client); | ||
266 | ok++; | 289 | ok++; |
267 | GNUNET_MESH_notify_transmit_ready(incoming_t, | 290 | GNUNET_MESH_notify_transmit_ready(tunnel, |
268 | GNUNET_NO, | 291 | GNUNET_NO, |
269 | 0, | 292 | 0, |
270 | GNUNET_TIME_UNIT_FOREVER_REL, | 293 | GNUNET_TIME_UNIT_FOREVER_REL, |
@@ -272,10 +295,13 @@ data_callback (void *cls, | |||
272 | sizeof(struct GNUNET_MessageHeader), | 295 | sizeof(struct GNUNET_MessageHeader), |
273 | &tmt_rdy, | 296 | &tmt_rdy, |
274 | (void *) 1L); | 297 | (void *) 1L); |
275 | GNUNET_SCHEDULER_cancel (disconnect_task); | 298 | if (GNUNET_SCHEDULER_NO_TASK != disconnect_task) |
276 | disconnect_task = GNUNET_SCHEDULER_add_delayed(SHORT_TIME, | 299 | { |
277 | &disconnect_mesh_peers, | 300 | GNUNET_SCHEDULER_cancel (disconnect_task); |
278 | NULL); | 301 | disconnect_task = GNUNET_SCHEDULER_add_delayed(SHORT_TIME, |
302 | &disconnect_mesh_peers, | ||
303 | NULL); | ||
304 | } | ||
279 | break; | 305 | break; |
280 | default: | 306 | default: |
281 | break; | 307 | break; |
@@ -311,14 +337,21 @@ incoming_tunnel (void *cls, | |||
311 | const struct GNUNET_ATS_Information * atsi) | 337 | const struct GNUNET_ATS_Information * atsi) |
312 | { | 338 | { |
313 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 339 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
314 | "test: Incoming tunnel from %s\n", | 340 | "***************** test: Incoming tunnel from %s to peer %d\n", |
315 | GNUNET_i2s(initiator)); | 341 | GNUNET_i2s(initiator), |
342 | (long) cls); | ||
316 | ok++; | 343 | ok++; |
317 | incoming_t = tunnel; | 344 | if ((long) cls == 1L) |
318 | GNUNET_SCHEDULER_cancel (disconnect_task); | 345 | incoming_t = tunnel; |
319 | disconnect_task = GNUNET_SCHEDULER_add_delayed(SHORT_TIME, | 346 | else |
320 | &disconnect_mesh_peers, | 347 | incoming_t2 = tunnel; |
321 | NULL); | 348 | if (GNUNET_SCHEDULER_NO_TASK != disconnect_task) |
349 | { | ||
350 | GNUNET_SCHEDULER_cancel (disconnect_task); | ||
351 | disconnect_task = GNUNET_SCHEDULER_add_delayed(SHORT_TIME, | ||
352 | &disconnect_mesh_peers, | ||
353 | NULL); | ||
354 | } | ||
322 | return NULL; | 355 | return NULL; |
323 | } | 356 | } |
324 | 357 | ||
@@ -338,14 +371,26 @@ tunnel_cleaner (void *cls, const struct GNUNET_MESH_Tunnel *tunnel, | |||
338 | long i = (long) cls; | 371 | long i = (long) cls; |
339 | 372 | ||
340 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 373 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
341 | "test: Incoming tunnel disconnected at peer %d\n", | 374 | "***************** test: Incoming tunnel disconnected at peer %d\n", |
342 | i); | 375 | i); |
343 | if (2L == i) | 376 | if (2L == i) |
344 | ok++; | 377 | ok++; |
345 | 378 | else if (3L == i) | |
346 | GNUNET_SCHEDULER_cancel (disconnect_task); | 379 | ok++; |
347 | disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_mesh_peers, NULL); | 380 | else |
348 | 381 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | |
382 | "***************** test: Unknown peer! %d\n", | ||
383 | i); | ||
384 | peers_in_tunnel--; | ||
385 | if (peers_in_tunnel > 0) | ||
386 | return; | ||
387 | |||
388 | if (GNUNET_SCHEDULER_NO_TASK != disconnect_task) | ||
389 | { | ||
390 | GNUNET_SCHEDULER_cancel (disconnect_task); | ||
391 | disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_mesh_peers, NULL); | ||
392 | } | ||
393 | |||
349 | return; | 394 | return; |
350 | } | 395 | } |
351 | 396 | ||
@@ -360,7 +405,7 @@ static void | |||
360 | dh (void *cls, const struct GNUNET_PeerIdentity *peer) | 405 | dh (void *cls, const struct GNUNET_PeerIdentity *peer) |
361 | { | 406 | { |
362 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 407 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
363 | "test: peer %s disconnected\n", | 408 | "***************** test: peer %s disconnected\n", |
364 | GNUNET_i2s(peer)); | 409 | GNUNET_i2s(peer)); |
365 | return; | 410 | return; |
366 | } | 411 | } |
@@ -379,30 +424,39 @@ ch (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
379 | { | 424 | { |
380 | struct GNUNET_PeerIdentity *dest; | 425 | struct GNUNET_PeerIdentity *dest; |
381 | 426 | ||
427 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
428 | "***************** test: peer %s connected\n", | ||
429 | GNUNET_i2s(peer)); | ||
430 | |||
431 | if (0 == memcmp(&d2->id, peer, sizeof(d2->id)) && (long) cls == 1L) | ||
432 | ok++; | ||
433 | if (test == MULTICAST && | ||
434 | 0 == memcmp(&d3->id, peer, sizeof(d3->id)) && | ||
435 | (long) cls == 1L) | ||
436 | ok++; | ||
382 | switch (test) | 437 | switch (test) |
383 | { | 438 | { |
384 | case UNICAST: | 439 | case UNICAST: |
385 | dest = &d2->id; | 440 | dest = &d2->id; |
386 | break; | 441 | break; |
387 | case MULTICAST: | 442 | case MULTICAST: |
443 | peers_in_tunnel++; | ||
444 | if (peers_in_tunnel < 2) | ||
445 | return; | ||
388 | dest = NULL; | 446 | dest = NULL; |
389 | break; | 447 | break; |
390 | default: | 448 | default: |
391 | return; | 449 | return; |
392 | } | 450 | } |
393 | |||
394 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
395 | "test: peer %s connected\n", | ||
396 | GNUNET_i2s(peer)); | ||
397 | if (0 == memcmp(&d2->id, peer, sizeof(d2->id)) && (long) cls == 1L) | ||
398 | ok++; | ||
399 | if (GNUNET_SCHEDULER_NO_TASK != disconnect_task) | 451 | if (GNUNET_SCHEDULER_NO_TASK != disconnect_task) |
400 | { | 452 | { |
401 | GNUNET_SCHEDULER_cancel (disconnect_task); | 453 | GNUNET_SCHEDULER_cancel (disconnect_task); |
402 | disconnect_task = GNUNET_SCHEDULER_add_delayed(SHORT_TIME, | 454 | disconnect_task = GNUNET_SCHEDULER_add_delayed(SHORT_TIME, |
403 | &disconnect_mesh_peers, | 455 | &disconnect_mesh_peers, |
404 | NULL); | 456 | NULL); |
405 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: Sending data...\n"); | 457 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
458 | "***************** test: Sending data...\n"); | ||
459 | peers_responded = 0; | ||
406 | GNUNET_MESH_notify_transmit_ready(t, | 460 | GNUNET_MESH_notify_transmit_ready(t, |
407 | GNUNET_NO, | 461 | GNUNET_NO, |
408 | 0, | 462 | 0, |
@@ -414,8 +468,8 @@ ch (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
414 | } | 468 | } |
415 | else | 469 | else |
416 | { | 470 | { |
417 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: Disconnect already run?\n"); | 471 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "***************** test: Disconnect already run?\n"); |
418 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: Aborting...\n"); | 472 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "***************** test: Aborting...\n"); |
419 | } | 473 | } |
420 | return; | 474 | return; |
421 | } | 475 | } |
@@ -424,12 +478,20 @@ ch (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
424 | static void | 478 | static void |
425 | do_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 479 | do_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
426 | { | 480 | { |
427 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: test_task\n"); | 481 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "***************** test: test_task\n"); |
428 | GNUNET_MESH_peer_request_connect_add(t, &d2->id); | 482 | GNUNET_MESH_peer_request_connect_add(t, &d2->id); |
429 | GNUNET_SCHEDULER_cancel (disconnect_task); | 483 | if (test == MULTICAST) |
430 | disconnect_task = GNUNET_SCHEDULER_add_delayed( | 484 | { |
431 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30), | 485 | GNUNET_MESH_peer_request_connect_add(t, &d3->id); |
432 | &disconnect_mesh_peers, NULL); | 486 | } |
487 | if (GNUNET_SCHEDULER_NO_TASK != disconnect_task) | ||
488 | { | ||
489 | GNUNET_SCHEDULER_cancel (disconnect_task); | ||
490 | disconnect_task = GNUNET_SCHEDULER_add_delayed( | ||
491 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30), | ||
492 | &disconnect_mesh_peers, | ||
493 | NULL); | ||
494 | } | ||
433 | } | 495 | } |
434 | 496 | ||
435 | 497 | ||
@@ -462,7 +524,7 @@ topo_cb (void *cls, | |||
462 | GNUNET_assert(p2 > 0); | 524 | GNUNET_assert(p2 > 0); |
463 | mesh_peers[p2]++; | 525 | mesh_peers[p2]++; |
464 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 526 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
465 | "test: %s IS a neighbor\n", | 527 | "***************** test: %s IS a neighbor\n", |
466 | GNUNET_i2s(second)); | 528 | GNUNET_i2s(second)); |
467 | return; | 529 | return; |
468 | } | 530 | } |
@@ -474,7 +536,7 @@ topo_cb (void *cls, | |||
474 | GNUNET_assert(p2 > 0); | 536 | GNUNET_assert(p2 > 0); |
475 | mesh_peers[p2]++; | 537 | mesh_peers[p2]++; |
476 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 538 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
477 | "test: %s IS a neighbor\n", | 539 | "***************** test: %s IS a neighbor\n", |
478 | GNUNET_i2s(first)); | 540 | GNUNET_i2s(first)); |
479 | return; | 541 | return; |
480 | } | 542 | } |
@@ -491,13 +553,13 @@ connect_mesh_service (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
491 | unsigned int i; | 553 | unsigned int i; |
492 | struct GNUNET_PeerIdentity id; | 554 | struct GNUNET_PeerIdentity id; |
493 | 555 | ||
494 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: connect_mesh_service\n"); | 556 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "***************** test: connect_mesh_service\n"); |
495 | 557 | ||
496 | for (i = 1; i <= num_peers; i++) | 558 | for (i = 1; i <= num_peers; i++) |
497 | { | 559 | { |
498 | GNUNET_PEER_resolve(i, &id); | 560 | GNUNET_PEER_resolve(i, &id); |
499 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 561 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
500 | "test: peer %s has %u conns to d1\n", | 562 | "***************** test: peer %s has %u conns to d1\n", |
501 | GNUNET_i2s (&id), | 563 | GNUNET_i2s (&id), |
502 | mesh_peers[i]); | 564 | mesh_peers[i]); |
503 | if (mesh_peers[i] == 0) | 565 | if (mesh_peers[i] == 0) |
@@ -505,20 +567,39 @@ connect_mesh_service (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
505 | } | 567 | } |
506 | GNUNET_assert (i < num_peers); | 568 | GNUNET_assert (i < num_peers); |
507 | d2 = GNUNET_TESTING_daemon_get_by_id (pg, &id); | 569 | d2 = GNUNET_TESTING_daemon_get_by_id (pg, &id); |
508 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 570 | if (test == MULTICAST) |
509 | "test: Peer searched: %s\n", | 571 | { |
510 | GNUNET_i2s (&d2->id)); | 572 | for (i++; i <= num_peers; i++) |
573 | { | ||
574 | GNUNET_PEER_resolve(i, &id); | ||
575 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
576 | "***************** test: peer %s has %u conns to d1\n", | ||
577 | GNUNET_i2s (&id), | ||
578 | mesh_peers[i]); | ||
579 | if (mesh_peers[i] == 0) | ||
580 | break; | ||
581 | } | ||
582 | GNUNET_assert (i < num_peers); | ||
583 | d3 = GNUNET_TESTING_daemon_get_by_id (pg, &id); | ||
584 | } | ||
511 | app = (GNUNET_MESH_ApplicationType) 0; | 585 | app = (GNUNET_MESH_ApplicationType) 0; |
512 | 586 | ||
513 | #if VERBOSE | 587 | #if VERBOSE |
514 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 588 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
515 | "test: connecting to mesh service of peer %s (%u)\n", | 589 | "***************** test: connecting to mesh service of peer %s (%u)\n", |
516 | GNUNET_i2s (&d1->id), | 590 | GNUNET_i2s (&d1->id), |
517 | mesh_peers[0]); | 591 | mesh_peers[0]); |
518 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 592 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
519 | "test: connecting to mesh service of peer %s (%u)\n", | 593 | "***************** test: connecting to mesh service of peer %s (%u)\n", |
520 | GNUNET_i2s (&d2->id), | 594 | GNUNET_i2s (&d2->id), |
521 | i); | 595 | i); |
596 | if (test == MULTICAST) | ||
597 | { | ||
598 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
599 | "***************** test: connecting to mesh service of peer %s (%u)\n", | ||
600 | GNUNET_i2s (&d3->id), | ||
601 | i); | ||
602 | } | ||
522 | #endif | 603 | #endif |
523 | h1 = GNUNET_MESH_connect (d1->cfg, | 604 | h1 = GNUNET_MESH_connect (d1->cfg, |
524 | 10, | 605 | 10, |
@@ -534,15 +615,18 @@ connect_mesh_service (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
534 | &tunnel_cleaner, | 615 | &tunnel_cleaner, |
535 | handlers, | 616 | handlers, |
536 | &app); | 617 | &app); |
537 | #if VERBOSE | 618 | if (test == MULTICAST) |
538 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 619 | { |
539 | "test: connected to mesh service of peer %s\n", | 620 | h3 = GNUNET_MESH_connect (d3->cfg, |
540 | GNUNET_i2s (&d1->id)); | 621 | 10, |
541 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 622 | (void *) 3L, |
542 | "test: connected to mesh service of peer %s\n", | 623 | &incoming_tunnel, |
543 | GNUNET_i2s (&d2->id)); | 624 | &tunnel_cleaner, |
544 | #endif | 625 | handlers, |
626 | &app); | ||
627 | } | ||
545 | t = GNUNET_MESH_tunnel_create (h1, NULL, &ch, &dh, (void *) 1L); | 628 | t = GNUNET_MESH_tunnel_create (h1, NULL, &ch, &dh, (void *) 1L); |
629 | peers_in_tunnel = 0; | ||
546 | test_task = | 630 | test_task = |
547 | GNUNET_SCHEDULER_add_delayed( | 631 | GNUNET_SCHEDULER_add_delayed( |
548 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 6), | 632 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 6), |
@@ -566,9 +650,9 @@ peergroup_ready (void *cls, const char *emsg) | |||
566 | if (emsg != NULL) | 650 | if (emsg != NULL) |
567 | { | 651 | { |
568 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 652 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
569 | "test: Peergroup callback called with error, aborting test!\n"); | 653 | "***************** test: Peergroup callback called with error, aborting test!\n"); |
570 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 654 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
571 | "test: Error from testing: `%s'\n", emsg); | 655 | "***************** test: Error from testing: `%s'\n", emsg); |
572 | ok--; | 656 | ok--; |
573 | GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); | 657 | GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); |
574 | return; | 658 | return; |
@@ -577,9 +661,9 @@ peergroup_ready (void *cls, const char *emsg) | |||
577 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 661 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
578 | "************************************************************\n"); | 662 | "************************************************************\n"); |
579 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 663 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
580 | "test: Peer Group started successfully!\n"); | 664 | "***************** test: Peer Group started successfully!\n"); |
581 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 665 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
582 | "test: Have %u connections\n", | 666 | "***************** test: Have %u connections\n", |
583 | total_connections); | 667 | total_connections); |
584 | #endif | 668 | #endif |
585 | 669 | ||
@@ -596,13 +680,13 @@ peergroup_ready (void *cls, const char *emsg) | |||
596 | { | 680 | { |
597 | d1 = GNUNET_TESTING_daemon_get (pg, i); | 681 | d1 = GNUNET_TESTING_daemon_get (pg, i); |
598 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 682 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
599 | "test: %u: %s\n", | 683 | "***************** test: %u: %s\n", |
600 | GNUNET_PEER_intern(&d1->id), | 684 | GNUNET_PEER_intern(&d1->id), |
601 | GNUNET_i2s (&d1->id)); | 685 | GNUNET_i2s (&d1->id)); |
602 | } | 686 | } |
603 | d1 = GNUNET_TESTING_daemon_get (pg, 0); | 687 | d1 = GNUNET_TESTING_daemon_get (pg, 0); |
604 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 688 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
605 | "test: Peer looking: %s\n", | 689 | "***************** test: Peer looking: %s\n", |
606 | GNUNET_i2s (&d1->id)); | 690 | GNUNET_i2s (&d1->id)); |
607 | pid1 = GNUNET_PEER_intern(&d1->id); | 691 | pid1 = GNUNET_PEER_intern(&d1->id); |
608 | mesh_peers[pid1] = 100; | 692 | mesh_peers[pid1] = 100; |
@@ -648,7 +732,7 @@ connect_cb (void *cls, const struct GNUNET_PeerIdentity *first, | |||
648 | else | 732 | else |
649 | { | 733 | { |
650 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 734 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
651 | "test: Problem with new connection (%s)\n", | 735 | "***************** test: Problem with new connection (%s)\n", |
652 | emsg); | 736 | emsg); |
653 | } | 737 | } |
654 | 738 | ||
@@ -682,7 +766,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
682 | NULL); | 766 | NULL); |
683 | 767 | ||
684 | #if VERBOSE | 768 | #if VERBOSE |
685 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: Starting daemons.\n"); | 769 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "***************** test: Starting daemons.\n"); |
686 | GNUNET_CONFIGURATION_set_value_string (testing_cfg, "testing", | 770 | GNUNET_CONFIGURATION_set_value_string (testing_cfg, "testing", |
687 | "use_progressbars", "YES"); | 771 | "use_progressbars", "YES"); |
688 | #endif | 772 | #endif |
@@ -801,22 +885,22 @@ main (int argc, char *argv[]) | |||
801 | }; | 885 | }; |
802 | int ok_goal; | 886 | int ok_goal; |
803 | 887 | ||
804 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: Start\n"); | 888 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "***************** test: Start\n"); |
805 | if (strstr (argv[0], "test_mesh_small_unicast") != NULL) | 889 | if (strstr (argv[0], "test_mesh_small_unicast") != NULL) |
806 | { | 890 | { |
807 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: UNICAST\n"); | 891 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "***************** test: UNICAST\n"); |
808 | test = UNICAST; | 892 | test = UNICAST; |
809 | ok_goal = 5; | 893 | ok_goal = 5; |
810 | } | 894 | } |
811 | else if (strstr (argv[0], "test_mesh_small_multicast") != NULL) | 895 | else if (strstr (argv[0], "test_mesh_small_multicast") != NULL) |
812 | { | 896 | { |
813 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: MULTICAST\n"); | 897 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "***************** test: MULTICAST\n"); |
814 | test = MULTICAST; | 898 | test = MULTICAST; |
815 | ok_goal = 5; | 899 | ok_goal = 10; |
816 | } | 900 | } |
817 | else | 901 | else |
818 | { | 902 | { |
819 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: UNKNOWN\n"); | 903 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "***************** test: UNKNOWN\n"); |
820 | test = SETUP; | 904 | test = SETUP; |
821 | ok_goal = 0; | 905 | ok_goal = 0; |
822 | } | 906 | } |
@@ -831,13 +915,11 @@ main (int argc, char *argv[]) | |||
831 | if (ok_goal != ok) | 915 | if (ok_goal != ok) |
832 | { | 916 | { |
833 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 917 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
834 | "test: %s FAILED! (%d/%d)\n", | 918 | "***************** test: FAILED! (%d/%d)\n", ok, ok_goal); |
835 | argv[0], ok, ok_goal); | ||
836 | return 1; | 919 | return 1; |
837 | } | 920 | } |
838 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 921 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
839 | "test: %s success\n", | 922 | "***************** test: success\n"); |
840 | argv[0]); | ||
841 | return 0; | 923 | return 0; |
842 | } | 924 | } |
843 | 925 | ||
diff --git a/src/mesh/test_mesh_small.conf b/src/mesh/test_mesh_small.conf index d3cd98429..90bae9ab2 100644 --- a/src/mesh/test_mesh_small.conf +++ b/src/mesh/test_mesh_small.conf | |||
@@ -40,8 +40,8 @@ INTERNAL_ADDRESS = 127.0.0.1 | |||
40 | EXTERNAL_ADDRESS = 127.0.0.1 | 40 | EXTERNAL_ADDRESS = 127.0.0.1 |
41 | 41 | ||
42 | [core] | 42 | [core] |
43 | TOTAL_QUOTA_IN = 1024000 | 43 | TOTAL_QUOTA_IN = 4000000 |
44 | TOTAL_QUOTA_OUT = 1024000 | 44 | TOTAL_QUOTA_OUT = 4000000 |
45 | AUTOSTART = YES | 45 | AUTOSTART = YES |
46 | PORT = 10003 | 46 | PORT = 10003 |
47 | 47 | ||