renaming GNUNET_TIME_relative_get_forever and GNUNET_TIME_absolute_get_forever method...
[oweals/gnunet.git] / src / namestore / test_namestore_api_create.c
index 1bda272e6e795b3b581f00f59275e8a76cbb43ca..131c934cb8adfc02c6f11a9c6fe817d1034054ce 100644 (file)
@@ -49,7 +49,7 @@ static struct GNUNET_CRYPTO_RsaPrivateKey * privkey;
 static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey;
 struct GNUNET_CRYPTO_RsaSignature *s_signature;
 struct GNUNET_CRYPTO_RsaSignature *s_signature_updated;
-static GNUNET_HashCode s_zone;
+static struct GNUNET_CRYPTO_ShortHashCode s_zone;
 struct GNUNET_NAMESTORE_RecordData *s_first_record;
 struct GNUNET_NAMESTORE_RecordData *s_second_record;
 static char *s_name;
@@ -79,7 +79,7 @@ stop_arm ()
     if (0 != GNUNET_OS_process_kill (arm, SIGTERM))
       GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
     GNUNET_OS_process_wait (arm);
-    GNUNET_OS_process_close (arm);
+    GNUNET_OS_process_destroy (arm);
     arm = NULL;
   }
 }
@@ -176,7 +176,14 @@ void name_lookup_second_proc (void *cls,
       }
     }
 
-    if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature(&pubkey, n, rd_count, rd, signature))
+    if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature(zone_key, expire, n, rd_count, rd, signature))
+    {
+      GNUNET_break (0);
+      failed = GNUNET_YES;
+    }
+
+
+    if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature(&pubkey, expire, n, rd_count, rd, signature))
     {
       GNUNET_break (0);
       failed = GNUNET_YES;
@@ -185,7 +192,7 @@ void name_lookup_second_proc (void *cls,
     struct GNUNET_NAMESTORE_RecordData rd_new[2];
     rd_new[0] = *s_first_record;
     rd_new[1] = *s_second_record;
-    s_signature_updated = GNUNET_NAMESTORE_create_signature(privkey, s_name, rd_new, 2);
+    s_signature_updated = GNUNET_NAMESTORE_create_signature(privkey, expire, s_name, rd_new, 2);
 
     if (0 != memcmp (s_signature_updated, signature, sizeof (struct GNUNET_CRYPTO_RsaSignature)))
     {
@@ -274,7 +281,7 @@ void name_lookup_initial_proc (void *cls,
       }
     }
 
-    if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature(&pubkey, n, rd_count, rd, signature))
+    if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature(&pubkey, expire,n, rd_count, rd, signature))
     {
       GNUNET_break (0);
       failed = GNUNET_YES;
@@ -294,7 +301,7 @@ void name_lookup_initial_proc (void *cls,
 
     /* create a second record */
     s_second_record = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_RecordData) + TEST_CREATE_RECORD_DATALEN);
-    s_second_record->expiration = GNUNET_TIME_absolute_get_forever();
+    s_second_record->expiration = GNUNET_TIME_UNIT_FOREVER_ABS;
     s_second_record->record_type = TEST_CREATE_RECORD_TYPE;
     s_second_record->flags = GNUNET_NAMESTORE_RF_AUTHORITY;
     s_second_record->data = &s_second_record[1];
@@ -401,7 +408,8 @@ run (void *cls, char *const *args, const char *cfgfile,
 
   /* load privat key */
   char *hostkey_file;
-  GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, "4UCICULTINKC87UO4326KEEDQ9MTEP2AJT88MJFVGTGNK12QNGMQI2S41VI07UUU6EO19BTB06PDL0HE6VP1OM50HOJEI75RHP4JP80.zone");
+  GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR,
+      "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey");
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file);
   privkey = GNUNET_CRYPTO_rsa_key_create_from_file(hostkey_file);
   GNUNET_free (hostkey_file);
@@ -416,12 +424,12 @@ run (void *cls, char *const *args, const char *cfgfile,
   char rd_ser[rd_ser_len];
   GNUNET_NAMESTORE_records_serialize(1, s_first_record, rd_ser_len, rd_ser);
 
-  s_signature = GNUNET_NAMESTORE_create_signature(privkey, s_name, s_first_record, 1);
+  s_signature = GNUNET_NAMESTORE_create_signature(privkey, s_first_record->expiration, s_name, s_first_record, 1);
 
   /* create random zone hash */
-  GNUNET_CRYPTO_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &s_zone);
+  GNUNET_CRYPTO_short_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &s_zone);
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Name: `%s' Zone: `%s' \n", s_name, GNUNET_h2s_full(&s_zone));
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Name: `%s' Zone: `%s' \n", s_name, GNUNET_short_h2s (&s_zone));
 
   start_arm (cfgfile);
   GNUNET_assert (arm != NULL);