use big endian
[oweals/gnunet.git] / src / datastore / test_datastore_api.c
index 2ae6dbe4ab87ae72b9cca994f396cbe3d16d1ea4..0ea3c4c86cee653ca365e26cb903ca1420fed52c 100644 (file)
@@ -111,10 +111,10 @@ enum RunPhase
     RP_PUT_MULTIPLE,
     RP_PUT_MULTIPLE_NEXT,
     RP_GET_MULTIPLE,
-    RP_GET_MULTIPLE_NEXT,
+    RP_GET_MULTIPLE_NEXT, /* 10 */
     RP_GET_MULTIPLE_DONE,
     RP_UPDATE,
-    RP_UPDATE_VALIDATE,
+    RP_UPDATE_VALIDATE, /* 13 */
     RP_UPDATE_DONE,
     RP_ERROR
   };
@@ -582,6 +582,28 @@ run_continuation (void *cls,
 }
 
 
+static void
+run_tests (void *cls,
+          int success,
+          const char *msg)
+{
+  struct CpsRunContext *crc = cls;
+
+  if (success != GNUNET_YES)
+    {
+      fprintf (stderr,
+              "Test 'put' operation failed with error `%s' database likely not setup, skipping test.",
+              msg);
+      GNUNET_free (crc);
+      return;
+    }
+  GNUNET_SCHEDULER_add_continuation (crc->sched,
+                                    &run_continuation,
+                                    crc,
+                                    GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+}
+
+
 static void
 run (void *cls,
      struct GNUNET_SCHEDULER_Handle *sched,
@@ -590,6 +612,7 @@ run (void *cls,
      const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   struct CpsRunContext *crc;
+  static GNUNET_HashCode zkey;
 
   crc = GNUNET_malloc(sizeof(struct CpsRunContext));
   crc->sched = sched;
@@ -597,15 +620,22 @@ run (void *cls,
   crc->phase = RP_PUT;
   now = GNUNET_TIME_absolute_get ();
   datastore = GNUNET_DATASTORE_connect (cfg, sched);
-  GNUNET_SCHEDULER_add_continuation (crc->sched,
-                                    &run_continuation,
-                                    crc,
-                                    GNUNET_SCHEDULER_REASON_PREREQ_DONE);
-
+  if (NULL ==
+      GNUNET_DATASTORE_put (datastore, 0,
+                           &zkey, 4, "TEST",
+                           GNUNET_BLOCK_TYPE_TEST,
+                           0, 0, GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_SECONDS),
+                           0, 1, GNUNET_TIME_UNIT_MINUTES,
+                           &run_tests, crc))
+    {
+      fprintf (stderr,
+              "Test 'put' operation failed.\n");
+      ok = 1;
+      GNUNET_free (crc);
+    }
 }
 
 
-
 static int
 check ()
 {