#include "gnunet_namestore_service.h"
#include "namestore.h"
-#define VERBOSE GNUNET_NO
-
-#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
+#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 100)
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));
}
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;
}
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
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[] = {