gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet] branch master updated: - added first testcase cmd code for send


From: gnunet
Subject: [gnunet] branch master updated: - added first testcase cmd code for sending a simple testmessage
Date: Thu, 22 Jul 2021 17:06:31 +0200

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

t3sserakt pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new 6b2c5a92f - added first testcase cmd code for sending a simple 
testmessage
6b2c5a92f is described below

commit 6b2c5a92fbc3a57c42fc9fb38c4705ecb7afb328
Author: t3sserakt <t3ss@posteo.de>
AuthorDate: Thu Jul 22 17:03:02 2021 +0200

    - added first testcase cmd code for sending a simple testmessage
---
 po/POTFILES.in                                     |   5 +-
 src/include/gnunet_testbed_ng_service.h            |   3 +-
 src/include/gnunet_testing_ng_lib.h                |  37 ++
 src/include/gnunet_testing_plugin.h                |   4 +-
 src/testbed/gnunet-cmds-helper.c                   |   5 +-
 src/testbed/plugin_testcmd.c                       |   6 +-
 src/testbed/test_testbed_api_cmd_netjail.c         |   5 +-
 .../testbed_api_cmd_netjail_start_testbed.c        |   9 +-
 src/testing/Makefile.am                            |   1 +
 src/testing/testing_api_cmd_start_peer.c           | 296 -----------
 src/testing/testing_api_cmd_system_create.c        |  14 +
 src/transport/Makefile.am                          |  29 +-
 .../plugin_cmd_simple_send.c}                      |  47 +-
 .../test_transport_api_cmd_simple_send.c}          |   7 +-
 src/transport/transport_api_cmd_connecting_peers.c | 178 +++++++
 src/transport/transport_api_cmd_send_simple.c      | 136 +++++
 src/transport/transport_api_cmd_start_peer.c       | 558 +++++++++++++++++++++
 17 files changed, 1009 insertions(+), 331 deletions(-)

diff --git a/po/POTFILES.in b/po/POTFILES.in
index c2c64a09b..042a4b1df 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -445,7 +445,6 @@ src/testing/testing_api_cmd_batch.c
 src/testing/testing_api_cmd_hello_world.c
 src/testing/testing_api_cmd_hello_world_birth.c
 src/testing/testing_api_cmd_send_peer_ready.c
-src/testing/testing_api_cmd_start_peer.c
 src/testing/testing_api_cmd_system_create.c
 src/testing/testing_api_loop.c
 src/testing/testing_api_trait_cmd.c
@@ -471,6 +470,7 @@ src/transport/gnunet-transport-profiler.c
 src/transport/gnunet-transport-wlan-receiver.c
 src/transport/gnunet-transport-wlan-sender.c
 src/transport/gnunet-transport.c
+src/transport/plugin_cmd_simple_send.c
 src/transport/plugin_transport_http_client.c
 src/transport/plugin_transport_http_common.c
 src/transport/plugin_transport_http_server.c
@@ -502,6 +502,9 @@ src/transport/transport_api2_core.c
 src/transport/transport_api2_monitor.c
 src/transport/transport_api_address_to_string.c
 src/transport/transport_api_blacklist.c
+src/transport/transport_api_cmd_connecting_peers.c
+src/transport/transport_api_cmd_send_simple.c
+src/transport/transport_api_cmd_start_peer.c
 src/transport/transport_api_core.c
 src/transport/transport_api_hello_get.c
 src/transport/transport_api_manipulation.c
diff --git a/src/include/gnunet_testbed_ng_service.h 
b/src/include/gnunet_testbed_ng_service.h
index caaee26b6..49e9f56bc 100644
--- a/src/include/gnunet_testbed_ng_service.h
+++ b/src/include/gnunet_testbed_ng_service.h
@@ -232,7 +232,8 @@ GNUNET_TESTBED_cmd_netjail_start (const char *label,
 struct GNUNET_TESTING_Command
 GNUNET_TESTBED_cmd_netjail_start_testbed (const char *label,
                                           char *local_m,
-                                          char *global_n);
+                                          char *global_n,
+                                          char *plugin_name);
 
 
 /**
diff --git a/src/include/gnunet_testing_ng_lib.h 
b/src/include/gnunet_testing_ng_lib.h
index 8927fd4f1..994ce31f1 100644
--- a/src/include/gnunet_testing_ng_lib.h
+++ b/src/include/gnunet_testing_ng_lib.h
@@ -29,6 +29,8 @@
 
 #include "gnunet_util_lib.h"
 #include "gnunet_testing_plugin.h"
+#include "gnunet_transport_application_service.h"
+#include "gnunet_testing_lib.h"
 
 
 /* ********************* Helper functions ********************* */
@@ -831,4 +833,39 @@ int
 GNUNET_TESTING_get_trait_what_am_i (const struct GNUNET_TESTING_Command *cmd,
                                     char **what_am_i);
 
+int
+GNUNET_TESTING_get_trait_application_handle (const struct
+                                             GNUNET_TESTING_Command *cmd,
+                                             struct
+                                             GNUNET_TRANSPORT_ApplicationHandle
+                                             **ah);
+
+int
+GNUNET_TESTING_get_trait_peer_id (const struct
+                                  GNUNET_TESTING_Command *cmd,
+                                  struct GNUNET_PeerIdentity **id);
+
+int
+GNUNET_TESTING_get_trait_connected_peers_map (const struct
+                                              GNUNET_TESTING_Command
+                                              *cmd,
+                                              struct
+                                              GNUNET_CONTAINER_MultiPeerMap **
+                                              connected_peers_map);
+int
+GNUNET_TESTING_get_trait_hello_size (const struct
+                                     GNUNET_TESTING_Command
+                                     *cmd,
+                                     size_t **hello_size);
+
+int
+GNUNET_TESTING_get_trait_hello (const struct
+                                GNUNET_TESTING_Command
+                                *cmd,
+                                char **hello);
+
+int
+GNUNET_TESTING_get_trait_test_system (const struct
+                                      GNUNET_TESTING_Command *cmd,
+                                      struct GNUNET_TESTING_System 
**test_system);
 #endif
diff --git a/src/include/gnunet_testing_plugin.h 
b/src/include/gnunet_testing_plugin.h
index 6a54cacd2..8395e2a49 100644
--- a/src/include/gnunet_testing_plugin.h
+++ b/src/include/gnunet_testing_plugin.h
@@ -43,7 +43,9 @@ typedef void
 typedef void
 (*GNUNET_TESTING_PLUGIN_StartTestCase) (TESTBED_CMD_HELPER_write_cb
                                         write_message, char *router_ip,
-                                        char *node_ip);
+                                        char *node_ip,
+                                        char *n,
+                                        char *m);
 
 typedef void
 (*GNUNET_TESTING_PLUGIN_ALL_PEERS_STARTED) ();
