aboutsummaryrefslogtreecommitdiff
path: root/src/psycstore
diff options
context:
space:
mode:
authorGabor X Toth <*@tg-x.net>2016-10-06 16:01:51 +0000
committerGabor X Toth <*@tg-x.net>2016-10-06 16:01:51 +0000
commitda0aae8584e524595e7c17cf3f2cce3090fbb035 (patch)
tree00bbb49044c3febe69e894a9cc14b45ffc1a12e7 /src/psycstore
parenta150b5db213e2fd9474ff7f4a6f639b22ece63ef (diff)
downloadgnunet-da0aae8584e524595e7c17cf3f2cce3090fbb035.tar.gz
gnunet-da0aae8584e524595e7c17cf3f2cce3090fbb035.zip
psycstore: mysql stmt fix, logging for tests
Diffstat (limited to 'src/psycstore')
-rw-r--r--src/psycstore/plugin_psycstore_mysql.c15
-rw-r--r--src/psycstore/test_plugin_psycstore.c59
2 files changed, 63 insertions, 11 deletions
diff --git a/src/psycstore/plugin_psycstore_mysql.c b/src/psycstore/plugin_psycstore_mysql.c
index 42c12119e..d857262d6 100644
--- a/src/psycstore/plugin_psycstore_mysql.c
+++ b/src/psycstore/plugin_psycstore_mysql.c
@@ -423,7 +423,7 @@ database_setup (struct Plugin *plugin)
423 " multicast_flags, psycstore_flags, data\n" 423 " multicast_flags, psycstore_flags, data\n"
424 "FROM messages\n" 424 "FROM messages\n"
425 "WHERE channel_id = (SELECT id FROM channels WHERE pub_key = ?)\n" 425 "WHERE channel_id = (SELECT id FROM channels WHERE pub_key = ?)\n"
426 " AND ? <= message_id AND message_id <= ?" 426 " AND ? <= message_id AND message_id <= ?\n"
427 "LIMIT ?;", 427 "LIMIT ?;",
428 &plugin->select_messages); 428 &plugin->select_messages);
429 429
@@ -1101,21 +1101,16 @@ fragment_row (struct GNUNET_MYSQL_StatementHandle *stmt,
1101 1101
1102 1102
1103static int 1103static int
1104fragment_select (struct Plugin *plugin, struct GNUNET_MYSQL_StatementHandle *stmt, 1104fragment_select (struct Plugin *plugin,
1105 struct GNUNET_MYSQL_StatementHandle *stmt,
1105 struct GNUNET_MY_QueryParam *params, 1106 struct GNUNET_MY_QueryParam *params,
1106 uint64_t *returned_fragments, 1107 uint64_t *returned_fragments,
1107 GNUNET_PSYCSTORE_FragmentCallback cb, void *cb_cls) 1108 GNUNET_PSYCSTORE_FragmentCallback cb,
1109 void *cb_cls)
1108{ 1110{
1109 int ret = GNUNET_SYSERR; 1111 int ret = GNUNET_SYSERR;
1110 int sql_ret; 1112 int sql_ret;
1111 1113
1112 // FIXME
1113 if (NULL == plugin->mc || NULL == stmt || NULL == params)
1114 {
1115 fprintf(stderr, "%p %p %p\n", plugin->mc, stmt, params);
1116 return GNUNET_SYSERR;
1117 }
1118
1119 sql_ret = GNUNET_MY_exec_prepared (plugin->mc, stmt, params); 1114 sql_ret = GNUNET_MY_exec_prepared (plugin->mc, stmt, params);
1120 switch (sql_ret) 1115 switch (sql_ret)
1121 { 1116 {
diff --git a/src/psycstore/test_plugin_psycstore.c b/src/psycstore/test_plugin_psycstore.c
index 53971bf23..c1a456e60 100644
--- a/src/psycstore/test_plugin_psycstore.c
+++ b/src/psycstore/test_plugin_psycstore.c
@@ -25,6 +25,9 @@
25 * @file 25 * @file
26 * Test for the PSYCstore plugins. 26 * Test for the PSYCstore plugins.
27 */ 27 */
28
29#include <inttypes.h>
30
28#include "platform.h" 31#include "platform.h"
29#include "gnunet_util_lib.h" 32#include "gnunet_util_lib.h"
30#include "gnunet_testing_lib.h" 33#include "gnunet_testing_lib.h"
@@ -175,6 +178,8 @@ run (void *cls, char *const *args, const char *cfgfile,
175 178
176 /* Store & test membership */ 179 /* Store & test membership */
177 180
181 LOG (GNUNET_ERROR_TYPE_INFO, "MEMBERSHIP\n");
182
178 channel_key = GNUNET_CRYPTO_eddsa_key_create (); 183 channel_key = GNUNET_CRYPTO_eddsa_key_create ();
179 slave_key = GNUNET_CRYPTO_ecdsa_key_create (); 184 slave_key = GNUNET_CRYPTO_ecdsa_key_create ();
180 185
@@ -182,10 +187,14 @@ run (void *cls, char *const *args, const char *cfgfile,
182 &channel_pub_key); 187 &channel_pub_key);
183 GNUNET_CRYPTO_ecdsa_key_get_public (slave_key, &slave_pub_key); 188 GNUNET_CRYPTO_ecdsa_key_get_public (slave_key, &slave_pub_key);
184 189
190 LOG (GNUNET_ERROR_TYPE_INFO, "membership_store()\n");
191
185 GNUNET_assert (GNUNET_OK == db->membership_store (db->cls, &channel_pub_key, 192 GNUNET_assert (GNUNET_OK == db->membership_store (db->cls, &channel_pub_key,
186 &slave_pub_key, GNUNET_YES, 193 &slave_pub_key, GNUNET_YES,
187 4, 2, 1)); 194 4, 2, 1));
188 195
196 LOG (GNUNET_ERROR_TYPE_INFO, "membership_test()\n");
197
189 GNUNET_assert (GNUNET_YES == db->membership_test (db->cls, &channel_pub_key, 198 GNUNET_assert (GNUNET_YES == db->membership_test (db->cls, &channel_pub_key,
190 &slave_pub_key, 4)); 199 &slave_pub_key, 4));
191 200
@@ -195,9 +204,10 @@ run (void *cls, char *const *args, const char *cfgfile,
195 GNUNET_assert (GNUNET_NO == db->membership_test (db->cls, &channel_pub_key, 204 GNUNET_assert (GNUNET_NO == db->membership_test (db->cls, &channel_pub_key,
196 &slave_pub_key, 1)); 205 &slave_pub_key, 1));
197 206
198
199 /* Store & get messages */ 207 /* Store & get messages */
200 208
209 LOG (GNUNET_ERROR_TYPE_INFO, "MESSAGES\n");
210
201 struct GNUNET_MULTICAST_MessageHeader *msg 211 struct GNUNET_MULTICAST_MessageHeader *msg
202 = GNUNET_malloc (sizeof (*msg) + sizeof (channel_pub_key)); 212 = GNUNET_malloc (sizeof (*msg) + sizeof (channel_pub_key));
203 GNUNET_assert (msg != NULL); 213 GNUNET_assert (msg != NULL);
@@ -228,6 +238,8 @@ run (void *cls, char *const *args, const char *cfgfile,
228 GNUNET_assert (GNUNET_OK == 238 GNUNET_assert (GNUNET_OK ==
229 GNUNET_CRYPTO_eddsa_sign (channel_key, &msg->purpose, &msg->signature)); 239 GNUNET_CRYPTO_eddsa_sign (channel_key, &msg->purpose, &msg->signature));
230 240
241 LOG (GNUNET_ERROR_TYPE_INFO, "fragment_store()\n");
242
231 struct FragmentClosure fcls = { 0 }; 243 struct FragmentClosure fcls = { 0 };
232 fcls.n = 0; 244 fcls.n = 0;
233 fcls.msg[0] = msg; 245 fcls.msg[0] = msg;
@@ -237,6 +249,8 @@ run (void *cls, char *const *args, const char *cfgfile,
237 GNUNET_OK == db->fragment_store (db->cls, &channel_pub_key, msg, 249 GNUNET_OK == db->fragment_store (db->cls, &channel_pub_key, msg,
238 fcls.flags[0])); 250 fcls.flags[0]));
239 251
252 LOG (GNUNET_ERROR_TYPE_INFO, "fragment_get(%" PRIu64 ")\n", fragment_id);
253
240 uint64_t ret_frags = 0; 254 uint64_t ret_frags = 0;
241 GNUNET_assert ( 255 GNUNET_assert (
242 GNUNET_OK == db->fragment_get (db->cls, &channel_pub_key, 256 GNUNET_OK == db->fragment_get (db->cls, &channel_pub_key,
@@ -244,8 +258,19 @@ run (void *cls, char *const *args, const char *cfgfile,
244 &ret_frags, fragment_cb, &fcls)); 258 &ret_frags, fragment_cb, &fcls));
245 GNUNET_assert (fcls.n == 1); 259 GNUNET_assert (fcls.n == 1);
246 260
261 LOG (GNUNET_ERROR_TYPE_INFO, "fragment_get(%" PRIu64 ")\n", fragment_id+1);
262
263 ret_frags = 0;
264 GNUNET_assert (
265 GNUNET_OK == db->fragment_get (db->cls, &channel_pub_key,
266 fragment_id+1, fragment_id+1,
267 &ret_frags, fragment_cb, &fcls));
268 GNUNET_assert (fcls.n == 1);
269
247 // FIXME: test fragment_get_latest and message_get_latest 270 // FIXME: test fragment_get_latest and message_get_latest
248 271
272 LOG (GNUNET_ERROR_TYPE_INFO, "message_get_fragment()\n");
273
249 fcls.n = 0; 274 fcls.n = 0;
250 275
251 GNUNET_assert ( 276 GNUNET_assert (
@@ -255,11 +280,15 @@ run (void *cls, char *const *args, const char *cfgfile,
255 fragment_cb, &fcls)); 280 fragment_cb, &fcls));
256 GNUNET_assert (fcls.n == 1); 281 GNUNET_assert (fcls.n == 1);
257 282
283 LOG (GNUNET_ERROR_TYPE_INFO, "message_add_flags()\n");
284
258 GNUNET_assert ( 285 GNUNET_assert (
259 GNUNET_OK == db->message_add_flags (db->cls, &channel_pub_key, 286 GNUNET_OK == db->message_add_flags (db->cls, &channel_pub_key,
260 GNUNET_ntohll (msg->message_id), 287 GNUNET_ntohll (msg->message_id),
261 GNUNET_PSYCSTORE_MESSAGE_STATE_APPLIED)); 288 GNUNET_PSYCSTORE_MESSAGE_STATE_APPLIED));
262 289
290 LOG (GNUNET_ERROR_TYPE_INFO, "fragment_get(%" PRIu64 ")\n", fragment_id);
291
263 fcls.n = 0; 292 fcls.n = 0;
264 fcls.flags[0] |= GNUNET_PSYCSTORE_MESSAGE_STATE_APPLIED; 293 fcls.flags[0] |= GNUNET_PSYCSTORE_MESSAGE_STATE_APPLIED;
265 294
@@ -270,6 +299,8 @@ run (void *cls, char *const *args, const char *cfgfile,
270 299
271 GNUNET_assert (fcls.n == 1); 300 GNUNET_assert (fcls.n == 1);
272 301
302 LOG (GNUNET_ERROR_TYPE_INFO, "fragment_store()\n");
303
273 struct GNUNET_MULTICAST_MessageHeader *msg1 304 struct GNUNET_MULTICAST_MessageHeader *msg1
274 = GNUNET_malloc (sizeof (*msg1) + sizeof (channel_pub_key)); 305 = GNUNET_malloc (sizeof (*msg1) + sizeof (channel_pub_key));
275 306
@@ -285,6 +316,8 @@ run (void *cls, char *const *args, const char *cfgfile,
285 GNUNET_assert (GNUNET_OK == db->fragment_store (db->cls, &channel_pub_key, msg1, 316 GNUNET_assert (GNUNET_OK == db->fragment_store (db->cls, &channel_pub_key, msg1,
286 fcls.flags[1])); 317 fcls.flags[1]));
287 318
319 LOG (GNUNET_ERROR_TYPE_INFO, "message_get()\n");
320
288 GNUNET_assert ( 321 GNUNET_assert (
289 GNUNET_OK == db->message_get (db->cls, &channel_pub_key, 322 GNUNET_OK == db->message_get (db->cls, &channel_pub_key,
290 message_id, message_id, 0, 323 message_id, message_id, 0,
@@ -293,6 +326,8 @@ run (void *cls, char *const *args, const char *cfgfile,
293 326
294 /* Message counters */ 327 /* Message counters */
295 328
329 LOG (GNUNET_ERROR_TYPE_INFO, "counters_message_get()\n");
330
296 fragment_id = 0; 331 fragment_id = 0;
297 message_id = 0; 332 message_id = 0;
298 group_generation = 0; 333 group_generation = 0;
@@ -306,6 +341,10 @@ run (void *cls, char *const *args, const char *cfgfile,
306 341
307 /* Modify state */ 342 /* Modify state */
308 343
344 LOG (GNUNET_ERROR_TYPE_INFO, "STATE\n");
345
346 LOG (GNUNET_ERROR_TYPE_INFO, "state_modify_*()\n");
347
309 message_id = GNUNET_ntohll (fcls.msg[0]->message_id) + 1; 348 message_id = GNUNET_ntohll (fcls.msg[0]->message_id) + 1;
310 GNUNET_assert (GNUNET_OK == db->state_modify_begin (db->cls, &channel_pub_key, 349 GNUNET_assert (GNUNET_OK == db->state_modify_begin (db->cls, &channel_pub_key,
311 message_id, 0)); 350 message_id, 0));
@@ -323,6 +362,8 @@ run (void *cls, char *const *args, const char *cfgfile,
323 GNUNET_assert (GNUNET_OK == db->state_modify_end (db->cls, &channel_pub_key, 362 GNUNET_assert (GNUNET_OK == db->state_modify_end (db->cls, &channel_pub_key,
324 message_id)); 363 message_id));
325 364
365 LOG (GNUNET_ERROR_TYPE_INFO, "state_get()\n");
366
326 struct StateClosure scls = { 0 }; 367 struct StateClosure scls = { 0 };
327 scls.n = 0; 368 scls.n = 0;
328 scls.value[0] = "one two three"; 369 scls.value[0] = "one two three";
@@ -332,6 +373,8 @@ run (void *cls, char *const *args, const char *cfgfile,
332 state_cb, &scls)); 373 state_cb, &scls));
333 GNUNET_assert (scls.n == 1); 374 GNUNET_assert (scls.n == 1);
334 375
376 LOG (GNUNET_ERROR_TYPE_INFO, "state_get_prefix()\n");
377
335 scls.n = 0; 378 scls.n = 0;
336 scls.value[1] = slave_key; 379 scls.value[1] = slave_key;
337 scls.value_size[1] = sizeof (*slave_key); 380 scls.value_size[1] = sizeof (*slave_key);
@@ -340,14 +383,20 @@ run (void *cls, char *const *args, const char *cfgfile,
340 "_foo", state_cb, &scls)); 383 "_foo", state_cb, &scls));
341 GNUNET_assert (scls.n == 2); 384 GNUNET_assert (scls.n == 2);
342 385
386 LOG (GNUNET_ERROR_TYPE_INFO, "state_get_signed()\n");
387
343 scls.n = 0; 388 scls.n = 0;
344 GNUNET_assert (GNUNET_NO == db->state_get_signed (db->cls, &channel_pub_key, 389 GNUNET_assert (GNUNET_NO == db->state_get_signed (db->cls, &channel_pub_key,
345 state_cb, &scls)); 390 state_cb, &scls));
346 GNUNET_assert (scls.n == 0); 391 GNUNET_assert (scls.n == 0);
347 392
393 LOG (GNUNET_ERROR_TYPE_INFO, "state_update_signed()\n");
394
348 GNUNET_assert (GNUNET_OK == db->state_update_signed (db->cls, 395 GNUNET_assert (GNUNET_OK == db->state_update_signed (db->cls,
349 &channel_pub_key)); 396 &channel_pub_key));
350 397
398 LOG (GNUNET_ERROR_TYPE_INFO, "state_get_signed()\n");
399
351 scls.n = 0; 400 scls.n = 0;
352 GNUNET_assert (GNUNET_YES == db->state_get_signed (db->cls, &channel_pub_key, 401 GNUNET_assert (GNUNET_YES == db->state_get_signed (db->cls, &channel_pub_key,
353 state_cb, &scls)); 402 state_cb, &scls));
@@ -355,6 +404,8 @@ run (void *cls, char *const *args, const char *cfgfile,
355 404
356 /* State counters */ 405 /* State counters */
357 406
407 LOG (GNUNET_ERROR_TYPE_INFO, "counters_state_get()\n");
408
358 uint64_t max_state_msg_id = 0; 409 uint64_t max_state_msg_id = 0;
359 GNUNET_assert (GNUNET_OK == db->counters_state_get (db->cls, &channel_pub_key, 410 GNUNET_assert (GNUNET_OK == db->counters_state_get (db->cls, &channel_pub_key,
360 &max_state_msg_id) 411 &max_state_msg_id)
@@ -362,6 +413,8 @@ run (void *cls, char *const *args, const char *cfgfile,
362 413
363 /* State sync */ 414 /* State sync */
364 415
416 LOG (GNUNET_ERROR_TYPE_INFO, "state_sync_*()\n");
417
365 scls.n = 0; 418 scls.n = 0;
366 scls.value[0] = channel_key; 419 scls.value[0] = channel_key;
367 scls.value_size[0] = sizeof (*channel_key); 420 scls.value_size[0] = sizeof (*channel_key);
@@ -397,6 +450,8 @@ run (void *cls, char *const *args, const char *cfgfile,
397 450
398 /* Modify state after sync */ 451 /* Modify state after sync */
399 452
453 LOG (GNUNET_ERROR_TYPE_INFO, "state_modify_*()\n");
454
400 message_id = GNUNET_ntohll (fcls.msg[0]->message_id) + 6; 455 message_id = GNUNET_ntohll (fcls.msg[0]->message_id) + 6;
401 GNUNET_assert (GNUNET_OK == db->state_modify_begin (db->cls, &channel_pub_key, 456 GNUNET_assert (GNUNET_OK == db->state_modify_begin (db->cls, &channel_pub_key,
402 message_id, 457 message_id,
@@ -412,6 +467,8 @@ run (void *cls, char *const *args, const char *cfgfile,
412 467
413 /* Reset state */ 468 /* Reset state */
414 469
470 LOG (GNUNET_ERROR_TYPE_INFO, "state_reset()\n");
471
415 scls.n = 0; 472 scls.n = 0;
416 GNUNET_assert (GNUNET_OK == db->state_reset (db->cls, &channel_pub_key)); 473 GNUNET_assert (GNUNET_OK == db->state_reset (db->cls, &channel_pub_key));
417 GNUNET_assert (scls.n == 0); 474 GNUNET_assert (scls.n == 0);