-ign
[oweals/gnunet.git] / src / gns / test_gns_pseu_shorten.c
1 /*
2      This file is part of GNUnet.
3      (C) 2009 Christian Grothoff (and other contributing authors)
4
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 3, or (at your
8      option) any later version.
9
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.
14
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.
19 */
20 /**
21  * @file gns/test_gns_pseu_shorten.c
22  * @brief base testcase for testing on the fly pseu import and shorten
23  *
24  */
25 #include "platform.h"
26 #include "gnunet_testing_lib.h"
27 #include "gnunet_core_service.h"
28 #include "block_gns.h"
29 #include "gnunet_signatures.h"
30 #include "gnunet_namestore_service.h"
31 #include "../namestore/namestore.h"
32 #include "gnunet_dnsparser_lib.h"
33 #include "gnunet_dht_service.h"
34 #include "gnunet_gns_service.h"
35
36 /* DEFINES */
37 #define VERBOSE GNUNET_YES
38
39 /* Timeout for entire testcase */
40 #define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5)
41
42 /* If number of peers not in config file, use this number */
43 #define DEFAULT_NUM_PEERS 2
44
45 /* test records to resolve */
46 #define TEST_DOMAIN "www.alice.bob.gnunet"
47 #define TEST_IP "127.0.0.1"
48 #define TEST_RECORD_NAME "www"
49
50 #define TEST_AUTHORITY_BOB "bob"
51 #define TEST_AUTHORITY_ALICE "alice"
52 #define TEST_PSEU_ALICE "carol"
53 #define TEST_EXPECTED_RESULT "www.carol.gnunet"
54
55 #define DHT_OPERATION_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
56
57 #define KEYFILE_BOB "../namestore/zonefiles/HGU0A0VCU334DN7F2I9UIUMVQMM7JMSD142LIMNUGTTV9R0CF4EG.zkey"
58 #define KEYFILE_ALICE "../namestore/zonefiles/N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey"
59
60 /* Globals */
61
62 /**
63  * Directory to store temp data in, defined in config file
64  */
65 static char *test_directory;
66
67 static struct GNUNET_TESTING_PeerGroup *pg;
68
69 /* Task handle to use to schedule test failure */
70 GNUNET_SCHEDULER_TaskIdentifier die_task;
71
72 /* Global return value (0 for success, anything else for failure) */
73 static int ok;
74
75 static struct GNUNET_NAMESTORE_Handle *namestore_handle;
76
77 static struct GNUNET_GNS_Handle *gns_handle;
78
79 static struct GNUNET_DHT_Handle *dht_handle;
80
81 const struct GNUNET_CONFIGURATION_Handle *cfg;
82
83 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded alice_pkey;
84 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded bob_pkey;
85 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded our_pkey;
86 struct GNUNET_CRYPTO_RsaPrivateKey *alice_key;
87 struct GNUNET_CRYPTO_RsaPrivateKey *bob_key;
88 struct GNUNET_CRYPTO_RsaPrivateKey *our_key;
89 struct GNUNET_CRYPTO_ShortHashCode alice_hash;
90 struct GNUNET_CRYPTO_ShortHashCode bob_hash;
91
92 /**
93  * Check whether peers successfully shut down.
94  */
95 void
96 shutdown_callback (void *cls, const char *emsg)
97 {
98   if (emsg != NULL)
99   {
100     GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error on shutdown! ret=%d\n", ok);
101     if (ok == 0)
102       ok = 2;
103   }
104
105   GNUNET_log (GNUNET_ERROR_TYPE_INFO, "done(ret=%d)!\n", ok);
106 }
107
108 static void
109 disco_dht(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
110 {
111   GNUNET_DHT_disconnect(dht_handle);
112   dht_handle = NULL;
113 }
114
115 /**
116  * Called when gns shorten finishes
117  */
118 static void
119 process_shorten_result(void* cls, const char* sname)
120 {
121   GNUNET_GNS_disconnect(gns_handle);
122   //GNUNET_SCHEDULER_add_now(disco_dht, NULL);
123   ok = 0;
124
125   if (sname == NULL)
126   {
127     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
128                 "shorten test failed!\n");
129     ok = 1;
130   }
131   else
132   {
133     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
134                 "%s shortened to %s\n", (char*)cls, sname);
135     if (0 != strcmp(sname, TEST_EXPECTED_RESULT))
136     {
137       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
138                   "shorten test failed! (wanted: %s got: %s\n",
139                   (char*)cls, sname);
140       ok = 1;
141     }
142
143     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "shorten test succeeded!\n");
144   }
145
146   GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down peer1!\n");
147   GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
148 }
149
150 static void
151 do_shorten(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
152 {
153   GNUNET_GNS_shorten(gns_handle, TEST_DOMAIN, &process_shorten_result,
154 TEST_DOMAIN);
155 }
156
157 static void
158 on_lookup_result(void *cls, uint32_t rd_count,
159                  const struct GNUNET_NAMESTORE_RecordData *rd)
160 {
161   struct in_addr a;
162   int i;
163   char* addr;
164   
165   if (rd_count == 0)
166   {
167     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
168                 "Lookup failed, rp_filtering?\n");
169     ok = 2;
170   }
171   else
172   {
173     ok = 1;
174     GNUNET_log (GNUNET_ERROR_TYPE_INFO, "name: %s\n", (char*)cls);
175     for (i=0; i<rd_count; i++)
176     {
177       GNUNET_log (GNUNET_ERROR_TYPE_INFO, "type: %d\n", rd[i].record_type);
178       if (rd[i].record_type == GNUNET_GNS_RECORD_TYPE_A)
179       {
180         memcpy(&a, rd[i].data, sizeof(a));
181         addr = inet_ntoa(a);
182         GNUNET_log (GNUNET_ERROR_TYPE_INFO, "address: %s\n", addr);
183         if (0 == strcmp(addr, TEST_IP))
184         {
185           GNUNET_log (GNUNET_ERROR_TYPE_INFO,
186                     "%s correctly resolved to %s!\n", TEST_DOMAIN, addr);
187           ok = 0;
188         }
189       }
190       else
191       {
192         GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No resolution!\n");
193       }
194     }
195   }
196   
197   GNUNET_SCHEDULER_add_delayed (TIMEOUT, &do_shorten, NULL);
198 }
199
200
201 /**
202  * Function scheduled to be run on the successful start of services
203  * tries to look up the dns record for TEST_DOMAIN
204  */
205 static void
206 commence_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
207 {
208   GNUNET_SCHEDULER_add_now(disco_dht, NULL);
209   //GNUNET_DHT_disconnect(dht_handle);
210
211   GNUNET_CRYPTO_rsa_key_free(our_key);
212   GNUNET_CRYPTO_rsa_key_free(bob_key);
213   GNUNET_CRYPTO_rsa_key_free(alice_key);
214
215   gns_handle = GNUNET_GNS_connect(cfg);
216
217   if (NULL == gns_handle)
218   {
219     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
220                 "Failed to connect to GNS!\n");
221   }
222
223   GNUNET_GNS_lookup(gns_handle, TEST_DOMAIN, GNUNET_GNS_RECORD_TYPE_A,
224                     &on_lookup_result, TEST_DOMAIN);
225 }
226
227 /**
228  * Continuation for the GNUNET_DHT_get_stop call, so that we don't shut
229  * down the peers without freeing memory associated with GET request.
230  */
231 static void
232 end_badly_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
233 {
234
235   if (pg != NULL)
236     GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
237   GNUNET_SCHEDULER_cancel (die_task);
238 }
239
240 /**
241  * Check if the get_handle is being used, if so stop the request.  Either
242  * way, schedule the end_badly_cont function which actually shuts down the
243  * test.
244  */
245 static void
246 end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
247 {
248   GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failing test with error: `%s'!\n",
249               (char *) cls);
250   GNUNET_SCHEDULER_add_now (&end_badly_cont, NULL);
251   ok = 1;
252 }
253
254 static void
255 put_pseu_dht(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
256 {
257   struct GNSNameRecordBlock *nrb;
258   struct GNUNET_CRYPTO_ShortHashCode name_hash;
259   struct GNUNET_CRYPTO_ShortHashCode zone_hash;
260   GNUNET_HashCode xor_hash;
261   GNUNET_HashCode name_hash_double;
262   GNUNET_HashCode zone_hash_double;
263   uint32_t rd_payload_length;
264   char* nrb_data = NULL;
265   struct GNUNET_CRYPTO_RsaSignature *sig;
266   struct GNUNET_NAMESTORE_RecordData rd;
267   
268   rd.expiration = GNUNET_TIME_absolute_get_forever ();
269   rd.data_size = strlen(TEST_PSEU_ALICE)+1;
270   rd.data = TEST_PSEU_ALICE;
271   rd.record_type = GNUNET_GNS_RECORD_PSEU;
272
273   sig = GNUNET_NAMESTORE_create_signature(alice_key,
274                                           GNUNET_TIME_absolute_get_forever(),
275                                           "+",
276                                           &rd, 1);
277   rd_payload_length = GNUNET_NAMESTORE_records_get_size (1, &rd);
278   nrb = GNUNET_malloc(rd_payload_length + strlen("+") + 1
279                       + sizeof(struct GNSNameRecordBlock));
280   nrb->signature = *sig;
281   nrb->public_key = alice_pkey;
282   nrb->rd_count = htonl(1);
283   memset(&nrb[1], 0, strlen("+") + 1);
284   strcpy((char*)&nrb[1], "+");
285   nrb_data = (char*)&nrb[1];
286   nrb_data += strlen("+") + 1;
287
288   if (-1 == GNUNET_NAMESTORE_records_serialize (1,
289                                                 &rd,
290                                                 rd_payload_length,
291                                                 nrb_data))
292   {
293     GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Record serialization failed!\n");
294     ok = 3;
295     GNUNET_DHT_disconnect(dht_handle);
296     
297     
298     GNUNET_CRYPTO_rsa_key_free(our_key);
299     GNUNET_CRYPTO_rsa_key_free(bob_key);
300     GNUNET_CRYPTO_rsa_key_free(alice_key);
301     GNUNET_free(sig);
302     GNUNET_free (nrb);
303     return;
304   }
305   GNUNET_CRYPTO_short_hash("+", strlen("+"), &name_hash);
306   GNUNET_CRYPTO_short_hash(&alice_pkey,
307                      sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
308                      &zone_hash);
309
310   GNUNET_CRYPTO_short_hash_double(&name_hash, &name_hash_double);
311   GNUNET_CRYPTO_short_hash_double(&zone_hash, &zone_hash_double);
312   GNUNET_CRYPTO_hash_xor(&zone_hash_double, &name_hash_double, &xor_hash);
313
314   rd_payload_length += sizeof(struct GNSNameRecordBlock) +
315     strlen("+") + 1;
316
317   GNUNET_DHT_put (dht_handle, &xor_hash,
318                   0,
319                   GNUNET_DHT_RO_NONE,
320                   GNUNET_BLOCK_TYPE_GNS_NAMERECORD,
321                   rd_payload_length,
322                   (char*)nrb,
323                   rd.expiration,
324                   DHT_OPERATION_TIMEOUT,
325                   &commence_testing,
326                   NULL);
327   
328   GNUNET_free(sig);
329   GNUNET_free (nrb);
330 }
331
332 static void
333 put_www_dht(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
334 {
335   struct GNSNameRecordBlock *nrb;
336   struct GNUNET_CRYPTO_ShortHashCode name_hash;
337   struct GNUNET_CRYPTO_ShortHashCode zone_hash;
338   GNUNET_HashCode xor_hash;
339   GNUNET_HashCode name_hash_double;
340   GNUNET_HashCode zone_hash_double;
341   uint32_t rd_payload_length;
342   char* nrb_data = NULL;
343   struct GNUNET_CRYPTO_RsaSignature *sig;
344   struct GNUNET_NAMESTORE_RecordData rd;
345   char* ip = TEST_IP;
346   struct in_addr *web = GNUNET_malloc(sizeof(struct in_addr));
347   
348   rd.expiration = GNUNET_TIME_absolute_get_forever ();
349   GNUNET_assert(1 == inet_pton (AF_INET, ip, web));
350   rd.data_size = sizeof(struct in_addr);
351   rd.data = web;
352   rd.record_type = GNUNET_DNSPARSER_TYPE_A;
353
354   sig = GNUNET_NAMESTORE_create_signature(alice_key,
355                                           GNUNET_TIME_absolute_get_forever(),
356                                           TEST_RECORD_NAME,
357                                           &rd, 1);
358   rd_payload_length = GNUNET_NAMESTORE_records_get_size (1, &rd);
359   nrb = GNUNET_malloc(rd_payload_length + strlen(TEST_RECORD_NAME) + 1
360                       + sizeof(struct GNSNameRecordBlock));
361   nrb->signature = *sig;
362   nrb->public_key = alice_pkey;
363   nrb->rd_count = htonl(1);
364   memset(&nrb[1], 0, strlen(TEST_RECORD_NAME) + 1);
365   strcpy((char*)&nrb[1], TEST_RECORD_NAME);
366   nrb_data = (char*)&nrb[1];
367   nrb_data += strlen(TEST_RECORD_NAME) + 1;
368
369   if (-1 == GNUNET_NAMESTORE_records_serialize (1,
370                                                 &rd,
371                                                 rd_payload_length,
372                                                 nrb_data))
373   {
374     GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Record serialization failed!\n");
375     ok = 3;
376     GNUNET_DHT_disconnect(dht_handle);
377     
378     GNUNET_CRYPTO_rsa_key_free(our_key);
379     GNUNET_CRYPTO_rsa_key_free(bob_key);
380     GNUNET_CRYPTO_rsa_key_free(alice_key);
381     GNUNET_free(web);
382     GNUNET_free (nrb);
383     return;
384   }
385   GNUNET_CRYPTO_short_hash(TEST_RECORD_NAME, strlen(TEST_RECORD_NAME), &name_hash);
386   GNUNET_CRYPTO_short_hash(&alice_pkey,
387                      sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
388                      &zone_hash);
389   GNUNET_CRYPTO_short_hash_double(&zone_hash, &zone_hash_double);
390   GNUNET_CRYPTO_short_hash_double(&name_hash, &name_hash_double);
391   GNUNET_CRYPTO_hash_xor(&zone_hash_double, &name_hash_double, &xor_hash);
392
393   rd_payload_length += sizeof(struct GNSNameRecordBlock) +
394     strlen(TEST_RECORD_NAME) + 1;
395
396   GNUNET_DHT_put (dht_handle, &xor_hash,
397                   0,
398                   GNUNET_DHT_RO_NONE,
399                   GNUNET_BLOCK_TYPE_GNS_NAMERECORD,
400                   rd_payload_length,
401                   (char*)nrb,
402                   rd.expiration,
403                   DHT_OPERATION_TIMEOUT,
404                   &put_pseu_dht,
405                   NULL);
406
407   GNUNET_free(web);
408   GNUNET_free (nrb);
409 }
410
411
412 static void
413 put_pkey_dht(void *cls, int32_t success, const char *emsg)
414 {
415   struct GNSNameRecordBlock *nrb;
416   struct GNUNET_CRYPTO_ShortHashCode name_hash;
417   struct GNUNET_CRYPTO_ShortHashCode zone_hash;
418   GNUNET_HashCode xor_hash;
419   GNUNET_HashCode name_hash_double;
420   GNUNET_HashCode zone_hash_double;
421   uint32_t rd_payload_length;
422   char* nrb_data = NULL;
423   struct GNUNET_CRYPTO_RsaSignature *sig;
424   struct GNUNET_NAMESTORE_RecordData rd;
425   
426   rd.expiration = GNUNET_TIME_absolute_get_forever ();
427   rd.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode);
428   rd.data = &alice_hash;
429   rd.record_type = GNUNET_GNS_RECORD_PKEY;
430
431   sig = GNUNET_NAMESTORE_create_signature(bob_key,
432                                           GNUNET_TIME_absolute_get_forever(),
433                                           TEST_AUTHORITY_ALICE,
434                                           &rd,
435                                           1);
436
437   rd_payload_length = GNUNET_NAMESTORE_records_get_size (1, &rd);
438   nrb = GNUNET_malloc(rd_payload_length + strlen(TEST_AUTHORITY_ALICE) + 1
439                       + sizeof(struct GNSNameRecordBlock));
440   nrb->signature = *sig;
441   nrb->public_key = bob_pkey;
442   nrb->rd_count = htonl(1);
443   memset(&nrb[1], 0, strlen(TEST_AUTHORITY_ALICE) + 1);
444   strcpy((char*)&nrb[1], TEST_AUTHORITY_ALICE);
445   nrb_data = (char*)&nrb[1];
446   nrb_data += strlen(TEST_AUTHORITY_ALICE) + 1;
447
448   if (-1 == GNUNET_NAMESTORE_records_serialize (1,
449                                                 &rd,
450                                                 rd_payload_length,
451                                                 nrb_data))
452   {
453     GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Record serialization failed!\n");
454     ok = 3;
455     
456     GNUNET_CRYPTO_rsa_key_free(our_key);
457     GNUNET_CRYPTO_rsa_key_free(bob_key);
458     GNUNET_CRYPTO_rsa_key_free(alice_key);
459     GNUNET_free(sig);
460     GNUNET_free (nrb);
461     return;
462   }
463
464
465   GNUNET_CRYPTO_short_hash(TEST_AUTHORITY_ALICE,
466                      strlen(TEST_AUTHORITY_ALICE), &name_hash);
467   GNUNET_CRYPTO_short_hash(&bob_pkey,
468                      sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
469                      &zone_hash);
470   GNUNET_CRYPTO_short_hash_double(&zone_hash, &zone_hash_double);
471   GNUNET_CRYPTO_short_hash_double(&name_hash, &name_hash_double);
472   GNUNET_CRYPTO_hash_xor(&zone_hash_double, &name_hash_double, &xor_hash); 
473
474   rd_payload_length += sizeof(struct GNSNameRecordBlock) +
475     strlen(TEST_AUTHORITY_ALICE) + 1;
476   GNUNET_DHT_put (dht_handle, &xor_hash,
477                   0,
478                   GNUNET_DHT_RO_NONE,
479                   GNUNET_BLOCK_TYPE_GNS_NAMERECORD,
480                   rd_payload_length,
481                   (char*)nrb,
482                   rd.expiration,
483                   DHT_OPERATION_TIMEOUT,
484                   &put_www_dht,
485                   NULL);
486   GNUNET_NAMESTORE_disconnect(namestore_handle, GNUNET_NO);
487   GNUNET_free (nrb);
488 }
489
490 static void
491 do_lookup(void *cls, const struct GNUNET_PeerIdentity *id,
492           const struct GNUNET_CONFIGURATION_Handle *_cfg,
493           struct GNUNET_TESTING_Daemon *d, const char *emsg)
494 {
495   
496   
497   char* our_keyfile;
498   
499   cfg = _cfg;
500
501   GNUNET_SCHEDULER_cancel (die_task);
502
503   /* put records into namestore */
504   namestore_handle = GNUNET_NAMESTORE_connect(cfg);
505   if (NULL == namestore_handle)
506   {
507     GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to connect to namestore\n");
508     ok = -1;
509     return;
510   }
511   
512   /* dht */
513   dht_handle = GNUNET_DHT_connect(cfg, 1);
514   if (NULL == dht_handle)
515   {
516     GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to connect to dht\n");
517     ok = -1;
518     return;
519   }
520
521   if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns",
522                                                           "ZONEKEY",
523                                                           &our_keyfile))
524   {
525     GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to get key from cfg\n");
526     ok = -1;
527     return;
528   }
529
530   our_key = GNUNET_CRYPTO_rsa_key_create_from_file (our_keyfile);
531   bob_key = GNUNET_CRYPTO_rsa_key_create_from_file (KEYFILE_BOB);
532   alice_key = GNUNET_CRYPTO_rsa_key_create_from_file (KEYFILE_ALICE);
533   
534   GNUNET_free(our_keyfile);
535
536   GNUNET_CRYPTO_rsa_key_get_public (our_key, &our_pkey);
537   GNUNET_CRYPTO_rsa_key_get_public (bob_key, &bob_pkey);
538   GNUNET_CRYPTO_rsa_key_get_public (alice_key, &alice_pkey);
539   GNUNET_CRYPTO_short_hash(&bob_pkey, sizeof(bob_pkey), &bob_hash);
540   GNUNET_CRYPTO_short_hash(&alice_pkey, sizeof(alice_pkey), &alice_hash);
541
542   struct GNUNET_NAMESTORE_RecordData rd;
543   rd.expiration = GNUNET_TIME_absolute_get_forever ();
544   rd.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode);
545   rd.data = &bob_hash;
546   rd.record_type = GNUNET_GNS_RECORD_PKEY;
547
548   GNUNET_NAMESTORE_record_create (namestore_handle,
549                                   our_key,
550                                   TEST_AUTHORITY_BOB,
551                                   &rd,
552                                   &put_pkey_dht,
553                                   NULL);
554
555
556 }
557
558 static void
559 run (void *cls, char *const *args, const char *cfgfile,
560      const struct GNUNET_CONFIGURATION_Handle *c)
561 {
562   cfg = c;
563    /* Get path from configuration file */
564   if (GNUNET_YES !=
565       GNUNET_CONFIGURATION_get_value_string (cfg, "paths", "servicehome",
566                                              &test_directory))
567   {
568     ok = 404;
569     return;
570   }
571
572     
573   /* Set up a task to end testing if peer start fails */
574   die_task =
575       GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly,
576                                     "didn't start all daemons in reasonable amount of time!!!");
577   
578   /* Start alice */
579   //d1 = GNUNET_TESTING_daemon_start(cfg, TIMEOUT, GNUNET_NO, NULL, NULL, 0,
580   //                                 NULL, NULL, NULL, &do_lookup, NULL);
581   pg = GNUNET_TESTING_daemons_start(cfg, 1, 1, 1, TIMEOUT,
582                                     NULL, NULL, &do_lookup, NULL,
583                                     NULL, NULL, NULL);
584 }
585
586 static int
587 check ()
588 {
589   int ret;
590
591   /* Arguments for GNUNET_PROGRAM_run */
592   char *const argv[] = { "test-gns-pseu-shorten", /* Name to give running binary */
593     "-c",
594     "test_gns_simple_lookup.conf",       /* Config file to use */
595 #if VERBOSE
596     "-L", "DEBUG",
597 #endif
598     NULL
599   };
600   struct GNUNET_GETOPT_CommandLineOption options[] = {
601     GNUNET_GETOPT_OPTION_END
602   };
603   /* Run the run function as a new program */
604   ret =
605       GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv,
606                           "test-gns-pseu-shorten", "nohelp", options, &run,
607                           &ok);
608   if (ret != GNUNET_OK)
609   {
610     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
611                 "`test-gns-pseu-shorten': Failed with error code %d\n", ret);
612   }
613   return ok;
614 }
615
616 int
617 main (int argc, char *argv[])
618 {
619   int ret;
620
621   GNUNET_log_setup ("test-gns-pseu-shorten",
622 #if VERBOSE
623                     "DEBUG",
624 #else
625                     "WARNING",
626 #endif
627                     NULL);
628   ret = check ();
629   /**
630    * Need to remove base directory, subdirectories taken care
631    * of by the testing framework.
632    */
633   return ret;
634 }
635
636 /* end of test_gns_twopeer.c */