-more debug messages
[oweals/gnunet.git] / src / namestore / test_namestore_record_serialization.c
index cd60a5dda49096499c337a7fb1a9decb7a11b8c9..362af0dd049b3bed10c636ec5a13483f1448c02f 100644 (file)
 
 static int res;
 
+
 static void
 run (void *cls, char *const *args, const char *cfgfile,
      const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
-  char * rd_ser = NULL;
   size_t len;
   int c;
-  int dst_elem = 0;
 
   int rd_count = 3;
   size_t data_len;
   struct GNUNET_NAMESTORE_RecordData src[rd_count];
-  struct GNUNET_NAMESTORE_RecordData *dst = NULL;
 
   memset(src, '\0', rd_count * sizeof (struct GNUNET_NAMESTORE_RecordData));
 
@@ -61,25 +59,27 @@ run (void *cls, char *const *args, const char *cfgfile,
   }
   res = 0;
 
-  len = GNUNET_NAMESTORE_records_serialize (&rd_ser, rd_count, src);
+  len = GNUNET_NAMESTORE_records_get_size(rd_count, src);
+  char rd_ser[len];
+  GNUNET_assert (len == GNUNET_NAMESTORE_records_serialize(rd_count, src, len, rd_ser));
+
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Serialized data len: %u\n",len);
 
   GNUNET_assert (rd_ser != NULL);
 
-  dst_elem = GNUNET_NAMESTORE_records_deserialize(&dst, rd_ser, len);
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deserialized elements: %u\n",dst_elem);
+  struct GNUNET_NAMESTORE_RecordData dst[rd_count];
+  GNUNET_assert (GNUNET_OK == GNUNET_NAMESTORE_records_deserialize (len, rd_ser, rd_count, dst));
 
-  GNUNET_assert (dst_elem == rd_count);
   GNUNET_assert (dst != NULL);
 
-  for (c = 0; c < dst_elem; c++)
+  for (c = 0; c < rd_count; c++)
   {
     if (src[c].data_size != dst[c].data_size)
     {
       GNUNET_break (0);
       res = 1;
     }
-    if (GNUNET_TIME_absolute_get_difference(src[c].expiration, dst[c].expiration).rel_value != GNUNET_TIME_relative_get_zero().rel_value)
+    if (src[c].expiration_time != dst[c].expiration_time)
     {
       GNUNET_break (0);
       res = 1;
@@ -118,9 +118,9 @@ run (void *cls, char *const *args, const char *cfgfile,
   }
 
   for (c = 0; c < rd_count; c++)
-    GNUNET_free ((void *)  src[c].data);
-  GNUNET_NAMESTORE_records_free (dst_elem, dst);
-  GNUNET_free (rd_ser);
+  {
+    GNUNET_free ((void *)src[c].data);
+  }
 }
 
 static int
@@ -129,9 +129,6 @@ check ()
   static char *const argv[] = { "test_namestore_record_serialization",
     "-c",
     "test_namestore_api.conf",
-#if VERBOSE
-    "-L", "DEBUG",
-#endif
     NULL
   };
   static struct GNUNET_GETOPT_CommandLineOption options[] = {