aboutsummaryrefslogtreecommitdiff
path: root/src/mesh/test_mesh_small.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesh/test_mesh_small.c')
-rw-r--r--src/mesh/test_mesh_small.c335
1 files changed, 147 insertions, 188 deletions
diff --git a/src/mesh/test_mesh_small.c b/src/mesh/test_mesh_small.c
index 68fc9cc24..42390e1a6 100644
--- a/src/mesh/test_mesh_small.c
+++ b/src/mesh/test_mesh_small.c
@@ -171,14 +171,16 @@ shutdown_callback (void *cls, const char *emsg)
171 if (emsg != NULL) 171 if (emsg != NULL)
172 { 172 {
173#if VERBOSE 173#if VERBOSE
174 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "***************** test: Shutdown of peers failed!\n"); 174 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
175 "***************** test: Shutdown of peers failed!\n");
175#endif 176#endif
176 ok--; 177 ok--;
177 } 178 }
178 else 179 else
179 { 180 {
180#if VERBOSE 181#if VERBOSE
181 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "***************** test: All peers successfully shut down!\n"); 182 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
183 "***************** test: All peers successfully shut down!\n");
182#endif 184#endif
183 } 185 }
184} 186}
@@ -188,7 +190,8 @@ static void
188shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 190shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
189{ 191{
190#if VERBOSE 192#if VERBOSE
191 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "***************** test: Ending test.\n"); 193 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
194 "***************** test: Ending test.\n");
192#endif 195#endif
193 196
194 if (disconnect_task != GNUNET_SCHEDULER_NO_TASK) 197 if (disconnect_task != GNUNET_SCHEDULER_NO_TASK)
@@ -210,14 +213,14 @@ disconnect_mesh_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
210 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 213 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
211 "***************** test: disconnecting mesh service of peers\n"); 214 "***************** test: disconnecting mesh service of peers\n");
212 disconnect_task = GNUNET_SCHEDULER_NO_TASK; 215 disconnect_task = GNUNET_SCHEDULER_NO_TASK;
213 GNUNET_MESH_disconnect(h1); 216 GNUNET_MESH_disconnect (h1);
214 GNUNET_MESH_disconnect(h2); 217 GNUNET_MESH_disconnect (h2);
215 if (test == MULTICAST) 218 if (test == MULTICAST)
216 GNUNET_MESH_disconnect(h3); 219 GNUNET_MESH_disconnect (h3);
217 if (GNUNET_SCHEDULER_NO_TASK != shutdown_handle) 220 if (GNUNET_SCHEDULER_NO_TASK != shutdown_handle)
218 { 221 {
219 GNUNET_SCHEDULER_cancel (shutdown_handle); 222 GNUNET_SCHEDULER_cancel (shutdown_handle);
220 shutdown_handle = GNUNET_SCHEDULER_add_now(&shutdown_task, NULL); 223 shutdown_handle = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
221 } 224 }
222} 225}
223 226
@@ -230,12 +233,13 @@ tmt_rdy (void *cls, size_t size, void *buf)
230{ 233{
231 struct GNUNET_MessageHeader *msg = buf; 234 struct GNUNET_MessageHeader *msg = buf;
232 235
233 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "***************** test: tmt_rdy called\n"); 236 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
234 if (size < sizeof(struct GNUNET_MessageHeader) || NULL == buf) 237 "***************** test: tmt_rdy called\n");
238 if (size < sizeof (struct GNUNET_MessageHeader) || NULL == buf)
235 return 0; 239 return 0;
236 msg->size = htons (sizeof(struct GNUNET_MessageHeader)); 240 msg->size = htons (sizeof (struct GNUNET_MessageHeader));
237 msg->type = htons ((long) cls); 241 msg->type = htons ((long) cls);
238 return sizeof(struct GNUNET_MessageHeader); 242 return sizeof (struct GNUNET_MessageHeader);
239} 243}
240 244
241 245
@@ -252,57 +256,51 @@ tmt_rdy (void *cls, size_t size, void *buf)
252 * GNUNET_SYSERR to close it (signal serious error) 256 * GNUNET_SYSERR to close it (signal serious error)
253 */ 257 */
254int 258int
255data_callback (void *cls, 259data_callback (void *cls, struct GNUNET_MESH_Tunnel *tunnel, void **tunnel_ctx,
256 struct GNUNET_MESH_Tunnel * tunnel, 260 const struct GNUNET_PeerIdentity *sender,
257 void **tunnel_ctx, 261 const struct GNUNET_MessageHeader *message,
258 const struct GNUNET_PeerIdentity *sender, 262 const struct GNUNET_ATS_Information *atsi)
259 const struct GNUNET_MessageHeader *message,
260 const struct GNUNET_ATS_Information *atsi)
261{ 263{
262 long client = (long) cls; 264 long client = (long) cls;
263 265
264 switch (client) 266 switch (client)
265 { 267 {
266 case 1L: 268 case 1L:
267 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 269 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
268 "***************** test: Origin client got a response!\n"); 270 "***************** test: Origin client got a response!\n");
269 ok++; 271 ok++;
270 peers_responded++; 272 peers_responded++;
271 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task) 273 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
272 { 274 {
273 GNUNET_SCHEDULER_cancel (disconnect_task); 275 GNUNET_SCHEDULER_cancel (disconnect_task);
274 disconnect_task = GNUNET_SCHEDULER_add_delayed(SHORT_TIME, 276 disconnect_task =
275 &disconnect_mesh_peers, 277 GNUNET_SCHEDULER_add_delayed (SHORT_TIME, &disconnect_mesh_peers,
276 NULL); 278 NULL);
277 } 279 }
278 if (test == MULTICAST && peers_responded < 2) 280 if (test == MULTICAST && peers_responded < 2)
279 return GNUNET_OK; 281 return GNUNET_OK;
280 GNUNET_MESH_tunnel_destroy (tunnel); 282 GNUNET_MESH_tunnel_destroy (tunnel);
281 break; 283 break;
282 case 2L: 284 case 2L:
283 case 3L: 285 case 3L:
284 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 286 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
285 "***************** test: Destination client %u got a message.\n", 287 "***************** test: Destination client %u got a message.\n",
286 client); 288 client);
287 ok++; 289 ok++;
288 GNUNET_MESH_notify_transmit_ready(tunnel, 290 GNUNET_MESH_notify_transmit_ready (tunnel, GNUNET_NO, 0,
289 GNUNET_NO, 291 GNUNET_TIME_UNIT_FOREVER_REL, sender,
290 0, 292 sizeof (struct GNUNET_MessageHeader),
291 GNUNET_TIME_UNIT_FOREVER_REL, 293 &tmt_rdy, (void *) 1L);
292 sender, 294 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
293 sizeof(struct GNUNET_MessageHeader), 295 {
294 &tmt_rdy, 296 GNUNET_SCHEDULER_cancel (disconnect_task);
295 (void *) 1L); 297 disconnect_task =
296 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task) 298 GNUNET_SCHEDULER_add_delayed (SHORT_TIME, &disconnect_mesh_peers,
297 { 299 NULL);
298 GNUNET_SCHEDULER_cancel (disconnect_task); 300 }
299 disconnect_task = GNUNET_SCHEDULER_add_delayed(SHORT_TIME, 301 break;
300 &disconnect_mesh_peers, 302 default:
301 NULL); 303 break;
302 }
303 break;
304 default:
305 break;
306 } 304 }
307 return GNUNET_OK; 305 return GNUNET_OK;
308} 306}
@@ -312,7 +310,7 @@ data_callback (void *cls,
312 * Handlers, for diverse services 310 * Handlers, for diverse services
313 */ 311 */
314static struct GNUNET_MESH_MessageHandler handlers[] = { 312static struct GNUNET_MESH_MessageHandler handlers[] = {
315 {&data_callback, 1, sizeof(struct GNUNET_MessageHeader)}, 313 {&data_callback, 1, sizeof (struct GNUNET_MessageHeader)},
316 {NULL, 0, 0} 314 {NULL, 0, 0}
317}; 315};
318 316
@@ -329,15 +327,13 @@ static struct GNUNET_MESH_MessageHandler handlers[] = {
329 * (can be NULL -- that's not an error) 327 * (can be NULL -- that's not an error)
330 */ 328 */
331static void * 329static void *
332incoming_tunnel (void *cls, 330incoming_tunnel (void *cls, struct GNUNET_MESH_Tunnel *tunnel,
333 struct GNUNET_MESH_Tunnel * tunnel, 331 const struct GNUNET_PeerIdentity *initiator,
334 const struct GNUNET_PeerIdentity * initiator, 332 const struct GNUNET_ATS_Information *atsi)
335 const struct GNUNET_ATS_Information * atsi)
336{ 333{
337 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 334 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
338 "***************** test: Incoming tunnel from %s to peer %d\n", 335 "***************** test: Incoming tunnel from %s to peer %d\n",
339 GNUNET_i2s(initiator), 336 GNUNET_i2s (initiator), (long) cls);
340 (long) cls);
341 ok++; 337 ok++;
342 if ((long) cls == 1L) 338 if ((long) cls == 1L)
343 incoming_t = tunnel; 339 incoming_t = tunnel;
@@ -346,9 +342,8 @@ incoming_tunnel (void *cls,
346 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task) 342 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
347 { 343 {
348 GNUNET_SCHEDULER_cancel (disconnect_task); 344 GNUNET_SCHEDULER_cancel (disconnect_task);
349 disconnect_task = GNUNET_SCHEDULER_add_delayed(SHORT_TIME, 345 disconnect_task =
350 &disconnect_mesh_peers, 346 GNUNET_SCHEDULER_add_delayed (SHORT_TIME, &disconnect_mesh_peers, NULL);
351 NULL);
352 } 347 }
353 return NULL; 348 return NULL;
354} 349}
@@ -377,8 +372,7 @@ tunnel_cleaner (void *cls, const struct GNUNET_MESH_Tunnel *tunnel,
377 ok++; 372 ok++;
378 else 373 else
379 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 374 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
380 "***************** test: Unknown peer! %d\n", 375 "***************** test: Unknown peer! %d\n", i);
381 i);
382 peers_in_tunnel--; 376 peers_in_tunnel--;
383 if (peers_in_tunnel > 0) 377 if (peers_in_tunnel > 0)
384 return; 378 return;
@@ -404,7 +398,7 @@ dh (void *cls, const struct GNUNET_PeerIdentity *peer)
404{ 398{
405 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 399 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
406 "***************** test: peer %s disconnected\n", 400 "***************** test: peer %s disconnected\n",
407 GNUNET_i2s(peer)); 401 GNUNET_i2s (peer));
408 return; 402 return;
409} 403}
410 404
@@ -423,51 +417,46 @@ ch (void *cls, const struct GNUNET_PeerIdentity *peer,
423 struct GNUNET_PeerIdentity *dest; 417 struct GNUNET_PeerIdentity *dest;
424 418
425 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 419 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
426 "***************** test: peer %s connected\n", 420 "***************** test: peer %s connected\n", GNUNET_i2s (peer));
427 GNUNET_i2s(peer));
428 421
429 if (0 == memcmp(&d2->id, peer, sizeof(d2->id)) && (long) cls == 1L) 422 if (0 == memcmp (&d2->id, peer, sizeof (d2->id)) && (long) cls == 1L)
430 ok++; 423 ok++;
431 if (test == MULTICAST && 424 if (test == MULTICAST && 0 == memcmp (&d3->id, peer, sizeof (d3->id)) &&
432 0 == memcmp(&d3->id, peer, sizeof(d3->id)) &&
433 (long) cls == 1L) 425 (long) cls == 1L)
434 ok++; 426 ok++;
435 switch (test) 427 switch (test)
436 { 428 {
437 case UNICAST: 429 case UNICAST:
438 dest = &d2->id; 430 dest = &d2->id;
439 break; 431 break;
440 case MULTICAST: 432 case MULTICAST:
441 peers_in_tunnel++; 433 peers_in_tunnel++;
442 if (peers_in_tunnel < 2) 434 if (peers_in_tunnel < 2)
443 return;
444 dest = NULL;
445 break;
446 default:
447 return; 435 return;
436 dest = NULL;
437 break;
438 default:
439 return;
448 } 440 }
449 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task) 441 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
450 { 442 {
451 GNUNET_SCHEDULER_cancel (disconnect_task); 443 GNUNET_SCHEDULER_cancel (disconnect_task);
452 disconnect_task = GNUNET_SCHEDULER_add_delayed(SHORT_TIME, 444 disconnect_task =
453 &disconnect_mesh_peers, 445 GNUNET_SCHEDULER_add_delayed (SHORT_TIME, &disconnect_mesh_peers, NULL);
454 NULL);
455 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 446 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
456 "***************** test: Sending data...\n"); 447 "***************** test: Sending data...\n");
457 peers_responded = 0; 448 peers_responded = 0;
458 GNUNET_MESH_notify_transmit_ready(t, 449 GNUNET_MESH_notify_transmit_ready (t, GNUNET_NO, 0,
459 GNUNET_NO, 450 GNUNET_TIME_UNIT_FOREVER_REL, dest,
460 0, 451 sizeof (struct GNUNET_MessageHeader),
461 GNUNET_TIME_UNIT_FOREVER_REL, 452 &tmt_rdy, (void *) 1L);
462 dest,
463 sizeof(struct GNUNET_MessageHeader),
464 &tmt_rdy,
465 (void *) 1L);
466 } 453 }
467 else 454 else
468 { 455 {
469 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "***************** test: Disconnect already run?\n"); 456 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
470 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "***************** test: Aborting...\n"); 457 "***************** test: Disconnect already run?\n");
458 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
459 "***************** test: Aborting...\n");
471 } 460 }
472 return; 461 return;
473} 462}
@@ -481,20 +470,19 @@ do_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
481 { 470 {
482 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 471 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
483 "***************** test: add peer 3\n"); 472 "***************** test: add peer 3\n");
484 GNUNET_MESH_peer_request_connect_add(t, &d3->id); 473 GNUNET_MESH_peer_request_connect_add (t, &d3->id);
485 } 474 }
486 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 475 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "***************** test: add peer 2\n");
487 "***************** test: add peer 2\n"); 476 GNUNET_MESH_peer_request_connect_add (t, &d2->id);
488 GNUNET_MESH_peer_request_connect_add(t, &d2->id);
489 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 477 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
490 "***************** test: schedule timeout in 30s\n"); 478 "***************** test: schedule timeout in 30s\n");
491 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task) 479 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
492 { 480 {
493 GNUNET_SCHEDULER_cancel (disconnect_task); 481 GNUNET_SCHEDULER_cancel (disconnect_task);
494 disconnect_task = GNUNET_SCHEDULER_add_delayed( 482 disconnect_task =
495 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30), 483 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
496 &disconnect_mesh_peers, 484 (GNUNET_TIME_UNIT_SECONDS, 30),
497 NULL); 485 &disconnect_mesh_peers, NULL);
498 } 486 }
499} 487}
500 488
@@ -510,50 +498,46 @@ do_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
510 * @param emsg error message (NULL on success) 498 * @param emsg error message (NULL on success)
511 */ 499 */
512void 500void
513topo_cb (void *cls, 501topo_cb (void *cls, const struct GNUNET_PeerIdentity *first,
514 const struct GNUNET_PeerIdentity* first, 502 const struct GNUNET_PeerIdentity *second, const char *emsg)
515 const struct GNUNET_PeerIdentity* second,
516 const char *emsg)
517{ 503{
518 GNUNET_PEER_Id p1; 504 GNUNET_PEER_Id p1;
519 GNUNET_PEER_Id p2; 505 GNUNET_PEER_Id p2;
520 struct GNUNET_PeerIdentity id; 506 struct GNUNET_PeerIdentity id;
521 507
522 GNUNET_PEER_resolve(1, &id); 508 GNUNET_PEER_resolve (1, &id);
523 p1 = GNUNET_PEER_search(first); 509 p1 = GNUNET_PEER_search (first);
524 if (p1 == pid1) 510 if (p1 == pid1)
525 { 511 {
526 p2 = GNUNET_PEER_search(second); 512 p2 = GNUNET_PEER_search (second);
527 if (p2 == 0 || p2 > num_peers) 513 if (p2 == 0 || p2 > num_peers)
528 { 514 {
529 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 515 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
530 "***************** test: %s is UNKNOWN!? (%u)\n", 516 "***************** test: %s is UNKNOWN!? (%u)\n",
531 GNUNET_i2s(second), 517 GNUNET_i2s (second), p2);
532 p2);
533 return; 518 return;
534 } 519 }
535 mesh_peers[p2]++; 520 mesh_peers[p2]++;
536 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 521 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
537 "***************** test: %s IS a neighbor\n", 522 "***************** test: %s IS a neighbor\n",
538 GNUNET_i2s(second)); 523 GNUNET_i2s (second));
539 return; 524 return;
540 } 525 }
541 p1 = GNUNET_PEER_search(second); 526 p1 = GNUNET_PEER_search (second);
542 if (p1 == pid1) 527 if (p1 == pid1)
543 { 528 {
544 p2 = GNUNET_PEER_search(first); 529 p2 = GNUNET_PEER_search (first);
545 if (p2 == 0 || p2 > num_peers) 530 if (p2 == 0 || p2 > num_peers)
546 { 531 {
547 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 532 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
548 "***************** test: %s is UNKNOWN!? (%u)\n", 533 "***************** test: %s is UNKNOWN!? (%u)\n",
549 GNUNET_i2s(first), 534 GNUNET_i2s (first), p2);
550 p2);
551 return; 535 return;
552 } 536 }
553 mesh_peers[p2]++; 537 mesh_peers[p2]++;
554 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 538 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
555 "***************** test: %s IS a neighbor\n", 539 "***************** test: %s IS a neighbor\n",
556 GNUNET_i2s(first)); 540 GNUNET_i2s (first));
557 return; 541 return;
558 } 542 }
559} 543}
@@ -569,15 +553,15 @@ connect_mesh_service (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
569 unsigned int i; 553 unsigned int i;
570 struct GNUNET_PeerIdentity id; 554 struct GNUNET_PeerIdentity id;
571 555
572 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "***************** test: connect_mesh_service\n"); 556 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
557 "***************** test: connect_mesh_service\n");
573 558
574 for (i = 1; i <= num_peers; i++) 559 for (i = 1; i <= num_peers; i++)
575 { 560 {
576 GNUNET_PEER_resolve(i, &id); 561 GNUNET_PEER_resolve (i, &id);
577 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 562 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
578 "***************** test: peer %s has %u conns to d1\n", 563 "***************** test: peer %s has %u conns to d1\n",
579 GNUNET_i2s (&id), 564 GNUNET_i2s (&id), mesh_peers[i]);
580 mesh_peers[i]);
581 if (mesh_peers[i] == 0) 565 if (mesh_peers[i] == 0)
582 break; 566 break;
583 } 567 }
@@ -587,11 +571,10 @@ connect_mesh_service (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
587 { 571 {
588 for (i++; i <= num_peers; i++) 572 for (i++; i <= num_peers; i++)
589 { 573 {
590 GNUNET_PEER_resolve(i, &id); 574 GNUNET_PEER_resolve (i, &id);
591 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 575 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
592 "***************** test: peer %s has %u conns to d1\n", 576 "***************** test: peer %s has %u conns to d1\n",
593 GNUNET_i2s (&id), 577 GNUNET_i2s (&id), mesh_peers[i]);
594 mesh_peers[i]);
595 if (mesh_peers[i] == 0) 578 if (mesh_peers[i] == 0)
596 break; 579 break;
597 } 580 }
@@ -603,50 +586,32 @@ connect_mesh_service (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
603#if VERBOSE 586#if VERBOSE
604 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 587 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
605 "***************** test: connecting to mesh service of peer %s (%u)\n", 588 "***************** test: connecting to mesh service of peer %s (%u)\n",
606 GNUNET_i2s (&d1->id), 589 GNUNET_i2s (&d1->id), mesh_peers[0]);
607 mesh_peers[0]);
608 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 590 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
609 "***************** test: connecting to mesh service of peer %s (%u)\n", 591 "***************** test: connecting to mesh service of peer %s (%u)\n",
610 GNUNET_i2s (&d2->id), 592 GNUNET_i2s (&d2->id), i);
611 i);
612 if (test == MULTICAST) 593 if (test == MULTICAST)
613 { 594 {
614 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 595 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
615 "***************** test: connecting to mesh service of peer %s (%u)\n", 596 "***************** test: connecting to mesh service of peer %s (%u)\n",
616 GNUNET_i2s (&d3->id), 597 GNUNET_i2s (&d3->id), i);
617 i);
618 } 598 }
619#endif 599#endif
620 h1 = GNUNET_MESH_connect (d1->cfg, 600 h1 = GNUNET_MESH_connect (d1->cfg, 10, (void *) 1L, NULL, &tunnel_cleaner,
621 10, 601 handlers, &app);
622 (void *) 1L, 602 h2 = GNUNET_MESH_connect (d2->cfg, 10, (void *) 2L, &incoming_tunnel,
623 NULL, 603 &tunnel_cleaner, handlers, &app);
624 &tunnel_cleaner,
625 handlers,
626 &app);
627 h2 = GNUNET_MESH_connect (d2->cfg,
628 10,
629 (void *) 2L,
630 &incoming_tunnel,
631 &tunnel_cleaner,
632 handlers,
633 &app);
634 if (test == MULTICAST) 604 if (test == MULTICAST)
635 { 605 {
636 h3 = GNUNET_MESH_connect (d3->cfg, 606 h3 = GNUNET_MESH_connect (d3->cfg, 10, (void *) 3L, &incoming_tunnel,
637 10, 607 &tunnel_cleaner, handlers, &app);
638 (void *) 3L,
639 &incoming_tunnel,
640 &tunnel_cleaner,
641 handlers,
642 &app);
643 } 608 }
644 t = GNUNET_MESH_tunnel_create (h1, NULL, &ch, &dh, (void *) 1L); 609 t = GNUNET_MESH_tunnel_create (h1, NULL, &ch, &dh, (void *) 1L);
645 peers_in_tunnel = 0; 610 peers_in_tunnel = 0;
646 test_task = 611 test_task =
647 GNUNET_SCHEDULER_add_delayed( 612 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
648 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 6), 613 (GNUNET_TIME_UNIT_SECONDS, 6), &do_test,
649 &do_test, NULL); 614 NULL);
650} 615}
651 616
652 617
@@ -697,25 +662,21 @@ peergroup_ready (void *cls, const char *emsg)
697 GNUNET_PEER_Id peer_id; 662 GNUNET_PEER_Id peer_id;
698 663
699 d1 = GNUNET_TESTING_daemon_get (pg, i); 664 d1 = GNUNET_TESTING_daemon_get (pg, i);
700 peer_id = GNUNET_PEER_intern(&d1->id); 665 peer_id = GNUNET_PEER_intern (&d1->id);
701 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 666 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "***************** test: %u: %s\n",
702 "***************** test: %u: %s\n", 667 peer_id, GNUNET_i2s (&d1->id));
703 peer_id,
704 GNUNET_i2s (&d1->id));
705 } 668 }
706 d1 = GNUNET_TESTING_daemon_get (pg, 0); 669 d1 = GNUNET_TESTING_daemon_get (pg, 0);
707 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 670 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
708 "***************** test: Peer looking: %s\n", 671 "***************** test: Peer looking: %s\n",
709 GNUNET_i2s (&d1->id)); 672 GNUNET_i2s (&d1->id));
710 pid1 = GNUNET_PEER_intern(&d1->id); 673 pid1 = GNUNET_PEER_intern (&d1->id);
711 mesh_peers[pid1] = 100; 674 mesh_peers[pid1] = 100;
712 GNUNET_TESTING_get_topology(pg, &topo_cb, NULL); 675 GNUNET_TESTING_get_topology (pg, &topo_cb, NULL);
713 676
714 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply( 677 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
715 GNUNET_TIME_UNIT_SECONDS, 678 (GNUNET_TIME_UNIT_SECONDS, 4),
716 4), 679 &connect_mesh_service, NULL);
717 &connect_mesh_service,
718 NULL);
719 disconnect_task = 680 disconnect_task =
720 GNUNET_SCHEDULER_add_delayed (wait_time, &disconnect_mesh_peers, NULL); 681 GNUNET_SCHEDULER_add_delayed (wait_time, &disconnect_mesh_peers, NULL);
721 682
@@ -753,11 +714,9 @@ connect_cb (void *cls, const struct GNUNET_PeerIdentity *first,
753 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 714 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
754 "***************** test: Problem with new connection (%s)\n", 715 "***************** test: Problem with new connection (%s)\n",
755 emsg); 716 emsg);
756 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 717 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "***************** test: (%s)\n",
757 "***************** test: (%s)\n",
758 GNUNET_i2s (first)); 718 GNUNET_i2s (first));
759 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 719 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "***************** test: (%s)\n",
760 "***************** test: (%s)\n",
761 GNUNET_i2s (second)); 720 GNUNET_i2s (second));
762 } 721 }
763 722
@@ -792,7 +751,8 @@ run (void *cls, char *const *args, const char *cfgfile,
792 NULL); 751 NULL);
793 752
794#if VERBOSE 753#if VERBOSE
795 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "***************** test: Starting daemons.\n"); 754 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
755 "***************** test: Starting daemons.\n");
796 GNUNET_CONFIGURATION_set_value_string (testing_cfg, "testing", 756 GNUNET_CONFIGURATION_set_value_string (testing_cfg, "testing",
797 "use_progressbars", "YES"); 757 "use_progressbars", "YES");
798#endif 758#endif
@@ -806,7 +766,7 @@ run (void *cls, char *const *args, const char *cfgfile,
806 return; 766 return;
807 } 767 }
808 768
809 mesh_peers = GNUNET_malloc (sizeof(uint16_t) * (num_peers + 1)); 769 mesh_peers = GNUNET_malloc (sizeof (uint16_t) * (num_peers + 1));
810 770
811 if (GNUNET_OK != 771 if (GNUNET_OK !=
812 GNUNET_CONFIGURATION_get_value_number (testing_cfg, "test_mesh_small", 772 GNUNET_CONFIGURATION_get_value_number (testing_cfg, "test_mesh_small",
@@ -833,15 +793,15 @@ run (void *cls, char *const *args, const char *cfgfile,
833 &data_filename)) 793 &data_filename))
834 { 794 {
835 data_file = 795 data_file =
836 GNUNET_DISK_file_open (data_filename, 796 GNUNET_DISK_file_open (data_filename,
837 GNUNET_DISK_OPEN_READWRITE | 797 GNUNET_DISK_OPEN_READWRITE |
838 GNUNET_DISK_OPEN_CREATE, 798 GNUNET_DISK_OPEN_CREATE,
839 GNUNET_DISK_PERM_USER_READ | 799 GNUNET_DISK_PERM_USER_READ |
840 GNUNET_DISK_PERM_USER_WRITE); 800 GNUNET_DISK_PERM_USER_WRITE);
841 if (data_file == NULL) 801 if (data_file == NULL)
842 { 802 {
843 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to open %s for output!\n", 803 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to open %s for output!\n",
844 data_filename); 804 data_filename);
845 GNUNET_free (data_filename); 805 GNUNET_free (data_filename);
846 } 806 }
847 } 807 }
@@ -939,8 +899,8 @@ main (int argc, char *argv[])
939 899
940 GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2, 900 GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2,
941 "test_mesh_small", 901 "test_mesh_small",
942 gettext_noop ("Test mesh in a small network."), 902 gettext_noop ("Test mesh in a small network."), options,
943 options, &run, NULL); 903 &run, NULL);
944#if REMOVE_DIR 904#if REMOVE_DIR
945 GNUNET_DISK_directory_remove ("/tmp/test_mesh_small"); 905 GNUNET_DISK_directory_remove ("/tmp/test_mesh_small");
946#endif 906#endif
@@ -950,8 +910,7 @@ main (int argc, char *argv[])
950 "***************** test: FAILED! (%d/%d)\n", ok, ok_goal); 910 "***************** test: FAILED! (%d/%d)\n", ok, ok_goal);
951 return 1; 911 return 1;
952 } 912 }
953 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 913 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "***************** test: success\n");
954 "***************** test: success\n");
955 return 0; 914 return 0;
956} 915}
957 916