aboutsummaryrefslogtreecommitdiff
path: root/src/social/test_social.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/social/test_social.c')
-rw-r--r--src/social/test_social.c95
1 files changed, 66 insertions, 29 deletions
diff --git a/src/social/test_social.c b/src/social/test_social.c
index dbcf822f8..93e7c9bf2 100644
--- a/src/social/test_social.c
+++ b/src/social/test_social.c
@@ -36,7 +36,7 @@
36#include "gnunet_core_service.h" 36#include "gnunet_core_service.h"
37#include "gnunet_identity_service.h" 37#include "gnunet_identity_service.h"
38 38
39#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300) 39#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
40 40
41#define DATA2ARG(data) data, sizeof (data) 41#define DATA2ARG(data) data, sizeof (data)
42 42
@@ -101,7 +101,7 @@ struct TransmitClosure
101 101
102struct ResultClosure { 102struct ResultClosure {
103 uint32_t n; 103 uint32_t n;
104}; 104} mod_foo_bar_rcls;
105 105
106uint8_t join_req_count; 106uint8_t join_req_count;
107struct GNUNET_PSYC_Message *join_resp; 107struct GNUNET_PSYC_Message *join_resp;
@@ -504,23 +504,44 @@ guest_recv_method (void *cls,
504 "Test #%u: Guest received method for message ID %" PRIu64 ":\n" 504 "Test #%u: Guest received method for message ID %" PRIu64 ":\n"
505 "%s (flags: %x)\n", 505 "%s (flags: %x)\n",
506 test, message_id, method_name, flags); 506 test, message_id, method_name, flags);
507 /* FIXME: check message */ 507 /** @todo FIXME: check message */
508} 508}
509 509
510 510
511static void 511static void
512guest_recv_modifier (void *cls, 512guest_recv_modifier (void *cls,
513 const struct GNUNET_PSYC_MessageModifier *mod, 513 const struct GNUNET_MessageHeader *msg,
514 uint64_t message_id, 514 uint64_t message_id,
515 enum GNUNET_ENV_Operator oper, 515 enum GNUNET_ENV_Operator oper,
516 const char *name, 516 const char *name,
517 const void *value, 517 const void *value,
518 uint16_t value_size) 518 uint16_t value_size,
519 uint16_t full_value_size)
519{ 520{
520 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 521 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
521 "Test #%u: Guest received modifier for message ID %" PRIu64 ":\n" 522 "Test #%u: Guest received modifier for message ID %" PRIu64 ":\n"
522 "%c%s: %.*s\n", 523 "%c%s: %.*s (size: %u)\n",
523 test, message_id, oper, name, value_size, value); 524 test, message_id, oper, name, value_size, value, value_size);
525 /** @todo FIXME: check modifier */
526}
527
528static void
529guest_recv_mod_foo_bar (void *cls,
530 const struct GNUNET_MessageHeader *msg,
531 uint64_t message_id,
532 enum GNUNET_ENV_Operator oper,
533 const char *name,
534 const void *value,
535 uint16_t value_size,
536 uint16_t full_value_size)
537{
538 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
539 "Test #%u: Guest received modifier matching _foo_bar for message ID %" PRIu64 ":\n"
540 "%c%s: %.*s (size: %u)\n",
541 test, message_id, oper, name, value_size, value, value_size);
542 struct ResultClosure *rc = cls;
543 rc->n++;
544 /** @todo FIXME: check modifier */
524} 545}
525 546
526 547
@@ -536,6 +557,7 @@ guest_recv_data (void *cls,
536 "Test #%u: Guest received data for message ID %" PRIu64 ":\n" 557 "Test #%u: Guest received data for message ID %" PRIu64 ":\n"
537 "%.*s\n", 558 "%.*s\n",
538 test, message_id, data_size, data); 559 test, message_id, data_size, data);
560 /** @todo FIXME: check data */
539} 561}
540 562
541 563
@@ -592,18 +614,19 @@ host_recv_method (void *cls,
592 "Test #%u: Host received method for message ID %" PRIu64 ":\n" 614 "Test #%u: Host received method for message ID %" PRIu64 ":\n"
593 "%s\n", 615 "%s\n",
594 test, message_id, method_name); 616 test, message_id, method_name);
595 /* FIXME: check message */ 617 /** @todo FIXME: check message */
596} 618}
597 619
598 620
599static void 621static void
600host_recv_modifier (void *cls, 622host_recv_modifier (void *cls,
601 const struct GNUNET_PSYC_MessageModifier *mod, 623 const struct GNUNET_MessageHeader *msg,
602 uint64_t message_id, 624 uint64_t message_id,
603 enum GNUNET_ENV_Operator oper, 625 enum GNUNET_ENV_Operator oper,
604 const char *name, 626 const char *name,
605 const void *value, 627 const void *value,
606 uint16_t value_size) 628 uint16_t value_size,
629 uint16_t full_value_size)
607{ 630{
608 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 631 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
609 "Test #%u: Host received modifier for message ID %" PRIu64 ":\n" 632 "Test #%u: Host received modifier for message ID %" PRIu64 ":\n"
@@ -657,7 +680,7 @@ host_recv_eom (void *cls,
657 break; 680 break;
658 681
659 case TEST_GUEST_TALK: 682 case TEST_GUEST_TALK:
660 guest_history_replay (); 683 guest_history_replay ();
661 break; 684 break;
662 685
663 default: 686 default:
@@ -695,6 +718,9 @@ host_announce ()
695{ 718{
696 test = TEST_HOST_ANNOUNCE; 719 test = TEST_HOST_ANNOUNCE;
697 720
721 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
722 "Test #%u: Host announcement.\n", test);
723
698 tmit = (struct TransmitClosure) {}; 724 tmit = (struct TransmitClosure) {};
699 tmit.env = GNUNET_ENV_environment_create (); 725 tmit.env = GNUNET_ENV_environment_create ();
700 GNUNET_ENV_environment_add (tmit.env, GNUNET_ENV_OP_ASSIGN, 726 GNUNET_ENV_environment_add (tmit.env, GNUNET_ENV_OP_ASSIGN,
@@ -720,8 +746,15 @@ host_announce ()
720static void 746static void
721host_announce2 () 747host_announce2 ()
722{ 748{
749 GNUNET_assert (2 == mod_foo_bar_rcls.n);
750 GNUNET_SOCIAL_slicer_modifier_remove (guest_slicer, "_foo_bar",
751 guest_recv_mod_foo_bar);
752
723 test = TEST_HOST_ANNOUNCE2; 753 test = TEST_HOST_ANNOUNCE2;
724 754
755 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
756 "Test #%u: Host announcement.\n", test);
757
725 tmit = (struct TransmitClosure) {}; 758 tmit = (struct TransmitClosure) {};
726 tmit.env = GNUNET_ENV_environment_create (); 759 tmit.env = GNUNET_ENV_environment_create ();
727 GNUNET_ENV_environment_add (tmit.env, GNUNET_ENV_OP_ASSIGN, 760 GNUNET_ENV_environment_add (tmit.env, GNUNET_ENV_OP_ASSIGN,
@@ -748,8 +781,8 @@ guest_recv_entry_decision (void *cls,
748 const struct GNUNET_PSYC_Message *entry_resp) 781 const struct GNUNET_PSYC_Message *entry_resp)
749{ 782{
750 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 783 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
751 "Guest received entry decision (try %u): %d.\n", 784 "Test #%u: Guest received entry decision (try %u): %d.\n",
752 join_req_count, is_admitted); 785 test, join_req_count, is_admitted);
753 786
754 if (NULL != entry_resp) 787 if (NULL != entry_resp)
755 { 788 {
@@ -762,7 +795,7 @@ guest_recv_entry_decision (void *cls,
762 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 795 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
763 "%s\n%.*s\n", 796 "%s\n%.*s\n",
764 method_name, data_size, data); 797 method_name, data_size, data);
765 /* FIXME: check response message */ 798 /** @todo FIXME: check response message */
766 } 799 }
767 800
768 switch (test) 801 switch (test)
@@ -795,8 +828,8 @@ host_answer_door (void *cls,
795 join_req_count++; 828 join_req_count++;
796 829
797 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 830 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
798 "Host received entry request from guest (try %u).\n", 831 "Test #%u: Host received entry request from guest (try %u).\n",
799 join_req_count); 832 test, join_req_count);
800 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 833 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
801 "%s\n%.*s\n", 834 "%s\n%.*s\n",
802 method_name, data_size, data); 835 method_name, data_size, data);
@@ -827,7 +860,8 @@ host_answer_door (void *cls,
827static void 860static void
828guest_recv_local_enter (void *cls, int result, uint64_t max_message_id) 861guest_recv_local_enter (void *cls, int result, uint64_t max_message_id)
829{ 862{
830 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Guest entered to local place.\n"); 863 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
864 "Test #%u: Guest entered to local place.\n", test);
831 865
832} 866}
833 867
@@ -835,7 +869,8 @@ guest_recv_local_enter (void *cls, int result, uint64_t max_message_id)
835static void 869static void
836guest_enter () 870guest_enter ()
837{ 871{
838 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Entering to place as guest.\n"); 872 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
873 "Test #%u: Entering to place as guest.\n", test);
839 874
840 struct GuestEnterMessage *emsg = &guest_enter_msg; 875 struct GuestEnterMessage *emsg = &guest_enter_msg;
841 876
@@ -865,11 +900,13 @@ id_guest_ego_cb (void *cls, const struct GNUNET_IDENTITY_Ego *ego)
865 guest_ego = ego; 900 guest_ego = ego;
866 901
867 guest_slicer = GNUNET_SOCIAL_slicer_create (); 902 guest_slicer = GNUNET_SOCIAL_slicer_create ();
868 GNUNET_SOCIAL_slicer_add (guest_slicer, "", 903 GNUNET_SOCIAL_slicer_method_add (guest_slicer, "",
869 &guest_recv_method, &guest_recv_modifier, 904 guest_recv_method, guest_recv_modifier,
870 &guest_recv_data, &guest_recv_eom, NULL); 905 guest_recv_data, guest_recv_eom, NULL);
906 GNUNET_SOCIAL_slicer_modifier_add (guest_slicer, "_foo_bar",
907 guest_recv_mod_foo_bar, &mod_foo_bar_rcls);
871 test = TEST_HOST_ANSWER_DOOR_ADMIT; 908 test = TEST_HOST_ANSWER_DOOR_ADMIT;
872 //host_announce (); 909
873 guest_enter (); 910 guest_enter ();
874} 911}
875 912
@@ -906,9 +943,9 @@ id_host_ego_cb (void *cls, const struct GNUNET_IDENTITY_Ego *ego)
906 host_ego = ego; 943 host_ego = ego;
907 944
908 host_slicer = GNUNET_SOCIAL_slicer_create (); 945 host_slicer = GNUNET_SOCIAL_slicer_create ();
909 GNUNET_SOCIAL_slicer_add (host_slicer, "", 946 GNUNET_SOCIAL_slicer_method_add (host_slicer, "",
910 &host_recv_method, &host_recv_modifier, 947 &host_recv_method, &host_recv_modifier,
911 &host_recv_data, &host_recv_eom, NULL); 948 &host_recv_data, &host_recv_eom, NULL);
912 949
913 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Entering to place as host.\n"); 950 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Entering to place as host.\n");
914 hst = GNUNET_SOCIAL_host_enter (cfg, host_ego, place_key, 951 hst = GNUNET_SOCIAL_host_enter (cfg, host_ego, place_key,