From 7ab9736205132a01282e38f9079040015de90248 Mon Sep 17 00:00:00 2001 From: t3sserakt Date: Sat, 11 Apr 2020 18:12:26 +0200 Subject: [PATCH] fixed destroy test --- src/cadet/gnunet-service-cadet_channel.c | 2 +- src/cadet/test_cadet.c | 52 ++++++++++++++++-------- 2 files changed, 35 insertions(+), 19 deletions(-) diff --git a/src/cadet/gnunet-service-cadet_channel.c b/src/cadet/gnunet-service-cadet_channel.c index 1c2438c54..598acbc3a 100644 --- a/src/cadet/gnunet-service-cadet_channel.c +++ b/src/cadet/gnunet-service-cadet_channel.c @@ -389,7 +389,7 @@ struct CadetChannel }; /** - * Check if type of message is the one to drop. + * Assign type of message to drop. * @param ch CadetChannel to assign type to drop. * @param message GNUNET_CADET_RequestDropCadetMessage to get the type from. */ diff --git a/src/cadet/test_cadet.c b/src/cadet/test_cadet.c index 92751a4fe..d2fccb229 100644 --- a/src/cadet/test_cadet.c +++ b/src/cadet/test_cadet.c @@ -567,14 +567,14 @@ get_from_cadets() } static unsigned int -get_peer_nr() +get_peer_nr(int outgoing) { if (0 < GNUNET_memcmp (testpeer_id[0], testpeer_id[1])) { - return peers_running - 1; + return GNUNET_YES == outgoing ? 0 : peers_running - 1; }else { - return 0; + return GNUNET_YES == outgoing ? peers_running -1 : 0; } } @@ -667,7 +667,7 @@ get_peers(void *cls) GNUNET_log (GNUNET_ERROR_TYPE_INFO, "requesting peers info!\n"); - plo = GNUNET_CADET_list_peers (p_cfg[get_peer_nr()], &peers_callback, NULL); + plo = GNUNET_CADET_list_peers (p_cfg[get_peer_nr(GNUNET_YES)], &peers_callback, NULL); } @@ -688,6 +688,10 @@ peers_callback (void *cls, const struct GNUNET_CADET_PeerListEntry *ple) { const struct GNUNET_PeerIdentity *p_id; + const struct GNUNET_PeerIdentity *peer; + + + peer = &ple->peer; if (NULL == ple) { @@ -697,24 +701,27 @@ peers_callback (void *cls, const struct GNUNET_CADET_PeerListEntry *ple) p_id = get_from_p_ids(); GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "peer %s equal to peer %s?", - GNUNET_i2s_full (&ple->peer), + "ple->peer %s\n", GNUNET_i2s_full (&ple->peer)); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "p_id %s\n", + GNUNET_i2s_full (p_id)); - if (p_id == &ple->peer && ple->have_tunnel) + if (0 == GNUNET_memcmp (&ple->peer, p_id ) && ple->have_tunnel) { - - if (NULL != get_peers_task) - { - GNUNET_SCHEDULER_cancel (get_peers_task); - plo = NULL; - get_peers_task = GNUNET_SCHEDULER_add_now (&get_peers, + + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "schedule get_peers again?\n"); + get_peers_task = GNUNET_SCHEDULER_add_now (&get_peers, NULL); - } + } - else if (p_id == &ple->peer) + else if (0 == GNUNET_memcmp (&ple->peer, p_id) ) { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "reopen channel\n"); + reopen_channel (); } @@ -1034,8 +1041,10 @@ handle_data (void *cls, ok, ok_goal); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "TEST both IDs: %s,%s\n", - GNUNET_i2s (testpeer_id[0]), + "TEST ID 0: %s\n", + GNUNET_i2s (testpeer_id[0])); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "TEST ID 1: %s\n", GNUNET_i2s (testpeer_id[1])); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "dropping message\n"); @@ -1142,7 +1151,7 @@ connect_handler (void *cls, ok, ok_goal); - if (peer == get_peer_nr()) + if (peer == get_peer_nr(GNUNET_NO)) { if (DESTROY != test && NULL != incoming_ch) { @@ -1326,6 +1335,12 @@ pi_cb (void *cls, return; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got all peer information, starting test\n"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "TEST ID 0: %s\n", + GNUNET_i2s (testpeer_id[0])); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "TEST ID 1: %s\n", + GNUNET_i2s (testpeer_id[1])); test_task = GNUNET_SCHEDULER_add_now (&start_test, NULL); } @@ -1522,6 +1537,7 @@ main (int argc, char *argv[]) test = DESTROY; test_name = "destroy"; ok_goal = 5; + short_time = GNUNET_TIME_relative_multiply (short_time, 5); } else { -- 2.25.1