-fixing some testcase builds
[oweals/gnunet.git] / src / gns / test_gns_dht_delegated_lookup.c
index 14a8cb100c9905882c1ada34540d5c7f3ac5370f..e7f2ea06056fc52492a630b65146527c891faab3 100644 (file)
@@ -60,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;
@@ -140,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);
 }
 
 
@@ -163,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);
 }
 
@@ -174,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);
 }
 
@@ -201,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;
@@ -211,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
@@ -256,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);
@@ -266,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)
 {
   
@@ -274,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);
 
@@ -305,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 (KEYFILE_BOB);
+  bob_key = GNUNET_CRYPTO_rsa_key_create_from_file (KEYFILE_BOB);
   
   GNUNET_free(alice_keyfile);
 
@@ -314,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;
@@ -351,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