gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnunet] 09/40: NEWS: Moved start peer command to testing subsystem.


From: gnunet
Subject: [gnunet] 09/40: NEWS: Moved start peer command to testing subsystem.
Date: Thu, 05 Oct 2023 08:57:12 +0200

This is an automated email from the git hooks/post-receive script.

martin-schanzenbach pushed a commit to branch master
in repository gnunet.

commit 03a5d174717d62724a4130aac3dff7818912c029
Author: t3sserakt <t3ss@posteo.de>
AuthorDate: Fri Jul 14 19:16:43 2023 +0200

    NEWS: Moved start peer command to testing subsystem.
---
 src/include/gnunet_testing_netjail_lib.h           |  21 +++
 src/testing/Makefile.am                            |   3 +
 .../testing_api_cmd_start_peer.c}                  | 137 ++--------------
 src/transport/test_transport_plugin_cmd_nat_upnp.c |   3 +-
 .../test_transport_plugin_cmd_simple_send.c        |   3 +-
 .../test_transport_plugin_cmd_simple_send_dv.c     |   5 +-
 ..._transport_plugin_cmd_simple_send_performance.c |   5 +-
 .../test_transport_plugin_cmd_udp_backchannel.c    |   3 +-
 src/transport/transport-testing-cmds.h             | 173 +--------------------
 src/transport/transport_api_cmd_connecting_peers.c |  48 ++++--
 src/transport/transport_api_cmd_start_peer.c       |  20 +--
 src/transport/transport_api_cmd_stop_peer.c        |   2 +-
 12 files changed, 103 insertions(+), 320 deletions(-)

diff --git a/src/include/gnunet_testing_netjail_lib.h 
b/src/include/gnunet_testing_netjail_lib.h
index 106d7cdae..b76ce060b 100644
--- a/src/include/gnunet_testing_netjail_lib.h
+++ b/src/include/gnunet_testing_netjail_lib.h
@@ -343,6 +343,7 @@ GNUNET_TESTING_calculate_num (struct
                               GNUNET_TESTING_NodeConnection *node_connection,
                               struct GNUNET_TESTING_NetjailTopology *topology);
 
+
 /**
  * Struct with information for callbacks.
  *
@@ -507,6 +508,26 @@ GNUNET_TESTING_cmd_local_test_prepared (const char *label,
                                         write_message);
 
 
+/**
+ * Create command.
+ *
+ * @param label name for command.
+ * @param system_label Label of the cmd to setup a test environment.
+ * @param no Decimal number representing the last byte of the IP address of 
this peer.
+ * @param node_ip The IP address of this node.
+ * @param cfgname Configuration file name for this peer.
+ * @param broadcast Flag indicating, if broadcast should be switched on.
+ * @return command.
+ */
+struct GNUNET_TESTING_Command
+GNUNET_TESTING_cmd_start_peer (const char *label,
+                                 const char *system_label,
+                                 uint32_t no,
+                                 const char *node_ip,
+                                 const char *cfgname,
+                                 unsigned int broadcast);
+
+
 /* ***** Netjail trait support ***** */
 
 
diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am
index fae442b56..b40706707 100644
--- a/src/testing/Makefile.am
+++ b/src/testing/Makefile.am
@@ -29,6 +29,7 @@ gnunet_cmds_helper_LDADD = $(XLIB) \
  $(LTLIBINTL) $(Z_LIBS)
 
 libgnunettesting_la_SOURCES = \
+  testing_api_cmd_start_peer.c \
   testing_api_cmd_exec_bash_script.c \
   testing_api_cmd_barrier.c \
   testing_api_cmd_barrier_reached.c \
@@ -50,6 +51,8 @@ libgnunettesting_la_SOURCES = \
 libgnunettesting_la_LIBADD = \
  $(top_builddir)/src/arm/libgnunetarm.la \
  $(top_builddir)/src/util/libgnunetutil.la \
