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