aboutsummaryrefslogtreecommitdiff
path: root/src/multicast
diff options
context:
space:
mode:
authorxrs <xrs@mail36.net>2016-08-26 22:15:13 +0000
committerxrs <xrs@mail36.net>2016-08-26 22:15:13 +0000
commit6df56da479bf8e600a69f058758a7fb371e63e9d (patch)
tree6e69af617f3c9b81b14ede9749f8ce94ff0ec80c /src/multicast
parentf93599e4e6b9417af6c228c3efde284b20503416 (diff)
downloadgnunet-6df56da479bf8e600a69f058758a7fb371e63e9d.tar.gz
gnunet-6df56da479bf8e600a69f058758a7fb371e63e9d.zip
test_multicast.c: Added some comments and a check
Diffstat (limited to 'src/multicast')
-rw-r--r--src/multicast/test_multicast.c36
1 files changed, 30 insertions, 6 deletions
diff --git a/src/multicast/test_multicast.c b/src/multicast/test_multicast.c
index a4288e93d..613a8c593 100644
--- a/src/multicast/test_multicast.c
+++ b/src/multicast/test_multicast.c
@@ -274,6 +274,7 @@ member_parted (void *cls)
274 switch (test) 274 switch (test)
275 { 275 {
276 case TEST_MEMBER_JOIN_REFUSE: 276 case TEST_MEMBER_JOIN_REFUSE:
277 // Test 3 starts here
277 member_join (TEST_MEMBER_JOIN_ADMIT); 278 member_join (TEST_MEMBER_JOIN_ADMIT);
278 break; 279 break;
279 280
@@ -304,6 +305,7 @@ member_part ()
304 test = TEST_MEMBER_PART; 305 test = TEST_MEMBER_PART;
305 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 306 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
306 "Test #%u: member_part()\n", test); 307 "Test #%u: member_part()\n", test);
308 // Test 10 starts here
307 GNUNET_SCHEDULER_add_now (&schedule_member_part, NULL); 309 GNUNET_SCHEDULER_add_now (&schedule_member_part, NULL);
308} 310}
309 311
@@ -311,6 +313,7 @@ member_part ()
311static void 313static void
312member_replay_ok () 314member_replay_ok ()
313{ 315{
316 // Execution of test 8 here
314 test = TEST_MEMBER_REPLAY_OK; 317 test = TEST_MEMBER_REPLAY_OK;
315 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 318 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
316 "Test #%u: member_replay_ok()\n", test); 319 "Test #%u: member_replay_ok()\n", test);
@@ -377,6 +380,7 @@ origin_recv_replay_frag (void *cls,
377 switch (test) 380 switch (test)
378 { 381 {
379 case TEST_MEMBER_REPLAY_ERROR: 382 case TEST_MEMBER_REPLAY_ERROR:
383 // Test 8 starts here
380 GNUNET_MULTICAST_replay_response (rh, NULL, GNUNET_SYSERR); 384 GNUNET_MULTICAST_replay_response (rh, NULL, GNUNET_SYSERR);
381 member_replay_ok (); 385 member_replay_ok ();
382 break; 386 break;
@@ -435,9 +439,12 @@ origin_recv_request (void *cls,
435 GNUNET_assert (0 == memcmp (&req->member_pub_key, 439 GNUNET_assert (0 == memcmp (&req->member_pub_key,
436 &member_pub_key, sizeof (member_pub_key))); 440 &member_pub_key, sizeof (member_pub_key)));
437 441
442 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
443 "Test #%u: verify message content, take first 3 bytes: %.3s\n",
444 test, &req[1]);
445 GNUNET_assert (0 == memcmp (&req[1], "abc", 3));
438 446
439 // FIXME: check message content 447 // Test 7 starts here
440
441 member_replay_error (); 448 member_replay_error ();
442} 449}
443 450
@@ -471,7 +478,8 @@ member_recv_message (void *cls,
471{ 478{
472 struct MemberClosure *mcls = cls; 479 struct MemberClosure *mcls = cls;
473 480
474 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 481 // Test 5 starts here after message has been received from origin
482 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
475 "Test #%u: member_recv_message() %u/%u\n", 483 "Test #%u: member_recv_message() %u/%u\n",
476 test, 484 test,
477 (unsigned int) (mcls->n + 1), 485 (unsigned int) (mcls->n + 1),
@@ -484,10 +492,12 @@ member_recv_message (void *cls,
484 switch (test) 492 switch (test)
485 { 493 {
486 case TEST_ORIGIN_TO_ALL_RECV: 494 case TEST_ORIGIN_TO_ALL_RECV:
495 // Test 6 starts here
487 member_to_origin (); 496 member_to_origin ();
488 break; 497 break;
489 498
490 case TEST_MEMBER_REPLAY_OK: 499 case TEST_MEMBER_REPLAY_OK:
500 // Test 9 starts here
491 GNUNET_assert (replay_fragment_id == GNUNET_ntohll (msg->fragment_id)); 501 GNUNET_assert (replay_fragment_id == GNUNET_ntohll (msg->fragment_id));
492 member_part (); 502 member_part ();
493 break; 503 break;
@@ -516,6 +526,7 @@ origin_recv_message (void *cls,
516 switch (test) 526 switch (test)
517 { 527 {
518 case TEST_ORIGIN_TO_ALL: 528 case TEST_ORIGIN_TO_ALL:
529 // Prepare to execute test 5
519 test = TEST_ORIGIN_TO_ALL_RECV; 530 test = TEST_ORIGIN_TO_ALL_RECV;
520 break; 531 break;
521 532
@@ -574,12 +585,14 @@ member_recv_join_decision (void *cls,
574 { 585 {
575 case TEST_MEMBER_JOIN_REFUSE: 586 case TEST_MEMBER_JOIN_REFUSE:
576 GNUNET_assert (0 == relay_count); 587 GNUNET_assert (0 == relay_count);
588 // Test 3 starts here
577 GNUNET_SCHEDULER_add_now (&schedule_member_part, NULL); 589 GNUNET_SCHEDULER_add_now (&schedule_member_part, NULL);
578 break; 590 break;
579 591
580 case TEST_MEMBER_JOIN_ADMIT: 592 case TEST_MEMBER_JOIN_ADMIT:
581 GNUNET_assert (1 == relay_count); 593 GNUNET_assert (1 == relay_count);
582 GNUNET_assert (0 == memcmp (relays, &this_peer, sizeof (this_peer))); 594 GNUNET_assert (0 == memcmp (relays, &this_peer, sizeof (this_peer)));
595 // Test 4 starts here
583 origin_to_all (); 596 origin_to_all ();
584 break; 597 break;
585 598
@@ -590,7 +603,9 @@ member_recv_join_decision (void *cls,
590 } 603 }
591} 604}
592 605
593 606/**
607 * Test: origin receives join request
608 */
594static void 609static void
595origin_recv_join_request (void *cls, 610origin_recv_join_request (void *cls,
596 const struct GNUNET_CRYPTO_EcdsaPublicKey *mem_key, 611 const struct GNUNET_CRYPTO_EcdsaPublicKey *mem_key,
@@ -615,10 +630,12 @@ origin_recv_join_request (void *cls,
615 switch (test) 630 switch (test)
616 { 631 {
617 case TEST_MEMBER_JOIN_REFUSE: 632 case TEST_MEMBER_JOIN_REFUSE:
633 // Test 3 starts here
618 GNUNET_MULTICAST_join_decision (jh, GNUNET_NO, 0, NULL, join_resp); 634 GNUNET_MULTICAST_join_decision (jh, GNUNET_NO, 0, NULL, join_resp);
619 break; 635 break;
620 636
621 case TEST_MEMBER_JOIN_ADMIT: 637 case TEST_MEMBER_JOIN_ADMIT:
638 // Test 3 is running
622 GNUNET_MULTICAST_join_decision (jh, GNUNET_YES, 1, &this_peer, join_resp); 639 GNUNET_MULTICAST_join_decision (jh, GNUNET_YES, 1, &this_peer, join_resp);
623 break; 640 break;
624 641
@@ -630,7 +647,9 @@ origin_recv_join_request (void *cls,
630 } 647 }
631} 648}
632 649
633 650/**
651 * Test: member joins multicast group
652 */
634static void 653static void
635member_join (int t) 654member_join (int t)
636{ 655{
@@ -661,7 +680,9 @@ member_join (int t)
661 &member_cls); 680 &member_cls);
662} 681}
663 682
664 683/**
684 * Test: Start a multicast group as origin
685 */
665static void 686static void
666origin_start () 687origin_start ()
667{ 688{
@@ -679,6 +700,7 @@ origin_start ()
679 origin_recv_request, 700 origin_recv_request,
680 origin_recv_message, 701 origin_recv_message,
681 &origin_cls); 702 &origin_cls);
703 // Test 2 starts here
682 member_join (TEST_MEMBER_JOIN_REFUSE); 704 member_join (TEST_MEMBER_JOIN_REFUSE);
683} 705}
684 706
@@ -687,6 +709,8 @@ static void
687core_connected (void *cls, const struct GNUNET_PeerIdentity *my_identity) 709core_connected (void *cls, const struct GNUNET_PeerIdentity *my_identity)
688{ 710{
689 this_peer = *my_identity; 711 this_peer = *my_identity;
712
713 // Test 1 starts here
690 origin_start (); 714 origin_start ();
691} 715}
692 716