+ $(top_builddir)/src/transport/libgnunettransportapplication.la \
+$(top_builddir)/src/peerstore/libgnunetpeerstore.la \
  $(LTLIBINTL)
 libgnunettesting_la_LDFLAGS = \
  $(GN_LIB_LDFLAGS) \
diff --git a/src/transport/transport_api_cmd_start_peer.c 
b/src/testing/testing_api_cmd_start_peer.c
similarity index 75%
copy from src/transport/transport_api_cmd_start_peer.c
copy to src/testing/testing_api_cmd_start_peer.c
index 1f8ef2f8f..f6b471be4 100644
--- a/src/transport/transport_api_cmd_start_peer.c
+++ b/src/testing/testing_api_cmd_start_peer.c
@@ -25,12 +25,12 @@
  */
 #include "platform.h"
 #include "gnunet_util_lib.h"
+#include "testing_cmds.h"
 #include "gnunet_testing_ng_lib.h"
 #include "gnunet_testing_netjail_lib.h"
 #include "gnunet_peerstore_service.h"
 #include "gnunet_transport_core_service.h"
 #include "gnunet_transport_application_service.h"
-#include "transport-testing-cmds.h"
 
 /**
  * Generic logging shortcut
@@ -51,7 +51,7 @@ hello_iter_cb (void *cb_cls,
                const struct GNUNET_PEERSTORE_Record *record,
                const char *emsg)
 {
-  struct StartPeerState *sps = cb_cls;
+  struct GNUNET_TESTING_StartPeerState *sps = cb_cls;
   if (NULL == record)
   {
     sps->pic = NULL;
@@ -81,7 +81,7 @@ hello_iter_cb (void *cb_cls,
 static void
 retrieve_hello (void *cls)
 {
-  struct StartPeerState *sps = cls;
+  struct GNUNET_TESTING_StartPeerState *sps = cls;
   sps->rh_task = NULL;
   sps->pic = GNUNET_PEERSTORE_iterate (sps->ph,
                                        "transport",
@@ -93,73 +93,6 @@ retrieve_hello (void *cls)
 }
 
 
-/**
- * Disconnect callback for the connection to the core service.
- *
- */
-static void
-notify_disconnect (void *cls,
-                   const struct GNUNET_PeerIdentity *peer,
-                   void *handler_cls)
-{
-  struct StartPeerState *sps = cls;
-
-  LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Peer %s disconnected from peer %u (`%s')\n",
-       GNUNET_i2s (peer),
-       sps->no,
-       GNUNET_i2s (&sps->id));
-
-}
-
-
-/**
- * Connect callback for the connection to the core service.
- *
- */
-static void *
-notify_connect (void *cls,
-                const struct GNUNET_PeerIdentity *peer,
-                struct GNUNET_MQ_Handle *mq)
-{
-  struct StartPeerState *sps = cls;
-  struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode);
-  struct GNUNET_HashCode hc;
-  struct GNUNET_CRYPTO_EddsaPublicKey public_key = peer->public_key;
-
-  void *ret = (struct GNUNET_PeerIdentity *) peer;
-
-  LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "This Peer %s \n",
-       GNUNET_i2s (&sps->id));
-
-
-  GNUNET_CRYPTO_hash (&public_key, sizeof(public_key), &hc);
-
-  LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Peer %s connected to peer number %u with mq %p\n",
-       GNUNET_i2s (peer),
-       sps->no,
-       mq);
-
-
-  memcpy (key,
-          &hc,
-          sizeof (*key));
-  GNUNET_CONTAINER_multishortmap_put (sps->connected_peers_map,
-                                      key,
-                                      mq,
-                                      
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
-
-  GNUNET_free (key);
-
-  sps->notify_connect (sps->ac.is,
-                       peer);
-
-  return ret;
-}
-
-
 /**
  * The run method of this cmd will start all services of a peer to test the 
transport service.
  *
@@ -168,7 +101,7 @@ static void
 start_peer_run (void *cls,
                 struct GNUNET_TESTING_Interpreter *is)
 {
-  struct StartPeerState *sps = cls;
+  struct GNUNET_TESTING_StartPeerState *sps = cls;
   char *emsg = NULL;
   struct GNUNET_PeerIdentity dummy;
   const struct GNUNET_TESTING_Command *system_cmd;
@@ -321,25 +254,8 @@ start_peer_run (void *cls,
        sps->no,
        GNUNET_i2s_full (&sps->id));
 
-  sps->th = GNUNET_TRANSPORT_core_connect (sps->cfg,
-                                           NULL,
-                                           sps->handlers,
-                                           sps,
-                                           &notify_connect,
-                                           &notify_disconnect);
-  if (NULL == sps->th)
-  {
-    LOG (GNUNET_ERROR_TYPE_ERROR,
-         "Failed to connect to transport service for peer `%s': `%s'\n",
-         sps->cfgname,
-         emsg);
-    GNUNET_free (emsg);
-    GNUNET_TESTING_interpreter_fail (is);
-    return;
-  }
-
   sps->ph = GNUNET_PEERSTORE_connect (sps->cfg);
