change default configurations on systems with UNIX domain sockets to NOT specify...
[oweals/gnunet.git] / src / util / test_crypto_hash.c
index e10aee9b1c11ebb531a537b1cfe7cd68a080efb4..bc0411482d2f0079146df0763d166895fd2c4588 100644 (file)
@@ -4,7 +4,7 @@
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
-     by the Free Software Foundation; either version 2, or (at your
+     by the Free Software Foundation; either version 3, or (at your
      option) any later version.
 
      GNUnet is distributed in the hope that it will be useful, but
      option) any later version.
 
      GNUnet is distributed in the hope that it will be useful, but
@@ -42,10 +42,10 @@ test (int number)
   memset (&h1, number, sizeof (GNUNET_HashCode));
   GNUNET_CRYPTO_hash_to_enc (&h1, &enc);
   if (GNUNET_OK != GNUNET_CRYPTO_hash_from_string ((char *) &enc, &h2))
   memset (&h1, number, sizeof (GNUNET_HashCode));
   GNUNET_CRYPTO_hash_to_enc (&h1, &enc);
   if (GNUNET_OK != GNUNET_CRYPTO_hash_from_string ((char *) &enc, &h2))
-    {
-      printf ("enc2hash failed!\n");
-      return 1;
-    }
+  {
+    printf ("enc2hash failed!\n");
+    return 1;
+  }
   if (0 != memcmp (&h1, &h2, sizeof (GNUNET_HashCode)))
     return 1;
   return 0;
   if (0 != memcmp (&h1, &h2, sizeof (GNUNET_HashCode)))
     return 1;
   return 0;
@@ -55,6 +55,7 @@ static int
 testEncoding ()
 {
   int i;
 testEncoding ()
 {
   int i;
+
   for (i = 0; i < 255; i++)
     if (0 != test (i))
       return 1;
   for (i = 0; i < 255; i++)
     if (0 != test (i))
       return 1;
@@ -73,8 +74,8 @@ testArithmetic ()
   struct GNUNET_CRYPTO_AesSessionKey skey;
   struct GNUNET_CRYPTO_AesInitializationVector iv;
 
   struct GNUNET_CRYPTO_AesSessionKey skey;
   struct GNUNET_CRYPTO_AesInitializationVector iv;
 
-  GNUNET_CRYPTO_hash_create_random (&h1);
-  GNUNET_CRYPTO_hash_create_random (&h2);
+  GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &h1);
+  GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &h2);
   if (GNUNET_CRYPTO_hash_distance_u32 (&h1, &h2) !=
       GNUNET_CRYPTO_hash_distance_u32 (&h2, &h1))
     return 1;
   if (GNUNET_CRYPTO_hash_distance_u32 (&h1, &h2) !=
       GNUNET_CRYPTO_hash_distance_u32 (&h2, &h1))
     return 1;
@@ -122,9 +123,9 @@ finished_task (void *cls, const GNUNET_HashCode * res)
 static void
 file_hasher (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
 static void
 file_hasher (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
-  GNUNET_CRYPTO_hash_file (tc->sched,
-                           GNUNET_SCHEDULER_PRIORITY_DEFAULT,
-                           GNUNET_NO, FILENAME, 1024, &finished_task, cls);
+  GNUNET_assert (NULL !=
+                 GNUNET_CRYPTO_hash_file (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
+                                          FILENAME, 1024, &finished_task, cls));
 }
 
 
 }
 
 
@@ -136,9 +137,9 @@ testFileHash ()
 
   memset (block, 42, sizeof (block) / 2);
   memset (&block[sizeof (block) / 2], 43, sizeof (block) / 2);
 
   memset (block, 42, sizeof (block) / 2);
   memset (&block[sizeof (block) / 2], 43, sizeof (block) / 2);
-  GNUNET_assert (NULL != (f = fopen (FILENAME, "w+")));
+  GNUNET_assert (NULL != (f = FOPEN (FILENAME, "w+")));
   GNUNET_break (sizeof (block) == fwrite (block, 1, sizeof (block), f));
   GNUNET_break (sizeof (block) == fwrite (block, 1, sizeof (block), f));
-  GNUNET_break (0 == fclose (f));
+  GNUNET_break (0 == FCLOSE (f));
   ret = 1;
   GNUNET_SCHEDULER_run (&file_hasher, &ret);
   GNUNET_break (0 == UNLINK (FILENAME));
   ret = 1;
   GNUNET_SCHEDULER_run (&file_hasher, &ret);
   GNUNET_break (0 == UNLINK (FILENAME));