From 2d9e81f88a3d11a427819f45981ae3b0a0586217 Mon Sep 17 00:00:00 2001 From: xrs Date: Sat, 29 Feb 2020 14:40:08 +0100 Subject: two peers on the stage --- src/cadet/test_cadeT.c | 201 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 201 insertions(+) create mode 100644 src/cadet/test_cadeT.c diff --git a/src/cadet/test_cadeT.c b/src/cadet/test_cadeT.c new file mode 100644 index 000000000..1b74eade2 --- /dev/null +++ b/src/cadet/test_cadeT.c @@ -0,0 +1,201 @@ +/* + This file is part of GNUnet. + Copyright (C) 2009 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/** + * @file cadet/test_cadeT.c + * @brief testcase for cadet.c + * @author xrs + * + * Goal: + * - test session resumption after a hard channel breakup + * + * ToDos: + * - setup peer A + * - setup peer B + * - setup cadet on peer B listening on port 1234 + * - create a channel from peer A to B + * - create method to find out session initiator + * - send a message over channel + * - check if message was received + * - breakup the connection without sending a channel destroy message + * - assert tunnel is down + * - resume channel (second handshake for tunnel) + * - send second message over channel + * - check if message was receveived + * - end test + * + * Questions: + * - can we simulate hard breakups with TESTBED? + * - yes, with GNUNET_TESTBED_underlay_configure_link + * - how can we test the sublayers of CADET, e.g. connection, tunnel, channel? + * + * Development + * - red -> green -> refactor (cyclic) + */ +#include "platform.h" +#include "gnunet_testbed_service.h" +#include "cadet.h" + +#define REQUESTED_PEERS 2 +#define CONFIG "test_cadet.conf" +#define TESTPROGAM_NAME "test-cadet-channel-resumption" +#define PORTNAME "cadet_port" + +struct GNUNET_TESTBED_Operation *testbed_to_svc[2]; + +/** + * Port name kown by the two peers. + */ +static struct GNUNET_HashCode hashed_portname; + +static int test_result = 0; + +// FIXME: temp cnt +static int cnt = 0; + +/****************************** TEST LOGIC ********************************/ + +// TBD + +/************************** TESBED MANAGEMENT *****************************/ + +static void +shutdown_task (void *cls) +{ + for (int i=0; i Date: Sat, 29 Feb 2020 14:40:42 +0100 Subject: add test_cadet_2_channel_resumption to Makefile.am --- src/cadet/Makefile.am | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cadet/Makefile.am b/src/cadet/Makefile.am index d8d81bf20..572bdf4d9 100644 --- a/src/cadet/Makefile.am +++ b/src/cadet/Makefile.am @@ -84,6 +84,7 @@ endif if HAVE_TESTING check_PROGRAMS = \ + test_cadet_2_channel_resumption \ test_cadet_local_mq \ test_cadet_2_forward \ test_cadet_2_forward \ @@ -139,6 +140,10 @@ dep_cadet_test_lib = \ libgnunetcadettest.la \ $(top_builddir)/src/statistics/libgnunetstatistics.la +test_cadet_2_channel_resumption_SOURCES = \ + test_cadeT.c +test_cadet_2_channel_resumption_LDADD = $(ld_cadet_test_lib) + test_cadet_2_forward_SOURCES = \ test_cadet.c test_cadet_2_forward_LDADD = $(ld_cadet_test_lib) -- cgit v1.2.3 From 03e8cc27f25e48659a488448c43c32e3340c08c9 Mon Sep 17 00:00:00 2001 From: xrs Date: Sat, 29 Feb 2020 15:54:52 +0100 Subject: add request for peer information --- src/cadet/test_cadeT.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/src/cadet/test_cadeT.c b/src/cadet/test_cadeT.c index 1b74eade2..f489ca56d 100644 --- a/src/cadet/test_cadeT.c +++ b/src/cadet/test_cadeT.c @@ -57,18 +57,45 @@ #define TESTPROGAM_NAME "test-cadet-channel-resumption" #define PORTNAME "cadet_port" +/** + * Testbed operation for connecting to the services. + */ struct GNUNET_TESTBED_Operation *testbed_to_svc[2]; +/** + * Testbed operation for requesting peer information. + */ +struct GNUNET_TESTBED_Operation *testbed_info_req[2]; + /** * Port name kown by the two peers. */ static struct GNUNET_HashCode hashed_portname; +/** + * Result of the test. + */ static int test_result = 0; // FIXME: temp cnt static int cnt = 0; +/** + * Structure for storing information of testbed peers. + */ +struct testbed_peers +{ + /** + * Index of the peer. + */ + int index; + + /** + * Peer Identity. + */ + struct GNUNET_PeerIdentity id; +} testbed_peers[2]; + /****************************** TEST LOGIC ********************************/ // TBD @@ -93,17 +120,33 @@ disconnect_from_peer (void *cls, GNUNET_CADET_disconnect (cadet); } +static void +handle_channel_destroy (void *cls, + const struct GNUNET_CADET_Channel *channel) +{ +} + static void * setup_initiating_peer (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) { struct GNUNET_CADET_Handle *cadet; + struct GNUNET_PeerIdentity *destination; + struct GNUNET_CADET_Channel *channel; GNUNET_log (GNUNET_ERROR_TYPE_INFO, "setup_initiating_peer()\n"); cadet = GNUNET_CADET_connect (cfg); + channel = GNUNET_CADET_channel_create (cadet, + NULL, + destination, + &hashed_portname, + NULL, + &handle_channel_destroy, + NULL); + if (NULL == cadet) GNUNET_SCHEDULER_shutdown (); @@ -161,6 +204,22 @@ check_test_readyness (void *cls, GNUNET_SCHEDULER_shutdown (); } + +static void +process_info_req (void *cb_cls, + struct GNUNET_TESTBED_Operation *op, + const struct GNUNET_TESTBED_PeerInformation *pinfo, + const char *emsg) +{ + struct testbed_peers *testbed_peer = cb_cls; + struct GNUNET_PeerIdentity id = testbed_peer->id; + + GNUNET_memcpy (&id, pinfo->result.id, sizeof (struct GNUNET_PeerIdentity)); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Peer %s ready\n", GNUNET_i2s (&id)); + + // TODO: connect_to_peer_services +} + static void connect_to_peers (void *cls, struct GNUNET_TESTBED_RunHandle *h, @@ -173,6 +232,18 @@ connect_to_peers (void *cls, GNUNET_assert (0 == links_failed); + for (int i=0; i Date: Sat, 29 Feb 2020 17:58:00 +0100 Subject: refactor function logs; refactor conntect to services --- src/cadet/test_cadeT.c | 99 +++++++++++++++++++++++++++++++------------------- 1 file changed, 61 insertions(+), 38 deletions(-) diff --git a/src/cadet/test_cadeT.c b/src/cadet/test_cadeT.c index f489ca56d..cf335a948 100644 --- a/src/cadet/test_cadeT.c +++ b/src/cadet/test_cadeT.c @@ -47,6 +47,7 @@ * * Development * - red -> green -> refactor (cyclic) + * - be aware of Continuation Passing Style (CPS) programming */ #include "platform.h" #include "gnunet_testbed_service.h" @@ -60,12 +61,12 @@ /** * Testbed operation for connecting to the services. */ -struct GNUNET_TESTBED_Operation *testbed_to_svc[2]; +static struct GNUNET_TESTBED_Operation *testbed_to_svc[2]; /** * Testbed operation for requesting peer information. */ -struct GNUNET_TESTBED_Operation *testbed_info_req[2]; +static struct GNUNET_TESTBED_Operation *testbed_info_req[2]; /** * Port name kown by the two peers. @@ -80,21 +81,32 @@ static int test_result = 0; // FIXME: temp cnt static int cnt = 0; +/** + * Counter for gathering peerinformation. + */ +static int peerinfo_cnt = 0; + /** * Structure for storing information of testbed peers. */ -struct testbed_peers +struct TEST_PEERS { /** * Index of the peer. */ - int index; + int idx; /** * Peer Identity. */ struct GNUNET_PeerIdentity id; -} testbed_peers[2]; + + struct GNUNET_TESTBED_Peer *testbed_peer; + + int ready; + +} test_peers[2]; + /****************************** TEST LOGIC ********************************/ @@ -115,7 +127,7 @@ disconnect_from_peer (void *cls, { struct GNUNET_CADET_Handle *cadet = op_result; - GNUNET_log (GNUNET_ERROR_TYPE_INFO, "disconnect_from_cadet ()\n"); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__); GNUNET_CADET_disconnect (cadet); } @@ -135,7 +147,7 @@ setup_initiating_peer (void *cls, struct GNUNET_PeerIdentity *destination; struct GNUNET_CADET_Channel *channel; - GNUNET_log (GNUNET_ERROR_TYPE_INFO, "setup_initiating_peer()\n"); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__); cadet = GNUNET_CADET_connect (cfg); @@ -174,7 +186,7 @@ setup_listening_peer (void *cls, struct GNUNET_CADET_Handle *cadet; struct GNUNET_CADET_Port *port; - GNUNET_log (GNUNET_ERROR_TYPE_INFO, "setup_listening_peer()\n"); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__); cadet = GNUNET_CADET_connect (cfg); @@ -198,26 +210,45 @@ check_test_readyness (void *cls, void *ca_result, const char *emsg) { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, "check_test_readyness()\n"); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__); if (2 == ++cnt) GNUNET_SCHEDULER_shutdown (); } -static void -process_info_req (void *cb_cls, - struct GNUNET_TESTBED_Operation *op, - const struct GNUNET_TESTBED_PeerInformation *pinfo, - const char *emsg) +static int +peerinfo_complete () { - struct testbed_peers *testbed_peer = cb_cls; - struct GNUNET_PeerIdentity id = testbed_peer->id; - - GNUNET_memcpy (&id, pinfo->result.id, sizeof (struct GNUNET_PeerIdentity)); - GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Peer %s ready\n", GNUNET_i2s (&id)); + return (REQUESTED_PEERS == ++peerinfo_cnt) ? GNUNET_YES : GNUNET_NO; +} - // TODO: connect_to_peer_services +static void +connect_to_service (void *cb_cls, + struct GNUNET_TESTBED_Operation *op, + const struct GNUNET_TESTBED_PeerInformation *pinfo, + const char *emsg) +{ + struct TEST_PEERS *test_peer = cb_cls; + + // Store peer ID. + test_peer->id = *(pinfo->result.id); + + if (peerinfo_complete()) + { + testbed_to_svc[1] = + GNUNET_TESTBED_service_connect (NULL, test_peers[1].testbed_peer, + "cadet", + &check_test_readyness, NULL, + &setup_listening_peer, + &disconnect_from_peer, NULL); + testbed_to_svc[0] = + GNUNET_TESTBED_service_connect (NULL, test_peers[0].testbed_peer, + "cadet", + &check_test_readyness, NULL, + &setup_initiating_peer, + &disconnect_from_peer, NULL); + } } static void @@ -228,33 +259,25 @@ connect_to_peers (void *cls, unsigned int links_succeeded, unsigned int links_failed) { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, "connect_to_peers()\n"); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__); GNUNET_assert (0 == links_failed); for (int i=0; i Date: Sat, 29 Feb 2020 18:39:43 +0100 Subject: setup channel --- src/cadet/test_cadeT.c | 53 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 15 deletions(-) diff --git a/src/cadet/test_cadeT.c b/src/cadet/test_cadeT.c index cf335a948..1c4a32791 100644 --- a/src/cadet/test_cadeT.c +++ b/src/cadet/test_cadeT.c @@ -56,6 +56,7 @@ #define REQUESTED_PEERS 2 #define CONFIG "test_cadet.conf" #define TESTPROGAM_NAME "test-cadet-channel-resumption" +#define TIMEOUT_IN_SEC 5 #define PORTNAME "cadet_port" /** @@ -78,9 +79,6 @@ static struct GNUNET_HashCode hashed_portname; */ static int test_result = 0; -// FIXME: temp cnt -static int cnt = 0; - /** * Counter for gathering peerinformation. */ @@ -101,10 +99,26 @@ struct TEST_PEERS */ struct GNUNET_PeerIdentity id; + /** + * Handle of TESTBED peer. + */ struct GNUNET_TESTBED_Peer *testbed_peer; + /** + * Testbed management is finished and test peer is ready for test logic. + */ int ready; + /** + * Channel of initiating peer. + */ + struct GNUNET_CADET_Channel *channel; + + /** + * CADET handle. + */ + struct GNUNET_CADET_Handle *cadet; + } test_peers[2]; @@ -117,10 +131,18 @@ struct TEST_PEERS static void shutdown_task (void *cls) { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__); + for (int i=0; i Date: Sat, 29 Feb 2020 18:46:58 +0100 Subject: update ToDo list --- src/cadet/test_cadeT.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cadet/test_cadeT.c b/src/cadet/test_cadeT.c index 1c4a32791..d4688273b 100644 --- a/src/cadet/test_cadeT.c +++ b/src/cadet/test_cadeT.c @@ -26,11 +26,11 @@ * - test session resumption after a hard channel breakup * * ToDos: - * - setup peer A - * - setup peer B - * - setup cadet on peer B listening on port 1234 - * - create a channel from peer A to B - * - create method to find out session initiator + * x setup peer A + * x setup peer B + * x setup cadet on peer B listening on port "cadet_port" + * x create a channel from peer A to B + * - create method to find out KX initiator * - send a message over channel * - check if message was received * - breakup the connection without sending a channel destroy message -- cgit v1.2.3 From c93059b8e817b24509628e12d3f3800c4a19e3cc Mon Sep 17 00:00:00 2001 From: xrs Date: Sat, 29 Feb 2020 19:12:19 +0100 Subject: separate testbed management from test logic --- src/cadet/Makefile.am | 3 +- src/cadet/test_cadeT.c | 247 +--------------------------------------- src/cadet/test_cadeT_util.c | 271 ++++++++++++++++++++++++++++++++++++++++++++ src/cadet/test_cadeT_util.h | 38 +++++++ 4 files changed, 317 insertions(+), 242 deletions(-) create mode 100644 src/cadet/test_cadeT_util.c create mode 100644 src/cadet/test_cadeT_util.h diff --git a/src/cadet/Makefile.am b/src/cadet/Makefile.am index 572bdf4d9..80294a785 100644 --- a/src/cadet/Makefile.am +++ b/src/cadet/Makefile.am @@ -141,7 +141,8 @@ dep_cadet_test_lib = \ $(top_builddir)/src/statistics/libgnunetstatistics.la test_cadet_2_channel_resumption_SOURCES = \ - test_cadeT.c + test_cadeT.c \ + test_cadeT_util.c test_cadeT_util.h test_cadet_2_channel_resumption_LDADD = $(ld_cadet_test_lib) test_cadet_2_forward_SOURCES = \ diff --git a/src/cadet/test_cadeT.c b/src/cadet/test_cadeT.c index d4688273b..58b6db543 100644 --- a/src/cadet/test_cadeT.c +++ b/src/cadet/test_cadeT.c @@ -52,258 +52,23 @@ #include "platform.h" #include "gnunet_testbed_service.h" #include "cadet.h" +#include -#define REQUESTED_PEERS 2 #define CONFIG "test_cadet.conf" #define TESTPROGAM_NAME "test-cadet-channel-resumption" -#define TIMEOUT_IN_SEC 5 -#define PORTNAME "cadet_port" - -/** - * Testbed operation for connecting to the services. - */ -static struct GNUNET_TESTBED_Operation *testbed_to_svc[2]; - -/** - * Testbed operation for requesting peer information. - */ -static struct GNUNET_TESTBED_Operation *testbed_info_req[2]; - -/** - * Port name kown by the two peers. - */ -static struct GNUNET_HashCode hashed_portname; - -/** - * Result of the test. - */ -static int test_result = 0; - -/** - * Counter for gathering peerinformation. - */ -static int peerinfo_cnt = 0; - -/** - * Structure for storing information of testbed peers. - */ -struct TEST_PEERS -{ - /** - * Index of the peer. - */ - int idx; - - /** - * Peer Identity. - */ - struct GNUNET_PeerIdentity id; - - /** - * Handle of TESTBED peer. - */ - struct GNUNET_TESTBED_Peer *testbed_peer; - - /** - * Testbed management is finished and test peer is ready for test logic. - */ - int ready; - - /** - * Channel of initiating peer. - */ - struct GNUNET_CADET_Channel *channel; - - /** - * CADET handle. - */ - struct GNUNET_CADET_Handle *cadet; - -} test_peers[2]; - /****************************** TEST LOGIC ********************************/ -// TBD - -/************************** TESBED MANAGEMENT *****************************/ - -static void -shutdown_task (void *cls) -{ - GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__); - - for (int i=0; iid = *(pinfo->result.id); - - if (peerinfo_complete()) - { - testbed_to_svc[1] = - GNUNET_TESTBED_service_connect (NULL, test_peers[1].testbed_peer, - "cadet", - &check_test_readyness, NULL, - &setup_listening_peer, - &disconnect_from_peer, NULL); - testbed_to_svc[0] = - GNUNET_TESTBED_service_connect (NULL, test_peers[0].testbed_peer, - "cadet", - &check_test_readyness, NULL, - &setup_initiating_peer, - &disconnect_from_peer, NULL); - } + /** + * Do testing here. + */ } -static void -connect_to_peers (void *cls, - struct GNUNET_TESTBED_RunHandle *h, - unsigned int num_peers, - struct GNUNET_TESTBED_Peer **peers, - unsigned int links_succeeded, - unsigned int links_failed) -{ - GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__); - - GNUNET_assert (0 == links_failed); - - for (int i=0; i. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/** + * @file cadet/test_cadeT_util.c + * @brief testcase for cadet.c + * @author xrs + */ + +#include + +/** + * Testbed operation for connecting to the services. + */ +static struct GNUNET_TESTBED_Operation *testbed_to_svc[2]; + +/** + * Testbed operation for requesting peer information. + */ +static struct GNUNET_TESTBED_Operation *testbed_info_req[2]; + +/** + * Port name kown by the two peers. + */ +static struct GNUNET_HashCode hashed_portname; + +/** + * Result of the test. + */ +int test_result = 0; + +/** + * Counter for gathering peerinformation. + */ +static int peerinfo_cnt = 0; + +/** + * Structure for storing information of testbed peers. + */ +struct TEST_PEERS +{ + /** + * Index of the peer. + */ + int idx; + + /** + * Peer Identity. + */ + struct GNUNET_PeerIdentity id; + + /** + * Handle of TESTBED peer. + */ + struct GNUNET_TESTBED_Peer *testbed_peer; + + /** + * Testbed management is finished and test peer is ready for test logic. + */ + int ready; + + /** + * Channel of initiating peer. + */ + struct GNUNET_CADET_Channel *channel; + + /** + * CADET handle. + */ + struct GNUNET_CADET_Handle *cadet; + +} test_peers[2]; + +/************************** TESBED MANAGEMENT *****************************/ + +static void +shutdown_task (void *cls) +{ + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__); + + for (int i=0; iid = *(pinfo->result.id); + + if (peerinfo_complete()) + { + testbed_to_svc[1] = + GNUNET_TESTBED_service_connect (NULL, test_peers[1].testbed_peer, + "cadet", + &check_test_readyness, NULL, + &setup_listening_peer, + &disconnect_from_peer, NULL); + testbed_to_svc[0] = + GNUNET_TESTBED_service_connect (NULL, test_peers[0].testbed_peer, + "cadet", + &check_test_readyness, NULL, + &setup_initiating_peer, + &disconnect_from_peer, NULL); + } +} + +void +connect_to_peers (void *cls, + struct GNUNET_TESTBED_RunHandle *h, + unsigned int num_peers, + struct GNUNET_TESTBED_Peer **peers, + unsigned int links_succeeded, + unsigned int links_failed) +{ + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__); + + GNUNET_assert (0 == links_failed); + + for (int i=0; i. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/** + * @file cadet/test_cadeT_util.h + * @brief testcase for cadet.c + * @author xrs + */ + +#include "platform.h" +#include "gnunet_testbed_service.h" +#include "cadet.h" + +#define REQUESTED_PEERS 2 +#define TIMEOUT_IN_SEC 5 +#define PORTNAME "cadet_port" + +int test_result; + +void connect_to_peers (); + +void run_test (); -- cgit v1.2.3 From c8dc2e8a4ffee9d646033c91f2282d1d55d73b67 Mon Sep 17 00:00:00 2001 From: xrs Date: Mon, 2 Mar 2020 21:11:21 +0100 Subject: fix names and add comments --- src/cadet/test_cadeT.c | 4 +++- src/cadet/test_cadeT_util.c | 10 ++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/cadet/test_cadeT.c b/src/cadet/test_cadeT.c index 58b6db543..014c64ebd 100644 --- a/src/cadet/test_cadeT.c +++ b/src/cadet/test_cadeT.c @@ -65,7 +65,9 @@ run_test () GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__); /** - * Do testing here. + * This function is called after all testbed management is done and the + * testbed peers are ready for the actual test logic. + * Use struct test_peers[i] to control the peers. */ } diff --git a/src/cadet/test_cadeT_util.c b/src/cadet/test_cadeT_util.c index 89fe2a5f0..2db619a38 100644 --- a/src/cadet/test_cadeT_util.c +++ b/src/cadet/test_cadeT_util.c @@ -28,12 +28,12 @@ /** * Testbed operation for connecting to the services. */ -static struct GNUNET_TESTBED_Operation *testbed_to_svc[2]; +static struct GNUNET_TESTBED_Operation *testbed_to_svc[REQUESTED_PEERS]; /** * Testbed operation for requesting peer information. */ -static struct GNUNET_TESTBED_Operation *testbed_info_req[2]; +static struct GNUNET_TESTBED_Operation *testbed_info_req[REQUESTED_PEERS]; /** * Port name kown by the two peers. @@ -85,7 +85,7 @@ struct TEST_PEERS */ struct GNUNET_CADET_Handle *cadet; -} test_peers[2]; +} test_peers[REQUESTED_PEERS]; /************************** TESBED MANAGEMENT *****************************/ @@ -198,6 +198,8 @@ check_test_readyness (void *cls, { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__); + // FIXME: check, if all peers are ready, then continue with the + // test logic. if (GNUNET_OK) run_test(); } @@ -247,7 +249,7 @@ connect_to_peers (void *cls, { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__); - GNUNET_assert (0 == links_failed); + GNUNET_assert (GNUNET_NO == links_failed); for (int i=0; i Date: Mon, 2 Mar 2020 22:40:01 +0100 Subject: fix names --- src/cadet/test_cadeT.c | 2 +- src/cadet/test_cadeT_util.c | 18 +++++++++--------- src/cadet/test_cadeT_util.h | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/cadet/test_cadeT.c b/src/cadet/test_cadeT.c index 014c64ebd..70f141514 100644 --- a/src/cadet/test_cadeT.c +++ b/src/cadet/test_cadeT.c @@ -78,7 +78,7 @@ main (int argc, char *argv[]) GNUNET_TESTBED_test_run (TESTPROGAM_NAME, CONFIG, REQUESTED_PEERS, 0LL, NULL, NULL, - connect_to_peers, NULL); + prepare_test, NULL); return test_result; } diff --git a/src/cadet/test_cadeT_util.c b/src/cadet/test_cadeT_util.c index 2db619a38..f087e624c 100644 --- a/src/cadet/test_cadeT_util.c +++ b/src/cadet/test_cadeT_util.c @@ -189,7 +189,6 @@ setup_listening_peer (void *cls, return cadet; } - static void check_test_readyness (void *cls, struct GNUNET_TESTBED_Operation *op, @@ -204,7 +203,6 @@ check_test_readyness (void *cls, run_test(); } - static int peerinfo_complete () { @@ -240,18 +238,19 @@ connect_to_service (void *cb_cls, } void -connect_to_peers (void *cls, - struct GNUNET_TESTBED_RunHandle *h, - unsigned int num_peers, - struct GNUNET_TESTBED_Peer **peers, - unsigned int links_succeeded, - unsigned int links_failed) +prepare_test (void *cls, + struct GNUNET_TESTBED_RunHandle *h, + unsigned int num_peers, + struct GNUNET_TESTBED_Peer **peers, + unsigned int links_succeeded, + unsigned int links_failed) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__); GNUNET_assert (GNUNET_NO == links_failed); + GNUNET_assert (REQUESTED_PEERS == num_peers); - for (int i=0; i Date: Wed, 4 Mar 2020 21:01:47 +0100 Subject: fix indent --- src/cadet/test_cadeT_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cadet/test_cadeT_util.c b/src/cadet/test_cadeT_util.c index f087e624c..6580b9907 100644 --- a/src/cadet/test_cadeT_util.c +++ b/src/cadet/test_cadeT_util.c @@ -124,7 +124,7 @@ disconnect_channel (void *cls, static void * setup_initiating_peer (void *cls, - const struct GNUNET_CONFIGURATION_Handle *cfg) + const struct GNUNET_CONFIGURATION_Handle *cfg) { struct GNUNET_CADET_Handle *cadet; struct GNUNET_CADET_Channel *channel; -- cgit v1.2.3 From a8b68c49e2212baeae761307fa9a747bbadf3a23 Mon Sep 17 00:00:00 2001 From: xrs Date: Thu, 5 Mar 2020 09:32:49 +0100 Subject: add condition for check_test_readyness; find kx_initiator --- src/cadet/test_cadeT.c | 10 +++++++++- src/cadet/test_cadeT_util.c | 41 +---------------------------------------- src/cadet/test_cadeT_util.h | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 41 deletions(-) diff --git a/src/cadet/test_cadeT.c b/src/cadet/test_cadeT.c index 70f141514..ee6bcd9e1 100644 --- a/src/cadet/test_cadeT.c +++ b/src/cadet/test_cadeT.c @@ -30,7 +30,7 @@ * x setup peer B * x setup cadet on peer B listening on port "cadet_port" * x create a channel from peer A to B - * - create method to find out KX initiator + * x create method to find out KX initiator * - send a message over channel * - check if message was received * - breakup the connection without sending a channel destroy message @@ -59,11 +59,19 @@ /****************************** TEST LOGIC ********************************/ +static int kx_initiator; + void run_test () { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__); + kx_initiator = (0 < GNUNET_memcmp (&test_peers[0].id, &test_peers[1].id)) ? 1 : 0; + + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "KX initiator is peer %s\n", + GNUNET_i2s (&test_peers[kx_initiator].id)); + /** * This function is called after all testbed management is done and the * testbed peers are ready for the actual test logic. diff --git a/src/cadet/test_cadeT_util.c b/src/cadet/test_cadeT_util.c index 6580b9907..fc59349aa 100644 --- a/src/cadet/test_cadeT_util.c +++ b/src/cadet/test_cadeT_util.c @@ -50,43 +50,6 @@ int test_result = 0; */ static int peerinfo_cnt = 0; -/** - * Structure for storing information of testbed peers. - */ -struct TEST_PEERS -{ - /** - * Index of the peer. - */ - int idx; - - /** - * Peer Identity. - */ - struct GNUNET_PeerIdentity id; - - /** - * Handle of TESTBED peer. - */ - struct GNUNET_TESTBED_Peer *testbed_peer; - - /** - * Testbed management is finished and test peer is ready for test logic. - */ - int ready; - - /** - * Channel of initiating peer. - */ - struct GNUNET_CADET_Channel *channel; - - /** - * CADET handle. - */ - struct GNUNET_CADET_Handle *cadet; - -} test_peers[REQUESTED_PEERS]; - /************************** TESBED MANAGEMENT *****************************/ static void @@ -197,9 +160,7 @@ check_test_readyness (void *cls, { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__); - // FIXME: check, if all peers are ready, then continue with the - // test logic. - if (GNUNET_OK) + if (NULL != test_peers[0].cadet && NULL != test_peers[1].cadet) run_test(); } diff --git a/src/cadet/test_cadeT_util.h b/src/cadet/test_cadeT_util.h index b2afa34a1..7b92dc2cb 100644 --- a/src/cadet/test_cadeT_util.h +++ b/src/cadet/test_cadeT_util.h @@ -36,3 +36,40 @@ int test_result; void prepare_test (); void run_test (); + +/** + * Structure for storing information of testbed peers. + */ +struct TEST_PEERS +{ + /** + * Index of the peer. + */ + int idx; + + /** + * Peer Identity. + */ + struct GNUNET_PeerIdentity id; + + /** + * Handle of TESTBED peer. + */ + struct GNUNET_TESTBED_Peer *testbed_peer; + + /** + * Testbed management is finished and test peer is ready for test logic. + */ + int ready; + + /** + * Channel of initiating peer. + */ + struct GNUNET_CADET_Channel *channel; + + /** + * CADET handle. + */ + struct GNUNET_CADET_Handle *cadet; + +} test_peers[REQUESTED_PEERS]; -- cgit v1.2.3 From de7ff319a67f68026e883dec6f74595d76a3cf1b Mon Sep 17 00:00:00 2001 From: xrs Date: Thu, 12 Mar 2020 12:05:35 +0100 Subject: add send_message() --- src/cadet/test_cadeT.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/cadet/test_cadeT.c b/src/cadet/test_cadeT.c index ee6bcd9e1..17db2418b 100644 --- a/src/cadet/test_cadeT.c +++ b/src/cadet/test_cadeT.c @@ -33,7 +33,7 @@ * x create method to find out KX initiator * - send a message over channel * - check if message was received - * - breakup the connection without sending a channel destroy message + * - breakup the connection without the receiver receiving a channel destroy message * - assert tunnel is down * - resume channel (second handshake for tunnel) * - send second message over channel @@ -61,6 +61,16 @@ static int kx_initiator; +static void +send_message () +{ +} + +/** + * This function is called after all testbed management is done and the + * testbed peers are ready for the actual test logic. + * Use struct test_peers[i] to control the peers. + */ void run_test () { @@ -72,11 +82,7 @@ run_test () "KX initiator is peer %s\n", GNUNET_i2s (&test_peers[kx_initiator].id)); - /** - * This function is called after all testbed management is done and the - * testbed peers are ready for the actual test logic. - * Use struct test_peers[i] to control the peers. - */ + send_message(); } -- cgit v1.2.3 From 268fd0ca3bd3681fd26f62dddce1aa49279db9b6 Mon Sep 17 00:00:00 2001 From: xrs Date: Wed, 18 Mar 2020 21:17:43 +0100 Subject: send a message from A to B --- src/cadet/test_cadeT.c | 14 ++++++++++++++ src/cadet/test_cadeT_util.c | 18 ++++++++++++++++-- src/cadet/test_cadeT_util.h | 2 ++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/cadet/test_cadeT.c b/src/cadet/test_cadeT.c index 17db2418b..c939976b2 100644 --- a/src/cadet/test_cadeT.c +++ b/src/cadet/test_cadeT.c @@ -61,9 +61,23 @@ static int kx_initiator; +void +handle_message () +{ + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__); +} + static void send_message () { + struct GNUNET_MQ_Envelope *envelope; + struct GNUNET_MessageHeader *msg; + + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__); + + envelope = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_DUMMY); + + GNUNET_MQ_send (GNUNET_CADET_get_mq (test_peers[0].channel), envelope); } /** diff --git a/src/cadet/test_cadeT_util.c b/src/cadet/test_cadeT_util.c index fc59349aa..e983dab12 100644 --- a/src/cadet/test_cadeT_util.c +++ b/src/cadet/test_cadeT_util.c @@ -91,6 +91,13 @@ setup_initiating_peer (void *cls, { struct GNUNET_CADET_Handle *cadet; struct GNUNET_CADET_Channel *channel; + struct GNUNET_MQ_MessageHandler msg_handlers[] = { + GNUNET_MQ_hd_fixed_size (message, + GNUNET_MESSAGE_TYPE_DUMMY, + struct GNUNET_MessageHeader, + NULL), + GNUNET_MQ_handler_end () + }; GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__); @@ -106,7 +113,7 @@ setup_initiating_peer (void *cls, &hashed_portname, NULL, &disconnect_channel, - NULL); + msg_handlers); test_peers[0].channel = channel; return cadet; @@ -132,6 +139,13 @@ setup_listening_peer (void *cls, { struct GNUNET_CADET_Handle *cadet; struct GNUNET_CADET_Port *port; + struct GNUNET_MQ_MessageHandler msg_handlers[] = { + GNUNET_MQ_hd_fixed_size (message, + GNUNET_MESSAGE_TYPE_DUMMY, + struct GNUNET_MessageHeader, + NULL), + GNUNET_MQ_handler_end () + }; GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__); @@ -147,7 +161,7 @@ setup_listening_peer (void *cls, NULL, NULL, &handle_port_disconnects, - NULL); + msg_handlers); return cadet; } diff --git a/src/cadet/test_cadeT_util.h b/src/cadet/test_cadeT_util.h index 7b92dc2cb..de1a24a26 100644 --- a/src/cadet/test_cadeT_util.h +++ b/src/cadet/test_cadeT_util.h @@ -37,6 +37,8 @@ void prepare_test (); void run_test (); +void handle_message (); + /** * Structure for storing information of testbed peers. */ -- cgit v1.2.3 From 7b2383a63afc08a5f09c3896708574edd4a23eca Mon Sep 17 00:00:00 2001 From: xrs Date: Thu, 19 Mar 2020 21:03:42 +0100 Subject: handle received message; fix format; fix testbed ops --- src/cadet/test_cadeT.c | 19 ++++++++++++------- src/cadet/test_cadeT_util.c | 14 +++++--------- src/cadet/test_cadeT_util.h | 3 ++- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/cadet/test_cadeT.c b/src/cadet/test_cadeT.c index c939976b2..3bf8e2ad9 100644 --- a/src/cadet/test_cadeT.c +++ b/src/cadet/test_cadeT.c @@ -31,8 +31,8 @@ * x setup cadet on peer B listening on port "cadet_port" * x create a channel from peer A to B * x create method to find out KX initiator - * - send a message over channel - * - check if message was received + * x send a message over channel + * x check if message was received * - breakup the connection without the receiver receiving a channel destroy message * - assert tunnel is down * - resume channel (second handshake for tunnel) @@ -42,7 +42,9 @@ * * Questions: * - can we simulate hard breakups with TESTBED? - * - yes, with GNUNET_TESTBED_underlay_configure_link + * - GNUNET_TESTBED_underlay_configure_link not implemented + * - GNUNET_TESTBED_underlaylinkmodel_set_link not usable + * - GNUNET_TESTBED_peer_stop evokes standard service disconnect * - how can we test the sublayers of CADET, e.g. connection, tunnel, channel? * * Development @@ -61,8 +63,9 @@ static int kx_initiator; -void -handle_message () +void +handle_message (void *cls, + const struct GNUNET_MessageHeader *msg) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__); } @@ -75,9 +78,11 @@ send_message () GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__); - envelope = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_DUMMY); + envelope = GNUNET_MQ_msg (msg, + GNUNET_MESSAGE_TYPE_DUMMY); - GNUNET_MQ_send (GNUNET_CADET_get_mq (test_peers[0].channel), envelope); + GNUNET_MQ_send (GNUNET_CADET_get_mq (test_peers[0].channel), + envelope); } /** diff --git a/src/cadet/test_cadeT_util.c b/src/cadet/test_cadeT_util.c index e983dab12..f2082a006 100644 --- a/src/cadet/test_cadeT_util.c +++ b/src/cadet/test_cadeT_util.c @@ -58,7 +58,10 @@ shutdown_task (void *cls) GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__); for (int i=0; i