-  if (NULL == sps->th)
+  if (NULL == sps->ph)
   {
     LOG (GNUNET_ERROR_TYPE_ERROR,
          "Failed to connect to peerstore service for peer `%s': `%s'\n",
@@ -378,13 +294,8 @@ start_peer_run (void *cls,
 static void
 start_peer_cleanup (void *cls)
 {
-  struct StartPeerState *sps = cls;
+  struct GNUNET_TESTING_StartPeerState *sps = cls;
 
-  if (NULL != sps->handlers)
-  {
-    GNUNET_free (sps->handlers);
-    sps->handlers = NULL;
-  }
   //TODO Investigate why this caused problems during shutdown.
   /*if (NULL != sps->cfg)
   {
@@ -410,7 +321,7 @@ start_peer_traits (void *cls,
                    const char *trait,
                    unsigned int index)
 {
-  struct StartPeerState *sps = cls;
+  struct GNUNET_TESTING_StartPeerState *sps = cls;
   struct GNUNET_TRANSPORT_ApplicationHandle *ah = sps->ah;
   struct GNUNET_PeerIdentity *id = &sps->id;
   struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map =
@@ -420,15 +331,15 @@ start_peer_traits (void *cls,
 
 
   struct GNUNET_TESTING_Trait traits[] = {
-    GNUNET_TRANSPORT_make_trait_application_handle ((const void *) ah),
-    GNUNET_TRANSPORT_make_trait_peer_id ((const void *) id),
-    GNUNET_TRANSPORT_make_trait_connected_peers_map ((const
+    GNUNET_TESTING_make_trait_application_handle ((const void *) ah),
+    GNUNET_TESTING_make_trait_peer_id ((const void *) id),
+    GNUNET_TESTING_make_trait_connected_peers_map ((const
                                                       void *)
                                                      connected_peers_map),
-    GNUNET_TRANSPORT_make_trait_hello ((const void *) hello),
-    GNUNET_TRANSPORT_make_trait_hello_size ((const void *) hello_size),
-    GNUNET_TRANSPORT_make_trait_state ((const void *) sps),
-    GNUNET_TRANSPORT_make_trait_broadcast ((const void *) &sps->broadcast),
+    GNUNET_TESTING_make_trait_hello ((const void *) hello),
+    GNUNET_TESTING_make_trait_hello_size ((const void *) hello_size),
+    GNUNET_TESTING_make_trait_state ((const void *) sps),
+    GNUNET_TESTING_make_trait_broadcast ((const void *) &sps->broadcast),
     GNUNET_TESTING_trait_end ()
   };
 
@@ -440,40 +351,26 @@ start_peer_traits (void *cls,
 
 
 struct GNUNET_TESTING_Command
-GNUNET_TRANSPORT_cmd_start_peer (const char *label,
+GNUNET_TESTING_cmd_start_peer (const char *label,
                                  const char *system_label,
                                  uint32_t no,
                                  const char *node_ip,
-                                 struct GNUNET_MQ_MessageHandler *handlers,
                                  const char *cfgname,
-                                 GNUNET_TRANSPORT_notify_connect_cb
-                                 notify_connect,
                                  unsigned int broadcast)
 {
-  struct StartPeerState *sps;
+  struct GNUNET_TESTING_StartPeerState *sps;
   struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map =
     GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO);
   unsigned int i;
 
-  sps = GNUNET_new (struct StartPeerState);
+  sps = GNUNET_new (struct GNUNET_TESTING_StartPeerState);
   sps->no = no;
   sps->system_label = GNUNET_strdup (system_label);
   sps->connected_peers_map = connected_peers_map;
   sps->cfgname = GNUNET_strdup (cfgname);
   sps->node_ip = GNUNET_strdup (node_ip);
-  sps->notify_connect = notify_connect;
   sps->broadcast = broadcast;
 
-  if (NULL != handlers)
-  {
-    for (i = 0; NULL != handlers[i].cb; i++)
-      ;
-    sps->handlers = GNUNET_new_array (i + 1,
-                                      struct GNUNET_MQ_MessageHandler);
-    GNUNET_memcpy (sps->handlers,
-                   handlers,
-                   i * sizeof(struct GNUNET_MQ_MessageHandler));
-  }
   return GNUNET_TESTING_command_new (sps,
                                      label,
                                      &start_peer_run,
diff --git a/src/transport/test_transport_plugin_cmd_nat_upnp.c 
b/src/transport/test_transport_plugin_cmd_nat_upnp.c
index 1b02fbfc2..5c5e71e85 100644
--- a/src/transport/test_transport_plugin_cmd_nat_upnp.c
+++ b/src/transport/test_transport_plugin_cmd_nat_upnp.c
@@ -286,7 +286,8 @@ start_testcase (GNUNET_TESTING_cmd_helper_write_cb 
write_message,
                                                       "system-create",
                                                       num,
                                                       topology,
-                                                      0);
+                                                      0,
+                                                      GNUNET_YES);
   local_prepared = GNUNET_TESTING_cmd_local_test_prepared (
     "local-test-prepared",
     write_message);
diff --git a/src/transport/test_transport_plugin_cmd_simple_send.c 
b/src/transport/test_transport_plugin_cmd_simple_send.c
index 375796dff..0c9bfa890 100644
--- a/src/transport/test_transport_plugin_cmd_simple_send.c
+++ b/src/transport/test_transport_plugin_cmd_simple_send.c
@@ -263,7 +263,8 @@ start_testcase (GNUNET_TESTING_cmd_helper_write_cb 
write_message,
                                                       "system-create",
                                                       num,
                                                       topology,
-                                                      0);
+                                                      0,
+                                                      GNUNET_YES);
   local_prepared = GNUNET_TESTING_cmd_local_test_prepared (
     "local-test-prepared",
     write_message);
diff --git a/src/transport/test_transport_plugin_cmd_simple_send_dv.c 
b/src/transport/test_transport_plugin_cmd_simple_send_dv.c
index 55ab4a48f..ac3e8b24b 100644
--- a/src/transport/test_transport_plugin_cmd_simple_send_dv.c
+++ b/src/transport/test_transport_plugin_cmd_simple_send_dv.c
@@ -89,7 +89,7 @@ handle_test (void *cls,
   unsigned int connected;
   struct GNUNET_TESTING_BlockState *bs;
   struct GNUNET_TRANSPORT_CoreHandle *ch;
-  const struct StartPeerState *sps;
+  const struct GNUNET_TESTING_StartPeerState *sps;
 
 
   GNUNET_TRANSPORT_get_trait_state (&start_peer,
@@ -325,7 +325,8 @@ start_testcase (GNUNET_TESTING_cmd_helper_write_cb 
write_message,
     "system-create",
     num,
     topology,
-    topology->additional_connects);
+    topology->additional_connects,
+    GNUNET_YES);
   local_prepared = GNUNET_TESTING_cmd_local_test_prepared (
     "local-test-prepared",
     write_message);
diff --git a/src/transport/test_transport_plugin_cmd_simple_send_performance.c 
b/src/transport/test_transport_plugin_cmd_simple_send_performance.c
index 013a3c2b2..931801d77 100644
--- a/src/transport/test_transport_plugin_cmd_simple_send_performance.c
+++ b/src/transport/test_transport_plugin_cmd_simple_send_performance.c
@@ -111,7 +111,7 @@ handle_test (void *cls,
   struct GNUNET_TIME_Relative time_traveled;
   uint32_t num;
   struct GNUNET_TRANSPORT_CoreHandle *ch;
-  const struct StartPeerState *sps;
+  const struct GNUNET_TESTING_StartPeerState *sps;
 
 
   GNUNET_TRANSPORT_get_trait_state (&start_peer,
@@ -393,7 +393,8 @@ start_testcase (GNUNET_TESTING_cmd_helper_write_cb 
write_message,
                                                       "system-create",
                                                       num,
                                                       topology,
-                                                      0);
+                                                      0,
+                                                      GNUNET_YES);
   local_prepared = GNUNET_TESTING_cmd_local_test_prepared (
     "local-test-prepared",
     write_message);
diff --git a/src/transport/test_transport_plugin_cmd_udp_backchannel.c 
b/src/transport/test_transport_plugin_cmd_udp_backchannel.c
index 5e931fbe3..5f411e20e 100644
--- a/src/transport/test_transport_plugin_cmd_udp_backchannel.c
+++ b/src/transport/test_transport_plugin_cmd_udp_backchannel.c
@@ -255,7 +255,8 @@ start_testcase (GNUNET_TESTING_cmd_helper_write_cb 
write_message,
                                                       "system-create",
                                                       num,
                                                       topology,
-                                                      0);
+                                                      0,
+                                                      GNUNET_YES);
   local_prepared = GNUNET_TESTING_cmd_local_test_prepared (
     "local-test-prepared",
     write_message);
diff --git a/src/transport/transport-testing-cmds.h 
b/src/transport/transport-testing-cmds.h
index 6e3c761f2..6b6fcf4f1 100644
--- a/src/transport/transport-testing-cmds.h
+++ b/src/transport/transport-testing-cmds.h
@@ -33,175 +33,7 @@ typedef void *
 (*GNUNET_TRANSPORT_notify_connect_cb) (struct GNUNET_TESTING_Interpreter *is,
                                        const struct GNUNET_PeerIdentity *peer);
 
-/**
- * Struct to store information needed in callbacks.
- *
- */
-struct ConnectPeersState
-{
-  /**
-   * Context for our asynchronous completion.
-   */
-  struct GNUNET_TESTING_AsyncContext ac;
-
-  GNUNET_TRANSPORT_notify_connect_cb notify_connect;
-
-  /**
-   * The testing system of this node.
-   */
-  const struct GNUNET_TESTING_System *tl_system;
-
-  // Label of the cmd which started the test system.
-  const char *create_label;
-
-  /**
-   * Number globally identifying the node.
-   *
-   */
-  uint32_t num;
-
-  /**
-   * Label of the cmd to start a peer.
-   *
-   */
-  const char *start_peer_label;
-
-  /**
-   * The topology of the test setup.
-   */
-  struct GNUNET_TESTING_NetjailTopology *topology;
-
-  /**
-   * Connections to other peers.
-   */
-  struct GNUNET_TESTING_NodeConnection *node_connections_head;
-
-  struct GNUNET_TESTING_Interpreter *is;
-
-  /**
-   * Number of connections.
-   */
-  unsigned int con_num;
-
-  /**
-   * Number of additional connects this cmd will wait for not triggered by 
this cmd.
-   */
-  unsigned int additional_connects;
-
-  /**
- * Number of connections we already have a notification for.
- */
-  unsigned int con_num_notified;
-
-  /**
-   * Number of additional connects this cmd will wait for not triggered by 
this cmd we already have a notification for.
-   */
-  unsigned int additional_connects_notified;
-};
-
-struct StartPeerState
-{
-  /**
-   * Context for our asynchronous completion.
-   */
-  struct GNUNET_TESTING_AsyncContext ac;
-
-  /**
-   * The ip of a node.
-   */
-  char *node_ip;
-
-  /**
-   * Receive callback
-   */
-  struct GNUNET_MQ_MessageHandler *handlers;
-
-  /**
-   * GNUnet configuration file used to start a peer.
-   */
-  char *cfgname;
-
-  /**
-   * Peer's configuration
-   */
-  struct GNUNET_CONFIGURATION_Handle *cfg;
-
-  /**
-   * struct GNUNET_TESTING_Peer returned by GNUNET_TESTING_peer_configure.
-   */
-  struct GNUNET_TESTING_Peer *peer;
-
-  /**
-   * Peer identity
-   */
-  struct GNUNET_PeerIdentity id;
-
-  /**
-   * Peer's transport service handle
-   */
-  struct GNUNET_TRANSPORT_CoreHandle *th;
 
-  /**
-   * Application handle
-   */
-  struct GNUNET_TRANSPORT_ApplicationHandle *ah;
-
-  /**
-   * Peer's PEERSTORE Handle
-   */
-  struct GNUNET_PEERSTORE_Handle *ph;
-
-  /**
-   * Hello get task
-   */
-  struct GNUNET_SCHEDULER_Task *rh_task;
-
-  /**
-   * Peer's transport get hello handle to retrieve peer's HELLO message
-   */
-  struct GNUNET_PEERSTORE_IterateContext *pic;
-
-  /**
-   * Hello
-   */
-  char *hello;
-
-  /**
-   * Hello size
-   */
-  size_t hello_size;
-
-  /**
-   * The label of the command which was started by calling 
GNUNET_TESTING_cmd_system_create.
-   */
-  char *system_label;
-
-  /**
-   * An unique number to identify the peer
-   */
-  unsigned int no;
-
-  /**
-   * A map with struct GNUNET_MQ_Handle values for each peer this peer
-   * is connected to.
-   */
-  struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map;
-
-  /**
-   * Test setup for this peer.
-   */
-  const struct GNUNET_TESTING_System *tl_system;
-
-  /**
-   * Callback which is called on neighbour connect events.
-   */
-  GNUNET_TRANSPORT_notify_connect_cb notify_connect;
-
-  /**
-   * Flag indicating, if udp broadcast should be switched on.
-   */
-  enum GNUNET_GenericReturnValue broadcast;
-};
 
 struct TestState
 {
@@ -283,7 +115,8 @@ GNUNET_TRANSPORT_cmd_connect_peers (
   const char *create_label,
   uint32_t num,
   struct GNUNET_TESTING_NetjailTopology *topology,
-  unsigned int additional_connects);
+  unsigned int additional_connects,
+  unsigned int wait_for_connect);
 
 
 /**
@@ -402,7 +235,7 @@ GNUNET_TRANSPORT_cmd_backchannel_check (const char *label,
   op (hello, const char) \
   op (application_handle, const struct GNUNET_TRANSPORT_ApplicationHandle) \
   op (connect_peer_state, const struct ConnectPeersState) \
-  op (state, const struct StartPeerState) \
+  op (state, const struct GNUNET_TESTING_StartPeerState) \
   op (broadcast, const enum GNUNET_GenericReturnValue)
 
 GNUNET_TRANSPORT_SIMPLE_TRAITS (GNUNET_TRANSPORT_MAKE_DECL_SIMPLE_TRAIT)
diff --git a/src/transport/transport_api_cmd_connecting_peers.c 
b/src/transport/transport_api_cmd_connecting_peers.c
index 7feecbcc7..8ff206a23 100644
--- a/src/transport/transport_api_cmd_connecting_peers.c
+++ b/src/transport/transport_api_cmd_connecting_peers.c
@@ -65,8 +65,21 @@ connect_peers_run (void *cls,
   cps->is = is;
   peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (is,
                                                          
cps->start_peer_label);
-  GNUNET_TRANSPORT_get_trait_application_handle (peer1_cmd,
-                                                 &ah);
+  if (GNUNET_YES == cps->wait_for_connect)
+  {
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "Wait for connect.\n");
+    GNUNET_TRANSPORT_get_trait_application_handle (peer1_cmd,
+                                                   &ah);
+  }
+  else
+  {
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "Not waiting for connect.\n");
+    GNUNET_TESTING_get_trait_application_handle (peer1_cmd,
+                                                   &ah);
+  }
+
   GNUNET_TRANSPORT_get_trait_broadcast (peer1_cmd,
                                         &broadcast);
 
@@ -139,12 +152,13 @@ connect_peers_run (void *cls,
         }
         peer = GNUNET_TESTING_get_peer (num, tl_system);
         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                    "validating peer number %u with identity %s and address %s 
%u %s\n",
+                    "validating peer number %u with identity %s and address %s 
%u %s and handle %p\n",
                     num,
                     GNUNET_i2s (peer),
                     addr_and_port,
                     *broadcast,
-                    pos_prefix->address_prefix);
+                    pos_prefix->address_prefix,
+                    ah);
         GNUNET_TRANSPORT_application_validate ((struct
                                                 
GNUNET_TRANSPORT_ApplicationHandle
                                                 *) ah,
@@ -252,7 +266,8 @@ GNUNET_TRANSPORT_cmd_connect_peers (const char *label,
                                     uint32_t num,
                                     struct GNUNET_TESTING_NetjailTopology *
                                     topology,
-                                    unsigned int additional_connects)
+                                    unsigned int additional_connects,
+                                    unsigned int wait_for_connect)
 {
   struct ConnectPeersState *cps;
   unsigned int node_additional_connects;
@@ -275,11 +290,20 @@ GNUNET_TRANSPORT_cmd_connect_peers (const char *label,
   cps->topology = topology;
   cps->notify_connect = notify_connect;
   cps->additional_connects = additional_connects;
-
-  return GNUNET_TESTING_command_new (cps,
-                                     label,
-                                     &connect_peers_run,
-                                     &connect_peers_cleanup,
-                                     &connect_peers_traits,
-                                     &cps->ac);
+  cps->wait_for_connect = wait_for_connect;
+
+  if (GNUNET_YES == wait_for_connect)
+    return GNUNET_TESTING_command_new (cps,
+                                       label,
+                                       &connect_peers_run,
+                                       &connect_peers_cleanup,
+                                       &connect_peers_traits,
+                                       &cps->ac);
+  else
+    return GNUNET_TESTING_command_new (cps,
+                                       label,
+                                       &connect_peers_run,
+                                       &connect_peers_cleanup,
+                                       &connect_peers_traits,
+                                       NULL);
 }
diff --git a/src/transport/transport_api_cmd_start_peer.c 
b/src/transport/transport_api_cmd_start_peer.c
index 1f8ef2f8f..c4098e26d 100644
--- a/src/transport/transport_api_cmd_start_peer.c
+++ b/src/transport/transport_api_cmd_start_peer.c
@@ -51,7 +51,7 @@ hello_iter_cb (void *cb_cls,
                const struct GNUNET_PEERSTORE_Record *record,
                const char *emsg)
 {
-  struct StartPeerState *sps = cb_cls;
+  struct GNUNET_TESTING_StartPeerState *sps = cb_cls;
   if (NULL == record)
   {
     sps->pic = NULL;
@@ -81,7 +81,7 @@ hello_iter_cb (void *cb_cls,
 static void
 retrieve_hello (void *cls)
 {
-  struct StartPeerState *sps = cls;
+  struct GNUNET_TESTING_StartPeerState *sps = cls;
   sps->rh_task = NULL;
   sps->pic = GNUNET_PEERSTORE_iterate (sps->ph,
                                        "transport",
@@ -102,7 +102,7 @@ notify_disconnect (void *cls,
                    const struct GNUNET_PeerIdentity *peer,
                    void *handler_cls)
 {
-  struct StartPeerState *sps = cls;
+  struct GNUNET_TESTING_StartPeerState *sps = cls;
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Peer %s disconnected from peer %u (`%s')\n",
@@ -122,7 +122,7 @@ notify_connect (void *cls,
                 const struct GNUNET_PeerIdentity *peer,
                 struct GNUNET_MQ_Handle *mq)
 {
-  struct StartPeerState *sps = cls;
+  struct GNUNET_TESTING_StartPeerState *sps = cls;
   struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode);
   struct GNUNET_HashCode hc;
   struct GNUNET_CRYPTO_EddsaPublicKey public_key = peer->public_key;
@@ -168,7 +168,7 @@ static void
 start_peer_run (void *cls,
                 struct GNUNET_TESTING_Interpreter *is)
 {
-  struct StartPeerState *sps = cls;
+  struct GNUNET_TESTING_StartPeerState *sps = cls;
   char *emsg = NULL;
   struct GNUNET_PeerIdentity dummy;
   const struct GNUNET_TESTING_Command *system_cmd;
@@ -339,7 +339,7 @@ start_peer_run (void *cls,
   }
 
   sps->ph = GNUNET_PEERSTORE_connect (sps->cfg);
-  if (NULL == sps->th)
+  if (NULL == sps->ph)
   {
     LOG (GNUNET_ERROR_TYPE_ERROR,
          "Failed to connect to peerstore service for peer `%s': `%s'\n",
@@ -378,7 +378,7 @@ start_peer_run (void *cls,
 static void
 start_peer_cleanup (void *cls)
 {
-  struct StartPeerState *sps = cls;
+  struct GNUNET_TESTING_StartPeerState *sps = cls;
 
   if (NULL != sps->handlers)
   {
@@ -410,7 +410,7 @@ start_peer_traits (void *cls,
                    const char *trait,
                    unsigned int index)
 {
-  struct StartPeerState *sps = cls;
+  struct GNUNET_TESTING_StartPeerState *sps = cls;
   struct GNUNET_TRANSPORT_ApplicationHandle *ah = sps->ah;
   struct GNUNET_PeerIdentity *id = &sps->id;
   struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map =
@@ -450,12 +450,12 @@ GNUNET_TRANSPORT_cmd_start_peer (const char *label,
                                  notify_connect,
                                  unsigned int broadcast)
 {
-  struct StartPeerState *sps;
+  struct GNUNET_TESTING_StartPeerState *sps;
   struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map =
     GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO);
   unsigned int i;
 
-  sps = GNUNET_new (struct StartPeerState);
+  sps = GNUNET_new (struct GNUNET_TESTING_StartPeerState);
   sps->no = no;
   sps->system_label = GNUNET_strdup (system_label);
   sps->connected_peers_map = connected_peers_map;
diff --git a/src/transport/transport_api_cmd_stop_peer.c 
b/src/transport/transport_api_cmd_stop_peer.c
index a80742b5f..60d48c56b 100644
--- a/src/transport/transport_api_cmd_stop_peer.c
+++ b/src/transport/transport_api_cmd_stop_peer.c
@@ -58,7 +58,7 @@ stop_peer_run (void *cls,
                struct GNUNET_TESTING_Interpreter *is)
 {
   struct StopPeerState *stop_ps = cls;
-  const struct StartPeerState *sps;
+  const struct GNUNET_TESTING_StartPeerState *sps;
   const struct GNUNET_TESTING_Command *start_cmd;
 
   start_cmd = GNUNET_TESTING_interpreter_lookup_command (is,

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]