-fixing some testcase builds
[oweals/gnunet.git] / src / gns / test_gns_dht_delegated_lookup.c
index 96768aa5cd91b1c8e5535bbb9b9d8e3ead0251af..e7f2ea06056fc52492a630b65146527c891faab3 100644 (file)
@@ -51,6 +51,8 @@
 
 #define DHT_OPERATION_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
 
+#define KEYFILE_BOB "../namestore/zonefiles/HGU0A0VCU334DN7F2I9UIUMVQMM7JMSD142LIMNUGTTV9R0CF4EG.zkey"
+
 /* Globals */
 
 /**
@@ -58,8 +60,7 @@
  */
 static char *test_directory;
 
-struct GNUNET_TESTING_Daemon *d1;
-
+static struct GNUNET_TESTING_PeerGroup *pg;
 
 /* Task handle to use to schedule test failure */
 GNUNET_SCHEDULER_TaskIdentifier die_task;
@@ -138,8 +139,9 @@ on_lookup_result(void *cls, uint32_t rd_count,
   }
   GNUNET_GNS_disconnect(gns_handle);
   GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down peer1!\n");
-  GNUNET_TESTING_daemon_stop (d1, TIMEOUT, &shutdown_callback, NULL,
-                              GNUNET_YES, GNUNET_NO);
+  //GNUNET_TESTING_daemon_stop (d1, TIMEOUT, &shutdown_callback, NULL,
+  //                            GNUNET_YES, GNUNET_NO);
+  GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
 }
 
 
@@ -161,6 +163,8 @@ commence_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   }
 
   GNUNET_GNS_lookup(gns_handle, TEST_DOMAIN, GNUNET_GNS_RECORD_TYPE_A,
+                    GNUNET_NO,
+                    NULL,
                     &on_lookup_result, TEST_DOMAIN);
 }
 
@@ -172,9 +176,9 @@ static void
 end_badly_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
 
-  if (d1 != NULL)
-    GNUNET_TESTING_daemon_stop (d1, TIMEOUT, &shutdown_callback, NULL,
-                                GNUNET_YES, GNUNET_NO);
+  if (pg != NULL) {
+    GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
+  }
   GNUNET_SCHEDULER_cancel (die_task);
 }
 
@@ -199,9 +203,9 @@ put_dht(void *cls, int32_t success, const char *emsg)
   struct GNSNameRecordBlock *nrb;
   struct GNUNET_CRYPTO_ShortHashCode name_hash;
   struct GNUNET_CRYPTO_ShortHashCode zone_hash;
-  GNUNET_HashCode xor_hash;
-  GNUNET_HashCode name_hash_double;
-  GNUNET_HashCode zone_hash_double;
+  struct GNUNET_HashCode xor_hash;
+  struct GNUNET_HashCode name_hash_double;
+  struct GNUNET_HashCode zone_hash_double;
   uint32_t rd_payload_length;
   char* nrb_data = NULL;
   struct GNUNET_CRYPTO_RsaSignature *sig;
@@ -209,13 +213,13 @@ put_dht(void *cls, int32_t success, const char *emsg)
   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));
   rd.data_size = sizeof(struct in_addr);
   rd.data = web;
   rd.record_type = GNUNET_DNSPARSER_TYPE_A;
 
-  sig = GNUNET_NAMESTORE_create_signature(bob_key, GNUNET_TIME_absolute_get_forever(), TEST_RECORD_NAME,
+  sig = GNUNET_NAMESTORE_create_signature(bob_key, GNUNET_TIME_UNIT_FOREVER_ABS, TEST_RECORD_NAME,
                                           &rd, 1);
   rd_payload_length = GNUNET_NAMESTORE_records_get_size (1, &rd);
   nrb = GNUNET_malloc(rd_payload_length + strlen(TEST_RECORD_NAME) + 1
@@ -254,7 +258,7 @@ put_dht(void *cls, int32_t success, const char *emsg)
                   GNUNET_BLOCK_TYPE_GNS_NAMERECORD,
                   rd_payload_length,
                   (char*)nrb,
-                  rd.expiration,
+                  GNUNET_TIME_UNIT_FOREVER_ABS,
                   DHT_OPERATION_TIMEOUT,
                   NULL,
                   NULL);
@@ -264,7 +268,7 @@ put_dht(void *cls, int32_t success, const char *emsg)
 
 static void
 do_lookup(void *cls, const struct GNUNET_PeerIdentity *id,
-          const struct GNUNET_CONFIGURATION_Handle *cfg,
+          const struct GNUNET_CONFIGURATION_Handle *_cfg,
           struct GNUNET_TESTING_Daemon *d, const char *emsg)
 {
   
@@ -272,6 +276,7 @@ do_lookup(void *cls, const struct GNUNET_PeerIdentity *id,
   char* alice_keyfile;
   struct GNUNET_CRYPTO_ShortHashCode bob_hash;
   
+  cfg = _cfg;
 
   GNUNET_SCHEDULER_cancel (die_task);
 
@@ -303,7 +308,7 @@ do_lookup(void *cls, const struct GNUNET_PeerIdentity *id,
   }
 
   alice_key = GNUNET_CRYPTO_rsa_key_create_from_file (alice_keyfile);
-  bob_key = GNUNET_CRYPTO_rsa_key_create ();
+  bob_key = GNUNET_CRYPTO_rsa_key_create_from_file (KEYFILE_BOB);
   
   GNUNET_free(alice_keyfile);
 
@@ -312,7 +317,7 @@ do_lookup(void *cls, const struct GNUNET_PeerIdentity *id,
   GNUNET_CRYPTO_short_hash(&bob_pkey, sizeof(bob_pkey), &bob_hash);
 
   struct GNUNET_NAMESTORE_RecordData rd;
-  rd.expiration = GNUNET_TIME_absolute_get_forever ();
+  rd.expiration_time = UINT64_MAX;
   rd.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode);
   rd.data = &bob_hash;
   rd.record_type = GNUNET_GNS_RECORD_PKEY;
@@ -349,8 +354,10 @@ run (void *cls, char *const *args, const char *cfgfile,
                                     "didn't start all daemons in reasonable amount of time!!!");
   
   /* Start alice */
-  d1 = GNUNET_TESTING_daemon_start(cfg, TIMEOUT, GNUNET_NO, NULL, NULL, 0,
-                                   NULL, NULL, NULL, &do_lookup, NULL);
+  //d1 = GNUNET_TESTING_daemon_start(cfg, TIMEOUT, GNUNET_NO, NULL, NULL, 0,
+  //                                 NULL, NULL, NULL, &do_lookup, NULL);
+  pg = GNUNET_TESTING_daemons_start(cfg, 1, 1, 1, TIMEOUT,
+                               NULL, NULL, &do_lookup, NULL, NULL, NULL, NULL);
 }
 
 static int