aboutsummaryrefslogtreecommitdiff
path: root/src/dht/test_dht_2dtorus.c
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2011-10-20 17:35:19 +0000
committerBart Polot <bart@net.in.tum.de>2011-10-20 17:35:19 +0000
commit3df90c73c968bc0efd3027aa0e1811ef7902fe2a (patch)
tree4b6a2f4dd59dd82018a5bb5b1c4bbd00b8da4fef /src/dht/test_dht_2dtorus.c
parent13dc02087efbf8a33a6669e12d294e8fd6aa702f (diff)
downloadgnunet-3df90c73c968bc0efd3027aa0e1811ef7902fe2a.tar.gz
gnunet-3df90c73c968bc0efd3027aa0e1811ef7902fe2a.zip
Added testcase for opposite peers in a small 2d grid
Diffstat (limited to 'src/dht/test_dht_2dtorus.c')
-rw-r--r--src/dht/test_dht_2dtorus.c57
1 files changed, 40 insertions, 17 deletions
diff --git a/src/dht/test_dht_2dtorus.c b/src/dht/test_dht_2dtorus.c
index d5acbbcb3..7c6c61a81 100644
--- a/src/dht/test_dht_2dtorus.c
+++ b/src/dht/test_dht_2dtorus.c
@@ -41,6 +41,8 @@
41 41
42static int ok; 42static int ok;
43 43
44static int far;
45
44/** 46/**
45 * Be verbose 47 * Be verbose
46 */ 48 */
@@ -204,15 +206,38 @@ do_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
204{ 206{
205 struct GNUNET_TESTING_Daemon *d; 207 struct GNUNET_TESTING_Daemon *d;
206 struct GNUNET_TESTING_Daemon *o; 208 struct GNUNET_TESTING_Daemon *o;
209 struct GNUNET_TESTING_Daemon *aux;
210 const char *id_aux;
211 const char *id_origin = "FC74";
212 const char *id_near = "9P6V";
213 const char *id_far = "KPST";
214 unsigned int i;
207 215
208 d = GNUNET_TESTING_daemon_get (pg, 2); 216 d = o = NULL;
209 o = GNUNET_TESTING_daemon_get (pg, 0); 217 for (i = 0; i < num_peers; i++)
218 {
219 aux = GNUNET_TESTING_daemon_get (pg, i);
220 id_aux = GNUNET_i2s (&aux->id);
221 if (strcmp (id_aux, id_origin) == 0)
222 o = aux;
223 if (far == GNUNET_YES && strcmp (id_aux, id_far) == 0)
224 d = aux;
225 if (far == GNUNET_NO && strcmp (id_aux, id_near) == 0)
226 d = aux;
227 }
228 if (NULL == o || NULL == d)
229 {
230 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
231 "test: Peers not found (hostkey file changed?)\n");
232 GNUNET_SCHEDULER_cancel (disconnect_task);
233 disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_peers, NULL);
234 }
210 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: test_task\n"); 235 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: test_task\n");
211 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 236 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
212 "test: looking for [2] %s\n", 237 "test: looking for %s\n",
213 GNUNET_h2s_full (&d->id.hashPubKey)); 238 GNUNET_h2s_full (&d->id.hashPubKey));
214 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 239 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
215 "test: from [0] %s\n", 240 "test: from %s\n",
216 GNUNET_h2s_full (&o->id.hashPubKey)); 241 GNUNET_h2s_full (&o->id.hashPubKey));
217 get_h = GNUNET_DHT_get_start (hs[0], 242 get_h = GNUNET_DHT_get_start (hs[0],
218 GNUNET_TIME_UNIT_FOREVER_REL, /* timeout */ 243 GNUNET_TIME_UNIT_FOREVER_REL, /* timeout */
@@ -353,23 +378,12 @@ connect_cb (void *cls, const struct GNUNET_PeerIdentity *first,
353 struct GNUNET_TESTING_Daemon *first_daemon, 378 struct GNUNET_TESTING_Daemon *first_daemon,
354 struct GNUNET_TESTING_Daemon *second_daemon, const char *emsg) 379 struct GNUNET_TESTING_Daemon *second_daemon, const char *emsg)
355{ 380{
356// GNUNET_PEER_Id f;
357// GNUNET_PEER_Id s;
358 381
359 if (emsg == NULL) 382 if (emsg == NULL)
360 { 383 {
361 total_connections++; 384 total_connections++;
362 /*f = */GNUNET_PEER_intern(first); 385 GNUNET_PEER_intern(first);
363 /*s = */GNUNET_PEER_intern(second); 386 GNUNET_PEER_intern(second);
364// GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: New connection!\n");
365// GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
366// "test: %s (%u)\n",
367// GNUNET_h2s(&first->hashPubKey),
368// f);
369// GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
370// "test: %s (%u)\n",
371// GNUNET_h2s(&second->hashPubKey),
372// s);
373 } 387 }
374 else 388 else
375 { 389 {
@@ -508,6 +522,15 @@ main (int xargc, char *xargv[])
508#endif 522#endif
509 NULL 523 NULL
510 }; 524 };
525
526 if (strstr (xargv[0], "2dtorus_far") != NULL)
527 {
528 far = GNUNET_YES;
529 }
530 else
531 {
532 far = GNUNET_NO;
533 }
511 534
512 GNUNET_PROGRAM_run (sizeof(argv)/sizeof(char*) - 1, argv, "test_dht_2dtorus", 535 GNUNET_PROGRAM_run (sizeof(argv)/sizeof(char*) - 1, argv, "test_dht_2dtorus",
513 gettext_noop ("Test dht in a small 2D torus."), options, 536 gettext_noop ("Test dht in a small 2D torus."), options,