diff --git a/src/testbed/gnunet-cmds-helper.c b/src/testbed/gnunet-cmds-helper.c
index 0d618bd48..113e3c386 100644
--- a/src/testbed/gnunet-cmds-helper.c
+++ b/src/testbed/gnunet-cmds-helper.c
@@ -427,7 +427,8 @@ tokenizer_cb (void *cls, const struct GNUNET_MessageHeader 
*message)
     strcat (node_ip, NODE_BASE_IP);
     strcat (node_ip, plugin->n);
 
-    plugin->api->start_testcase (&write_message, router_ip, node_ip);
+    plugin->api->start_testcase (&write_message, router_ip, node_ip, plugin->m,
+                                 plugin->n);
 
     LOG (GNUNET_ERROR_TYPE_ERROR,
          "We got here!\n");
@@ -479,8 +480,6 @@ tokenizer_cb (void *cls, const struct GNUNET_MessageHeader 
*message)
   else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED == ntohs (
              message->type))
   {
-    LOG (GNUNET_ERROR_TYPE_ERROR,
-         "We got here 8!\n");
     plugin->api->all_peers_started ();
     return GNUNET_OK;
   }
diff --git a/src/testbed/plugin_testcmd.c b/src/testbed/plugin_testcmd.c
index 70b6ad3ae..797826781 100644
--- a/src/testbed/plugin_testcmd.c
+++ b/src/testbed/plugin_testcmd.c
@@ -46,7 +46,9 @@ all_peers_started ()
 
 static void
 start_testcase (TESTBED_CMD_HELPER_write_cb write_message, char *router_ip,
-                char *node_ip)
+                char *node_ip,
+                char *n,
+                char *m)
 {
   struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
 
@@ -110,4 +112,4 @@ libgnunet_plugin_testcmd_done (void *cls)
 }
 
 
-/* end of plugin_gnsrecord_dns.c */
+/* end of plugin_testcmd.c */
diff --git a/src/testbed/test_testbed_api_cmd_netjail.c 
b/src/testbed/test_testbed_api_cmd_netjail.c
index e5fc0877e..8bb9e40e8 100644
--- a/src/testbed/test_testbed_api_cmd_netjail.c
+++ b/src/testbed/test_testbed_api_cmd_netjail.c
@@ -19,7 +19,7 @@
  */
 
 /**
- * @file testing/test_testing_api_cmd_netjail.c
+ * @file testing/test_testbed_api_cmd_netjail.c
  * @brief Test case executing a script in a network name space.
  * @author t3sserakt
  */
@@ -44,7 +44,8 @@ run (void *cls)
                                       "2"),
     GNUNET_TESTBED_cmd_netjail_start_testbed ("netjail-start-testbed-1",
                                               "2",
-                                              "2"),
+                                              "2",
+                                              "libgnunet_plugin_testcmd"),
     GNUNET_TESTBED_cmd_stop_testbed ("stop-testbed",
                                      "netjail-start-testbed-1",
                                      "2",
diff --git a/src/testbed/testbed_api_cmd_netjail_start_testbed.c 
b/src/testbed/testbed_api_cmd_netjail_start_testbed.c
index bc4674b74..9b68c52f6 100644
--- a/src/testbed/testbed_api_cmd_netjail_start_testbed.c
+++ b/src/testbed/testbed_api_cmd_netjail_start_testbed.c
@@ -97,6 +97,8 @@ struct NetJailState
   struct GNUNET_TESTBED_Host **host;
 
   unsigned int n_host;
+
+  char *plugin_name;
 };
 
 struct TestbedCount
