diff options
author | Nathan S. Evans <evans@in.tum.de> | 2010-11-16 15:21:20 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2010-11-16 15:21:20 +0000 |
commit | 03b104dab570998b1f791994a8134d35b4b4dc0a (patch) | |
tree | 98851c89adfbdeef8e0f1a3eff3d1854160ebd48 /src/testing/test_testing_topology.c | |
parent | 7f8e018e0b12b0ecc1a6021020af9e5f84846b02 (diff) | |
download | gnunet-03b104dab570998b1f791994a8134d35b4b4dc0a.tar.gz gnunet-03b104dab570998b1f791994a8134d35b4b4dc0a.zip |
Testing changes required to work with new core api. Revert GNUNET_CORE_iterate_peers call to work properly.
Diffstat (limited to 'src/testing/test_testing_topology.c')
-rw-r--r-- | src/testing/test_testing_topology.c | 99 |
1 files changed, 81 insertions, 18 deletions
diff --git a/src/testing/test_testing_topology.c b/src/testing/test_testing_topology.c index 36ccad6c9..f9d5fb9af 100644 --- a/src/testing/test_testing_topology.c +++ b/src/testing/test_testing_topology.c | |||
@@ -142,6 +142,12 @@ struct TestMessageContext | |||
142 | /* Identifier for this message, so we don't disconnect other peers! */ | 142 | /* Identifier for this message, so we don't disconnect other peers! */ |
143 | uint32_t uid; | 143 | uint32_t uid; |
144 | 144 | ||
145 | /* Has peer1 been notified already of a connection to peer2? */ | ||
146 | int peer1notified; | ||
147 | |||
148 | /* Has the core of peer2 been connected already? */ | ||
149 | int peer2connected; | ||
150 | |||
145 | /* Task for disconnecting cores, allow task to be cancelled on shutdown */ | 151 | /* Task for disconnecting cores, allow task to be cancelled on shutdown */ |
146 | GNUNET_SCHEDULER_TaskIdentifier disconnect_task; | 152 | GNUNET_SCHEDULER_TaskIdentifier disconnect_task; |
147 | 153 | ||
@@ -364,6 +370,7 @@ process_mtype (void *cls, | |||
364 | #endif | 370 | #endif |
365 | 371 | ||
366 | total_messages_received++; | 372 | total_messages_received++; |
373 | |||
367 | #if VERBOSE > 1 | 374 | #if VERBOSE > 1 |
368 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 375 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
369 | "Received message from `%4s', type %d.\n", GNUNET_i2s (peer), | 376 | "Received message from `%4s', type %d.\n", GNUNET_i2s (peer), |
@@ -491,33 +498,89 @@ init_notify_peer2 (void *cls, | |||
491 | { | 498 | { |
492 | struct TestMessageContext *pos = cls; | 499 | struct TestMessageContext *pos = cls; |
493 | 500 | ||
501 | total_server_connections++; | ||
502 | |||
503 | pos->peer2connected = GNUNET_YES; | ||
504 | if (pos->peer1notified == GNUNET_YES) /* Peer 1 has been notified of connection to peer 2 */ | ||
505 | { | ||
494 | #if VERBOSE > 1 | 506 | #if VERBOSE > 1 |
495 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 507 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
496 | "Core connection to `%4s' established, scheduling message send\n", | 508 | "Scheduling message send to peer `%s' from peer `%s' (init_notify_peer2)\n", |
497 | GNUNET_i2s (my_identity)); | 509 | GNUNET_i2s (my_identity), GNUNET_h2s(&pos->peer1->id.hashPubKey)); |
498 | #endif | 510 | #endif |
499 | total_server_connections++; | 511 | if (NULL == GNUNET_CORE_notify_transmit_ready (pos->peer1handle, |
512 | 0, | ||
513 | TIMEOUT, | ||
514 | &pos->peer2->id, | ||
515 | sizeof (struct | ||
516 | GNUNET_TestMessage), | ||
517 | &transmit_ready, pos)) | ||
518 | { | ||
519 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
520 | "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n", | ||
521 | GNUNET_i2s (&pos->peer2->id)); | ||
522 | transmit_ready_failed++; | ||
523 | } | ||
524 | else | ||
525 | { | ||
526 | transmit_ready_scheduled++; | ||
527 | } | ||
528 | } | ||
529 | } | ||
530 | |||
531 | /** | ||
532 | * Method called whenever a given peer connects. | ||
533 | * | ||
534 | * @param cls closure | ||
535 | * @param peer peer identity this notification is about | ||
536 | * @param atsi performance data for the connection | ||
537 | */ | ||
538 | static void connect_notify_peers (void *cls, | ||
539 | const struct | ||
540 | GNUNET_PeerIdentity *peer, | ||
541 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | ||
542 | { | ||
543 | struct TestMessageContext *pos = cls; | ||
500 | 544 | ||
501 | if (NULL == GNUNET_CORE_notify_transmit_ready (pos->peer1handle, | 545 | if (0 == memcmp(peer, &pos->peer2->id, sizeof(struct GNUNET_PeerIdentity))) |
502 | 0, | ||
503 | TIMEOUT, | ||
504 | &pos->peer2->id, | ||
505 | sizeof (struct | ||
506 | GNUNET_TestMessage), | ||
507 | &transmit_ready, pos)) | ||
508 | { | 546 | { |
547 | pos->peer1notified = GNUNET_YES; | ||
548 | #if VERBOSE > 1 | ||
509 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 549 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
510 | "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n", | 550 | "Peer `%s' notified of connection to peer `%s'\n", |
511 | GNUNET_i2s (&pos->peer2->id)); | 551 | GNUNET_i2s (&pos->peer1->id), GNUNET_h2s(&peer->hashPubKey)); |
512 | transmit_ready_failed++; | 552 | #endif |
513 | } | 553 | } |
514 | else | 554 | else |
555 | return; | ||
556 | |||
557 | if (pos->peer2connected == GNUNET_YES) /* Already connected and notified of connection, send message! */ | ||
515 | { | 558 | { |
516 | transmit_ready_scheduled++; | 559 | #if VERBOSE > 1 |
560 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
561 | "Scheduling message send to peer `%s' from peer `%s' (init_notify_peer2)\n", | ||
562 | GNUNET_i2s (&pos->peer2->id), GNUNET_h2s(&pos->peer1->id.hashPubKey)); | ||
563 | #endif | ||
564 | if (NULL == GNUNET_CORE_notify_transmit_ready (pos->peer1handle, | ||
565 | 0, | ||
566 | TIMEOUT, | ||
567 | &pos->peer2->id, | ||
568 | sizeof (struct | ||
569 | GNUNET_TestMessage), | ||
570 | &transmit_ready, pos)) | ||
571 | { | ||
572 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
573 | "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n", | ||
574 | GNUNET_i2s (&pos->peer2->id)); | ||
575 | transmit_ready_failed++; | ||
576 | } | ||
577 | else | ||
578 | { | ||
579 | transmit_ready_scheduled++; | ||
580 | } | ||
517 | } | 581 | } |
518 | } | 582 | } |
519 | 583 | ||
520 | |||
521 | static void | 584 | static void |
522 | init_notify_peer1 (void *cls, | 585 | init_notify_peer1 (void *cls, |
523 | struct GNUNET_CORE_Handle *server, | 586 | struct GNUNET_CORE_Handle *server, |
@@ -585,7 +648,7 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
585 | 1, | 648 | 1, |
586 | pos, | 649 | pos, |
587 | &init_notify_peer1, | 650 | &init_notify_peer1, |
588 | NULL, NULL, | 651 | &connect_notify_peers, NULL, |
589 | NULL, | 652 | NULL, |
590 | NULL, | 653 | NULL, |
591 | GNUNET_NO, NULL, GNUNET_NO, | 654 | GNUNET_NO, NULL, GNUNET_NO, |
@@ -639,7 +702,7 @@ topology_callback (void *cls, | |||
639 | #endif | 702 | #endif |
640 | total_connections++; | 703 | total_connections++; |
641 | #if VERBOSE > 1 | 704 | #if VERBOSE > 1 |
642 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "connected peer %s to peer %s\n", | 705 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "connected peer %s to peer %s\n", |
643 | first_daemon->shortname, second_daemon->shortname); | 706 | first_daemon->shortname, second_daemon->shortname); |
644 | #endif | 707 | #endif |
645 | temp_context = GNUNET_malloc (sizeof (struct TestMessageContext)); | 708 | temp_context = GNUNET_malloc (sizeof (struct TestMessageContext)); |