summaryrefslogtreecommitdiff
path: root/src/psycstore/test_psycstore.c
diff options
context:
space:
mode:
authorGabor X Toth <*@tg-x.net>2013-09-25 17:46:03 +0000
committerGabor X Toth <*@tg-x.net>2013-09-25 17:46:03 +0000
commit303d6a97bc552a337c992944c3151ea53c1f74dc (patch)
tree295d478fd8e82879830588da0c47778512ffad9b /src/psycstore/test_psycstore.c
parentffc11bb1c2c09cda9e7bed84e56cedb8ed49d46c (diff)
downloadgnunet-303d6a97bc552a337c992944c3151ea53c1f74dc.tar.gz
gnunet-303d6a97bc552a337c992944c3151ea53c1f74dc.zip
psycstore: single counters function for master & slave
Diffstat (limited to 'src/psycstore/test_psycstore.c')
-rw-r--r--src/psycstore/test_psycstore.c71
1 files changed, 28 insertions, 43 deletions
diff --git a/src/psycstore/test_psycstore.c b/src/psycstore/test_psycstore.c
index cfda6819e..bb6f88665 100644
--- a/src/psycstore/test_psycstore.c
+++ b/src/psycstore/test_psycstore.c
@@ -28,8 +28,8 @@
28#include "platform.h" 28#include "platform.h"
29#include "gnunet_common.h" 29#include "gnunet_common.h"
30#include "gnunet_util_lib.h" 30#include "gnunet_util_lib.h"
31#include "gnunet_psycstore_service.h"
32#include "gnunet_testing_lib.h" 31#include "gnunet_testing_lib.h"
32#include "gnunet_psycstore_service.h"
33 33
34#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) 34#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
35 35
@@ -231,16 +231,20 @@ state_get_result (void *cls, int64_t result, const char *err_msg)
231 231
232 232
233void 233void
234counters_slave_result (void *cls, uint64_t max_state_msg_id) 234counters_result (void *cls, uint64_t max_fragment_id, uint64_t max_message_id,
235 uint64_t max_group_generation, uint64_t max_state_message_id)
235{ 236{
236 struct FragmentClosure *fcls = cls; 237 struct FragmentClosure *fcls = cls;
237 int result = 0; 238 int result = 0;
238 op = NULL; 239 op = NULL;
239 240
240 if (max_state_msg_id == GNUNET_ntohll (fcls->msg[0]->message_id)) 241 if (max_fragment_id == GNUNET_ntohll (fcls->msg[2]->fragment_id)
242 && max_message_id == GNUNET_ntohll (fcls->msg[2]->message_id)
243 && max_group_generation == GNUNET_ntohll (fcls->msg[2]->group_generation)
244 && max_state_message_id == GNUNET_ntohll (fcls->msg[0]->message_id))
241 result = 1; 245 result = 1;
242 246
243 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "counters_get_slave:\t%d\n", result); 247 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "counters_get:\t%d\n", result);
244 GNUNET_assert (result == 1); 248 GNUNET_assert (result == 1);
245 249
246 scls.n = 0; 250 scls.n = 0;
@@ -260,8 +264,8 @@ state_modify_result (void *cls, int64_t result, const char *err_msg)
260 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "state_modify_result:\t%d\n", result); 264 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "state_modify_result:\t%d\n", result);
261 GNUNET_assert (GNUNET_OK == result); 265 GNUNET_assert (GNUNET_OK == result);
262 266
263 op = GNUNET_PSYCSTORE_counters_get_slave (h, &channel_pub_key, 267 op = GNUNET_PSYCSTORE_counters_get (h, &channel_pub_key,
264 &counters_slave_result, cls); 268 &counters_result, cls);
265} 269}
266 270
267 271
@@ -292,41 +296,6 @@ state_sync_result (void *cls, int64_t result, const char *err_msg)
292} 296}
293 297
294 298
295void
296counters_master_result (void *cls, uint64_t fragment_id, uint64_t message_id,
297 uint64_t group_generation)
298{
299 struct FragmentClosure *fcls = cls;
300 int result = 0;
301 op = NULL;
302
303 if (fragment_id == GNUNET_ntohll (fcls->msg[2]->fragment_id) &&
304 message_id == GNUNET_ntohll (fcls->msg[2]->message_id) &&
305 group_generation == GNUNET_ntohll (fcls->msg[2]->group_generation))
306 result = 1;
307
308 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "counters_get_master:\t%d\n", result);
309 GNUNET_assert (result == 1);
310
311 modifiers[0] = (struct GNUNET_ENV_Modifier) {
312 .oper = '=',
313 .name = "_sync_foo",
314 .value = "three two one",
315 .value_size = sizeof ("three two one") - 1
316 };
317 modifiers[1] = (struct GNUNET_ENV_Modifier) {
318 .oper = '=',
319 .name = "_sync_bar",
320 .value = "ten eleven twelve",
321 .value_size = sizeof ("ten eleven twelve") - 1
322 };
323
324 op = GNUNET_PSYCSTORE_state_sync (h, &channel_pub_key,
325 GNUNET_ntohll (fcls->msg[0]->message_id) + 1,
326 2, modifiers, state_sync_result, fcls);
327}
328
329
330int 299int
331fragment_result (void *cls, 300fragment_result (void *cls,
332 struct GNUNET_MULTICAST_MessageHeader *msg, 301 struct GNUNET_MULTICAST_MessageHeader *msg,
@@ -361,8 +330,24 @@ message_get_result (void *cls, int64_t result, const char *err_msg)
361 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "message_get:\t%d\n", result); 330 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "message_get:\t%d\n", result);
362 GNUNET_assert (result > 0 && fcls->n && fcls->n_expected); 331 GNUNET_assert (result > 0 && fcls->n && fcls->n_expected);
363 332
364 op = GNUNET_PSYCSTORE_counters_get_master (h, &channel_pub_key, 333
365 &counters_master_result, fcls); 334
335 modifiers[0] = (struct GNUNET_ENV_Modifier) {
336 .oper = '=',
337 .name = "_sync_foo",
338 .value = "three two one",
339 .value_size = sizeof ("three two one") - 1
340 };
341 modifiers[1] = (struct GNUNET_ENV_Modifier) {
342 .oper = '=',
343 .name = "_sync_bar",
344 .value = "ten eleven twelve",
345 .value_size = sizeof ("ten eleven twelve") - 1
346 };
347
348 op = GNUNET_PSYCSTORE_state_sync (h, &channel_pub_key,
349 GNUNET_ntohll (fcls->msg[0]->message_id) + 1,
350 2, modifiers, state_sync_result, fcls);
366} 351}
367 352
368 353