fix
[oweals/gnunet.git] / src / gns / test_gns_simple_zkey_lookup.c
index 32298cba56baf413af65067e5f974457d2aef37d..136b3b7db2cc36a15ccc90ffdaf6a47a5dfcd4ba 100644 (file)
@@ -37,7 +37,7 @@
 #define VERBOSE GNUNET_YES
 
 /* Timeout for entire testcase */
-#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 20)
+#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 40)
 
 /* If number of peers not in config file, use this number */
 #define DEFAULT_NUM_PEERS 2
@@ -97,10 +97,11 @@ on_lookup_result(void *cls, uint32_t rd_count,
   int i;
   char* addr;
   
+  GNUNET_NAMESTORE_disconnect (namestore_handle);
   if (rd_count == 0)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "Lookup failed, rp_filtering?\n");
+                "Lookup failed\n");
     ok = 2;
   }
   else
@@ -110,7 +111,7 @@ on_lookup_result(void *cls, uint32_t rd_count,
     for (i=0; i<rd_count; i++)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_INFO, "type: %d\n", rd[i].record_type);
-      if (rd[i].record_type == GNUNET_GNS_RECORD_TYPE_A)
+      if (rd[i].record_type == GNUNET_GNS_RECORD_A)
       {
         memcpy(&a, rd[i].data, sizeof(a));
         addr = inet_ntoa(a);
@@ -145,7 +146,6 @@ commence_testing (void *cls, int32_t success, const char *emsg)
   char* pos;
   struct GNUNET_CRYPTO_ShortHashAsciiEncoded hash_str;
   
-  GNUNET_NAMESTORE_disconnect(namestore_handle, GNUNET_YES);
 
   gns_handle = GNUNET_GNS_connect(cfg);
 
@@ -167,7 +167,9 @@ commence_testing (void *cls, int32_t success, const char *emsg)
   pos++;
   strcpy(pos, GNUNET_GNS_TLD_ZKEY);
 
-  GNUNET_GNS_lookup(gns_handle, name, GNUNET_GNS_RECORD_TYPE_A,
+  GNUNET_GNS_lookup(gns_handle, name, GNUNET_GNS_RECORD_A,
+                    GNUNET_NO,
+                    NULL,
                     &on_lookup_result, NULL);
 }
 
@@ -241,7 +243,7 @@ do_lookup(void *cls, const struct GNUNET_PeerIdentity *id,
   struct GNUNET_NAMESTORE_RecordData rd;
   char* ip = TEST_IP;
   struct in_addr *web = GNUNET_malloc(sizeof(struct in_addr));
-  rd.expiration = GNUNET_TIME_absolute_get_forever ();
+  rd.expiration_time = UINT64_MAX;
   GNUNET_assert(1 == inet_pton (AF_INET, ip, web));
   
   GNUNET_CRYPTO_short_hash(&bob_pkey, sizeof(bob_pkey), &bob_hash);
@@ -249,6 +251,7 @@ do_lookup(void *cls, const struct GNUNET_PeerIdentity *id,
   rd.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode);
   rd.data = &bob_hash;
   rd.record_type = GNUNET_GNS_RECORD_PKEY;
+  rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY;
 
   GNUNET_NAMESTORE_record_create (namestore_handle,
                                   alice_key,
@@ -261,14 +264,14 @@ do_lookup(void *cls, const struct GNUNET_PeerIdentity *id,
   rd.data = web;
   rd.record_type = GNUNET_DNSPARSER_TYPE_A;
   sig = GNUNET_NAMESTORE_create_signature(bob_key,
-                                          GNUNET_TIME_absolute_get_forever(),
+                                          GNUNET_TIME_UNIT_FOREVER_ABS,
                                           TEST_RECORD_NAME,
                                           &rd, 1);
 
   GNUNET_NAMESTORE_record_put (namestore_handle,
                                &bob_pkey,
                                TEST_RECORD_NAME,
-                               rd.expiration,
+                               GNUNET_TIME_UNIT_FOREVER_ABS,
                                1,
                                &rd,
                                sig,
@@ -311,12 +314,9 @@ check ()
   int ret;
 
   /* Arguments for GNUNET_PROGRAM_run */
-  char *const argv[] = { "test-gns-simple-delegated-lookup", /* Name to give running binary */
+  char *const argv[] = { "test-gns-simple-zkey-lookup", /* Name to give running binary */
     "-c",
     "test_gns_simple_lookup.conf",       /* Config file to use */
-#if VERBOSE
-    "-L", "DEBUG",
-#endif
     NULL
   };
   struct GNUNET_GETOPT_CommandLineOption options[] = {
@@ -325,12 +325,12 @@ check ()
   /* Run the run function as a new program */
   ret =
       GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv,
-                          "test-gns-simple-delegated-lookup", "nohelp", options, &run,
+                          "test-gns-simple-zkey-lookup", "nohelp", options, &run,
                           &ok);
   if (ret != GNUNET_OK)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                "`test-gns-simple-delegated-lookup': Failed with error code %d\n", ret);
+                "`test-gns-simple-zkey-lookup': Failed with error code %d\n", ret);
   }
   return ok;
 }
@@ -340,12 +340,8 @@ main (int argc, char *argv[])
 {
   int ret;
 
-  GNUNET_log_setup ("test-gns-simple-lookup",
-#if VERBOSE
-                    "DEBUG",
-#else
+  GNUNET_log_setup ("test-gns-simple-zkey-lookup",
                     "WARNING",
-#endif
                     NULL);
   ret = check ();
   /**