2 This file is part of GNUnet
3 (C) 2008, 2009 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file testing/testing.c
23 * @brief convenience API for writing testcases for GNUnet
24 * Many testcases need to start and stop gnunetd,
25 * and this library is supposed to make that easier
26 * for TESTCASES. Normal programs should always
27 * use functions from gnunet_{util,arm}_lib.h. This API is
28 * ONLY for writing testcases!
29 * @author Christian Grothoff
32 * - modify configuration to allow 2087-connections from
33 * controlling host (otherwise shutdown won't work)
37 #include "gnunet_arm_service.h"
38 #include "gnunet_core_service.h"
39 #include "gnunet_constants.h"
40 #include "gnunet_testing_lib.h"
41 #include "gnunet_transport_service.h"
43 #define DEBUG_TESTING GNUNET_NO
46 * How long do we wait after starting gnunet-service-arm
47 * for the core service to be alive?
49 #define ARM_START_WAIT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
52 * How many times are we willing to try to wait for "scp" or
53 * "gnunet-service-arm" to complete (waitpid) before giving up?
55 #define MAX_EXEC_WAIT_RUNS 50
59 * Function called after GNUNET_CORE_connect has succeeded
60 * (or failed for good). Note that the private key of the
61 * peer is intentionally not exposed here; if you need it,
62 * your process should try to read the private key file
63 * directly (which should work if you are authorized...).
66 * @param server handle to the server, NULL if we failed
67 * @param my_identity ID of this peer, NULL if we failed
68 * @param publicKey public key of this peer, NULL if we failed
71 testing_init (void *cls,
72 struct GNUNET_CORE_Handle *server,
73 const struct GNUNET_PeerIdentity *my_identity,
74 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey)
76 struct GNUNET_TESTING_Daemon *d = cls;
77 GNUNET_TESTING_NotifyDaemonRunning cb;
79 GNUNET_assert (d->phase == SP_START_CORE);
80 d->phase = SP_START_DONE;
86 if (GNUNET_YES == d->dead)
87 GNUNET_TESTING_daemon_stop (d, d->dead_cb, d->dead_cb_cls);
89 cb (d->cb_cls, NULL, d->cfg, d,
90 _("Failed to connect to core service\n"));
94 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
95 "Successfully started peer `%4s'.\n", GNUNET_i2s (my_identity));
98 d->shortname = strdup (GNUNET_i2s (my_identity));
100 if (GNUNET_YES == d->dead)
101 GNUNET_TESTING_daemon_stop (d, d->dead_cb, d->dead_cb_cls);
103 cb (d->cb_cls, my_identity, d->cfg, d, NULL);
108 * Finite-state machine for starting GNUnet.
110 * @param cls our "struct GNUNET_TESTING_Daemon"
114 start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
116 static struct GNUNET_CORE_MessageHandler no_handlers[] = { {NULL, 0, 0} };
117 struct GNUNET_TESTING_Daemon *d = cls;
118 GNUNET_TESTING_NotifyDaemonRunning cb;
119 enum GNUNET_OS_ProcessStatusType type;
124 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
125 "Peer FSM is in phase %u.\n", d->phase);
127 d->task = GNUNET_SCHEDULER_NO_TASK;
131 /* confirm copying complete */
132 if (GNUNET_OK != GNUNET_OS_process_status (d->pid, &type, &code))
135 if (d->wait_runs > MAX_EXEC_WAIT_RUNS)
142 d->cfg, d, _("`scp' does not seem to terminate.\n"));
147 = GNUNET_SCHEDULER_add_delayed (d->sched,
148 GNUNET_CONSTANTS_EXEC_WAIT,
152 if ((type != GNUNET_OS_PROCESS_EXITED) || (code != 0))
158 NULL, d->cfg, d, _("`scp' did not complete cleanly.\n"));
162 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
163 "Successfully copied configuration file.\n");
165 d->phase = SP_COPIED;
168 /* start GNUnet on remote host */
169 if (NULL == d->hostname)
171 d->pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-arm",
181 if (d->username != NULL)
182 GNUNET_asprintf (&dst, "%s@%s", d->username, d->hostname);
184 dst = GNUNET_strdup (d->hostname);
185 d->pid = GNUNET_OS_start_process (NULL, NULL, "ssh",
192 "-c", d->cfgfile, "-s", NULL);
197 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
198 _("Could not start `%s' process to start GNUnet.\n"),
199 (NULL == d->hostname) ? "gnunet-arm" : "ssh");
207 (NULL == d->hostname)
208 ? _("Failed to start `gnunet-arm' process.\n")
209 : _("Failed to start `ssh' process.\n"));
212 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
213 "Started `%s', waiting for `%s' to be up.\n",
214 "gnunet-arm", "gnunet-service-core");
216 d->phase = SP_START_ARMING;
219 = GNUNET_SCHEDULER_add_delayed (d->sched,
220 GNUNET_CONSTANTS_EXEC_WAIT,
223 case SP_START_ARMING:
224 if (GNUNET_OK != GNUNET_OS_process_status (d->pid, &type, &code))
227 if (d->wait_runs > MAX_EXEC_WAIT_RUNS)
236 (NULL == d->hostname)
237 ? _("`gnunet-arm' does not seem to terminate.\n")
238 : _("`ssh' does not seem to terminate.\n"));
243 = GNUNET_SCHEDULER_add_delayed (d->sched,
244 GNUNET_CONSTANTS_EXEC_WAIT,
249 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
250 "Successfully started `%s'.\n", "gnunet-arm");
252 d->phase = SP_START_CORE;
253 d->server = GNUNET_CORE_connect (d->sched,
260 NULL, GNUNET_NO, no_handlers);
268 case SP_SHUTDOWN_START:
269 /* confirm copying complete */
270 if (GNUNET_OK != GNUNET_OS_process_status (d->pid, &type, &code))
273 if (d->wait_runs > MAX_EXEC_WAIT_RUNS)
275 d->dead_cb (d->dead_cb_cls,
276 _("either `gnunet-arm' or `ssh' does not seem to terminate.\n"));
277 GNUNET_CONFIGURATION_destroy (d->cfg);
278 GNUNET_free (d->cfgfile);
279 GNUNET_free_non_null (d->hostname);
280 GNUNET_free_non_null (d->username);
281 GNUNET_free_non_null (d->shortname);
287 = GNUNET_SCHEDULER_add_delayed (d->sched,
288 GNUNET_CONSTANTS_EXEC_WAIT,
292 if ((type != GNUNET_OS_PROCESS_EXITED) || (code != 0))
294 if (NULL != d->dead_cb)
295 d->dead_cb (d->dead_cb_cls,
296 _("shutdown (either `gnunet-arm' or `ssh') did not complete cleanly.\n"));
297 GNUNET_CONFIGURATION_destroy (d->cfg);
298 GNUNET_free (d->cfgfile);
299 GNUNET_free_non_null (d->hostname);
300 GNUNET_free_non_null (d->username);
301 GNUNET_free_non_null (d->shortname);
306 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer shutdown complete.\n");
308 /* state clean up and notifications */
309 GNUNET_CONFIGURATION_destroy (d->cfg);
310 GNUNET_free (d->cfgfile);
311 GNUNET_free_non_null (d->hostname);
312 GNUNET_free_non_null (d->username);
313 GNUNET_free_non_null (d->shortname);
314 if (NULL != d->dead_cb)
315 d->dead_cb (d->dead_cb_cls, NULL);
318 case SP_CONFIG_UPDATE:
319 /* confirm copying complete */
320 if (GNUNET_OK != GNUNET_OS_process_status (d->pid, &type, &code))
323 if (d->wait_runs > MAX_EXEC_WAIT_RUNS)
330 d->cfg, d, _("`scp' does not seem to terminate.\n"));
335 = GNUNET_SCHEDULER_add_delayed (d->sched,
336 GNUNET_CONSTANTS_EXEC_WAIT,
340 if ((type != GNUNET_OS_PROCESS_EXITED) || (code != 0))
342 if (NULL != d->update_cb)
343 d->update_cb (d->update_cb_cls,
344 _("`scp' did not complete cleanly.\n"));
348 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
349 "Successfully copied configuration file.\n");
351 if (NULL != d->update_cb)
352 d->update_cb (d->update_cb_cls, NULL);
353 d->phase = SP_START_DONE;
360 * Starts a GNUnet daemon. GNUnet must be installed on the target
361 * system and available in the PATH. The machine must furthermore be
362 * reachable via "ssh" (unless the hostname is "NULL") without the
363 * need to enter a password.
365 * @param sched scheduler to use
366 * @param cfg configuration to use
367 * @param hostname name of the machine where to run GNUnet
368 * (use NULL for localhost).
369 * @param cb function to call with the result
370 * @param cb_cls closure for cb
371 * @return handle to the daemon (actual start will be completed asynchronously)
373 struct GNUNET_TESTING_Daemon *
374 GNUNET_TESTING_daemon_start (struct GNUNET_SCHEDULER_Handle *sched,
375 const struct GNUNET_CONFIGURATION_Handle *cfg,
376 const char *hostname,
377 GNUNET_TESTING_NotifyDaemonRunning cb,
380 struct GNUNET_TESTING_Daemon *ret;
384 ret = GNUNET_malloc (sizeof (struct GNUNET_TESTING_Daemon));
386 ret->hostname = (hostname == NULL) ? NULL : GNUNET_strdup (hostname);
387 ret->cfgfile = GNUNET_DISK_mktemp ("gnunet-testing-config");
389 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
390 "Setting up peer with configuration file `%s'.\n",
393 if (NULL == ret->cfgfile)
395 GNUNET_free_non_null (ret->hostname);
400 ret->cb_cls = cb_cls;
401 ret->cfg = GNUNET_CONFIGURATION_dup (cfg);
402 GNUNET_CONFIGURATION_set_value_string (ret->cfg,
404 "DEFAULTCONFIG", ret->cfgfile);
405 /* 1) write configuration to temporary file */
406 if (GNUNET_OK != GNUNET_CONFIGURATION_write (ret->cfg, ret->cfgfile))
408 if (0 != UNLINK (ret->cfgfile))
409 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
410 "unlink", ret->cfgfile);
411 GNUNET_CONFIGURATION_destroy (ret->cfg);
412 GNUNET_free_non_null (ret->hostname);
413 GNUNET_free (ret->cfgfile);
418 GNUNET_CONFIGURATION_get_value_string (cfg,
420 "USERNAME", &username))
422 if (NULL != getenv ("USER"))
423 username = GNUNET_strdup (getenv ("USER"));
427 ret->username = username;
429 /* 2) copy file to remote host */
430 if (NULL != hostname)
433 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
434 "Copying configuration file to host `%s'.\n", hostname);
436 ret->phase = SP_COPYING;
437 if (NULL != username)
438 GNUNET_asprintf (&arg, "%s@%s:%s", username, hostname, ret->cfgfile);
440 GNUNET_asprintf (&arg, "%s:%s", hostname, ret->cfgfile);
441 ret->pid = GNUNET_OS_start_process (NULL, NULL, "scp",
442 "scp", ret->cfgfile, arg, NULL);
446 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
448 ("Could not start `%s' process to copy configuration file.\n"),
450 if (0 != UNLINK (ret->cfgfile))
451 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
452 "unlink", ret->cfgfile);
453 GNUNET_CONFIGURATION_destroy (ret->cfg);
454 GNUNET_free_non_null (ret->hostname);
455 GNUNET_free_non_null (ret->username);
456 GNUNET_free (ret->cfgfile);
461 = GNUNET_SCHEDULER_add_delayed (sched,
462 GNUNET_CONSTANTS_EXEC_WAIT,
467 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
468 "No need to copy configuration file since we are running locally.\n");
470 ret->phase = SP_COPIED;
471 GNUNET_SCHEDULER_add_continuation (sched,
474 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
480 * Stops a GNUnet daemon.
482 * @param d the daemon that should be stopped
483 * @param cb function called once the daemon was stopped
484 * @param cb_cls closure for cb
487 GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d,
488 GNUNET_TESTING_NotifyCompletion cb, void *cb_cls)
493 d->dead_cb_cls = cb_cls;
497 d->dead = GNUNET_YES;
500 if (d->phase == SP_CONFIG_UPDATE)
502 GNUNET_SCHEDULER_cancel (d->sched, d->task);
503 d->phase = SP_START_DONE;
505 if (d->server != NULL)
507 GNUNET_CORE_disconnect (d->server);
510 /* shutdown ARM process (will terminate others) */
512 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
513 _("Terminating peer `%4s'\n"), GNUNET_i2s (&d->id));
514 /* sleep(15); Manual check for running */
517 d->phase = SP_SHUTDOWN_START;
519 /* Check if this is a local or remote process */
520 if (NULL != d->hostname)
523 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
524 "Stopping gnunet-arm on with config `%s' on host `%s'.\n", d->cfgfile, d->hostname);
527 if (d->username != NULL)
528 GNUNET_asprintf (&arg, "%s@%s", d->username, d->hostname);
530 arg = GNUNET_strdup (d->hostname);
532 d->pid = GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh",
537 "-c", d->cfgfile, "-e", "-d", NULL);
538 /* Use -e to end arm, and -d to remove temp files */
545 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
546 "Stopping gnunet-arm with config `%s' locally.\n", d->cfgfile);
548 d->pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-arm",
553 "-c", d->cfgfile, "-e", "-d", NULL);
558 = GNUNET_SCHEDULER_add_delayed (d->sched,
559 GNUNET_CONSTANTS_EXEC_WAIT,
566 * Changes the configuration of a GNUnet daemon.
568 * @param d the daemon that should be modified
569 * @param cfg the new configuration for the daemon
570 * @param cb function called once the configuration was changed
571 * @param cb_cls closure for cb
574 GNUNET_TESTING_daemon_reconfigure (struct GNUNET_TESTING_Daemon *d,
575 struct GNUNET_CONFIGURATION_Handle *cfg,
576 GNUNET_TESTING_NotifyCompletion cb,
581 if (d->phase != SP_START_DONE)
586 ("Peer not yet running, can not change configuration at this point."));
590 /* 1) write configuration to temporary file */
591 if (GNUNET_OK != GNUNET_CONFIGURATION_write (cfg, d->cfgfile))
594 cb (cb_cls, _("Failed to write new configuration to disk."));
598 /* 2) copy file to remote host (if necessary) */
599 if (NULL == d->hostname)
607 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
608 "Copying updated configuration file to remote host `%s'.\n",
611 d->phase = SP_CONFIG_UPDATE;
612 if (NULL != d->username)
613 GNUNET_asprintf (&arg, "%s@%s:%s", d->username, d->hostname, d->cfgfile);
615 GNUNET_asprintf (&arg, "%s:%s", d->hostname, d->cfgfile);
616 d->pid = GNUNET_OS_start_process (NULL, NULL, "scp", "scp", d->cfgfile, arg, NULL);
620 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
622 ("Could not start `%s' process to copy configuration file.\n"),
625 cb (cb_cls, _("Failed to copy new configuration to remote machine."));
626 d->phase = SP_START_DONE;
630 d->update_cb_cls = cb_cls;
632 = GNUNET_SCHEDULER_add_delayed (d->sched,
633 GNUNET_CONSTANTS_EXEC_WAIT,
639 * Data kept for each pair of peers that we try
642 struct ConnectContext
645 * Testing handle to the first daemon.
647 struct GNUNET_TESTING_Daemon *d1;
650 * Handle to core of first daemon (to check connect)
652 struct GNUNET_CORE_Handle * d1core;
655 * Testing handle to the second daemon.
657 struct GNUNET_TESTING_Daemon *d2;
660 * Handle to core of second daemon (to check connect)
662 struct GNUNET_CORE_Handle * d2core;
665 * Transport handle to the first daemon.
667 struct GNUNET_TRANSPORT_Handle *d1th;
670 * Transport handle to the second daemon.
672 struct GNUNET_TRANSPORT_Handle *d2th;
675 * Function to call once we are done (or have timed out).
677 GNUNET_TESTING_NotifyConnection cb;
685 * Transmit handle for our request for transmission
686 * (as given to d2 asking to talk to d1).
688 struct GNUNET_CORE_TransmitHandle *ntr;
691 * When should this operation be complete (or we must trigger
694 struct GNUNET_TIME_Absolute timeout;
699 GNUNET_SCHEDULER_TaskIdentifier hello_send_task;
702 * Connect timeout task
704 GNUNET_SCHEDULER_TaskIdentifier timeout_task;
707 * When should this operation be complete (or we must trigger
710 struct GNUNET_TIME_Relative timeout_hello;
713 * The current hello message we have (for d1)
715 struct GNUNET_MessageHeader *hello;
718 * Was the connection successful?
725 * Receive the HELLO from one peer, give it to the other
726 * and ask them to connect.
728 * @param cls "struct ConnectContext"
729 * @param message HELLO message of peer
732 process_hello (void *cls, const struct GNUNET_MessageHeader *message)
734 struct ConnectContext *ctx = cls;
737 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
738 "Received `%s' from transport service of `%4s'\n",
739 "HELLO", GNUNET_i2s (&ctx->d1->id));
742 GNUNET_assert (message != NULL);
743 GNUNET_free_non_null(ctx->hello);
744 ctx->hello = GNUNET_malloc(ntohs(message->size));
745 memcpy(ctx->hello, message, ntohs(message->size));
751 * Notify callback about success or failure of the attempt
752 * to connect the two peers
754 * @param cls our "struct ConnectContext" (freed)
755 * @param tc reason tells us if we succeeded or failed
758 notify_connect_result (void *cls,
759 const struct GNUNET_SCHEDULER_TaskContext *tc)
761 struct ConnectContext *ctx = cls;
763 GNUNET_TRANSPORT_get_hello_cancel (ctx->d1th, &process_hello, ctx);
764 GNUNET_SCHEDULER_cancel(ctx->d1->sched, ctx->hello_send_task);
768 if (ctx->connected == GNUNET_NO)
770 ctx->cb (ctx->cb_cls, &ctx->d1->id, &ctx->d2->id, ctx->d1->cfg,
771 ctx->d2->cfg, ctx->d1, ctx->d2,
772 _("Peers failed to connect"));
776 ctx->cb (ctx->cb_cls, &ctx->d1->id, &ctx->d2->id, ctx->d1->cfg,
777 ctx->d2->cfg, ctx->d1, ctx->d2, NULL);
778 GNUNET_SCHEDULER_cancel(ctx->d1->sched, ctx->timeout_task);
783 GNUNET_TRANSPORT_disconnect (ctx->d1th);
785 GNUNET_TRANSPORT_disconnect (ctx->d2th);
787 GNUNET_CORE_disconnect (ctx->d1core);
789 GNUNET_free_non_null (ctx->hello);
795 * Success, connection is up. Signal client our success.
797 * @param cls our "struct ConnectContext"
798 * @param peer identity of the peer that has connected
799 * @param latency the round trip latency of the connection to this peer
800 * @param distance distance the transport level distance to this peer
804 connect_notify (void *cls, const struct GNUNET_PeerIdentity * peer, struct GNUNET_TIME_Relative latency,
807 struct ConnectContext *ctx = cls;
810 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
811 "Core notified us about connection to a peer\n");
813 if (memcmp(&ctx->d2->id, peer, sizeof(struct GNUNET_PeerIdentity)) == 0)
816 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
817 "Core notified us about connection to peer %s\n", GNUNET_i2s(peer));
820 * If we disconnect here, then the hello may never get sent (if it was delayed!)
821 * However I'm sure there was a reason it was here... so I'm just commenting.
823 ctx->connected = GNUNET_YES;
824 GNUNET_SCHEDULER_add_now (ctx->d1->sched,
825 ¬ify_connect_result,
832 send_hello(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
834 struct ConnectContext *ctx = cls;
836 if (ctx->hello != NULL)
838 GNUNET_TRANSPORT_offer_hello (ctx->d2th, ctx->hello);
839 ctx->timeout_hello = GNUNET_TIME_relative_add(ctx->timeout_hello,
840 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS,
843 ctx->hello_send_task = GNUNET_SCHEDULER_add_delayed(ctx->d1->sched,
850 * Establish a connection between two GNUnet daemons.
852 * @param d1 handle for the first daemon
853 * @param d2 handle for the second daemon
854 * @param timeout how long is the connection attempt
856 * @param cb function to call at the end
857 * @param cb_cls closure for cb
860 GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1,
861 struct GNUNET_TESTING_Daemon *d2,
862 struct GNUNET_TIME_Relative timeout,
863 GNUNET_TESTING_NotifyConnection cb,
866 struct ConnectContext *ctx;
867 static struct GNUNET_CORE_MessageHandler no_handlers[] = { {NULL, 0, 0} };
869 if ((d1->server == NULL) || (d2->server == NULL))
872 cb (cb_cls, &d1->id, &d2->id, d1->cfg, d2->cfg, d1, d2,
873 _("Peers are not fully running yet, can not connect!\n"));
876 ctx = GNUNET_malloc (sizeof (struct ConnectContext));
879 ctx->timeout = GNUNET_TIME_relative_to_absolute (timeout);
881 ctx->cb_cls = cb_cls;
882 ctx->timeout_hello = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 400);
883 ctx->connected = GNUNET_NO;
885 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
886 "Asked to connect peer %s to peer %s\n",
887 d1->shortname, d2->shortname);
888 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
889 "Connecting to transport service of peer %s\n", d1->shortname);
892 ctx->d1core = GNUNET_CORE_connect (d1->sched,
897 NULL, &connect_notify, NULL,
899 NULL, GNUNET_NO, no_handlers);
900 if (ctx->d1core == NULL)
904 cb (cb_cls, &d1->id, &d2->id, d1->cfg, d2->cfg, d1, d2,
905 _("Failed to connect to core service of first peer!\n"));
909 ctx->d1th = GNUNET_TRANSPORT_connect (d1->sched,
910 d1->cfg, d1, NULL, NULL, NULL);
911 if (ctx->d1th == NULL)
915 cb (cb_cls, &d1->id, &d2->id, d1->cfg, d2->cfg, d1, d2,
916 _("Failed to connect to transport service!\n"));
920 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
921 "Asked to connect peer %s to peer %s\n",
922 d1->shortname, d2->shortname);
923 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
924 "Connecting to transport service of peer %s\n", d2->shortname);
928 ctx->d2th = GNUNET_TRANSPORT_connect (d2->sched,
929 d2->cfg, d2, NULL, NULL, NULL);
930 if (ctx->d2th == NULL)
932 GNUNET_TRANSPORT_disconnect (ctx->d1th);
935 cb (cb_cls, &d1->id, &d2->id, d1->cfg, d2->cfg, d1, d2,
936 _("Failed to connect to transport service!\n"));
941 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
942 "Asking for HELLO from peer %s\n", GNUNET_i2s (&d1->id));
945 ctx->timeout_task = GNUNET_SCHEDULER_add_delayed (d1->sched,
947 ¬ify_connect_result, ctx);
949 GNUNET_TRANSPORT_get_hello (ctx->d1th, &process_hello, ctx);
950 ctx->hello_send_task = GNUNET_SCHEDULER_add_delayed(ctx->d1->sched, ctx->timeout_hello,
955 /* end of testing.c */