fix quota calculations
[oweals/gnunet.git] / src / datastore / test_datastore_api_management.c
index 54289dd7b3905b4f05546890bbc2701f565b6b20..0bdea5135f5ecc904cbbbaff0ac8414182a1c49d 100644 (file)
@@ -33,7 +33,7 @@
 /**
  * How long until we give up on transmitting the message?
  */
-#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15)
+#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
 
 /**
  * Number of iterations to run; must be large enough
@@ -111,7 +111,6 @@ struct CpsRunContext
   struct GNUNET_SCHEDULER_Handle *sched;
   const struct GNUNET_CONFIGURATION_Handle *cfg;
   void *data;
-  size_t size;
   enum RunPhase phase;
 };
 
@@ -134,7 +133,6 @@ check_success (void *cls,
   GNUNET_free_non_null (crc->data);
   crc->data = NULL;
   GNUNET_SCHEDULER_add_continuation (crc->sched,
-                                    GNUNET_NO,
                                     &run_continuation,
                                     crc,
                                     GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -146,7 +144,7 @@ check_value (void *cls,
             const GNUNET_HashCode * key,
             uint32_t size,
             const void *data,
-            uint32_t type,
+            enum GNUNET_BLOCK_Type type,
             uint32_t priority,
             uint32_t anonymity,
             struct GNUNET_TIME_Absolute
@@ -172,7 +170,6 @@ check_value (void *cls,
       if (0 == crc->i)
        crc->phase = RP_DONE;
       GNUNET_SCHEDULER_add_continuation (crc->sched,
-                                        GNUNET_NO,
                                         &run_continuation,
                                         crc,
                                         GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -192,23 +189,21 @@ check_value (void *cls,
 
 static void 
 check_nothing (void *cls,
-            const GNUNET_HashCode * key,
-            uint32_t size,
-            const void *data,
-            uint32_t type,
-            uint32_t priority,
-            uint32_t anonymity,
-            struct GNUNET_TIME_Absolute
-            expiration, uint64_t uid)
+              const GNUNET_HashCode * key,
+              uint32_t size,
+              const void *data,
+              enum GNUNET_BLOCK_Type type,
+              uint32_t priority,
+              uint32_t anonymity,
+              struct GNUNET_TIME_Absolute
+              expiration, uint64_t uid)
 {
   struct CpsRunContext *crc = cls;
+
   GNUNET_assert (key == NULL);
-  if (crc->i == 0)
-    {
-      crc->phase = RP_DONE;
-    }
+  if (0 == --crc->i)
+    crc->phase = RP_DONE;
   GNUNET_SCHEDULER_add_continuation (crc->sched,
-                                    GNUNET_NO,
                                     &run_continuation,
                                     crc,
                                     GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -240,7 +235,7 @@ run_continuation (void *cls,
                            get_priority (crc->i),
                            get_anonymity (crc->i),
                            get_expiration (crc->i),
-                           TIMEOUT,
+                           1, 1, TIMEOUT,
                            &check_success,
                            crc);
       crc->i++;
@@ -264,9 +259,9 @@ run_continuation (void *cls,
       GNUNET_DATASTORE_get (datastore, 
                            &crc->key,
                            get_type (crc->i),
+                           1, 1, TIMEOUT,
                            &check_value,
-                           crc,
-                           TIMEOUT);
+                           crc);
       break;
     case RP_GET_FAIL:
 #if VERBOSE
@@ -279,11 +274,12 @@ run_continuation (void *cls,
       GNUNET_DATASTORE_get (datastore, 
                            &crc->key,
                            get_type (crc->i),
+                           1, 1, TIMEOUT,
                            &check_nothing,
-                           crc,
-                           TIMEOUT);
+                           crc);
       break;
     case RP_DONE:
+      GNUNET_assert (0 == crc->i);
 #if VERBOSE
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                  "Finished, disconnecting\n");
@@ -311,7 +307,6 @@ run (void *cls,
   now = GNUNET_TIME_absolute_get ();
   datastore = GNUNET_DATASTORE_connect (cfg, sched);
   GNUNET_SCHEDULER_add_continuation (crc->sched,
-                                    GNUNET_NO,
                                     &run_continuation,
                                     crc,
                                     GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -335,13 +330,12 @@ check ()
   struct GNUNET_GETOPT_CommandLineOption options[] = {
     GNUNET_GETOPT_OPTION_END
   };
-  pid = GNUNET_OS_start_process ("gnunet-service-datastore",
-                                 "gnunet-service-datastore",
+  pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+                                 "gnunet-service-arm",
 #if VERBOSE
                                  "-L", "DEBUG",
 #endif
                                  "-c", "test_datastore_api_data.conf", NULL);
-  sleep (1);
   GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
                       argv, "test-datastore-api", "nohelp",
                       options, &run, NULL);
@@ -361,7 +355,7 @@ main (int argc, char *argv[])
 {
   int ret;
   
-  GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-datastore");
+  GNUNET_DISK_directory_remove ("/tmp/test-gnunet-datastore");
   GNUNET_log_setup ("test-datastore-api",
 #if VERBOSE
                     "DEBUG",
@@ -370,7 +364,7 @@ main (int argc, char *argv[])
 #endif
                     NULL);
   ret = check ();
-  GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-datastore");
+  GNUNET_DISK_directory_remove ("/tmp/test-gnunet-datastore");
   return ret;
 }