aboutsummaryrefslogtreecommitdiff
path: root/src/dht/test_dht_twopeer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/dht/test_dht_twopeer.c')
-rw-r--r--src/dht/test_dht_twopeer.c90
1 files changed, 38 insertions, 52 deletions
diff --git a/src/dht/test_dht_twopeer.c b/src/dht/test_dht_twopeer.c
index 6ba3799dc..50a27a093 100644
--- a/src/dht/test_dht_twopeer.c
+++ b/src/dht/test_dht_twopeer.c
@@ -155,8 +155,7 @@ static void do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
155 * @param data pointer to the result data 155 * @param data pointer to the result data
156 */ 156 */
157void 157void
158get_result_iterator (void *cls, 158get_result_iterator (void *cls, struct GNUNET_TIME_Absolute exp,
159 struct GNUNET_TIME_Absolute exp,
160 const GNUNET_HashCode * key, 159 const GNUNET_HashCode * key,
161 const struct GNUNET_PeerIdentity *const *get_path, 160 const struct GNUNET_PeerIdentity *const *get_path,
162 const struct GNUNET_PeerIdentity *const *put_path, 161 const struct GNUNET_PeerIdentity *const *put_path,
@@ -200,8 +199,8 @@ get_result_iterator (void *cls,
200 199
201} 200}
202 201
203static void 202static void stop_retry_get (void *cls,
204stop_retry_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); 203 const struct GNUNET_SCHEDULER_TaskContext *tc);
205 204
206static void 205static void
207get_stop_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 206get_stop_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
@@ -260,24 +259,20 @@ do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
260 (GNUNET_TIME_UNIT_SECONDS, 10), 259 (GNUNET_TIME_UNIT_SECONDS, 10),
261 &stop_retry_get, get_context); 260 &stop_retry_get, get_context);
262 261
263 get_context->get_handle = GNUNET_DHT_get_start (get_context->dht_handle, 262 get_context->get_handle =
264 GNUNET_TIME_relative_multiply 263 GNUNET_DHT_get_start (get_context->dht_handle,
265 (GNUNET_TIME_UNIT_SECONDS, 5), 264 GNUNET_TIME_relative_multiply
266 GNUNET_BLOCK_TYPE_DHT_HELLO, 265 (GNUNET_TIME_UNIT_SECONDS, 5),
267 &get_context-> 266 GNUNET_BLOCK_TYPE_DHT_HELLO,
268 peer->hashPubKey, 267 &get_context->peer->hashPubKey,
269 DEFAULT_GET_REPLICATION, 268 DEFAULT_GET_REPLICATION, GNUNET_DHT_RO_NONE, NULL,
270 GNUNET_DHT_RO_NONE, NULL, 0, 269 0, NULL, 0, &get_result_iterator, get_context);
271 NULL, 0, &get_result_iterator,
272 get_context);
273} 270}
274 271
275 272
276void 273void
277topology_callback (void *cls, 274topology_callback (void *cls, const struct GNUNET_PeerIdentity *first,
278 const struct GNUNET_PeerIdentity *first, 275 const struct GNUNET_PeerIdentity *second, uint32_t distance,
279 const struct GNUNET_PeerIdentity *second,
280 uint32_t distance,
281 const struct GNUNET_CONFIGURATION_Handle *first_cfg, 276 const struct GNUNET_CONFIGURATION_Handle *first_cfg,
282 const struct GNUNET_CONFIGURATION_Handle *second_cfg, 277 const struct GNUNET_CONFIGURATION_Handle *second_cfg,
283 struct GNUNET_TESTING_Daemon *first_daemon, 278 struct GNUNET_TESTING_Daemon *first_daemon,
@@ -311,8 +306,8 @@ topology_callback (void *cls,
311 total_connections); 306 total_connections);
312#endif 307#endif
313 GNUNET_SCHEDULER_cancel (die_task); 308 GNUNET_SCHEDULER_cancel (die_task);
314 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, 309 die_task =
315 &end_badly, "from test gets"); 310 GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, "from test gets");
316 311
317 curr_get_ctx.dht_handle = peer1dht; 312 curr_get_ctx.dht_handle = peer1dht;
318 curr_get_ctx.peer = &peer2id; 313 curr_get_ctx.peer = &peer2id;
@@ -334,12 +329,10 @@ connect_topology (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
334{ 329{
335 expected_connections = -1; 330 expected_connections = -1;
336 if ((pg != NULL) && (peers_left == 0)) 331 if ((pg != NULL) && (peers_left == 0))
337 expected_connections = GNUNET_TESTING_connect_topology (pg, 332 expected_connections =
338 GNUNET_TESTING_TOPOLOGY_CLIQUE, 333 GNUNET_TESTING_connect_topology (pg, GNUNET_TESTING_TOPOLOGY_CLIQUE,
339 GNUNET_TESTING_TOPOLOGY_OPTION_ALL, 334 GNUNET_TESTING_TOPOLOGY_OPTION_ALL,
340 0.0, 335 0.0, TIMEOUT, 12, NULL, NULL);
341 TIMEOUT, 12, NULL,
342 NULL);
343 336
344 GNUNET_SCHEDULER_cancel (die_task); 337 GNUNET_SCHEDULER_cancel (die_task);
345 if (expected_connections == GNUNET_SYSERR) 338 if (expected_connections == GNUNET_SYSERR)
@@ -348,14 +341,13 @@ connect_topology (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
348 "from connect topology (bad return)"); 341 "from connect topology (bad return)");
349 342
350 343
351 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, 344 die_task =
352 &end_badly, 345 GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly,
353 "from connect topology (timeout)"); 346 "from connect topology (timeout)");
354} 347}
355 348
356static void 349static void
357peers_started_callback (void *cls, 350peers_started_callback (void *cls, const struct GNUNET_PeerIdentity *id,
358 const struct GNUNET_PeerIdentity *id,
359 const struct GNUNET_CONFIGURATION_Handle *cfg, 351 const struct GNUNET_CONFIGURATION_Handle *cfg,
360 struct GNUNET_TESTING_Daemon *d, const char *emsg) 352 struct GNUNET_TESTING_Daemon *d, const char *emsg)
361{ 353{
@@ -399,9 +391,9 @@ peers_started_callback (void *cls,
399 GNUNET_SCHEDULER_cancel (die_task); 391 GNUNET_SCHEDULER_cancel (die_task);
400 /* Set up task in case topology creation doesn't finish 392 /* Set up task in case topology creation doesn't finish
401 * within a reasonable amount of time */ 393 * within a reasonable amount of time */
402 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, 394 die_task =
403 &end_badly, 395 GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly,
404 "from peers_started_callback"); 396 "from peers_started_callback");
405 397
406 GNUNET_SCHEDULER_add_now (&connect_topology, NULL); 398 GNUNET_SCHEDULER_add_now (&connect_topology, NULL);
407 ok = 0; 399 ok = 0;
@@ -409,9 +401,8 @@ peers_started_callback (void *cls,
409} 401}
410 402
411static void 403static void
412run (void *cls, 404run (void *cls, char *const *args, const char *cfgfile,
413 char *const *args, 405 const struct GNUNET_CONFIGURATION_Handle *cfg)
414 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
415{ 406{
416 407
417 if (GNUNET_YES != 408 if (GNUNET_YES !=
@@ -431,18 +422,13 @@ run (void *cls,
431 total_gets = num_peers; 422 total_gets = num_peers;
432 gets_succeeded = 0; 423 gets_succeeded = 0;
433 /* Set up a task to end testing if peer start fails */ 424 /* Set up a task to end testing if peer start fails */
434 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, 425 die_task =
435 &end_badly, 426 GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly,
436 "didn't start all daemons in reasonable amount of time!!!"); 427 "didn't start all daemons in reasonable amount of time!!!");
437 428
438 pg = GNUNET_TESTING_daemons_start (cfg, 429 pg = GNUNET_TESTING_daemons_start (cfg, num_peers, 10, num_peers, TIMEOUT,
439 num_peers, 430 NULL, NULL, &peers_started_callback, NULL,
440 10, 431 &topology_callback, NULL, NULL);
441 num_peers,
442 TIMEOUT,
443 NULL, NULL,
444 &peers_started_callback,
445 NULL, &topology_callback, NULL, NULL);
446 432
447} 433}
448 434
@@ -462,9 +448,9 @@ check ()
462 struct GNUNET_GETOPT_CommandLineOption options[] = { 448 struct GNUNET_GETOPT_CommandLineOption options[] = {
463 GNUNET_GETOPT_OPTION_END 449 GNUNET_GETOPT_OPTION_END
464 }; 450 };
465 ret = GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, 451 ret =
466 argv, "test-dht-twopeer", "nohelp", 452 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv,
467 options, &run, &ok); 453 "test-dht-twopeer", "nohelp", options, &run, &ok);
468 if (ret != GNUNET_OK) 454 if (ret != GNUNET_OK)
469 { 455 {
470 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 456 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,