aboutsummaryrefslogtreecommitdiff
path: root/src/testing/testing_api_cmd_start_peer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/testing_api_cmd_start_peer.c')
-rw-r--r--src/testing/testing_api_cmd_start_peer.c84
1 files changed, 1 insertions, 83 deletions
diff --git a/src/testing/testing_api_cmd_start_peer.c b/src/testing/testing_api_cmd_start_peer.c
index f6b471be4..e2a2c0fbf 100644
--- a/src/testing/testing_api_cmd_start_peer.c
+++ b/src/testing/testing_api_cmd_start_peer.c
@@ -28,9 +28,6 @@
28#include "testing_cmds.h" 28#include "testing_cmds.h"
29#include "gnunet_testing_ng_lib.h" 29#include "gnunet_testing_ng_lib.h"
30#include "gnunet_testing_netjail_lib.h" 30#include "gnunet_testing_netjail_lib.h"
31#include "gnunet_peerstore_service.h"
32#include "gnunet_transport_core_service.h"
33#include "gnunet_transport_application_service.h"
34 31
35/** 32/**
36 * Generic logging shortcut 33 * Generic logging shortcut
@@ -38,61 +35,6 @@
38#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) 35#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
39 36
40 37
41static void
42retrieve_hello (void *cls);
43
44
45/**
46 * Callback delivering the hello of this peer from peerstore.
47 *
48 */
49static void
50hello_iter_cb (void *cb_cls,
51 const struct GNUNET_PEERSTORE_Record *record,
52 const char *emsg)
53{
54 struct GNUNET_TESTING_StartPeerState *sps = cb_cls;
55 if (NULL == record)
56 {
57 sps->pic = NULL;
58 sps->rh_task = GNUNET_SCHEDULER_add_now (retrieve_hello, sps);
59 return;
60 }
61 // Check record type et al?
62 sps->hello_size = record->value_size;
63 sps->hello = GNUNET_malloc (sps->hello_size);
64 memcpy (sps->hello, record->value, sps->hello_size);
65 sps->hello[sps->hello_size - 1] = '\0';
66
67 LOG (GNUNET_ERROR_TYPE_DEBUG,
68 "Our hello %s\n",
69 sps->hello);
70 GNUNET_PEERSTORE_iterate_cancel (sps->pic);
71 sps->pic = NULL;
72 GNUNET_TESTING_async_finish (&sps->ac);
73}
74
75
76/**
77 * Function to start the retrieval task to retrieve the hello of this peer
78 * from the peerstore.
79 *
80 */
81static void
82retrieve_hello (void *cls)
83{
84 struct GNUNET_TESTING_StartPeerState *sps = cls;
85 sps->rh_task = NULL;
86 sps->pic = GNUNET_PEERSTORE_iterate (sps->ph,
87 "transport",
88 &sps->id,
89 GNUNET_PEERSTORE_TRANSPORT_HELLO_KEY,
90 hello_iter_cb,
91 sps);
92
93}
94
95
96/** 38/**
97 * The run method of this cmd will start all services of a peer to test the transport service. 39 * The run method of this cmd will start all services of a peer to test the transport service.
98 * 40 *
@@ -254,30 +196,6 @@ start_peer_run (void *cls,
254 sps->no, 196 sps->no,
255 GNUNET_i2s_full (&sps->id)); 197 GNUNET_i2s_full (&sps->id));
256 198
257 sps->ph = GNUNET_PEERSTORE_connect (sps->cfg);
258 if (NULL == sps->ph)
259 {
260 LOG (GNUNET_ERROR_TYPE_ERROR,
261 "Failed to connect to peerstore service for peer `%s': `%s'\n",
262 sps->cfgname,
263 emsg);
264 GNUNET_free (emsg);
265 GNUNET_TESTING_interpreter_fail (is);
266 return;
267 }
268
269 sps->ah = GNUNET_TRANSPORT_application_init (sps->cfg);
270 if (NULL == sps->ah)
271 {
272 LOG (GNUNET_ERROR_TYPE_ERROR,
273 "Failed to initialize the TRANSPORT application suggestion client handle for peer `%s': `%s'\n",
274 sps->cfgname,
275 emsg);
276 GNUNET_free (emsg);
277 GNUNET_TESTING_interpreter_fail (is);
278 return;
279 }
280 sps->rh_task = GNUNET_SCHEDULER_add_now (retrieve_hello, sps);
281 GNUNET_free (home); 199 GNUNET_free (home);
282 GNUNET_free (transport_unix_path); 200 GNUNET_free (transport_unix_path);
283 GNUNET_free (tcp_communicator_unix_path); 201 GNUNET_free (tcp_communicator_unix_path);
@@ -376,5 +294,5 @@ GNUNET_TESTING_cmd_start_peer (const char *label,
376 &start_peer_run, 294 &start_peer_run,
377 &start_peer_cleanup, 295 &start_peer_cleanup,
378 &start_peer_traits, 296 &start_peer_traits,
379 &sps->ac); 297 NULL);
380} 298}