From 81405b6abff2f0b6fb774bdf227ded577c1ce2de Mon Sep 17 00:00:00 2001 From: xrs Date: Thu, 5 Mar 2020 09:32:49 +0100 Subject: [PATCH] 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]; -- 2.25.1