diff options
Diffstat (limited to 'src/psyc/test_psyc.c')
-rw-r--r-- | src/psyc/test_psyc.c | 348 |
1 files changed, 310 insertions, 38 deletions
diff --git a/src/psyc/test_psyc.c b/src/psyc/test_psyc.c index 5eadef62c..044895809 100644 --- a/src/psyc/test_psyc.c +++ b/src/psyc/test_psyc.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include "gnunet_env_lib.h" | 35 | #include "gnunet_env_lib.h" |
36 | #include "gnunet_psyc_util_lib.h" | 36 | #include "gnunet_psyc_util_lib.h" |
37 | #include "gnunet_psyc_service.h" | 37 | #include "gnunet_psyc_service.h" |
38 | #include "gnunet_core_service.h" | ||
38 | 39 | ||
39 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) | 40 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) |
40 | 41 | ||
@@ -45,6 +46,9 @@ int res; | |||
45 | 46 | ||
46 | const struct GNUNET_CONFIGURATION_Handle *cfg; | 47 | const struct GNUNET_CONFIGURATION_Handle *cfg; |
47 | 48 | ||
49 | struct GNUNET_CORE_Handle *core; | ||
50 | struct GNUNET_PeerIdentity this_peer; | ||
51 | |||
48 | /** | 52 | /** |
49 | * Handle for task for timeout termination. | 53 | * Handle for task for timeout termination. |
50 | */ | 54 | */ |
@@ -53,6 +57,8 @@ GNUNET_SCHEDULER_TaskIdentifier end_badly_task; | |||
53 | struct GNUNET_PSYC_Master *mst; | 57 | struct GNUNET_PSYC_Master *mst; |
54 | struct GNUNET_PSYC_Slave *slv; | 58 | struct GNUNET_PSYC_Slave *slv; |
55 | 59 | ||
60 | struct GNUNET_PSYC_Channel *mst_chn, *slv_chn; | ||
61 | |||
56 | struct GNUNET_CRYPTO_EddsaPrivateKey *channel_key; | 62 | struct GNUNET_CRYPTO_EddsaPrivateKey *channel_key; |
57 | struct GNUNET_CRYPTO_EcdsaPrivateKey *slave_key; | 63 | struct GNUNET_CRYPTO_EcdsaPrivateKey *slave_key; |
58 | 64 | ||
@@ -80,9 +86,19 @@ uint8_t join_req_count; | |||
80 | 86 | ||
81 | enum | 87 | enum |
82 | { | 88 | { |
83 | TEST_NONE, | 89 | TEST_NONE = 0, |
84 | TEST_SLAVE_TRANSMIT, | 90 | TEST_MASTER_START = 1, |
85 | TEST_MASTER_TRANSMIT, | 91 | TEST_SLAVE_JOIN = 2, |
92 | TEST_SLAVE_TRANSMIT = 3, | ||
93 | TEST_MASTER_TRANSMIT = 4, | ||
94 | TEST_MASTER_HISTORY_REPLAY_LATEST = 5, | ||
95 | TEST_SLAVE_HISTORY_REPLAY_LATEST = 6, | ||
96 | TEST_MASTER_HISTORY_REPLAY = 7, | ||
97 | TEST_SLAVE_HISTORY_REPLAY = 8, | ||
98 | TEST_MASTER_STATE_GET = 9, | ||
99 | TEST_SLAVE_STATE_GET = 10, | ||
100 | TEST_MASTER_STATE_GET_PREFIX = 11, | ||
101 | TEST_SLAVE_STATE_GET_PREFIX = 12, | ||
86 | } test; | 102 | } test; |
87 | 103 | ||
88 | 104 | ||
@@ -118,6 +134,11 @@ void slave_parted (void *cls) | |||
118 | void | 134 | void |
119 | cleanup () | 135 | cleanup () |
120 | { | 136 | { |
137 | if (NULL != core) | ||
138 | { | ||
139 | GNUNET_CORE_disconnect (core); | ||
140 | core = NULL; | ||
141 | } | ||
121 | if (NULL != slv) | 142 | if (NULL != slv) |
122 | { | 143 | { |
123 | GNUNET_PSYC_slave_part (slv, GNUNET_NO, &slave_parted, NULL); | 144 | GNUNET_PSYC_slave_part (slv, GNUNET_NO, &slave_parted, NULL); |
@@ -177,13 +198,203 @@ end () | |||
177 | 198 | ||
178 | 199 | ||
179 | void | 200 | void |
201 | state_get_var (void *cls, const char *name, const void *value, size_t value_size) | ||
202 | { | ||
203 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
204 | "Got state var: %s\n%.*s\n", name, value_size, value); | ||
205 | } | ||
206 | |||
207 | |||
208 | /*** Slave state_get_prefix() ***/ | ||
209 | |||
210 | void | ||
211 | slave_state_get_prefix_result (void *cls, int64_t result, const char *err_msg) | ||
212 | { | ||
213 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
214 | "slave_state_get_prefix:\t%" PRId64 " (%s)\n", result, err_msg); | ||
215 | // FIXME: GNUNET_assert (2 == result); | ||
216 | end (); | ||
217 | } | ||
218 | |||
219 | |||
220 | void | ||
221 | slave_state_get_prefix () | ||
222 | { | ||
223 | test = TEST_SLAVE_STATE_GET_PREFIX; | ||
224 | GNUNET_PSYC_channel_state_get_prefix (slv_chn, "_foo", &state_get_var, | ||
225 | &slave_state_get_prefix_result, NULL); | ||
226 | } | ||
227 | |||
228 | |||
229 | /*** Master state_get_prefix() ***/ | ||
230 | |||
231 | |||
232 | void | ||
233 | master_state_get_prefix_result (void *cls, int64_t result, const char *err_msg) | ||
234 | { | ||
235 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
236 | "master_state_get_prefix:\t%" PRId64 " (%s)\n", result, err_msg); | ||
237 | // FIXME: GNUNET_assert (2 == result); | ||
238 | slave_state_get_prefix (); | ||
239 | } | ||
240 | |||
241 | |||
242 | void | ||
243 | master_state_get_prefix () | ||
244 | { | ||
245 | test = TEST_MASTER_STATE_GET_PREFIX; | ||
246 | GNUNET_PSYC_channel_state_get_prefix (mst_chn, "_foo", &state_get_var, | ||
247 | &master_state_get_prefix_result, NULL); | ||
248 | } | ||
249 | |||
250 | |||
251 | /*** Slave state_get() ***/ | ||
252 | |||
253 | |||
254 | void | ||
255 | slave_state_get_result (void *cls, int64_t result, const char *err_msg) | ||
256 | { | ||
257 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
258 | "slave_state_get:\t%" PRId64 " (%s)\n", result, err_msg); | ||
259 | // FIXME: GNUNET_assert (2 == result); | ||
260 | master_state_get_prefix (); | ||
261 | } | ||
262 | |||
263 | |||
264 | void | ||
265 | slave_state_get () | ||
266 | { | ||
267 | test = TEST_SLAVE_STATE_GET; | ||
268 | GNUNET_PSYC_channel_state_get (slv_chn, "_foo_bar_baz", &state_get_var, | ||
269 | &slave_state_get_result, NULL); | ||
270 | } | ||
271 | |||
272 | |||
273 | /*** Master state_get() ***/ | ||
274 | |||
275 | |||
276 | void | ||
277 | master_state_get_result (void *cls, int64_t result, const char *err_msg) | ||
278 | { | ||
279 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
280 | "master_state_get:\t%" PRId64 " (%s)\n", result, err_msg); | ||
281 | // FIXME: GNUNET_assert (1 == result); | ||
282 | slave_state_get (); | ||
283 | } | ||
284 | |||
285 | |||
286 | void | ||
287 | master_state_get () | ||
288 | { | ||
289 | test = TEST_MASTER_STATE_GET; | ||
290 | GNUNET_PSYC_channel_state_get (mst_chn, "_foo_bar_baz", &state_get_var, | ||
291 | &master_state_get_result, NULL); | ||
292 | } | ||
293 | |||
294 | |||
295 | /*** Slave history_replay() ***/ | ||
296 | |||
297 | void | ||
298 | slave_history_replay_result (void *cls, int64_t result, const char *err_msg) | ||
299 | { | ||
300 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
301 | "slave_history_replay:\t%" PRId64 " (%s)\n", result, err_msg); | ||
302 | GNUNET_assert (9 == result); | ||
303 | |||
304 | master_state_get (); | ||
305 | } | ||
306 | |||
307 | |||
308 | void | ||
309 | slave_history_replay () | ||
310 | { | ||
311 | test = TEST_SLAVE_HISTORY_REPLAY; | ||
312 | GNUNET_PSYC_channel_history_replay (slv_chn, 1, 1, | ||
313 | &slave_history_replay_result, | ||
314 | NULL); | ||
315 | } | ||
316 | |||
317 | |||
318 | /*** Master history_replay() ***/ | ||
319 | |||
320 | |||
321 | void | ||
322 | master_history_replay_result (void *cls, int64_t result, const char *err_msg) | ||
323 | { | ||
324 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
325 | "master_history_replay:\t%" PRId64 " (%s)\n", result, err_msg); | ||
326 | GNUNET_assert (9 == result); | ||
327 | |||
328 | slave_history_replay (); | ||
329 | } | ||
330 | |||
331 | |||
332 | void | ||
333 | master_history_replay () | ||
334 | { | ||
335 | test = TEST_MASTER_HISTORY_REPLAY; | ||
336 | GNUNET_PSYC_channel_history_replay (mst_chn, 1, 1, | ||
337 | &master_history_replay_result, | ||
338 | NULL); | ||
339 | } | ||
340 | |||
341 | |||
342 | /*** Slave history_replay_latest() ***/ | ||
343 | |||
344 | |||
345 | void | ||
346 | slave_history_replay_latest_result (void *cls, int64_t result, const char *err_msg) | ||
347 | { | ||
348 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
349 | "slave_history_replay_latest:\t%" PRId64 " (%s)\n", result, err_msg); | ||
350 | GNUNET_assert (9 == result); | ||
351 | |||
352 | master_history_replay (); | ||
353 | } | ||
354 | |||
355 | |||
356 | void | ||
357 | slave_history_replay_latest () | ||
358 | { | ||
359 | test = TEST_SLAVE_HISTORY_REPLAY_LATEST; | ||
360 | GNUNET_PSYC_channel_history_replay_latest (slv_chn, 1, | ||
361 | &slave_history_replay_latest_result, | ||
362 | NULL); | ||
363 | } | ||
364 | |||
365 | |||
366 | /*** Master history_replay_latest() ***/ | ||
367 | |||
368 | |||
369 | void | ||
370 | master_history_replay_latest_result (void *cls, int64_t result, const char *err_msg) | ||
371 | { | ||
372 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
373 | "master_history_replay_latest:\t%" PRId64 " (%s)\n", result, err_msg); | ||
374 | GNUNET_assert (9 == result); | ||
375 | |||
376 | slave_history_replay_latest (); | ||
377 | } | ||
378 | |||
379 | |||
380 | void | ||
381 | master_history_replay_latest () | ||
382 | { | ||
383 | test = TEST_MASTER_HISTORY_REPLAY_LATEST; | ||
384 | GNUNET_PSYC_channel_history_replay_latest (mst_chn, 1, | ||
385 | &master_history_replay_latest_result, | ||
386 | NULL); | ||
387 | } | ||
388 | |||
389 | |||
390 | void | ||
180 | master_message_cb (void *cls, uint64_t message_id, uint32_t flags, | 391 | master_message_cb (void *cls, uint64_t message_id, uint32_t flags, |
181 | const struct GNUNET_PSYC_MessageHeader *msg) | 392 | const struct GNUNET_PSYC_MessageHeader *msg) |
182 | { | 393 | { |
183 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 394 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
184 | "Master got PSYC message fragment of size %u " | 395 | "Test #%d: Master got PSYC message fragment of size %u " |
185 | "belonging to message ID %llu with flags %x\n", | 396 | "belonging to message ID %" PRIu64 " with flags %x\n", |
186 | ntohs (msg->header.size), message_id, flags); | 397 | test, ntohs (msg->header.size), message_id, flags); |
187 | // FIXME | 398 | // FIXME |
188 | } | 399 | } |
189 | 400 | ||
@@ -196,7 +407,7 @@ master_message_part_cb (void *cls, uint64_t message_id, | |||
196 | if (NULL == msg) | 407 | if (NULL == msg) |
197 | { | 408 | { |
198 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 409 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
199 | "Error while receiving message %llu\n", message_id); | 410 | "Error while receiving message %" PRIu64 "\n", message_id); |
200 | return; | 411 | return; |
201 | } | 412 | } |
202 | 413 | ||
@@ -204,9 +415,9 @@ master_message_part_cb (void *cls, uint64_t message_id, | |||
204 | uint16_t size = ntohs (msg->size); | 415 | uint16_t size = ntohs (msg->size); |
205 | 416 | ||
206 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 417 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
207 | "Master got message part of type %u and size %u " | 418 | "Test #%d: Master got message part of type %u and size %u " |
208 | "belonging to message ID %llu with flags %x\n", | 419 | "belonging to message ID %" PRIu64 " with flags %x\n", |
209 | type, size, message_id, flags); | 420 | test, type, size, message_id, flags); |
210 | 421 | ||
211 | switch (test) | 422 | switch (test) |
212 | { | 423 | { |
@@ -227,6 +438,18 @@ master_message_part_cb (void *cls, uint64_t message_id, | |||
227 | case TEST_MASTER_TRANSMIT: | 438 | case TEST_MASTER_TRANSMIT: |
228 | break; | 439 | break; |
229 | 440 | ||
441 | case TEST_MASTER_HISTORY_REPLAY: | ||
442 | case TEST_MASTER_HISTORY_REPLAY_LATEST: | ||
443 | if (GNUNET_PSYC_MESSAGE_HISTORIC != flags) | ||
444 | { | ||
445 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
446 | "Test #%d: Unexpected flags for historic message: %x" PRIu32 "\n", | ||
447 | flags); | ||
448 | GNUNET_assert (0); | ||
449 | return; | ||
450 | } | ||
451 | break; | ||
452 | |||
230 | default: | 453 | default: |
231 | GNUNET_assert (0); | 454 | GNUNET_assert (0); |
232 | } | 455 | } |
@@ -238,9 +461,9 @@ slave_message_cb (void *cls, uint64_t message_id, uint32_t flags, | |||
238 | const struct GNUNET_PSYC_MessageHeader *msg) | 461 | const struct GNUNET_PSYC_MessageHeader *msg) |
239 | { | 462 | { |
240 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 463 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
241 | "Slave got PSYC message fragment of size %u " | 464 | "Test #%d: Slave got PSYC message fragment of size %u " |
242 | "belonging to message ID %llu with flags %x\n", | 465 | "belonging to message ID %" PRIu64 " with flags %x\n", |
243 | ntohs (msg->header.size), message_id, flags); | 466 | test, ntohs (msg->header.size), message_id, flags); |
244 | // FIXME | 467 | // FIXME |
245 | } | 468 | } |
246 | 469 | ||
@@ -253,7 +476,7 @@ slave_message_part_cb (void *cls, uint64_t message_id, | |||
253 | if (NULL == msg) | 476 | if (NULL == msg) |
254 | { | 477 | { |
255 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 478 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
256 | "Error while receiving message %llu\n", message_id); | 479 | "Error while receiving message " PRIu64 "\n", message_id); |
257 | return; | 480 | return; |
258 | } | 481 | } |
259 | 482 | ||
@@ -261,15 +484,27 @@ slave_message_part_cb (void *cls, uint64_t message_id, | |||
261 | uint16_t size = ntohs (msg->size); | 484 | uint16_t size = ntohs (msg->size); |
262 | 485 | ||
263 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 486 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
264 | "Slave got message part of type %u and size %u " | 487 | "Test #%d: Slave got message part of type %u and size %u " |
265 | "belonging to message ID %llu with flags %x\n", | 488 | "belonging to message ID %" PRIu64 " with flags %x\n", |
266 | type, size, message_id, flags); | 489 | test, type, size, message_id, flags); |
267 | 490 | ||
268 | switch (test) | 491 | switch (test) |
269 | { | 492 | { |
270 | case TEST_MASTER_TRANSMIT: | 493 | case TEST_MASTER_TRANSMIT: |
271 | if (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END == type) | 494 | if (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END == type) |
272 | end (); | 495 | master_history_replay_latest (); |
496 | break; | ||
497 | |||
498 | case TEST_SLAVE_HISTORY_REPLAY: | ||
499 | case TEST_SLAVE_HISTORY_REPLAY_LATEST: | ||
500 | if (GNUNET_PSYC_MESSAGE_HISTORIC != flags) | ||
501 | { | ||
502 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
503 | "Test #%d: Unexpected flags for historic message: %x" PRIu32 "\n", | ||
504 | flags); | ||
505 | GNUNET_assert (0); | ||
506 | return; | ||
507 | } | ||
273 | break; | 508 | break; |
274 | 509 | ||
275 | default: | 510 | default: |
@@ -417,7 +652,6 @@ slave_transmit () | |||
417 | { | 652 | { |
418 | 653 | ||
419 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Slave sending request to master.\n"); | 654 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Slave sending request to master.\n"); |
420 | |||
421 | test = TEST_SLAVE_TRANSMIT; | 655 | test = TEST_SLAVE_TRANSMIT; |
422 | 656 | ||
423 | tmit = GNUNET_new (struct TransmitClosure); | 657 | tmit = GNUNET_new (struct TransmitClosure); |
@@ -438,6 +672,29 @@ slave_transmit () | |||
438 | 672 | ||
439 | 673 | ||
440 | void | 674 | void |
675 | slave_remove_cb (void *cls, int64_t result, const char *err_msg) | ||
676 | { | ||
677 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
678 | "slave_remove:\t%" PRId64 " (%s)\n", result, err_msg); | ||
679 | |||
680 | slave_transmit (); | ||
681 | } | ||
682 | |||
683 | |||
684 | void | ||
685 | slave_add_cb (void *cls, int64_t result, const char *err_msg) | ||
686 | { | ||
687 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
688 | "slave_add:\t%" PRId64 " (%s)\n", result, err_msg); | ||
689 | |||
690 | struct GNUNET_PSYC_Channel *chn = cls; | ||
691 | GNUNET_PSYC_channel_slave_remove (chn, &slave_pub_key, 2, | ||
692 | &slave_remove_cb, chn); | ||
693 | |||
694 | } | ||
695 | |||
696 | |||
697 | void | ||
441 | join_decision_cb (void *cls, | 698 | join_decision_cb (void *cls, |
442 | const struct GNUNET_PSYC_JoinDecisionMessage *dcsn, | 699 | const struct GNUNET_PSYC_JoinDecisionMessage *dcsn, |
443 | int is_admitted, | 700 | int is_admitted, |
@@ -453,7 +710,8 @@ join_decision_cb (void *cls, | |||
453 | return; | 710 | return; |
454 | } | 711 | } |
455 | 712 | ||
456 | slave_transmit (); | 713 | struct GNUNET_PSYC_Channel *chn = GNUNET_PSYC_master_get_channel (mst); |
714 | GNUNET_PSYC_channel_slave_add (chn, &slave_pub_key, 2, 2, &slave_add_cb, chn); | ||
457 | } | 715 | } |
458 | 716 | ||
459 | 717 | ||
@@ -473,19 +731,17 @@ join_request_cb (void *cls, | |||
473 | /* Reject first request */ | 731 | /* Reject first request */ |
474 | int is_admitted = (0 < join_req_count++) ? GNUNET_YES : GNUNET_NO; | 732 | int is_admitted = (0 < join_req_count++) ? GNUNET_YES : GNUNET_NO; |
475 | GNUNET_PSYC_join_decision (jh, is_admitted, 0, NULL, NULL); | 733 | GNUNET_PSYC_join_decision (jh, is_admitted, 0, NULL, NULL); |
476 | |||
477 | /* Membership store */ | ||
478 | struct GNUNET_PSYC_Channel *chn = GNUNET_PSYC_master_get_channel (mst); | ||
479 | GNUNET_PSYC_channel_slave_add (chn, slave_key, 2, 2); | ||
480 | GNUNET_PSYC_channel_slave_remove (chn, &slave_pub_key, 2); | ||
481 | } | 734 | } |
482 | 735 | ||
483 | 736 | ||
484 | void | 737 | void |
485 | slave_connect_cb (void *cls, uint64_t max_message_id) | 738 | slave_connect_cb (void *cls, int result, uint64_t max_message_id) |
486 | { | 739 | { |
487 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 740 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
488 | "Slave connected: %lu\n", max_message_id); | 741 | "Slave connected: %d, max_message_id: %" PRIu64 "\n", |
742 | result, max_message_id); | ||
743 | GNUNET_assert (TEST_SLAVE_JOIN == test); | ||
744 | GNUNET_assert (GNUNET_OK == result || GNUNET_NO == result); | ||
489 | } | 745 | } |
490 | 746 | ||
491 | 747 | ||
@@ -493,8 +749,9 @@ void | |||
493 | slave_join () | 749 | slave_join () |
494 | { | 750 | { |
495 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Joining slave.\n"); | 751 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Joining slave.\n"); |
752 | test = TEST_SLAVE_JOIN; | ||
496 | 753 | ||
497 | struct GNUNET_PeerIdentity origin = {}; // FIXME: this peer | 754 | struct GNUNET_PeerIdentity origin = this_peer; |
498 | struct GNUNET_ENV_Environment *env = GNUNET_ENV_environment_create (); | 755 | struct GNUNET_ENV_Environment *env = GNUNET_ENV_environment_create (); |
499 | GNUNET_ENV_environment_add (env, GNUNET_ENV_OP_ASSIGN, | 756 | GNUNET_ENV_environment_add (env, GNUNET_ENV_OP_ASSIGN, |
500 | "_foo", "bar baz", 7); | 757 | "_foo", "bar baz", 7); |
@@ -507,6 +764,7 @@ slave_join () | |||
507 | &slave_message_cb, &slave_message_part_cb, | 764 | &slave_message_cb, &slave_message_part_cb, |
508 | &slave_connect_cb, &join_decision_cb, NULL, | 765 | &slave_connect_cb, &join_decision_cb, NULL, |
509 | join_msg); | 766 | join_msg); |
767 | slv_chn = GNUNET_PSYC_slave_get_channel (slv); | ||
510 | GNUNET_ENV_environment_destroy (env); | 768 | GNUNET_ENV_environment_destroy (env); |
511 | } | 769 | } |
512 | 770 | ||
@@ -564,10 +822,13 @@ master_transmit () | |||
564 | 822 | ||
565 | 823 | ||
566 | void | 824 | void |
567 | master_start_cb (void *cls, uint64_t max_message_id) | 825 | master_start_cb (void *cls, int result, uint64_t max_message_id) |
568 | { | 826 | { |
569 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 827 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
570 | "Master started: %" PRIu64 "\n", max_message_id); | 828 | "Master started: %d, max_message_id: %" PRIu64 "\n", |
829 | result, max_message_id); | ||
830 | GNUNET_assert (TEST_MASTER_START == test); | ||
831 | GNUNET_assert (GNUNET_OK == result || GNUNET_NO == result); | ||
571 | slave_join (); | 832 | slave_join (); |
572 | } | 833 | } |
573 | 834 | ||
@@ -576,10 +837,12 @@ void | |||
576 | master_start () | 837 | master_start () |
577 | { | 838 | { |
578 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Starting master.\n"); | 839 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Starting master.\n"); |
840 | test = TEST_MASTER_START; | ||
579 | mst = GNUNET_PSYC_master_start (cfg, channel_key, GNUNET_PSYC_CHANNEL_PRIVATE, | 841 | mst = GNUNET_PSYC_master_start (cfg, channel_key, GNUNET_PSYC_CHANNEL_PRIVATE, |
580 | &master_start_cb, &join_request_cb, | 842 | &master_start_cb, &join_request_cb, |
581 | &master_message_cb, &master_message_part_cb, | 843 | &master_message_cb, &master_message_part_cb, |
582 | NULL); | 844 | NULL); |
845 | mst_chn = GNUNET_PSYC_master_get_channel (mst); | ||
583 | } | 846 | } |
584 | 847 | ||
585 | void | 848 | void |
@@ -589,6 +852,21 @@ schedule_master_start (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
589 | } | 852 | } |
590 | 853 | ||
591 | 854 | ||
855 | void | ||
856 | core_connected (void *cls, const struct GNUNET_PeerIdentity *my_identity) | ||
857 | { | ||
858 | this_peer = *my_identity; | ||
859 | |||
860 | #if DEBUG_TEST_PSYC | ||
861 | master_start (); | ||
862 | #else | ||
863 | /* Allow some time for the services to initialize. */ | ||
864 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | ||
865 | &schedule_master_start, NULL); | ||
866 | #endif | ||
867 | |||
868 | } | ||
869 | |||
592 | /** | 870 | /** |
593 | * Main function of the test, run from scheduler. | 871 | * Main function of the test, run from scheduler. |
594 | * | 872 | * |
@@ -615,14 +893,8 @@ run (void *cls, | |||
615 | GNUNET_CRYPTO_eddsa_key_get_public (channel_key, &channel_pub_key); | 893 | GNUNET_CRYPTO_eddsa_key_get_public (channel_key, &channel_pub_key); |
616 | GNUNET_CRYPTO_ecdsa_key_get_public (slave_key, &slave_pub_key); | 894 | GNUNET_CRYPTO_ecdsa_key_get_public (slave_key, &slave_pub_key); |
617 | 895 | ||
618 | #if DEBUG_TEST_PSYC | 896 | core = GNUNET_CORE_connect (cfg, NULL, &core_connected, NULL, NULL, |
619 | master_start (); | 897 | NULL, GNUNET_NO, NULL, GNUNET_NO, NULL); |
620 | #else | ||
621 | /* Allow some time for the services to initialize. */ | ||
622 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | ||
623 | &schedule_master_start, NULL); | ||
624 | #endif | ||
625 | return; | ||
626 | } | 898 | } |
627 | 899 | ||
628 | 900 | ||