fixme: testpeer_id[i] still containing same IDs
authorxrs <xrs@mail36.net>
Thu, 27 Feb 2020 06:43:53 +0000 (07:43 +0100)
committerxrs <xrs@mail36.net>
Thu, 27 Feb 2020 06:43:53 +0000 (07:43 +0100)
src/cadet/test_cadet.c

index d58f76cdba68e93dbaf283f2adb2e06b7fdc3df7..92751a4fe9542dd139477b2f6bc5324b8ff54bab 100644 (file)
@@ -135,7 +135,12 @@ static struct GNUNET_TESTBED_Operation *t_op[2];
 /**
  * Peer ids.
  */
-static struct GNUNET_PeerIdentity *p_id[2];
+static struct GNUNET_PeerIdentity *testpeer_id[2];
+
+/**
+ * Peer ids.
+ */
+static struct GNUNET_CONFIGURATION_Handle *p_cfg[2];
 
 /**
  * Port ID
@@ -145,7 +150,7 @@ static struct GNUNET_HashCode port;
 /**
  * Peer ids counter.
  */
-static unsigned int p_ids;
+static unsigned int peerinfo_task_cnt;
 
 /**
  * Is the setup initialized?
@@ -535,12 +540,12 @@ disconnect_handler (void *cls,
 static struct GNUNET_PeerIdentity * 
 get_from_p_ids()
 {
-  if (0 < GNUNET_memcmp (p_id[0], p_id[1]))
+  if (0 < GNUNET_memcmp (testpeer_id[0], testpeer_id[1]))
   {
-    return p_id[1];
+    return testpeer_id[1];
   }else
   {
-     return p_id[0];
+     return testpeer_id[0];
   }
 }
 
@@ -549,7 +554,7 @@ get_from_cadets()
 {
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "1\n");
-  if (0 < GNUNET_memcmp (p_id[0], p_id[1]))
+  if (0 < GNUNET_memcmp (testpeer_id[0], testpeer_id[1]))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "standard peer\n");
     return cadets_running[0];
@@ -564,7 +569,7 @@ get_from_cadets()
 static unsigned int
 get_peer_nr()
 {
-  if (0 < GNUNET_memcmp (p_id[0], p_id[1]))
+  if (0 < GNUNET_memcmp (testpeer_id[0], testpeer_id[1]))
   {
     return peers_running - 1;
   }else
@@ -662,7 +667,7 @@ get_peers(void *cls)
 
     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                 "requesting peers info!\n");
-    plo = GNUNET_CADET_list_peers (get_from_cadets(), &peers_callback, NULL);
+    plo = GNUNET_CADET_list_peers (p_cfg[get_peer_nr()], &peers_callback, NULL);
 
 }
 
@@ -1028,6 +1033,10 @@ handle_data (void *cls,
                   " ok: (%d/%d)\n",
                   ok,
                   ok_goal);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "TEST both IDs: %s,%s\n",
+                GNUNET_i2s (testpeer_id[0]),
+                GNUNET_i2s (testpeer_id[1]));
 
       GNUNET_log (GNUNET_ERROR_TYPE_INFO, "dropping message\n");
       GNUNET_CADET_drop_message (GNUNET_CADET_get_mq (outgoing_ch),
@@ -1280,9 +1289,6 @@ pi_cb (void *cls,
 {
   long i = (long) cls;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "ID callback for %ld\n",
-              i);
   if ((NULL == pinfo) ||
       (NULL != emsg))
   {
@@ -1292,15 +1298,34 @@ pi_cb (void *cls,
     abort_test (__LINE__);
     return;
   }
-  p_id[i] = pinfo->result.id;
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "id: %s\n",
-              GNUNET_i2s (p_id[i]));
-  p_ids++;
-  if (p_ids < 2)
+
+  if (GNUNET_TESTBED_PIT_IDENTITY == pinfo->pit) 
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "ID callback for %ld\n",
+                i);
+    testpeer_id[i] = pinfo->result.id;
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "id: %s\n",
+                GNUNET_i2s (testpeer_id[i]));
+  }
+  else if (GNUNET_TESTBED_PIT_CONFIGURATION == pinfo->pit) 
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "CFG callback for %ld\n",
+                i);
+    p_cfg[i] = pinfo->result.cfg;
+  }
+  else 
+  {
+    GNUNET_break (0);
+  }
+  
+  peerinfo_task_cnt++;
+  if (peerinfo_task_cnt < 4)
     return;
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Got all IDs, starting test\n");
+              "Got all peer information, starting test\n");
   test_task = GNUNET_SCHEDULER_add_now (&start_test, NULL);
 }
 
@@ -1342,6 +1367,14 @@ tmain (void *cls,
                                                  GNUNET_TESTBED_PIT_IDENTITY,
                                                  &pi_cb,
                                                  (void *) 1L);
+  t_op[0] = GNUNET_TESTBED_peer_get_information (peers[0],
+                                                 GNUNET_TESTBED_PIT_CONFIGURATION,
+                                                 &pi_cb,
+                                                 (void *) 0L);
+  t_op[1] = GNUNET_TESTBED_peer_get_information (peers[num_peers - 1],
+                                                 GNUNET_TESTBED_PIT_CONFIGURATION,
+                                                 &pi_cb,
+                                                 (void *) 1L);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "requested peer ids\n");
 }
 
@@ -1504,7 +1537,7 @@ main (int argc, char *argv[])
     GNUNET_asprintf (&test_name, "backwards %s", test_name);
   }
 
-  p_ids = 0;
+  peerinfo_task_cnt = 0;
   ports[0] = &port;
   ports[1] = NULL;
   GNUNET_CADET_TEST_ruN ("test_cadet_small",