wip
[oweals/gnunet.git] / src / include / gnunet_testing_lib.h
index 6ddc4ea7418c2035ff938cca9abb9c5c32e50026..8c76457e3f050abfbf5a29d69ba9208450f07f6e 100644 (file)
@@ -157,6 +157,11 @@ enum GNUNET_TESTING_StartPhase
    */
   SP_START_CORE,
 
+  /**
+   * CORE is up, now make sure we get the HELLO for this peer.
+   */
+  SP_GET_HELLO,
+
   /**
    * Core has notified us that we've established a connection to the service.
    * The main FSM halts here and waits to be moved to UPDATE or CLEANUP.
@@ -295,6 +300,12 @@ struct GNUNET_TESTING_Daemon
    */
   int dead;
 
+  /**
+   * GNUNET_YES if the hostkey has been created
+   * for this peer, GNUNET_NO otherwise.
+   */
+  int have_hostkey;
+
   /**
    * PID of the process that we started last.
    */
@@ -407,6 +418,8 @@ typedef void (*GNUNET_TESTING_NotifyTopology)(void *cls,
  *
  * @param cfg configuration to use
  * @param timeout how long to wait starting up peers
+ * @param pretend GNUNET_YES to set up files but not start peer GNUNET_NO
+ *                to really start the peer (default)
  * @param hostname name of the machine where to run GNUnet
  *        (use NULL for localhost).
  * @param ssh_username ssh username to use when connecting to hostname
@@ -423,6 +436,7 @@ typedef void (*GNUNET_TESTING_NotifyTopology)(void *cls,
 struct GNUNET_TESTING_Daemon *
 GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
                              struct GNUNET_TIME_Relative timeout,
+                             int pretend,
                              const char *hostname,
                              const char *ssh_username,
                              uint16_t sshport,
@@ -545,15 +559,19 @@ void GNUNET_TESTING_daemon_reconfigure (struct GNUNET_TESTING_Daemon *d,
  *        allowed to take?
  * @param max_connect_attempts how many times should we try to reconnect
  *        (within timeout)
+ * @param send_hello GNUNET_YES to send the HELLO, GNUNET_NO to assume
+ *                   the HELLO has already been exchanged
  * @param cb function to call at the end
  * @param cb_cls closure for cb
  */
-void GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1,
-                                    struct GNUNET_TESTING_Daemon *d2,
-                                    struct GNUNET_TIME_Relative timeout,
-                                    unsigned int max_connect_attempts,
-                                    GNUNET_TESTING_NotifyConnection cb,
-                                    void *cb_cls);
+void
+GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1,
+                                struct GNUNET_TESTING_Daemon *d2,
+                                struct GNUNET_TIME_Relative timeout,
+                                unsigned int max_connect_attempts,
+                                int send_hello,
+                                GNUNET_TESTING_NotifyConnection cb,
+                                void *cb_cls);
 
 
 
@@ -888,6 +906,20 @@ void
 GNUNET_TESTING_get_topology (struct GNUNET_TESTING_PeerGroup *pg,
                             GNUNET_TESTING_NotifyTopology cb, void *cls);
 
+/**
+ * Stop the connection process temporarily.
+ *
+ * @param pg the peer group to stop connecting
+ */
+void GNUNET_TESTING_stop_connections(struct GNUNET_TESTING_PeerGroup *pg);
+
+/**
+ * Resume the connection process.
+ *
+ * @param pg the peer group to resume connecting
+ */
+void GNUNET_TESTING_resume_connections(struct GNUNET_TESTING_PeerGroup *pg);
+
 /**
  * There are many ways to connect peers that are supported by this function.
  * To connect peers in the same topology that was created via the
@@ -938,6 +970,33 @@ GNUNET_TESTING_daemons_vary (struct GNUNET_TESTING_PeerGroup *pg,
                             GNUNET_TESTING_NotifyCompletion cb,
                             void *cb_cls);
 
+/**
+ * Start a peer group with a given number of peers.  Notify
+ * on completion of peer startup and connection based on given
+ * topological constraints.  Optionally notify on each
+ * established connection.
+ *
+ * @param cfg configuration template to use
+ * @param total number of daemons to start
+ * @param timeout total time allowed for peers to start
+ * @param connect_cb function to call each time two daemons are connected
+ * @param peergroup_cb function to call once all peers are up and connected
+ * @param peergroup_cls closure for peergroup callbacks
+ * @param hostnames linked list of host structs to use to start peers on
+ *                  (NULL to run on localhost only)
+ *
+ * @return NULL on error, otherwise handle to control peer group
+ */
+struct GNUNET_TESTING_PeerGroup *
+GNUNET_TESTING_peergroup_start(
+                               const struct GNUNET_CONFIGURATION_Handle *cfg,
+                               unsigned int total,
+                               struct GNUNET_TIME_Relative timeout,
+                               GNUNET_TESTING_NotifyConnection connect_cb,
+                               GNUNET_TESTING_NotifyCompletion peergroup_cb,
+                               void *peergroup_cls,
+                               const struct GNUNET_TESTING_Host *hostnames);
+
 
 #if 0                           /* keep Emacsens' auto-indent happy */
 {