add condition for check_test_readyness; find kx_initiator
authorxrs <xrs@mail36.net>
Thu, 5 Mar 2020 08:32:49 +0000 (09:32 +0100)
committerxrs <xrs@mail36.net>
Thu, 21 May 2020 20:46:49 +0000 (22:46 +0200)
src/cadet/test_cadeT.c
src/cadet/test_cadeT_util.c
src/cadet/test_cadeT_util.h

index 70f141514e43da77731b7b18f6626bcd12f08f8b..ee6bcd9e164fbc5a51bcc2628592d89d1839a656 100644 (file)
@@ -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
 
 /****************************** 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.
index 6580b99077f6d48e9db595109f826862b3804363..fc59349aaeffd39cdeff737466e3e0847ae7bdc7 100644 (file)
@@ -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();
 }
 
index b2afa34a143cd23dcf8c66c0d203924eeab976bf..7b92dc2cb3280e014f818749d65204bd791880c9 100644 (file)
@@ -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];