aboutsummaryrefslogtreecommitdiff
path: root/src/social/test_social.c
diff options
context:
space:
mode:
authorGabor X Toth <*@tg-x.net>2015-09-08 01:36:33 +0000
committerGabor X Toth <*@tg-x.net>2015-09-08 01:36:33 +0000
commita86a539258282bedabd24919e8af9bd113a6538a (patch)
tree84d67a3ed9adca66e71709dda6c86f69ad3e9360 /src/social/test_social.c
parent8752370da610cd9313b4dbfcb261420b6c181344 (diff)
downloadgnunet-a86a539258282bedabd24919e8af9bd113a6538a.tar.gz
gnunet-a86a539258282bedabd24919e8af9bd113a6538a.zip
social: advertise; farewell fix
Diffstat (limited to 'src/social/test_social.c')
-rw-r--r--src/social/test_social.c36
1 files changed, 28 insertions, 8 deletions
diff --git a/src/social/test_social.c b/src/social/test_social.c
index ad4101bd6..50150449c 100644
--- a/src/social/test_social.c
+++ b/src/social/test_social.c
@@ -127,7 +127,9 @@ enum
127 TEST_GUEST_LOOK_AT = 12, 127 TEST_GUEST_LOOK_AT = 12,
128 TEST_GUEST_LOOK_FOR = 13, 128 TEST_GUEST_LOOK_FOR = 13,
129 TEST_GUEST_LEAVE = 14, 129 TEST_GUEST_LEAVE = 14,
130 TEST_HOST_LEAVE = 15, 130 TEST_HOST_ADVERTISE = 15,
131 TEST_GUEST_ENTER_BY_NAME = 16,
132 TEST_HOST_LEAVE = 17,
131} test; 133} test;
132 134
133 135
@@ -307,17 +309,36 @@ schedule_host_leave (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
307 309
308 310
309static void 311static void
312host_recv_advertise_result (void *cls, int32_t success, const char *emsg)
313{
314 GNUNET_assert (GNUNET_YES == success);
315 GNUNET_SCHEDULER_add_now (&schedule_host_leave, NULL);
316}
317
318
319static void
320host_advertise ()
321{
322 test = TEST_HOST_ADVERTISE;
323 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test #%u: Advertising place.\n", test);
324 GNUNET_SOCIAL_host_advertise (hst, "home", 1, &this_peer,
325 GNUNET_TIME_UNIT_MINUTES, "let.me*in!",
326 host_recv_advertise_result, hst);
327}
328
329
330static void
310host_farewell (void *cls, 331host_farewell (void *cls,
311 const struct GNUNET_SOCIAL_Nym *nym, 332 const struct GNUNET_SOCIAL_Nym *nym,
312 struct GNUNET_ENV_Environment *env) 333 struct GNUNET_ENV_Environment *env)
313{ 334{
314 const struct GNUNET_CRYPTO_EcdsaPublicKey *nym_key = GNUNET_SOCIAL_nym_get_key (nym); 335 const struct GNUNET_CRYPTO_EcdsaPublicKey *
315 char *str; 336 nym_key = GNUNET_SOCIAL_nym_get_key (nym);
316 337
317 str = GNUNET_CRYPTO_ecdsa_public_key_to_string (nym_key); 338 char *str = GNUNET_CRYPTO_ecdsa_public_key_to_string (nym_key);
318 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 339 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
319 "Farewell: nym %s has left the place.\n", 340 "Farewell: nym %s (%s) has left the place.\n",
320 str); 341 GNUNET_h2s (GNUNET_SOCIAL_nym_get_key_hash (nym)), str);
321 GNUNET_free (str); 342 GNUNET_free (str);
322 GNUNET_assert (1 == GNUNET_ENV_environment_get_count (env)); 343 GNUNET_assert (1 == GNUNET_ENV_environment_get_count (env));
323 if (0 != memcmp (&guest_pub_key, nym_key, sizeof (*nym_key))) 344 if (0 != memcmp (&guest_pub_key, nym_key, sizeof (*nym_key)))
@@ -328,8 +349,7 @@ host_farewell (void *cls,
328 GNUNET_free (str); 349 GNUNET_free (str);
329 GNUNET_assert (0); 350 GNUNET_assert (0);
330 } 351 }
331 352 host_advertise ();
332 GNUNET_SCHEDULER_add_now (&schedule_host_leave, NULL);
333} 353}
334 354
335 355