#define VERBOSE GNUNET_NO
-#define START_DATASTORE GNUNET_NO
+#define START_DATASTORE GNUNET_YES
/**
* How long until we give up on transmitting the message?
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
};
{
if (crc->phase != RP_GET_MULTIPLE_DONE)
{
+ fprintf (stderr,
+ "Wrong phase: %d\n",
+ crc->phase);
GNUNET_break (0);
crc->phase = RP_ERROR;
}
if (key == NULL)
{
- GNUNET_assert (crc->phase == RP_UPDATE_DONE);
- crc->phase = RP_DONE;
+ if (crc->phase != RP_UPDATE_DONE)
+ {
+ GNUNET_break (0);
+ crc->phase = RP_ERROR;
+ }
+ else
+ {
+ crc->phase = RP_DONE;
+ }
GNUNET_SCHEDULER_add_continuation (crc->sched,
&run_continuation,
crc,
}
+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,
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
struct CpsRunContext *crc;
+ static GNUNET_HashCode zkey;
crc = GNUNET_malloc(sizeof(struct CpsRunContext));
crc->sched = sched;
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 ()
{