@@ -345,6 +347,7 @@ start_testbed (struct NetJailState *ns, struct
 
   cfg = GNUNET_CONFIGURATION_dup (config);
 
+  // TODO We do not need this?
   GNUNET_array_append (ns->host, ns->n_host,
                        GNUNET_TESTBED_host_create_with_id (tbc->count - 1,
                                                            NULL,
@@ -374,7 +377,7 @@ start_testbed (struct NetJailState *ns, struct
 
   msg = create_helper_init_msg_ (m_char,
                                  n_char,
-                                 "libgnunet_plugin_testcmd");
+                                 ns->plugin_name);
   GNUNET_array_append (ns->msg, ns->n_msg, &msg->header);
 
   GNUNET_array_append (ns->shandle, ns->n_shandle, GNUNET_HELPER_send (
@@ -506,13 +509,15 @@ netjail_start_finish (void *cls,
 struct GNUNET_TESTING_Command
 GNUNET_TESTBED_cmd_netjail_start_testbed (const char *label,
                                           char *local_m,
-                                          char *global_n)
+                                          char *global_n,
+                                          char *plugin_name)
 {
   struct NetJailState *ns;
 
   ns = GNUNET_new (struct NetJailState);
   ns->local_m = local_m;
   ns->global_n = global_n;
+  ns->plugin_name = plugin_name;
 
   struct GNUNET_TESTING_Command cmd = {
     .cls = ns,
diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am
index 95fc5c805..868e3fcec 100644
--- a/src/testing/Makefile.am
+++ b/src/testing/Makefile.am
@@ -16,6 +16,7 @@ lib_LTLIBRARIES = \
 
 libgnunettesting_la_SOURCES = \
   testing.c \
+  testing_api_cmd_system_create.c \
   testing_api_cmd_batch.c \
   testing_api_cmd_hello_world.c \
   testing_api_cmd_hello_world_birth.c \
diff --git a/src/testing/testing_api_cmd_start_peer.c 
b/src/testing/testing_api_cmd_start_peer.c
deleted file mode 100644
index 0f8c618b8..000000000
--- a/src/testing/testing_api_cmd_start_peer.c
+++ /dev/null
@@ -1,296 +0,0 @@
-/*
-      This file is part of GNUnet
-      Copyright (C) 2021 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 <http://www.gnu.org/licenses/>.
-
-     SPDX-License-Identifier: AGPL3.0-or-later
- */
-
-/**
- * @file testing_api_cmd_start_peer.c
- * @brief cmd to start a peer.
- * @author t3sserakt
- */
-#include "platform.h"
-#include "gnunet_util_lib.h"
-#include "gnunet_testing_ng_lib.h"
-
-
-struct StartPeerState
-{
-  /**
-   * Receive callback
-   */
-  struct GNUNET_MQ_MessageHandler *handlers;
-
-  const char *cfgname;
-
-  /**
-   * Peer's configuration
-   */
-  struct GNUNET_CONFIGURATION_Handle *cfg;
-
-  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;
-
-  char *m;
-
-  char *n;
-
-  unsigned int finished;
-};
-
-
-static void
-retrieve_hello (void *cls);
-
-static void
-hello_iter_cb (void *cb_cls,
-               const struct GNUNET_PEERSTORE_Record *record,
-               const char *emsg)
-{
-  struct StartPeerState *sps = cb_cls;
-  if (NULL == record)
-  {
-    sps->pic = NULL;
-    sps->rh_task = GNUNET_SCHEDULER_add_now (retrieve_hello, p);
-    return;
-  }
-  // Check record type et al?
-  sps->hello_size = record->value_size;
-  sps->hello = GNUNET_malloc (sps->hello_size);
-  memcpy (sps->hello, record->value, sps->hello_size);
-  p->hello[p->hello_size - 1] = '\0';
-
-  GNUNET_PEERSTORE_iterate_cancel (sps->pic);
-  sps->pic = NULL;
-  sps->finished = GNUNET_YES;
-}
-
-
-static void
-retrieve_hello (void *cls)
-{
-  struct StartPeerState *sps = cls;
-  sps->rh_task = NULL;
-  sps->pic = GNUNET_PEERSTORE_iterate (sps->ph,
-                                       "transport",
-                                       &sps->id,
-                                       GNUNET_PEERSTORE_TRANSPORT_HELLO_KEY,
-                                       hello_iter_cb,
-                                       sps);
-
-}
-
-static int
-start_peer_finish (void *cls,
-                   GNUNET_SCHEDULER_TaskCallback cont,
-                   void *cont_cls)
-{
-  struct StartPeerState *sps = cls;
-
-  return sps->finished;
-}
-
-
-static void
-start_peer_run (void *cls,
-                const struct GNUNET_TESTING_Command *cmd,
-                struct GNUNET_TESTING_Interpreter *is)
-{
-  struct StartPeerState *sps = cls;
-  char *emsg = NULL;
-  struct GNUNET_PeerIdentity dummy;
-
-  if (GNUNET_NO == GNUNET_DISK_file_test (sps->cfgname))
-  {
-    LOG (GNUNET_ERROR_TYPE_ERROR,
-         "File not found: `%s'\n",
-         cfgname);
-    return NULL;
-  }
-
-  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));
-  }
-  sps->cfg = GNUNET_CONFIGURATION_create ();
-  GNUNET_assert (GNUNET_OK ==
-                 GNUNET_CONFIGURATION_load (sps->cfg, sps->cfgname));
-  if (GNUNET_SYSERR ==
-      GNUNET_TESTING_configuration_create (tl_system,
-                                           sps->cfg))
-  {
-    LOG (GNUNET_ERROR_TYPE_ERROR,
-         "Testing library failed to create unique configuration based on 
`%s'\n",
-         sps->cfgname);
-    GNUNET_CONFIGURATION_destroy (sps->cfg);
-    GNUNET_TESTING_interpreter_fail ();
-  }
-
-  sps->peer = GNUNET_TESTING_peer_configure (tth->tl_system,
-                                             p->cfg,
-                                             p->no,
-                                             NULL,
-                                             &emsg);
-  if (NULL == sps->peer)
-  {
-    LOG (GNUNET_ERROR_TYPE_ERROR,
-         "Testing library failed to create unique configuration based on `%s': 
`%s'\n",
-         cfgname,
-         emsg);
-    GNUNET_free (emsg);
-    GNUNET_TESTING_interpreter_fail ();
-  }
-
-  if (GNUNET_OK != GNUNET_TESTING_peer_start (p->peer))
-  {
-    LOG (GNUNET_ERROR_TYPE_ERROR,
-         "Testing library failed to create unique configuration based on 
`%s'\n",
-         cfgname);
-    GNUNET_free (emsg);
-    GNUNET_TESTING_interpreter_fail ();
-  }
-
-  memset (&dummy,
-          '\0',
-          sizeof(dummy));
-  GNUNET_TESTING_peer_get_identity (sps->peer,
-                                    &sps->id);
-  if (0 == memcmp (&dummy,
-                   &sps->id,
-                   sizeof(struct GNUNET_PeerIdentity)))
-  {
-    LOG (GNUNET_ERROR_TYPE_ERROR,
-         "Testing library failed to obtain peer identity for peer %s_%s\n",
-         p->no);
-    GNUNET_free (emsg);
-    GNUNET_TESTING_interpreter_fail ();
-  }
-  LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Peer %u configured with identity `%s'\n",
-       p->no,
-       GNUNET_i2s_full (&p->id));
-  sps->th = GNUNET_TRANSPORT_core_connect (p->cfg,
-                                           NULL,
-                                           handlers,
-                                           p,
-                                           &notify_connect,
-                                           &notify_disconnect);
-  if (NULL == sps->th)
-  {
-    LOG (GNUNET_ERROR_TYPE_ERROR,
-         "Failed to connect to transport service for peer `%s': `%s'\n",
-         cfgname,
-         emsg);
-    GNUNET_free (emsg);
-    GNUNET_TESTING_interpreter_fail ();
-  }
-  sps->ph = GNUNET_PEERSTORE_connect (p->cfg);
-  if (NULL == sps->th)
-  {
-    LOG (GNUNET_ERROR_TYPE_ERROR,
-         "Failed to connect to peerstore service for peer `%s': `%s'\n",
-         cfgname,
-         emsg);
-    GNUNET_free (emsg);
-    GNUNET_TESTING_interpreter_fail ();
-  }
-  sps->ah = GNUNET_TRANSPORT_application_init (p->cfg);
-  if (NULL == sps->ah)
-  {
-    LOG (GNUNET_ERROR_TYPE_ERROR,
-         "Failed to initialize the TRANSPORT application suggestion client 
handle for peer `%s': `%s'\n",
-         cfgname,
-         emsg);
-    GNUNET_free (emsg);
-    GNUNET_TESTING_interpreter_fail ();
-  }
-  p->rh_task = GNUNET_SCHEDULER_add_now (retrieve_hello, p);
-}
-
-
-/**
- * Create command.
- *
- * @param label name for command.
- * @return command.
- */
-struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_start_peer (const char *label,
-                               char *m,
-                               char *n)
-{
-  struct StartPeerState *sps;
-
-  sps = GNUNET_new (struct StartPeerState);
-  sps->m = m;
-  sps->n = n;
-
-  struct GNUNET_TESTING_Command cmd = {
-    .cls = sps,
-    .label = label,
-    .run = &start_peer_run,
-    .cleanup = &start_peer_cleanup,
-    .traits = &start_peer_traits
-  };
-
-  return cmd;
-}
diff --git a/src/testing/testing_api_cmd_system_create.c 
b/src/testing/testing_api_cmd_system_create.c
index ad0aa4f90..a324940bb 100644
--- a/src/testing/testing_api_cmd_system_create.c
+++ b/src/testing/testing_api_cmd_system_create.c
@@ -26,10 +26,13 @@
 #include "platform.h"
 #include "gnunet_util_lib.h"
 #include "gnunet_testing_ng_lib.h"
+#include "gnunet_testing_lib.h"
 
 struct TestSystemState
 {
   struct GNUNET_TESTING_System *test_system;
+
+  const char *testdir;
 };
 
 
@@ -83,6 +86,17 @@ GNUNET_TESTING_get_trait_test_system (const struct
 }
 
 
+static void
+system_create_cleanup (void *cls,
+                       const struct GNUNET_TESTING_Command *cmd)
+{
+  struct TestSystemState *tss = cls;
+
+  GNUNET_free (tss->test_system);
+  GNUNET_free (tss);
+}
+
+
 /**
  * Create command.
  *
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am
index bc3004a70..9f680ad3b 100644
--- a/src/transport/Makefile.am
+++ b/src/transport/Makefile.am
@@ -167,6 +167,9 @@ libgnunettransporttesting_la_LDFLAGS = \
  $(GN_LIB_LDFLAGS)
 
 libgnunettransporttesting2_la_SOURCES = \
+  transport_api_cmd_connecting_peers.c \
+  transport_api_cmd_start_peer.c \
+  transport_api_cmd_send_simple.c \
   transport-testing2.c transport-testing2.h \
   transport-testing-filenames2.c \
   transport-testing-loggers2.c \
@@ -394,7 +397,19 @@ plugin_LTLIBRARIES = \
   $(HTTP_SERVER_PLUGIN_LA) \
   $(HTTPS_SERVER_PLUGIN_LA) \
   $(WLAN_PLUGIN_LA) \
-  $(BT_PLUGIN_LA)
+  $(BT_PLUGIN_LA) 
+  # libgnunet_plugin_simple_send.la
+
+# libgnunet_plugin_cmd_simple_send_la_SOURCES = \
+#  plugin_cmd_simple_send.c
+# libgnunet_plugin_cmd_simple_send_la_LIBADD = \
+#  $(top_builddir)/src/util/libgnunetutil.la \
+#  $(top_builddir)/src/testing/libgnunettesting.la \
+#  $(top_builddir)/src/statistics/libgnunetstatistics.la \
+#  $(top_builddir)/src/testbed/libgnunettestbed.la \
+#  $(LTLIBINTL)
+# libgnunet_plugin_cmd_simple_send_la_LDFLAGS = \
+#  $(GN_PLUGIN_LDFLAGS)
 
 if HAVE_EXPERIMENTAL
 plugin_LTLIBRARIES += libgnunet_plugin_transport_udp.la
@@ -541,6 +556,7 @@ libgnunet_plugin_transport_https_server_la_CFLAGS = \
 
 if HAVE_TESTING
 check_PROGRAMS = \
+ test_transport_api_cmd_simple_send \
  test_transport_address_switch_tcp \
  test_transport_testing_startstop \
  test_transport_testing_restart \
@@ -629,6 +645,7 @@ endif
 if ENABLE_TEST_RUN
 AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export 
PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset 
XDG_CONFIG_HOME;
 TESTS = \
+ test_transport_api_cmd_simple_send \
  test_transport_address_switch_tcp \
  $(HTTP_SWITCH) \
  $(HTTPS_SWITCH) \
@@ -705,6 +722,16 @@ TESTS += \
 endif
 endif
 
+test_transport_api_cmd_simple_send_SOURCES = \
+ test_transport_api_cmd_simple_send.c
+test_transport_api_cmd_simple_send_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(top_builddir)/src/testbed/libgnunettestbed.la \
+ libgnunettransport.la \
+ $(top_builddir)/src/hello/libgnunethello.la \
+ libgnunettransporttesting.la
+
 test_transport_testing_startstop_SOURCES = \
  test_transport_testing_startstop.c
 test_transport_testing_startstop_LDADD = \
diff --git a/src/testbed/plugin_testcmd.c 
b/src/transport/plugin_cmd_simple_send.c
similarity index 66%
copy from src/testbed/plugin_testcmd.c
copy to src/transport/plugin_cmd_simple_send.c
index 70b6ad3ae..ed3481c00 100644
--- a/src/testbed/plugin_testcmd.c
+++ b/src/transport/plugin_cmd_simple_send.c
@@ -33,36 +33,47 @@
  */
 #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
 
-unsigned int are_all_peers_started;
+#define BASE_DIR "testdir"
 
-static void
-all_peers_started ()
-{
-  are_all_peers_started = GNUNET_YES;
-  LOG (GNUNET_ERROR_TYPE_ERROR,
-       "setting are_all_peers_started: %d\n",
-       are_all_peers_started);
-}
 
 static void
 start_testcase (TESTBED_CMD_HELPER_write_cb write_message, char *router_ip,
-                char *node_ip)
+                char *node_ip,
+                char *m,
+                char *n)
 {
   struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
+  char *testdir;
 
-  LOG (GNUNET_ERROR_TYPE_ERROR,
-       "We got here 6!\n");
+  testdir = GNUNET_malloc (strlen (basedir) + strlen (m) + strlen (n)
+                           + 1);
 
-  are_all_peers_started = GNUNET_NO;
+  strcpy (testdir, BASE_DIR);
+  strcat (testdir, m);
+  strcat (testdir, n);
 
   struct GNUNET_TESTING_Command commands[] = {
-    GNUNET_TESTING_cmd_hello_world_birth ("hello-world-birth-0",
-                                          &now),
-    GNUNET_TESTING_cmd_hello_world ("hello-world-0","hello-world-birth-0",""),
+    GNUNET_TESTING_cmd_system_create ("system-create-1",
+                                      testdir),
+    GNUNET_TESTING_cmd_start_peer ("start-peer-1",
+                                   "system-create-1",
+                                   m,
+                                   n,
+                                   struct GNUNET_MQ_MessageHandler *handlers,
+                                   const char *cfgname),
     GNUNET_TESTING_cmd_send_peer_ready ("send-peer-ready-1",
                                         write_message),
     GNUNET_TESTING_cmd_block_until_all_peers_started ("block-1",
                                                       &are_all_peers_started),
+    GNUNET_TESTING_cmd_connect_peers ("connect-peers-1",
+                                      "start-peer-1",
+                                      "this is useless"),
+    /*GNUNET_TESTING_cmd_send_simple ("send-simple-1",
+                                    char *m,
+                                    char *n,
+                                    uint32_t num,
+                                    const char *peer1_label,
+                                    const char *peer2_label),*/
     GNUNET_TESTING_cmd_local_test_finished ("local-test-finished-1",
                                             write_message)
   };
@@ -70,8 +81,6 @@ start_testcase (TESTBED_CMD_HELPER_write_cb write_message, 
char *router_ip,
   GNUNET_TESTING_run (NULL,
                       commands,
                       GNUNET_TIME_UNIT_FOREVER_REL);
-  LOG (GNUNET_ERROR_TYPE_ERROR,
-       "We got here 7!\n");
 
 }
 
@@ -110,4 +119,4 @@ libgnunet_plugin_testcmd_done (void *cls)
 }
 
 
-/* end of plugin_gnsrecord_dns.c */
+/* end of plugin_testcmd.c */
diff --git a/src/testbed/test_testbed_api_cmd_netjail.c 
b/src/transport/test_transport_api_cmd_simple_send.c
similarity index 88%
copy from src/testbed/test_testbed_api_cmd_netjail.c
copy to src/transport/test_transport_api_cmd_simple_send.c
index e5fc0877e..36c7d23b2 100644
--- a/src/testbed/test_testbed_api_cmd_netjail.c
+++ b/src/transport/test_transport_api_cmd_simple_send.c
@@ -19,8 +19,8 @@
  */
 
 /**
- * @file testing/test_testing_api_cmd_netjail.c
- * @brief Test case executing a script in a network name space.
+ * @file transport/test_transport_api_cmd_simple_send.c
+ * @brief Test case executing a script which sends a test message between two 
peers.
  * @author t3sserakt
  */
 #include "platform.h"
@@ -44,7 +44,8 @@ run (void *cls)
                                       "2"),
     GNUNET_TESTBED_cmd_netjail_start_testbed ("netjail-start-testbed-1",
                                               "2",
-                                              "2"),
+                                              "2",
+                                              
"libgnunet_plugin_cmd_simple_send"),
     GNUNET_TESTBED_cmd_stop_testbed ("stop-testbed",
                                      "netjail-start-testbed-1",
                                      "2",
diff --git a/src/transport/transport_api_cmd_connecting_peers.c 
b/src/transport/transport_api_cmd_connecting_peers.c
new file mode 100644
index 000000000..297b90864
--- /dev/null
+++ b/src/transport/transport_api_cmd_connecting_peers.c
@@ -0,0 +1,178 @@
+/*
+      This file is part of GNUnet
+      Copyright (C) 2021 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 <http://www.gnu.org/licenses/>.
+
+     SPDX-License-Identifier: AGPL3.0-or-later
+ */
+
+/**
+ * @file testing_api_cmd_start_peer.c
+ * @brief cmd to start a peer.
+ * @author t3sserakt
+ */
+#include "platform.h"
+#include "gnunet_util_lib.h"
+#include "gnunet_testing_ng_lib.h"
+#include "gnunet_transport_application_service.h"
+#include "gnunet_hello_lib.h"
+
+/**
+ * Generic logging shortcut
+ */
+#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
+
+struct ConnectPeersState
+{
+  const char *peer1_label;
+
+  const char *peer2_label;
+};
+
+
+static void
+connect_peers_run (void *cls,
+                   const struct GNUNET_TESTING_Command *cmd,
+                   struct GNUNET_TESTING_Interpreter *is)
+{
+  struct ConnectPeersState *cps = cls;
+  const struct GNUNET_TESTING_Command *peer1_cmd;
+  const struct GNUNET_TESTING_Command *peer2_cmd;
+  struct GNUNET_TRANSPORT_ApplicationHandle *ah;
+  struct GNUNET_PeerIdentity *id;
+  char *addr;
+  struct GNUNET_TIME_Absolute t;
+  char *hello;
+  size_t *hello_size;
+  enum GNUNET_NetworkType nt = 0;
+
+  peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->peer1_label);
+  GNUNET_TESTING_get_trait_application_handle (peer1_cmd,
+                                               &ah);
+
+  GNUNET_TESTING_get_trait_hello (peer1_cmd,
+                                  &hello);
+
+  LOG (GNUNET_ERROR_TYPE_ERROR,
+       "hello: %s\n",
+       hello);
+
+  // TODO This does not work, because the other peer is running in another 
local loop. We need to message between different local loops. For now we will 
create the hello manually with the known information about the other local 
peers.
+  // ---------------------------------------------
+  /*peer2_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->peer2_label);
+  GNUNET_TESTING_get_trait_peer_id (peer2_cmd,
+                                    &id);
+  GNUNET_TESTING_get_trait_hello (peer2_cmd,
+                                  &hello);
+  GNUNET_TESTING_get_trait_hello_size (peer2_cmd,
+                                       &hello_size);
+
+  addr = GNUNET_HELLO_extract_address (hello,
+                                       *hello_size,
+                                       id,
+                                       &nt,
+                                       &t);
+
+  //----------------------------------------------
+
+  GNUNET_TRANSPORT_application_validate (ah,
+                                         id,
+                                         nt,
+                                         addr);*/
+}
+
+
+static int
+connect_peers_finish (void *cls,
+                      GNUNET_SCHEDULER_TaskCallback cont,
+                      void *cont_cls)
+{
+  /*struct ConnectPeersState *cps = cls;
+  const struct GNUNET_TESTING_Command *peer1_cmd;
+  const struct GNUNET_TESTING_Command *peer2_cmd;
+  struct GNUNET_CONTAINER_MultiPeerMap *connected_peers_map;
+  unsigned int ret;
+  struct GNUNET_PeerIdentity *id;
+
+  peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->peer1_label);
+  GNUNET_TESTING_get_trait_peer_id (peer1_cmd,
+                                    &id);
+
+  peer2_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->peer2_label);
+  GNUNET_TESTING_get_trait_connected_peers_map (peer2_cmd,
+                                                &connected_peers_map);
+
+  ret = GNUNET_CONTAINER_multipeermap_contains (connected_peers_map,
+                                                id);
+
+  if (GNUNET_YES == ret)
+  {
+    cont (cont_cls);
+  }
+
+  return ret;*/
+  return GNUNET_OK;
+}
+
+
+static int
+connect_peers_traits (void *cls,
+                      const void **ret,
+                      const char *trait,
+                      unsigned int index)
+{
+  return GNUNET_OK;
+}
+
+
+static void
+connect_peers_cleanup (void *cls,
+                       const struct GNUNET_TESTING_Command *cmd)
+{
+  struct ConnectPeersState *cps = cls;
+
+  GNUNET_free (cps);
+}
+
+
+/**
+ * Create command.
+ *
+ * @param label name for command.
+ * @return command.
+ */
+struct GNUNET_TESTING_Command
+GNUNET_TESTING_cmd_connect_peers (const char *label,
+                                  const char *peer1_label,
+                                  const char *peer2_label)
+{
+  struct ConnectPeersState *cps;
+
+  cps = GNUNET_new (struct ConnectPeersState);
+  cps->peer1_label = peer1_label;
+  cps->peer2_label = peer2_label;
+
+
+  struct GNUNET_TESTING_Command cmd = {
+    .cls = cps,
+    .label = label,
+    .run = &connect_peers_run,
+    .finish = &connect_peers_finish,
+    .cleanup = &connect_peers_cleanup,
+    .traits = &connect_peers_traits
+  };
+
+  return cmd;
+}
diff --git a/src/transport/transport_api_cmd_send_simple.c 
b/src/transport/transport_api_cmd_send_simple.c
new file mode 100644
index 000000000..e4ac199d1
--- /dev/null
+++ b/src/transport/transport_api_cmd_send_simple.c
@@ -0,0 +1,136 @@
+/*
+      This file is part of GNUnet
+      Copyright (C) 2021 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 <http://www.gnu.org/licenses/>.
+
+     SPDX-License-Identifier: AGPL3.0-or-later
+ */
+
+/**
+ * @file testing_api_cmd_start_peer.c
+ * @brief cmd to start a peer.
+ * @author t3sserakt
+ */
+#include "platform.h"
+#include "gnunet_util_lib.h"
+#include "gnunet_testing_ng_lib.h"
+#include "transport-testing.h"
+
+struct SendSimpleState
+{
+  char *m;
+
+  char *n;
+
+  uint32_t num;
+
+  const char *peer1_label;
+
+  const char *peer2_label;
+};
+
+static int
+send_simple_traits (void *cls,
+                    const void **ret,
+                    const char *trait,
+                    unsigned int index)
+{
+  return GNUNET_OK;
+}
+
+
+static void
+send_simple_cleanup (void *cls,
+                     const struct GNUNET_TESTING_Command *cmd)
+{
+  struct SendSimpleState *sss = cls;
+
+  GNUNET_free (sss);
+}
+
+
+static void
+send_simple_run (void *cls,
+                 const struct GNUNET_TESTING_Command *cmd,
+                 struct GNUNET_TESTING_Interpreter *is)
+{
+  struct SendSimpleState *sss = cls;
+  struct GNUNET_MQ_Envelope *env;
+  struct GNUNET_TRANSPORT_TESTING_TestMessage *test;
+  struct GNUNET_MQ_Handle *mq;
+  struct GNUNET_CONTAINER_MultiPeerMap *connected_peers_map;
+  struct GNUNET_PeerIdentity *id;
+  const struct GNUNET_TESTING_Command *peer1_cmd;
+  const struct GNUNET_TESTING_Command *peer2_cmd;
+
+  peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (sss->peer1_label);
+  GNUNET_TESTING_get_trait_connected_peers_map (peer1_cmd,
+                                                &connected_peers_map);
+
+  peer2_cmd = GNUNET_TESTING_interpreter_lookup_command (sss->peer2_label);
+  GNUNET_TESTING_get_trait_peer_id (peer2_cmd,
+                                    &id);
+
+  mq = GNUNET_CONTAINER_multipeermap_get (connected_peers_map,
+                                          id);
+
+  env = GNUNET_MQ_msg_extra (test,
+                             2600 - sizeof(*test),
+                             GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE);
+  test->num = htonl (sss->num);
+  memset (&test[1],
+          sss->num,
+          2600 - sizeof(*test));
+  /*GNUNET_MQ_notify_sent (env,
+                         cont,
+                         cont_cls);*/
+  GNUNET_MQ_send (mq,
+                  env);
+
+
+}
+
+
+/**
+ * Create command.
+ *
+ * @param label name for command.
+ * @return command.
+ */
+struct GNUNET_TESTING_Command
+GNUNET_TESTING_cmd_send_simple (const char *label,
+                                char *m,
+                                char *n,
+                                uint32_t num,
+                                const char *peer1_label,
+                                const char *peer2_label)
+{
+  struct SendSimpleState *sss;
+
+  sss = GNUNET_new (struct SendSimpleState);
+  sss->m = m;
+  sss->n = n;
+  sss->num = num;
+
+  struct GNUNET_TESTING_Command cmd = {
+    .cls = sss,
+    .label = label,
+    .run = &send_simple_run,
+    .cleanup = &send_simple_cleanup,
+    .traits = &send_simple_traits
+  };
+
+  return cmd;
+}
diff --git a/src/transport/transport_api_cmd_start_peer.c 
b/src/transport/transport_api_cmd_start_peer.c
new file mode 100644
index 000000000..4077b7561
--- /dev/null
+++ b/src/transport/transport_api_cmd_start_peer.c
@@ -0,0 +1,558 @@
+/*
+      This file is part of GNUnet
+      Copyright (C) 2021 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 <http://www.gnu.org/licenses/>.
+
+     SPDX-License-Identifier: AGPL3.0-or-later
+ */
+
+/**
+ * @file testing_api_cmd_start_peer.c
+ * @brief cmd to start a peer.
+ * @author t3sserakt
+ */
+#include "platform.h"
+#include "gnunet_util_lib.h"
+#include "gnunet_testing_ng_lib.h"
+#include "gnunet_peerstore_service.h"
+#include "gnunet_transport_core_service.h"
+
+/**
+ * Generic logging shortcut
+ */
+#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
+
+struct StartPeerState
+{
+  /**
+   * Receive callback
+   */
+  struct GNUNET_MQ_MessageHandler *handlers;
+
+  const char *cfgname;
+
+  /**
+   * Peer's configuration
+   */
+  struct GNUNET_CONFIGURATION_Handle *cfg;
+
+  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;
+
+  char *m;
+
+  char *n;
+
+  unsigned int finished;
+
+  const char *system_label;
+
+  /**
+   * An unique number to identify the peer
+   */
+  unsigned int no;
+
+  struct GNUNET_CONTAINER_MultiPeerMap *connected_peers_map;
+
+  struct GNUNET_TESTING_System *tl_system;
+
+};
+
+
+static void
+retrieve_hello (void *cls);
+
+static void
+hello_iter_cb (void *cb_cls,
+               const struct GNUNET_PEERSTORE_Record *record,
+               const char *emsg)
+{
+  struct StartPeerState *sps = cb_cls;
+  if (NULL == record)
+  {
+    sps->pic = NULL;
+    sps->rh_task = GNUNET_SCHEDULER_add_now (retrieve_hello, sps);
+    return;
+  }
+  // Check record type et al?
+  sps->hello_size = record->value_size;
+  sps->hello = GNUNET_malloc (sps->hello_size);
+  memcpy (sps->hello, record->value, sps->hello_size);
+  sps->hello[sps->hello_size - 1] = '\0';
+
+  GNUNET_PEERSTORE_iterate_cancel (sps->pic);
+  sps->pic = NULL;
+  sps->finished = GNUNET_YES;
+}
+
+
+static void
+retrieve_hello (void *cls)
+{
+  struct StartPeerState *sps = cls;
+  sps->rh_task = NULL;
+  sps->pic = GNUNET_PEERSTORE_iterate (sps->ph,
+                                       "transport",
+                                       sps->id,
+                                       GNUNET_PEERSTORE_TRANSPORT_HELLO_KEY,
+                                       hello_iter_cb,
+                                       sps);
+
+}
+
+static int
+start_peer_finish (void *cls,
+                   GNUNET_SCHEDULER_TaskCallback cont,
+                   void *cont_cls)
+{
+  struct StartPeerState *sps = cls;
+
+  if (GNUNET_YES == sps->finished)
+  {
+    cont (cont_cls);
+  }
+
+  return sps->finished;
+}
+
+
+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));
+
+}
+
+
+static void *
+notify_connect (void *cls,
+                const struct GNUNET_PeerIdentity *peer,
+                struct GNUNET_MQ_Handle *mq)
+{
+  struct StartPeerState *sps = cls;
+
+
+  void *ret;
+
+
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "Peer %s connected to peer %u (`%s')\n",
+       GNUNET_i2s (peer),
+       sps->no,
+       GNUNET_i2s (sps->id));
+
+  GNUNET_CONTAINER_multipeermap_put (sps->connected_peers_map,
+                                     peer,
+                                     mq,
+                                     
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
+
+  // TODO what does the handler function need?
+  return ret;
+}
+
+
+static void
+start_peer_run (void *cls,
+                const struct GNUNET_TESTING_Command *cmd,
+                struct GNUNET_TESTING_Interpreter *is)
+{
+  struct StartPeerState *sps = cls;
+  char *emsg = NULL;
+  struct GNUNET_PeerIdentity dummy;
+  const struct GNUNET_TESTING_Command *system_cmd;
+  struct GNUNET_TESTING_System *tl_system;
+
+  if (GNUNET_NO == GNUNET_DISK_file_test (sps->cfgname))
+  {
+    LOG (GNUNET_ERROR_TYPE_ERROR,
+         "File not found: `%s'\n",
+         sps->cfgname);
+    GNUNET_TESTING_interpreter_fail ();
+    return;
+  }
+
+
+  sps->cfg = GNUNET_CONFIGURATION_create ();
+  GNUNET_assert (GNUNET_OK ==
+                 GNUNET_CONFIGURATION_load (sps->cfg, sps->cfgname));
+
+  system_cmd = GNUNET_TESTING_interpreter_lookup_command (sps->system_label);
+  GNUNET_TESTING_get_trait_test_system (system_cmd,
+                                        &tl_system);
+
+  sps->tl_system = tl_system;
+
+  if (GNUNET_SYSERR ==
+      GNUNET_TESTING_configuration_create (tl_system,
+                                           sps->cfg))
+  {
+    LOG (GNUNET_ERROR_TYPE_ERROR,
+         "Testing library failed to create unique configuration based on 
`%s'\n",
+         sps->cfgname);
+    GNUNET_CONFIGURATION_destroy (sps->cfg);
+    GNUNET_TESTING_interpreter_fail ();
+  }
+
+  sps->peer = GNUNET_TESTING_peer_configure (sps->tl_system,
+                                             sps->cfg,
+                                             sps->no,
+                                             NULL,
+                                             &emsg);
+  if (NULL == sps->peer)
+  {
+    LOG (GNUNET_ERROR_TYPE_ERROR,
+         "Testing library failed to create unique configuration based on `%s': 
`%s'\n",
+         sps->cfgname,
+         emsg);
+    GNUNET_free (emsg);
+    GNUNET_TESTING_interpreter_fail ();
+  }
+
+  if (GNUNET_OK != GNUNET_TESTING_peer_start (sps->peer))
+  {
+    LOG (GNUNET_ERROR_TYPE_ERROR,
+         "Testing library failed to create unique configuration based on 
`%s'\n",
+         sps->cfgname);
+    GNUNET_free (emsg);
+    GNUNET_TESTING_interpreter_fail ();
+  }
+
+  memset (&dummy,
+          '\0',
+          sizeof(dummy));
+  GNUNET_TESTING_peer_get_identity (sps->peer,
+                                    sps->id);
+  if (0 == memcmp (&dummy,
+                   &sps->id,
+                   sizeof(struct GNUNET_PeerIdentity)))
+  {
+    LOG (GNUNET_ERROR_TYPE_ERROR,
+         "Testing library failed to obtain peer identity for peer %u\n",
+         sps->no);
+    GNUNET_free (emsg);
+    GNUNET_TESTING_interpreter_fail ();
+  }
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "Peer %u configured with identity `%s'\n",
+       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 ();
+  }
+  sps->ph = GNUNET_PEERSTORE_connect (sps->cfg);
+  if (NULL == sps->th)
+  {
+    LOG (GNUNET_ERROR_TYPE_ERROR,
+         "Failed to connect to peerstore service for peer `%s': `%s'\n",
+         sps->cfgname,
+         emsg);
+    GNUNET_free (emsg);
+    GNUNET_TESTING_interpreter_fail ();
+  }
+  sps->ah = GNUNET_TRANSPORT_application_init (sps->cfg);
+  if (NULL == sps->ah)
+  {
+    LOG (GNUNET_ERROR_TYPE_ERROR,
+         "Failed to initialize the TRANSPORT application suggestion client 
handle for peer `%s': `%s'\n",
+         sps->cfgname,
+         emsg);
+    GNUNET_free (emsg);
+    GNUNET_TESTING_interpreter_fail ();
+  }
+  sps->rh_task = GNUNET_SCHEDULER_add_now (retrieve_hello, sps);
+}
+
+
+static void
+start_peer_cleanup (void *cls,
+                    const struct GNUNET_TESTING_Command *cmd)
+{
+  struct StartPeerState *sps = cls;
+
+  if (NULL != sps->rh_task)
+    GNUNET_SCHEDULER_cancel (sps->rh_task);
+  sps->rh_task = NULL;
+  if (NULL != sps->ah)
+  {
+    GNUNET_TRANSPORT_application_done (sps->ah);
+    sps->ah = NULL;
+  }
+  if (NULL != sps->ph)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Disconnecting from PEERSTORE service\n");
+    GNUNET_PEERSTORE_disconnect (sps->ph, GNUNET_NO);
+    sps->ph = NULL;
+  }
+  if (NULL != sps->handlers)
+  {
+    GNUNET_free (sps->handlers);
+    sps->handlers = NULL;
+  }
+  if (NULL != sps->cfg)
+  {
+    GNUNET_CONFIGURATION_destroy (sps->cfg);
+    sps->cfg = NULL;
+  }
+  if (NULL != sps->peer)
+  {
+    if (GNUNET_OK !=
+        GNUNET_TESTING_peer_stop (sps->peer))
+    {
+      LOG (GNUNET_ERROR_TYPE_DEBUG,
+           "Testing lib failed to stop peer %u (`%s')\n",
+           sps->no,
+           GNUNET_i2s (sps->id));
+    }
+    GNUNET_TESTING_peer_destroy (sps->peer);
+    sps->peer = NULL;
+  }
+  if (NULL != sps->th)
+  {
+    GNUNET_TRANSPORT_core_disconnect (sps->th);
+    sps->th = NULL;
+  }
+  if (NULL != sps->tl_system)
+  {
+    GNUNET_free (sps->tl_system);
+  }
+  GNUNET_free (sps->hello);
+  GNUNET_free (sps->connected_peers_map);
+  GNUNET_free (sps);
+}
+
+
+static int
+start_peer_traits (void *cls,
+                   const void **ret,
+                   const char *trait,
+                   unsigned int index)
+{
+  struct StartPeerState *sps = cls;
+  struct GNUNET_TRANSPORT_ApplicationHandle *ah = sps->ah;
+  struct GNUNET_PeerIdentity *id = sps->id;
+  struct GNUNET_CONTAINER_MultiPeerMap *connected_peers_map =
+    sps->connected_peers_map;
+  char *hello = sps->hello;
+  size_t hello_size = sps->hello_size;
+
+
+  struct GNUNET_TESTING_Trait traits[] = {
+    {
+      .index = 0,
+      .trait_name = "application_handle",
+      .ptr = (const void *) ah,
+    },
+    {
+      .index = 1,
+      .trait_name = "peer_id",
+      .ptr = (const void *) id,
+    },
+    {
+      .index = 2,
+      .trait_name = "connected_peers_map",
+      .ptr = (const void *) connected_peers_map,
+    },
+    {
+      .index = 3,
+      .trait_name = "hello",
+      .ptr = (const void *) hello,
+    },
+    {
+      .index = 4,
+      .trait_name = "hello_size",
+      .ptr = (const void *) hello_size,
+    },
+    GNUNET_TESTING_trait_end ()
+  };
+
+  return GNUNET_TESTING_get_trait (traits,
+                                   ret,
+                                   trait,
+                                   index);
+}
+
+int
+GNUNET_TESTING_get_trait_hello_size (const struct
+                                     GNUNET_TESTING_Command
+                                     *cmd,
+                                     size_t **hello_size)
+{
+  return cmd->traits (cmd->cls,
+                      (const void **) hello_size,
+                      "hello_size",
+                      (unsigned int) 4);
+}
+
+int
+GNUNET_TESTING_get_trait_hello (const struct
+                                GNUNET_TESTING_Command
+                                *cmd,
+                                char **hello)
+{
+  return cmd->traits (cmd->cls,
+                      (const void **) hello,
+                      "hello",
+                      (unsigned int) 3);
+}
+
+int
+GNUNET_TESTING_get_trait_connected_peers_map (const struct
+                                              GNUNET_TESTING_Command
+                                              *cmd,
+                                              struct
+                                              GNUNET_CONTAINER_MultiPeerMap **
+                                              connected_peers_map)
+{
+  return cmd->traits (cmd->cls,
+                      (const void **) connected_peers_map,
+                      "connected_peers_map",
+                      (unsigned int) 2);
+}
+
+
+int
+GNUNET_TESTING_get_trait_application_handle (const struct
+                                             GNUNET_TESTING_Command *cmd,
+                                             struct
+                                             GNUNET_TRANSPORT_ApplicationHandle
+                                             **ah)
+{
+  return cmd->traits (cmd->cls,
+                      (const void **) ah,
+                      "application_handle",
+                      (unsigned int) 0);
+}
+
+
+int
+GNUNET_TESTING_get_trait_peer_id (const struct
+                                  GNUNET_TESTING_Command *cmd,
+                                  struct GNUNET_PeerIdentity **id)
+{
+  return cmd->traits (cmd->cls,
+                      (const void **) id,
+                      "peer_id",
+                      (unsigned int) 1);
+}
+
+
+/**
+ * Create command.
+ *
+ * @param label name for command.
+ * @return command.
+ */
+struct GNUNET_TESTING_Command
+GNUNET_TESTING_cmd_start_peer (const char *label,
+                               const char *system_label,
+                               char *m,
+                               char *n,
+                               struct GNUNET_MQ_MessageHandler *handlers,
+                               const char *cfgname)
+{
+  struct StartPeerState *sps;
+  struct GNUNET_CONTAINER_MultiPeerMap *connected_peers_map =
+    GNUNET_CONTAINER_multipeermap_create (1,GNUNET_NO);
+  unsigned int i;
+
+  sps = GNUNET_new (struct StartPeerState);
+  sps->m = m;
+  sps->n = n;
+  sps->system_label = system_label;
+  sps->connected_peers_map = connected_peers_map;
+  sps->cfgname = cfgname;
+
+  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));
+  }
+
+  struct GNUNET_TESTING_Command cmd = {
+    .cls = sps,
+    .label = label,
+    .run = &start_peer_run,
+    .finish = &start_peer_finish,
+    .cleanup = &start_peer_cleanup,
+    .traits = &start_peer_traits
+  };
+
+  return cmd;
+}

-- 
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]