fix tests and do not assert since this will break make check
[oweals/gnunet.git] / src / namestore / test_namestore_api_lookup_shadow.c
index 6f9fd563877dc3cd449fdf7c40605790892176b9..442d3eb1c7046ef31d55679616896e2c1fc92a3f 100644 (file)
      Boston, MA 02111-1307, USA.
 */
 /**
- * @file namestore/test_namestore_api.c
- * @brief testcase for namestore_api.c: store a record and perform a lookup
+ * @file namestore/test_namestore_api_lookup_shadow_filter.c
+ * @brief testcase for namestore_api.c: store a shadow record and perform a lookup
+ * test passes if test returns the record but without the shadow flag since no
+ * other valid record is available
  */
 #include "platform.h"
 #include "gnunet_namecache_service.h"
@@ -113,15 +115,44 @@ rd_decrypt_cb (void *cls,
 {
   char rd_cmp_data[TEST_RECORD_DATALEN];
 
-  GNUNET_assert (1 == rd_count);
-  GNUNET_assert (NULL != rd);
-
+  if (1 != rd_count)
+  {
+    GNUNET_SCHEDULER_add_now (&endbadly, NULL);
+    GNUNET_break (0);
+    return;
+  }
+  if (NULL == rd)
+  {
+    GNUNET_SCHEDULER_add_now (&endbadly, NULL);
+    GNUNET_break (0);
+    return;
+  }
   memset (rd_cmp_data, 'a', TEST_RECORD_DATALEN);
 
-  GNUNET_assert (TEST_RECORD_TYPE == rd[0].record_type);
-  GNUNET_assert (TEST_RECORD_DATALEN == rd[0].data_size);
-  GNUNET_assert (0 == memcmp (&rd_cmp_data, rd[0].data, TEST_RECORD_DATALEN));
-  GNUNET_assert (GNUNET_GNSRECORD_RF_SHADOW_RECORD == rd[0].flags);
+  if (TEST_RECORD_TYPE != rd[0].record_type)
+  {
+    GNUNET_SCHEDULER_add_now (&endbadly, NULL);
+    GNUNET_break (0);
+    return;
+  }
+  if (TEST_RECORD_DATALEN != rd[0].data_size)
+  {
+    GNUNET_SCHEDULER_add_now (&endbadly, NULL);
+    GNUNET_break (0);
+    return;
+  }
+  if (0 != memcmp (&rd_cmp_data, rd[0].data, TEST_RECORD_DATALEN))
+  {
+    GNUNET_SCHEDULER_add_now (&endbadly, NULL);
+    GNUNET_break (0);
+    return;
+  }
+  if (0 != (GNUNET_GNSRECORD_RF_SHADOW_RECORD & rd[0].flags))
+  {
+    GNUNET_SCHEDULER_add_now (&endbadly, NULL);
+    GNUNET_break (0);
+    return;
+  }
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Block was decrypted successfully \n");
@@ -206,7 +237,6 @@ run (void *cls,
   GNUNET_assert (privkey != NULL);
   GNUNET_CRYPTO_ecdsa_key_get_public (privkey, &pubkey);
 
-
   rd.expiration_time = GNUNET_TIME_absolute_get().abs_value_us + 1000000000;
   rd.record_type = TEST_RECORD_TYPE;
   rd.data_size = TEST_RECORD_DATALEN;
@@ -225,7 +255,6 @@ run (void *cls,
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
              _("Namestore cannot store no block\n"));
   }
-
   GNUNET_free ((void *)rd.data);
 }
 
@@ -244,4 +273,4 @@ main (int argc, char *argv[])
 }
 
 
-/* end of test_namestore_api_lookup_public.c */
+/* end of test_namestore_api_lookup_shadow_filter.c */