add completion callback for overlay topology configure functions
[oweals/gnunet.git] / src / namestore / test_namestore_api_remove_not_existing_record.c
index 5dfe8e22067bc3d8779c06c0ca72b2ef12362efd..973cf94e48f6e9a31592b9111075fe4b340a6582 100644 (file)
@@ -24,7 +24,7 @@
 #include "platform.h"
 #include "gnunet_common.h"
 #include "gnunet_namestore_service.h"
-#include "gnunet_testing_lib-new.h"
+#include "gnunet_testing_lib.h"
 #include "namestore.h"
 #include "gnunet_signatures.h"
 
@@ -42,7 +42,7 @@
 
 #define TEST_REMOVE_RECORD_DATA 'b'
 
-#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
+#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 100)
 
 
 static struct GNUNET_NAMESTORE_Handle * nsh;
@@ -74,11 +74,12 @@ static void
 endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   if (nsh != NULL)
-    GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES);
+    GNUNET_NAMESTORE_disconnect (nsh);
   nsh = NULL;
   if (privkey != NULL)
     GNUNET_CRYPTO_rsa_key_free (privkey);
   privkey = NULL;
+  GNUNET_free_non_null (s_name);
   res = 1;
 }
 
@@ -101,8 +102,9 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
     GNUNET_CRYPTO_rsa_key_free (privkey);
   privkey = NULL;
   if (nsh != NULL)
-    GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES);
+    GNUNET_NAMESTORE_disconnect (nsh);
   nsh = NULL;
+  GNUNET_free_non_null (s_name);
 }
 
 
@@ -137,7 +139,8 @@ put_cont (void *cls, int32_t success, const char *emsg)
 
     struct GNUNET_NAMESTORE_RecordData rd;
     char data[TEST_REMOVE_RECORD_DATALEN];
-    rd.expiration = GNUNET_TIME_absolute_get();
+
+    rd.expiration_time = GNUNET_TIME_absolute_get().abs_value;
     rd.record_type = TEST_REMOVE_RECORD_TYPE;
     rd.data_size = TEST_REMOVE_RECORD_DATALEN;
     rd.data = &data;
@@ -154,15 +157,15 @@ put_cont (void *cls, int32_t success, const char *emsg)
 
 
 static struct GNUNET_NAMESTORE_RecordData *
-create_record (int count)
+create_record (unsigned int count)
 {
-  int c;
+  unsigned int c;
   struct GNUNET_NAMESTORE_RecordData * rd;
 
   rd = GNUNET_malloc (count * sizeof (struct GNUNET_NAMESTORE_RecordData));
-  for (c = 0; c < RECORDS; c++)
+  for (c = 0; c < count; c++)
   {
-    rd[c].expiration = GNUNET_TIME_absolute_get();
+    rd[c].expiration_time = GNUNET_TIME_absolute_get().abs_value;
     rd[c].record_type = TEST_RECORD_TYPE;
     rd[c].data_size = TEST_RECORD_DATALEN;
     rd[c].data = GNUNET_malloc(TEST_RECORD_DATALEN);
@@ -174,10 +177,12 @@ create_record (int count)
 
 static void
 run (void *cls,
-     const struct GNUNET_CONFIGURATION_Handle *cfg)
+     const struct GNUNET_CONFIGURATION_Handle *cfg,
+     struct GNUNET_TESTING_Peer *peer)
 {
   char *hostkey_file;
   size_t rd_ser_len;
+  struct GNUNET_TIME_Absolute et;
 
   endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT,endbadly, NULL);
 
@@ -192,7 +197,7 @@ run (void *cls,
   GNUNET_CRYPTO_rsa_key_get_public(privkey, &pubkey);
 
   /* create record */
-  s_name = "dummy.dummy.gnunet";
+  s_name = GNUNET_NAMESTORE_normalize_string ("DUMMY.dummy.gnunet");
   s_rd = create_record (RECORDS);
 
   rd_ser_len = GNUNET_NAMESTORE_records_get_size(RECORDS, s_rd);
@@ -200,7 +205,8 @@ run (void *cls,
   GNUNET_NAMESTORE_records_serialize(RECORDS, s_rd, rd_ser_len, rd_ser);
 
   /* sign */
-  s_signature = GNUNET_NAMESTORE_create_signature(privkey, s_rd[0].expiration, s_name, s_rd, RECORDS);
+  et.abs_value = s_rd[0].expiration_time;
+  s_signature = GNUNET_NAMESTORE_create_signature(privkey, et, s_name, s_rd, RECORDS);
 
   /* create random zone hash */
   GNUNET_CRYPTO_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &s_zone);