diff options
author | Gabor X Toth <*@tg-x.net> | 2015-09-05 23:44:11 +0000 |
---|---|---|
committer | Gabor X Toth <*@tg-x.net> | 2015-09-05 23:44:11 +0000 |
commit | 8752370da610cd9313b4dbfcb261420b6c181344 (patch) | |
tree | 7b19fc7ea58565ed0df19e1b4849996bb702338c /src/social/test_social.c | |
parent | 878b09fe6521df37c2d39f884a6c892b370473a5 (diff) | |
download | gnunet-8752370da610cd9313b4dbfcb261420b6c181344.tar.gz gnunet-8752370da610cd9313b4dbfcb261420b6c181344.zip |
social: farewell
Diffstat (limited to 'src/social/test_social.c')
-rw-r--r-- | src/social/test_social.c | 53 |
1 files changed, 32 insertions, 21 deletions
diff --git a/src/social/test_social.c b/src/social/test_social.c index 93e7c9bf2..ad4101bd6 100644 --- a/src/social/test_social.c +++ b/src/social/test_social.c | |||
@@ -78,6 +78,8 @@ struct GNUNET_SOCIAL_Guest *gst; | |||
78 | struct GNUNET_SOCIAL_Place *hst_plc; | 78 | struct GNUNET_SOCIAL_Place *hst_plc; |
79 | struct GNUNET_SOCIAL_Place *gst_plc; | 79 | struct GNUNET_SOCIAL_Place *gst_plc; |
80 | 80 | ||
81 | struct GNUNET_SOCIAL_Nym *nym_eject; | ||
82 | |||
81 | struct GuestEnterMessage | 83 | struct GuestEnterMessage |
82 | { | 84 | { |
83 | struct GNUNET_PSYC_Message *msg; | 85 | struct GNUNET_PSYC_Message *msg; |
@@ -161,7 +163,7 @@ cleanup () | |||
161 | 163 | ||
162 | if (NULL != gst) | 164 | if (NULL != gst) |
163 | { | 165 | { |
164 | GNUNET_SOCIAL_guest_leave (gst, GNUNET_NO, NULL, NULL); | 166 | GNUNET_SOCIAL_guest_leave (gst, GNUNET_NO, NULL, NULL, NULL); |
165 | gst = NULL; | 167 | gst = NULL; |
166 | gst_plc = NULL; | 168 | gst_plc = NULL; |
167 | } | 169 | } |
@@ -306,21 +308,26 @@ schedule_host_leave (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
306 | 308 | ||
307 | static void | 309 | static void |
308 | host_farewell (void *cls, | 310 | host_farewell (void *cls, |
309 | struct GNUNET_SOCIAL_Nym *nym, | 311 | const struct GNUNET_SOCIAL_Nym *nym, |
310 | struct GNUNET_ENV_Environment *env, | 312 | struct GNUNET_ENV_Environment *env) |
311 | size_t variable_count, | ||
312 | struct GNUNET_ENV_Modifier *variables) | ||
313 | { | 313 | { |
314 | // FIXME: this function is not called yet | 314 | const struct GNUNET_CRYPTO_EcdsaPublicKey *nym_key = GNUNET_SOCIAL_nym_get_key (nym); |
315 | struct GNUNET_CRYPTO_EcdsaPublicKey *nym_key = GNUNET_SOCIAL_nym_get_key (nym); | ||
316 | char *str; | 315 | char *str; |
317 | 316 | ||
318 | str = GNUNET_CRYPTO_ecdsa_public_key_to_string (nym_key); | 317 | str = GNUNET_CRYPTO_ecdsa_public_key_to_string (nym_key); |
319 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 318 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
320 | "Nym %s has left the place.\n", | 319 | "Farewell: nym %s has left the place.\n", |
321 | str); | 320 | str); |
322 | GNUNET_free (str); | 321 | GNUNET_free (str); |
323 | GNUNET_assert (0 == memcmp (&guest_pub_key, nym_key, sizeof (*nym_key))); | 322 | GNUNET_assert (1 == GNUNET_ENV_environment_get_count (env)); |
323 | if (0 != memcmp (&guest_pub_key, nym_key, sizeof (*nym_key))) | ||
324 | { | ||
325 | str = GNUNET_CRYPTO_ecdsa_public_key_to_string (&guest_pub_key); | ||
326 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
327 | "Farewell: nym does not match guest: %s\n", str); | ||
328 | GNUNET_free (str); | ||
329 | GNUNET_assert (0); | ||
330 | } | ||
324 | 331 | ||
325 | GNUNET_SCHEDULER_add_now (&schedule_host_leave, NULL); | 332 | GNUNET_SCHEDULER_add_now (&schedule_host_leave, NULL); |
326 | } | 333 | } |
@@ -335,8 +342,6 @@ guest_left (void *cls) | |||
335 | guest_slicer = NULL; | 342 | guest_slicer = NULL; |
336 | gst = NULL; | 343 | gst = NULL; |
337 | gst_plc = NULL; | 344 | gst_plc = NULL; |
338 | |||
339 | GNUNET_SCHEDULER_add_now (&schedule_host_leave, NULL); | ||
340 | } | 345 | } |
341 | 346 | ||
342 | 347 | ||
@@ -344,8 +349,14 @@ static void | |||
344 | guest_leave() | 349 | guest_leave() |
345 | { | 350 | { |
346 | test = TEST_GUEST_LEAVE; | 351 | test = TEST_GUEST_LEAVE; |
347 | /* FIXME test keep_active */ | 352 | |
348 | GNUNET_SOCIAL_guest_leave (gst, GNUNET_NO, &guest_left, NULL); | 353 | struct GNUNET_ENV_Environment *env = GNUNET_ENV_environment_create (); |
354 | GNUNET_ENV_environment_add (env, GNUNET_ENV_OP_SET, | ||
355 | "_message", DATA2ARG ("Leaving.")); | ||
356 | GNUNET_SOCIAL_guest_leave (gst, GNUNET_NO, env, &guest_left, NULL); | ||
357 | GNUNET_ENV_environment_destroy (env); | ||
358 | |||
359 | /* @todo test keep_active */ | ||
349 | } | 360 | } |
350 | 361 | ||
351 | 362 | ||
@@ -683,6 +694,9 @@ host_recv_eom (void *cls, | |||
683 | guest_history_replay (); | 694 | guest_history_replay (); |
684 | break; | 695 | break; |
685 | 696 | ||
697 | case TEST_GUEST_LEAVE: | ||
698 | break; | ||
699 | |||
686 | default: | 700 | default: |
687 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "invalid test: %d\n", test); | 701 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "invalid test: %d\n", test); |
688 | GNUNET_assert (0); | 702 | GNUNET_assert (0); |
@@ -738,8 +752,7 @@ host_announce () | |||
738 | tmit.host_ann | 752 | tmit.host_ann |
739 | = GNUNET_SOCIAL_host_announce (hst, "_message_host", tmit.env, | 753 | = GNUNET_SOCIAL_host_announce (hst, "_message_host", tmit.env, |
740 | ¬ify_data, &tmit, | 754 | ¬ify_data, &tmit, |
741 | GNUNET_SOCIAL_ANNOUNCE_NONE | 755 | GNUNET_SOCIAL_ANNOUNCE_NONE); |
742 | | GNUNET_PSYC_MASTER_TRANSMIT_STATE_MODIFY); | ||
743 | } | 756 | } |
744 | 757 | ||
745 | 758 | ||
@@ -753,7 +766,7 @@ host_announce2 () | |||
753 | test = TEST_HOST_ANNOUNCE2; | 766 | test = TEST_HOST_ANNOUNCE2; |
754 | 767 | ||
755 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 768 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
756 | "Test #%u: Host announcement.\n", test); | 769 | "Test #%u: Host announcement 2.\n", test); |
757 | 770 | ||
758 | tmit = (struct TransmitClosure) {}; | 771 | tmit = (struct TransmitClosure) {}; |
759 | tmit.env = GNUNET_ENV_environment_create (); | 772 | tmit.env = GNUNET_ENV_environment_create (); |
@@ -898,6 +911,7 @@ id_guest_ego_cb (void *cls, const struct GNUNET_IDENTITY_Ego *ego) | |||
898 | { | 911 | { |
899 | GNUNET_assert (NULL != ego); | 912 | GNUNET_assert (NULL != ego); |
900 | guest_ego = ego; | 913 | guest_ego = ego; |
914 | GNUNET_IDENTITY_ego_get_public_key (ego, &guest_pub_key); | ||
901 | 915 | ||
902 | guest_slicer = GNUNET_SOCIAL_slicer_create (); | 916 | guest_slicer = GNUNET_SOCIAL_slicer_create (); |
903 | GNUNET_SOCIAL_slicer_method_add (guest_slicer, "", | 917 | GNUNET_SOCIAL_slicer_method_add (guest_slicer, "", |
@@ -950,8 +964,8 @@ id_host_ego_cb (void *cls, const struct GNUNET_IDENTITY_Ego *ego) | |||
950 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Entering to place as host.\n"); | 964 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Entering to place as host.\n"); |
951 | hst = GNUNET_SOCIAL_host_enter (cfg, host_ego, place_key, | 965 | hst = GNUNET_SOCIAL_host_enter (cfg, host_ego, place_key, |
952 | GNUNET_PSYC_CHANNEL_PRIVATE, host_slicer, | 966 | GNUNET_PSYC_CHANNEL_PRIVATE, host_slicer, |
953 | &host_entered, &host_answer_door, | 967 | host_entered, host_answer_door, |
954 | &host_farewell, NULL); | 968 | host_farewell, NULL); |
955 | hst_plc = GNUNET_SOCIAL_host_get_place (hst); | 969 | hst_plc = GNUNET_SOCIAL_host_get_place (hst); |
956 | } | 970 | } |
957 | 971 | ||
@@ -1011,10 +1025,7 @@ run (void *cls, | |||
1011 | end_badly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); | 1025 | end_badly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); |
1012 | 1026 | ||
1013 | place_key = GNUNET_CRYPTO_eddsa_key_create (); | 1027 | place_key = GNUNET_CRYPTO_eddsa_key_create (); |
1014 | guest_key = GNUNET_CRYPTO_ecdsa_key_create (); | ||
1015 | |||
1016 | GNUNET_CRYPTO_eddsa_key_get_public (place_key, &place_pub_key); | 1028 | GNUNET_CRYPTO_eddsa_key_get_public (place_key, &place_pub_key); |
1017 | GNUNET_CRYPTO_ecdsa_key_get_public (guest_key, &guest_pub_key); | ||
1018 | 1029 | ||
1019 | core = GNUNET_CORE_connect (cfg, NULL, &core_connected, NULL, NULL, | 1030 | core = GNUNET_CORE_connect (cfg, NULL, &core_connected, NULL, NULL, |
1020 | NULL, GNUNET_NO, NULL, GNUNET_NO, NULL); | 1031 | NULL, GNUNET_NO, NULL, GNUNET_NO, NULL); |