From: xrs Date: Thu, 16 Jan 2020 16:10:11 +0000 (+0100) Subject: modify test to introduce recovery after tunnel destroy X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=e73d603f626649dc7c78cb1732b029a61f6da7cc;p=oweals%2Fgnunet.git modify test to introduce recovery after tunnel destroy --- diff --git a/src/cadet/test_cadet.c b/src/cadet/test_cadet.c index 661e8c06c..249a656de 100644 --- a/src/cadet/test_cadet.c +++ b/src/cadet/test_cadet.c @@ -856,6 +856,15 @@ handle_data (void *cls, uint32_t *data; uint32_t payload; int *counter; + struct GNUNET_MQ_MessageHandler handlers[] = { + GNUNET_MQ_hd_var_size (data, + GNUNET_MESSAGE_TYPE_DUMMY, + struct GNUNET_MessageHeader, + NULL), + GNUNET_MQ_handler_end () + }; + static struct GNUNET_CADET_Handle *h1; + static struct GNUNET_PeerIdentity *p_id; ok++; GNUNET_CADET_receive_done (channel); @@ -900,6 +909,49 @@ handle_data (void *cls, payload, *counter); } + if (DESTROY == test) + { + if (2 == ok) + { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "dropping message\n"); + GNUNET_CADET_drop_message (GNUNET_CADET_get_mq (outgoing_ch), + outgoing_ch->ccn, + GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY); + GNUNET_CADET_channel_destroy(outgoing_ch); + + ok++; + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + " ok: (%d/%d)\n", + ok, + ok_goal); + + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "creating channel again\n"); + p_id = get_from_p_ids(); + ch = GNUNET_new (struct CadetTestChannelWrapper); + outgoing_ch = GNUNET_CADET_channel_create (h1, + ch, + p_id, + &port, + NULL, + &disconnect_handler, + handlers); + ch->ch = outgoing_ch; + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Sending second test data (after destroying the channel) on channel %p...\n", + outgoing_ch); + send_test_message (outgoing_ch); + } + else if (3 == ok) + { + ok++; + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + " ok: (%d/%d)\n", + ok, + ok_goal); + // End of DESTROY test. + } + } + if (GNUNET_NO == initialized) { initialized = GNUNET_YES; @@ -1028,6 +1080,7 @@ connect_handler (void *cls, &reconnect_op, (void *) __LINE__); } + /* TODO: cannot return channel as-is, in order to unify the data handlers */ ch = GNUNET_new (struct CadetTestChannelWrapper); @@ -1056,8 +1109,8 @@ start_test (void *cls) GNUNET_MQ_handler_end () }; struct CadetTestChannelWrapper *ch; - static struct GNUNET_PeerIdentity *p_id; static struct GNUNET_CADET_Handle *h1; + static struct GNUNET_PeerIdentity *p_id; test_task = NULL; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "start_test: %s\n", test_name); @@ -1087,31 +1140,6 @@ start_test (void *cls) ch->ch = outgoing_ch; - if (DESTROY == test) - { - - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "dropping message\n"); - GNUNET_CADET_drop_message (GNUNET_CADET_get_mq (outgoing_ch), - outgoing_ch->ccn, - GNUNET_MESSAGE_TYPE_CADET_DROP_CADET_MESSAGE); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "destroying channel\n"); - GNUNET_CADET_channel_destroy(outgoing_ch); - - p_id = get_from_p_ids(); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "creating channel again\n"); - outgoing_ch = GNUNET_CADET_channel_create (h1, - ch, - p_id, - &port, - NULL, - &disconnect_handler, - handlers); - - ch->ch = outgoing_ch; - - } - - disconnect_task = GNUNET_SCHEDULER_add_delayed (short_time, &gather_stats_and_exit, (void *) __LINE__); @@ -1365,6 +1393,7 @@ main (int argc, char *argv[]) { test = DESTROY; test_name = "destroy"; + ok_goal = 4; } else {