aboutsummaryrefslogtreecommitdiff
path: root/src/social/test_social.c
diff options
context:
space:
mode:
authorGabor X Toth <*@tg-x.net>2016-01-12 23:26:47 +0000
committerGabor X Toth <*@tg-x.net>2016-01-12 23:26:47 +0000
commit50eaf8d7de763d25b7dae7ffdee8d7c6b5fe71ea (patch)
treea8023bdb9c9446a45792d7100303265c78713a50 /src/social/test_social.c
parent3cbdbe18dbd56def00c0014381ff90b4ee664904 (diff)
downloadgnunet-50eaf8d7de763d25b7dae7ffdee8d7c6b5fe71ea.tar.gz
gnunet-50eaf8d7de763d25b7dae7ffdee8d7c6b5fe71ea.zip
psycutil reorg: message, env, slicer
Diffstat (limited to 'src/social/test_social.c')
-rw-r--r--src/social/test_social.c127
1 files changed, 63 insertions, 64 deletions
diff --git a/src/social/test_social.c b/src/social/test_social.c
index 1fb9cc568..925fff03e 100644
--- a/src/social/test_social.c
+++ b/src/social/test_social.c
@@ -30,7 +30,6 @@
30#include "gnunet_common.h" 30#include "gnunet_common.h"
31#include "gnunet_util_lib.h" 31#include "gnunet_util_lib.h"
32#include "gnunet_testing_lib.h" 32#include "gnunet_testing_lib.h"
33#include "gnunet_env_lib.h"
34#include "gnunet_psyc_util_lib.h" 33#include "gnunet_psyc_util_lib.h"
35#include "gnunet_social_service.h" 34#include "gnunet_social_service.h"
36#include "gnunet_core_service.h" 35#include "gnunet_core_service.h"
@@ -75,8 +74,8 @@ struct GNUNET_HashCode place_pub_hash;
75struct GNUNET_CRYPTO_EcdsaPublicKey guest_pub_key; 74struct GNUNET_CRYPTO_EcdsaPublicKey guest_pub_key;
76struct GNUNET_CRYPTO_EcdsaPublicKey host_pub_key; 75struct GNUNET_CRYPTO_EcdsaPublicKey host_pub_key;
77 76
78struct GNUNET_SOCIAL_Slicer *host_slicer; 77struct GNUNET_PSYC_Slicer *host_slicer;
79struct GNUNET_SOCIAL_Slicer *guest_slicer; 78struct GNUNET_PSYC_Slicer *guest_slicer;
80 79
81struct GNUNET_SOCIAL_Host *hst; 80struct GNUNET_SOCIAL_Host *hst;
82struct GNUNET_SOCIAL_Guest *gst; 81struct GNUNET_SOCIAL_Guest *gst;
@@ -90,7 +89,7 @@ struct GuestEnterMessage
90{ 89{
91 struct GNUNET_PSYC_Message *msg; 90 struct GNUNET_PSYC_Message *msg;
92 const char *method_name; 91 const char *method_name;
93 struct GNUNET_ENV_Environment *env; 92 struct GNUNET_PSYC_Environment *env;
94 void *data; 93 void *data;
95 uint16_t data_size; 94 uint16_t data_size;
96} guest_enter_msg; 95} guest_enter_msg;
@@ -99,7 +98,7 @@ struct TransmitClosure
99{ 98{
100 struct GNUNET_SOCIAL_Announcement *host_ann; 99 struct GNUNET_SOCIAL_Announcement *host_ann;
101 struct GNUNET_SOCIAL_TalkRequest *guest_talk; 100 struct GNUNET_SOCIAL_TalkRequest *guest_talk;
102 struct GNUNET_ENV_Environment *env; 101 struct GNUNET_PSYC_Environment *env;
103 char *data[16]; 102 char *data[16];
104 uint8_t data_delay[16]; 103 uint8_t data_delay[16];
105 uint8_t data_count; 104 uint8_t data_count;
@@ -156,7 +155,7 @@ static void
156host_answer_door (void *cls, 155host_answer_door (void *cls,
157 struct GNUNET_SOCIAL_Nym *nym, 156 struct GNUNET_SOCIAL_Nym *nym,
158 const char *method_name, 157 const char *method_name,
159 struct GNUNET_ENV_Environment *env, 158 struct GNUNET_PSYC_Environment *env,
160 size_t data_size, 159 size_t data_size,
161 const void *data); 160 const void *data);
162 161
@@ -199,13 +198,13 @@ cleanup ()
199 198
200 if (NULL != guest_slicer) 199 if (NULL != guest_slicer)
201 { 200 {
202 GNUNET_SOCIAL_slicer_destroy (guest_slicer); 201 GNUNET_PSYC_slicer_destroy (guest_slicer);
203 guest_slicer = NULL; 202 guest_slicer = NULL;
204 } 203 }
205 204
206 if (NULL != host_slicer) 205 if (NULL != host_slicer)
207 { 206 {
208 GNUNET_SOCIAL_slicer_destroy (host_slicer); 207 GNUNET_PSYC_slicer_destroy (host_slicer);
209 host_slicer = NULL; 208 host_slicer = NULL;
210 } 209 }
211 210
@@ -292,7 +291,7 @@ notify_data (void *cls, uint16_t *data_size, void *data)
292 struct TransmitClosure *tmit = cls; 291 struct TransmitClosure *tmit = cls;
293 if (NULL != tmit->env) 292 if (NULL != tmit->env)
294 { 293 {
295 GNUNET_ENV_environment_destroy (tmit->env); 294 GNUNET_PSYC_env_destroy (tmit->env);
296 tmit->env = NULL; 295 tmit->env = NULL;
297 } 296 }
298 if (0 == tmit->data_count) 297 if (0 == tmit->data_count)
@@ -355,7 +354,7 @@ schedule_host_leave (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
355static void 354static void
356host_farewell2 (void *cls, 355host_farewell2 (void *cls,
357 const struct GNUNET_SOCIAL_Nym *nym, 356 const struct GNUNET_SOCIAL_Nym *nym,
358 struct GNUNET_ENV_Environment *env) 357 struct GNUNET_PSYC_Environment *env)
359{ 358{
360 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 359 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
361 "Nym left the place again.\n"); 360 "Nym left the place again.\n");
@@ -526,7 +525,7 @@ zone_add_place ()
526static void 525static void
527host_farewell (void *cls, 526host_farewell (void *cls,
528 const struct GNUNET_SOCIAL_Nym *nym, 527 const struct GNUNET_SOCIAL_Nym *nym,
529 struct GNUNET_ENV_Environment *env) 528 struct GNUNET_PSYC_Environment *env)
530{ 529{
531 const struct GNUNET_CRYPTO_EcdsaPublicKey * 530 const struct GNUNET_CRYPTO_EcdsaPublicKey *
532 nym_key = GNUNET_SOCIAL_nym_get_pub_key (nym); 531 nym_key = GNUNET_SOCIAL_nym_get_pub_key (nym);
@@ -536,7 +535,7 @@ host_farewell (void *cls,
536 "Farewell: nym %s (%s) has left the place.\n", 535 "Farewell: nym %s (%s) has left the place.\n",
537 GNUNET_h2s (GNUNET_SOCIAL_nym_get_pub_key_hash (nym)), str); 536 GNUNET_h2s (GNUNET_SOCIAL_nym_get_pub_key_hash (nym)), str);
538 GNUNET_free (str); 537 GNUNET_free (str);
539 GNUNET_assert (1 == GNUNET_ENV_environment_get_count (env)); 538 GNUNET_assert (1 == GNUNET_PSYC_env_get_count (env));
540 if (0 != memcmp (&guest_pub_key, nym_key, sizeof (*nym_key))) 539 if (0 != memcmp (&guest_pub_key, nym_key, sizeof (*nym_key)))
541 { 540 {
542 str = GNUNET_CRYPTO_ecdsa_public_key_to_string (&guest_pub_key); 541 str = GNUNET_CRYPTO_ecdsa_public_key_to_string (&guest_pub_key);
@@ -565,11 +564,11 @@ guest_leave()
565 else 564 else
566 test = TEST_GUEST_LEAVE2; 565 test = TEST_GUEST_LEAVE2;
567 566
568 struct GNUNET_ENV_Environment *env = GNUNET_ENV_environment_create (); 567 struct GNUNET_PSYC_Environment *env = GNUNET_PSYC_env_create ();
569 GNUNET_ENV_environment_add (env, GNUNET_ENV_OP_SET, 568 GNUNET_PSYC_env_add (env, GNUNET_PSYC_OP_SET,
570 "_message", DATA2ARG ("Leaving.")); 569 "_message", DATA2ARG ("Leaving."));
571 GNUNET_SOCIAL_guest_leave (gst, env, &guest_left, NULL); 570 GNUNET_SOCIAL_guest_leave (gst, env, &guest_left, NULL);
572 GNUNET_ENV_environment_destroy (env); 571 GNUNET_PSYC_env_destroy (env);
573 gst = NULL; 572 gst = NULL;
574 gst_plc = NULL; 573 gst_plc = NULL;
575} 574}
@@ -723,7 +722,7 @@ guest_recv_method (void *cls,
723 const struct GNUNET_PSYC_MessageMethod *meth, 722 const struct GNUNET_PSYC_MessageMethod *meth,
724 uint64_t message_id, 723 uint64_t message_id,
725 uint32_t flags, 724 uint32_t flags,
726 const struct GNUNET_SOCIAL_Nym *nym, 725 const struct GNUNET_CRYPTO_EcdsaPublicKey *nym_pub_key,
727 const char *method_name) 726 const char *method_name)
728{ 727{
729 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 728 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -738,7 +737,7 @@ static void
738guest_recv_modifier (void *cls, 737guest_recv_modifier (void *cls,
739 const struct GNUNET_MessageHeader *msg, 738 const struct GNUNET_MessageHeader *msg,
740 uint64_t message_id, 739 uint64_t message_id,
741 enum GNUNET_ENV_Operator oper, 740 enum GNUNET_PSYC_Operator oper,
742 const char *name, 741 const char *name,
743 const void *value, 742 const void *value,
744 uint16_t value_size, 743 uint16_t value_size,
@@ -755,7 +754,7 @@ static void
755guest_recv_mod_foo_bar (void *cls, 754guest_recv_mod_foo_bar (void *cls,
756 const struct GNUNET_MessageHeader *msg, 755 const struct GNUNET_MessageHeader *msg,
757 uint64_t message_id, 756 uint64_t message_id,
758 enum GNUNET_ENV_Operator oper, 757 enum GNUNET_PSYC_Operator oper,
759 const char *name, 758 const char *name,
760 const void *value, 759 const void *value,
761 uint16_t value_size, 760 uint16_t value_size,
@@ -833,7 +832,7 @@ host_recv_method (void *cls,
833 const struct GNUNET_PSYC_MessageMethod *meth, 832 const struct GNUNET_PSYC_MessageMethod *meth,
834 uint64_t message_id, 833 uint64_t message_id,
835 uint32_t flags, 834 uint32_t flags,
836 const struct GNUNET_SOCIAL_Nym *nym, 835 const struct GNUNET_CRYPTO_EcdsaPublicKey *nym_pub_key,
837 const char *method_name) 836 const char *method_name)
838{ 837{
839 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 838 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -848,7 +847,7 @@ static void
848host_recv_modifier (void *cls, 847host_recv_modifier (void *cls,
849 const struct GNUNET_MessageHeader *msg, 848 const struct GNUNET_MessageHeader *msg,
850 uint64_t message_id, 849 uint64_t message_id,
851 enum GNUNET_ENV_Operator oper, 850 enum GNUNET_PSYC_Operator oper,
852 const char *name, 851 const char *name,
853 const void *value, 852 const void *value,
854 uint16_t value_size, 853 uint16_t value_size,
@@ -924,11 +923,11 @@ guest_talk ()
924 test = TEST_GUEST_TALK; 923 test = TEST_GUEST_TALK;
925 924
926 tmit = (struct TransmitClosure) {}; 925 tmit = (struct TransmitClosure) {};
927 tmit.env = GNUNET_ENV_environment_create (); 926 tmit.env = GNUNET_PSYC_env_create ();
928 GNUNET_ENV_environment_add (tmit.env, GNUNET_ENV_OP_ASSIGN, 927 GNUNET_PSYC_env_add (tmit.env, GNUNET_PSYC_OP_ASSIGN,
929 "_bar_foo", DATA2ARG ("one two three")); 928 "_bar_foo", DATA2ARG ("one two three"));
930 GNUNET_ENV_environment_add (tmit.env, GNUNET_ENV_OP_ASSIGN, 929 GNUNET_PSYC_env_add (tmit.env, GNUNET_PSYC_OP_ASSIGN,
931 "_bar_baz", DATA2ARG ("four five")); 930 "_bar_baz", DATA2ARG ("four five"));
932 tmit.data[0] = "zzz xxx yyy"; 931 tmit.data[0] = "zzz xxx yyy";
933 tmit.data[1] = "zyx wvu tsr qpo"; 932 tmit.data[1] = "zyx wvu tsr qpo";
934 tmit.data_delay[1] = 1; 933 tmit.data_delay[1] = 1;
@@ -951,13 +950,13 @@ host_announce ()
951 "Test #%u: Host announcement.\n", test); 950 "Test #%u: Host announcement.\n", test);
952 951
953 tmit = (struct TransmitClosure) {}; 952 tmit = (struct TransmitClosure) {};
954 tmit.env = GNUNET_ENV_environment_create (); 953 tmit.env = GNUNET_PSYC_env_create ();
955 GNUNET_ENV_environment_add (tmit.env, GNUNET_ENV_OP_ASSIGN, 954 GNUNET_PSYC_env_add (tmit.env, GNUNET_PSYC_OP_ASSIGN,
956 "_foo", DATA2ARG ("bar baz")); 955 "_foo", DATA2ARG ("bar baz"));
957 GNUNET_ENV_environment_add (tmit.env, GNUNET_ENV_OP_ASSIGN, 956 GNUNET_PSYC_env_add (tmit.env, GNUNET_PSYC_OP_ASSIGN,
958 "_foo_bar", DATA2ARG ("foo bar")); 957 "_foo_bar", DATA2ARG ("foo bar"));
959 GNUNET_ENV_environment_add (tmit.env, GNUNET_ENV_OP_ASSIGN, 958 GNUNET_PSYC_env_add (tmit.env, GNUNET_PSYC_OP_ASSIGN,
960 "_foo_bar_baz", DATA2ARG ("foo bar baz")); 959 "_foo_bar_baz", DATA2ARG ("foo bar baz"));
961 tmit.data[0] = "aaa bbb ccc"; 960 tmit.data[0] = "aaa bbb ccc";
962 tmit.data[1] = "abc def ghi jkl"; 961 tmit.data[1] = "abc def ghi jkl";
963 tmit.data_delay[1] = 1; 962 tmit.data_delay[1] = 1;
@@ -976,8 +975,8 @@ static void
976host_announce2 () 975host_announce2 ()
977{ 976{
978 GNUNET_assert (2 == mod_foo_bar_rcls.n); 977 GNUNET_assert (2 == mod_foo_bar_rcls.n);
979 GNUNET_SOCIAL_slicer_modifier_remove (guest_slicer, "_foo_bar", 978 GNUNET_PSYC_slicer_modifier_remove (guest_slicer, "_foo_bar",
980 guest_recv_mod_foo_bar); 979 guest_recv_mod_foo_bar);
981 980
982 test = TEST_HOST_ANNOUNCE2; 981 test = TEST_HOST_ANNOUNCE2;
983 982
@@ -985,13 +984,13 @@ host_announce2 ()
985 "Test #%u: Host announcement 2.\n", test); 984 "Test #%u: Host announcement 2.\n", test);
986 985
987 tmit = (struct TransmitClosure) {}; 986 tmit = (struct TransmitClosure) {};
988 tmit.env = GNUNET_ENV_environment_create (); 987 tmit.env = GNUNET_PSYC_env_create ();
989 GNUNET_ENV_environment_add (tmit.env, GNUNET_ENV_OP_ASSIGN, 988 GNUNET_PSYC_env_add (tmit.env, GNUNET_PSYC_OP_ASSIGN,
990 "_foo2", DATA2ARG ("BAR BAZ")); 989 "_foo2", DATA2ARG ("BAR BAZ"));
991 GNUNET_ENV_environment_add (tmit.env, GNUNET_ENV_OP_ASSIGN, 990 GNUNET_PSYC_env_add (tmit.env, GNUNET_PSYC_OP_ASSIGN,
992 "_foo2_bar", DATA2ARG ("FOO BAR")); 991 "_foo2_bar", DATA2ARG ("FOO BAR"));
993 GNUNET_ENV_environment_add (tmit.env, GNUNET_ENV_OP_ASSIGN, 992 GNUNET_PSYC_env_add (tmit.env, GNUNET_PSYC_OP_ASSIGN,
994 "_foo2_bar", DATA2ARG ("FOO BAR BAZ")); 993 "_foo2_bar", DATA2ARG ("FOO BAR BAZ"));
995 tmit.data[0] = "AAA BBB CCC"; 994 tmit.data[0] = "AAA BBB CCC";
996 tmit.data[1] = "ABC DEF GHI JKL"; 995 tmit.data[1] = "ABC DEF GHI JKL";
997 tmit.data[2] = "TESTING ONE TWO THREE"; 996 tmit.data[2] = "TESTING ONE TWO THREE";
@@ -1015,7 +1014,7 @@ guest_recv_entry_decision (void *cls,
1015 1014
1016 if (NULL != entry_msg) 1015 if (NULL != entry_msg)
1017 { 1016 {
1018 struct GNUNET_ENV_Environment *env = GNUNET_ENV_environment_create (); 1017 struct GNUNET_PSYC_Environment *env = GNUNET_PSYC_env_create ();
1019 const char *method_name = NULL; 1018 const char *method_name = NULL;
1020 const void *data = NULL; 1019 const void *data = NULL;
1021 uint16_t data_size = 0; 1020 uint16_t data_size = 0;
@@ -1057,7 +1056,7 @@ static void
1057host_answer_door (void *cls, 1056host_answer_door (void *cls,
1058 struct GNUNET_SOCIAL_Nym *nym, 1057 struct GNUNET_SOCIAL_Nym *nym,
1059 const char *method_name, 1058 const char *method_name,
1060 struct GNUNET_ENV_Environment *env, 1059 struct GNUNET_PSYC_Environment *env,
1061 size_t data_size, 1060 size_t data_size,
1062 const void *data) 1061 const void *data)
1063{ 1062{
@@ -1113,11 +1112,11 @@ guest_enter ()
1113 struct GuestEnterMessage *emsg = &guest_enter_msg; 1112 struct GuestEnterMessage *emsg = &guest_enter_msg;
1114 1113
1115 emsg->method_name = "_request_enter"; 1114 emsg->method_name = "_request_enter";
1116 emsg->env = GNUNET_ENV_environment_create (); 1115 emsg->env = GNUNET_PSYC_env_create ();
1117 GNUNET_ENV_environment_add (emsg->env, GNUNET_ENV_OP_ASSIGN, 1116 GNUNET_PSYC_env_add (emsg->env, GNUNET_PSYC_OP_ASSIGN,
1118 "_abc", "abc def", 7); 1117 "_abc", "abc def", 7);
1119 GNUNET_ENV_environment_add (emsg->env, GNUNET_ENV_OP_ASSIGN, 1118 GNUNET_PSYC_env_add (emsg->env, GNUNET_PSYC_OP_ASSIGN,
1120 "_abc_def", "abc def ghi", 11); 1119 "_abc_def", "abc def ghi", 11);
1121 emsg->data = "let me in"; 1120 emsg->data = "let me in";
1122 emsg->data_size = strlen (emsg->data) + 1; 1121 emsg->data_size = strlen (emsg->data) + 1;
1123 emsg->msg = GNUNET_PSYC_message_create (emsg->method_name, emsg->env, 1122 emsg->msg = GNUNET_PSYC_message_create (emsg->method_name, emsg->env,
@@ -1142,11 +1141,11 @@ guest_enter_by_name ()
1142 struct GuestEnterMessage *emsg = &guest_enter_msg; 1141 struct GuestEnterMessage *emsg = &guest_enter_msg;
1143 1142
1144 emsg->method_name = "_request_enter"; 1143 emsg->method_name = "_request_enter";
1145 emsg->env = GNUNET_ENV_environment_create (); 1144 emsg->env = GNUNET_PSYC_env_create ();
1146 GNUNET_ENV_environment_add (emsg->env, GNUNET_ENV_OP_ASSIGN, 1145 GNUNET_PSYC_env_add (emsg->env, GNUNET_PSYC_OP_ASSIGN,
1147 "_abc", "abc def", 7); 1146 "_abc", "abc def", 7);
1148 GNUNET_ENV_environment_add (emsg->env, GNUNET_ENV_OP_ASSIGN, 1147 GNUNET_PSYC_env_add (emsg->env, GNUNET_PSYC_OP_ASSIGN,
1149 "_abc_def", "abc def ghi", 11); 1148 "_abc_def", "abc def ghi", 11);
1150 emsg->data = "let me in"; 1149 emsg->data = "let me in";
1151 emsg->data_size = strlen (emsg->data) + 1; 1150 emsg->data_size = strlen (emsg->data) + 1;
1152 emsg->msg = GNUNET_PSYC_message_create (emsg->method_name, emsg->env, 1151 emsg->msg = GNUNET_PSYC_message_create (emsg->method_name, emsg->env,
@@ -1175,12 +1174,12 @@ guest_init ()
1175{ 1174{
1176 guest_pub_key = *(GNUNET_SOCIAL_ego_get_pub_key (guest_ego)); 1175 guest_pub_key = *(GNUNET_SOCIAL_ego_get_pub_key (guest_ego));
1177 1176
1178 guest_slicer = GNUNET_SOCIAL_slicer_create (); 1177 guest_slicer = GNUNET_PSYC_slicer_create ();
1179 GNUNET_SOCIAL_slicer_method_add (guest_slicer, "", 1178 GNUNET_PSYC_slicer_method_add (guest_slicer, "",
1180 guest_recv_method, guest_recv_modifier, 1179 guest_recv_method, guest_recv_modifier,
1181 guest_recv_data, guest_recv_eom, NULL); 1180 guest_recv_data, guest_recv_eom, NULL);
1182 GNUNET_SOCIAL_slicer_modifier_add (guest_slicer, "_foo_bar", 1181 GNUNET_PSYC_slicer_modifier_add (guest_slicer, "_foo_bar",
1183 guest_recv_mod_foo_bar, &mod_foo_bar_rcls); 1182 guest_recv_mod_foo_bar, &mod_foo_bar_rcls);
1184 test = TEST_HOST_ANSWER_DOOR_ADMIT; 1183 test = TEST_HOST_ANSWER_DOOR_ADMIT;
1185 1184
1186 GNUNET_SOCIAL_zone_add_nym (app, guest_ego, "host", &host_pub_key, 1185 GNUNET_SOCIAL_zone_add_nym (app, guest_ego, "host", &host_pub_key,
@@ -1224,10 +1223,10 @@ host_entered (void *cls, int result,
1224static void 1223static void
1225host_enter () 1224host_enter ()
1226{ 1225{
1227 host_slicer = GNUNET_SOCIAL_slicer_create (); 1226 host_slicer = GNUNET_PSYC_slicer_create ();
1228 GNUNET_SOCIAL_slicer_method_add (host_slicer, "", 1227 GNUNET_PSYC_slicer_method_add (host_slicer, "",
1229 &host_recv_method, &host_recv_modifier, 1228 &host_recv_method, &host_recv_modifier,
1230 &host_recv_data, &host_recv_eom, NULL); 1229 &host_recv_data, &host_recv_eom, NULL);
1231 1230
1232 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Entering to place as host.\n"); 1231 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Entering to place as host.\n");
1233 test = TEST_HOST_ENTER; 1232 test = TEST_HOST_ENTER;