aboutsummaryrefslogtreecommitdiff
path: root/src/psyc/test_psyc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/psyc/test_psyc.c')
-rw-r--r--src/psyc/test_psyc.c117
1 files changed, 61 insertions, 56 deletions
diff --git a/src/psyc/test_psyc.c b/src/psyc/test_psyc.c
index 1169b49d5..5ea83dd63 100644
--- a/src/psyc/test_psyc.c
+++ b/src/psyc/test_psyc.c
@@ -41,28 +41,28 @@
41/** 41/**
42 * Return value from 'main'. 42 * Return value from 'main'.
43 */ 43 */
44int res; 44static int res;
45 45
46const struct GNUNET_CONFIGURATION_Handle *cfg; 46static const struct GNUNET_CONFIGURATION_Handle *cfg;
47 47
48struct GNUNET_CORE_Handle *core; 48static struct GNUNET_CORE_Handle *core;
49struct GNUNET_PeerIdentity this_peer; 49static struct GNUNET_PeerIdentity this_peer;
50 50
51/** 51/**
52 * Handle for task for timeout termination. 52 * Handle for task for timeout termination.
53 */ 53 */
54struct GNUNET_SCHEDULER_Task * end_badly_task; 54static struct GNUNET_SCHEDULER_Task * end_badly_task;
55 55
56struct GNUNET_PSYC_Master *mst; 56static struct GNUNET_PSYC_Master *mst;
57struct GNUNET_PSYC_Slave *slv; 57static struct GNUNET_PSYC_Slave *slv;
58 58
59struct GNUNET_PSYC_Channel *mst_chn, *slv_chn; 59static struct GNUNET_PSYC_Channel *mst_chn, *slv_chn;
60 60
61struct GNUNET_CRYPTO_EddsaPrivateKey *channel_key; 61static struct GNUNET_CRYPTO_EddsaPrivateKey *channel_key;
62struct GNUNET_CRYPTO_EcdsaPrivateKey *slave_key; 62static struct GNUNET_CRYPTO_EcdsaPrivateKey *slave_key;
63 63
64struct GNUNET_CRYPTO_EddsaPublicKey channel_pub_key; 64static struct GNUNET_CRYPTO_EddsaPublicKey channel_pub_key;
65struct GNUNET_CRYPTO_EcdsaPublicKey slave_pub_key; 65static struct GNUNET_CRYPTO_EcdsaPublicKey slave_pub_key;
66 66
67struct TransmitClosure 67struct TransmitClosure
68{ 68{
@@ -79,9 +79,9 @@ struct TransmitClosure
79 uint8_t n; 79 uint8_t n;
80}; 80};
81 81
82struct TransmitClosure *tmit; 82static struct TransmitClosure *tmit;
83 83
84uint8_t join_req_count, end_count; 84static uint8_t join_req_count, end_count;
85 85
86enum 86enum
87{ 87{
@@ -104,14 +104,15 @@ enum
104} test; 104} test;
105 105
106 106
107void 107static void
108master_transmit (); 108master_transmit ();
109 109
110void 110static void
111master_history_replay_latest (); 111master_history_replay_latest ();
112 112
113 113
114void master_stopped (void *cls) 114static void
115master_stopped (void *cls)
115{ 116{
116 if (NULL != tmit) 117 if (NULL != tmit)
117 { 118 {
@@ -122,7 +123,9 @@ void master_stopped (void *cls)
122 GNUNET_SCHEDULER_shutdown (); 123 GNUNET_SCHEDULER_shutdown ();
123} 124}
124 125
125void slave_parted (void *cls) 126
127static void
128slave_parted (void *cls)
126{ 129{
127 if (NULL != mst) 130 if (NULL != mst)
128 { 131 {
@@ -133,10 +136,11 @@ void slave_parted (void *cls)
133 master_stopped (NULL); 136 master_stopped (NULL);
134} 137}
135 138
139
136/** 140/**
137 * Clean up all resources used. 141 * Clean up all resources used.
138 */ 142 */
139void 143static void
140cleanup () 144cleanup ()
141{ 145{
142 if (NULL != core) 146 if (NULL != core)
@@ -185,7 +189,7 @@ end_normally (void *cls)
185/** 189/**
186 * Finish the test case (successfully). 190 * Finish the test case (successfully).
187 */ 191 */
188void 192static void
189end () 193end ()
190{ 194{
191 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ending tests.\n"); 195 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ending tests.\n");
@@ -200,7 +204,7 @@ end ()
200} 204}
201 205
202 206
203void 207static void
204master_message_cb (void *cls, const struct GNUNET_PSYC_MessageHeader *msg) 208master_message_cb (void *cls, const struct GNUNET_PSYC_MessageHeader *msg)
205{ 209{
206 GNUNET_assert (NULL != msg); 210 GNUNET_assert (NULL != msg);
@@ -213,7 +217,7 @@ master_message_cb (void *cls, const struct GNUNET_PSYC_MessageHeader *msg)
213} 217}
214 218
215 219
216void 220static void
217master_message_part_cb (void *cls, const struct GNUNET_PSYC_MessageHeader *msg, 221master_message_part_cb (void *cls, const struct GNUNET_PSYC_MessageHeader *msg,
218 const struct GNUNET_MessageHeader *pmsg) 222 const struct GNUNET_MessageHeader *pmsg)
219{ 223{
@@ -270,7 +274,7 @@ master_message_part_cb (void *cls, const struct GNUNET_PSYC_MessageHeader *msg,
270} 274}
271 275
272 276
273void 277static void
274slave_message_cb (void *cls, const struct GNUNET_PSYC_MessageHeader *msg) 278slave_message_cb (void *cls, const struct GNUNET_PSYC_MessageHeader *msg)
275{ 279{
276 GNUNET_assert (NULL != msg); 280 GNUNET_assert (NULL != msg);
@@ -283,7 +287,7 @@ slave_message_cb (void *cls, const struct GNUNET_PSYC_MessageHeader *msg)
283} 287}
284 288
285 289
286void 290static void
287slave_message_part_cb (void *cls, 291slave_message_part_cb (void *cls,
288 const struct GNUNET_PSYC_MessageHeader *msg, 292 const struct GNUNET_PSYC_MessageHeader *msg,
289 const struct GNUNET_MessageHeader *pmsg) 293 const struct GNUNET_MessageHeader *pmsg)
@@ -326,7 +330,7 @@ slave_message_part_cb (void *cls,
326} 330}
327 331
328 332
329void 333static void
330state_get_var (void *cls, const struct GNUNET_MessageHeader *mod, 334state_get_var (void *cls, const struct GNUNET_MessageHeader *mod,
331 const char *name, const void *value, 335 const char *name, const void *value,
332 uint32_t value_size, uint32_t full_value_size) 336 uint32_t value_size, uint32_t full_value_size)
@@ -338,7 +342,7 @@ state_get_var (void *cls, const struct GNUNET_MessageHeader *mod,
338 342
339/*** Slave state_get_prefix() ***/ 343/*** Slave state_get_prefix() ***/
340 344
341void 345static void
342slave_state_get_prefix_result (void *cls, int64_t result, 346slave_state_get_prefix_result (void *cls, int64_t result,
343 const void *err_msg, uint16_t err_msg_size) 347 const void *err_msg, uint16_t err_msg_size)
344{ 348{
@@ -350,7 +354,7 @@ slave_state_get_prefix_result (void *cls, int64_t result,
350} 354}
351 355
352 356
353void 357static void
354slave_state_get_prefix () 358slave_state_get_prefix ()
355{ 359{
356 test = TEST_SLAVE_STATE_GET_PREFIX; 360 test = TEST_SLAVE_STATE_GET_PREFIX;
@@ -362,7 +366,7 @@ slave_state_get_prefix ()
362/*** Master state_get_prefix() ***/ 366/*** Master state_get_prefix() ***/
363 367
364 368
365void 369static void
366master_state_get_prefix_result (void *cls, int64_t result, 370master_state_get_prefix_result (void *cls, int64_t result,
367 const void *err_msg, uint16_t err_msg_size) 371 const void *err_msg, uint16_t err_msg_size)
368{ 372{
@@ -373,7 +377,7 @@ master_state_get_prefix_result (void *cls, int64_t result,
373} 377}
374 378
375 379
376void 380static void
377master_state_get_prefix () 381master_state_get_prefix ()
378{ 382{
379 test = TEST_MASTER_STATE_GET_PREFIX; 383 test = TEST_MASTER_STATE_GET_PREFIX;
@@ -385,7 +389,7 @@ master_state_get_prefix ()
385/*** Slave state_get() ***/ 389/*** Slave state_get() ***/
386 390
387 391
388void 392static void
389slave_state_get_result (void *cls, int64_t result, 393slave_state_get_result (void *cls, int64_t result,
390 const void *err_msg, uint16_t err_msg_size) 394 const void *err_msg, uint16_t err_msg_size)
391{ 395{
@@ -397,7 +401,7 @@ slave_state_get_result (void *cls, int64_t result,
397} 401}
398 402
399 403
400void 404static void
401slave_state_get () 405slave_state_get ()
402{ 406{
403 test = TEST_SLAVE_STATE_GET; 407 test = TEST_SLAVE_STATE_GET;
@@ -409,7 +413,7 @@ slave_state_get ()
409/*** Master state_get() ***/ 413/*** Master state_get() ***/
410 414
411 415
412void 416static void
413master_state_get_result (void *cls, int64_t result, 417master_state_get_result (void *cls, int64_t result,
414 const void *err_msg, uint16_t err_msg_size) 418 const void *err_msg, uint16_t err_msg_size)
415{ 419{
@@ -421,7 +425,7 @@ master_state_get_result (void *cls, int64_t result,
421} 425}
422 426
423 427
424void 428static void
425master_state_get () 429master_state_get ()
426{ 430{
427 test = TEST_MASTER_STATE_GET; 431 test = TEST_MASTER_STATE_GET;
@@ -432,7 +436,7 @@ master_state_get ()
432 436
433/*** Slave history_replay() ***/ 437/*** Slave history_replay() ***/
434 438
435void 439static void
436slave_history_replay_result (void *cls, int64_t result, 440slave_history_replay_result (void *cls, int64_t result,
437 const void *err_msg, uint16_t err_msg_size) 441 const void *err_msg, uint16_t err_msg_size)
438{ 442{
@@ -445,7 +449,7 @@ slave_history_replay_result (void *cls, int64_t result,
445} 449}
446 450
447 451
448void 452static void
449slave_history_replay () 453slave_history_replay ()
450{ 454{
451 test = TEST_SLAVE_HISTORY_REPLAY; 455 test = TEST_SLAVE_HISTORY_REPLAY;
@@ -460,7 +464,7 @@ slave_history_replay ()
460/*** Master history_replay() ***/ 464/*** Master history_replay() ***/
461 465
462 466
463void 467static void
464master_history_replay_result (void *cls, int64_t result, 468master_history_replay_result (void *cls, int64_t result,
465 const void *err_msg, uint16_t err_msg_size) 469 const void *err_msg, uint16_t err_msg_size)
466{ 470{
@@ -473,7 +477,7 @@ master_history_replay_result (void *cls, int64_t result,
473} 477}
474 478
475 479
476void 480static void
477master_history_replay () 481master_history_replay ()
478{ 482{
479 test = TEST_MASTER_HISTORY_REPLAY; 483 test = TEST_MASTER_HISTORY_REPLAY;
@@ -488,7 +492,7 @@ master_history_replay ()
488/*** Slave history_replay_latest() ***/ 492/*** Slave history_replay_latest() ***/
489 493
490 494
491void 495static void
492slave_history_replay_latest_result (void *cls, int64_t result, 496slave_history_replay_latest_result (void *cls, int64_t result,
493 const void *err_msg, uint16_t err_msg_size) 497 const void *err_msg, uint16_t err_msg_size)
494{ 498{
@@ -501,7 +505,7 @@ slave_history_replay_latest_result (void *cls, int64_t result,
501} 505}
502 506
503 507
504void 508static void
505slave_history_replay_latest () 509slave_history_replay_latest ()
506{ 510{
507 test = TEST_SLAVE_HISTORY_REPLAY_LATEST; 511 test = TEST_SLAVE_HISTORY_REPLAY_LATEST;
@@ -517,7 +521,7 @@ slave_history_replay_latest ()
517/*** Master history_replay_latest() ***/ 521/*** Master history_replay_latest() ***/
518 522
519 523
520void 524static void
521master_history_replay_latest_result (void *cls, int64_t result, 525master_history_replay_latest_result (void *cls, int64_t result,
522 const void *err_msg, uint16_t err_msg_size) 526 const void *err_msg, uint16_t err_msg_size)
523{ 527{
@@ -530,7 +534,7 @@ master_history_replay_latest_result (void *cls, int64_t result,
530} 534}
531 535
532 536
533void 537static void
534master_history_replay_latest () 538master_history_replay_latest ()
535{ 539{
536 test = TEST_MASTER_HISTORY_REPLAY_LATEST; 540 test = TEST_MASTER_HISTORY_REPLAY_LATEST;
@@ -555,7 +559,7 @@ transmit_resume (void *cls)
555} 559}
556 560
557 561
558int 562static int
559tmit_notify_data (void *cls, uint16_t *data_size, void *data) 563tmit_notify_data (void *cls, uint16_t *data_size, void *data)
560{ 564{
561 struct TransmitClosure *tmit = cls; 565 struct TransmitClosure *tmit = cls;
@@ -598,7 +602,7 @@ tmit_notify_data (void *cls, uint16_t *data_size, void *data)
598} 602}
599 603
600 604
601int 605static int
602tmit_notify_mod (void *cls, uint16_t *data_size, void *data, uint8_t *oper, 606tmit_notify_mod (void *cls, uint16_t *data_size, void *data, uint8_t *oper,
603 uint32_t *full_value_size) 607 uint32_t *full_value_size)
604{ 608{
@@ -678,7 +682,7 @@ static void
678slave_join (); 682slave_join ();
679 683
680 684
681void 685static void
682slave_transmit () 686slave_transmit ()
683{ 687{
684 test = TEST_SLAVE_TRANSMIT; 688 test = TEST_SLAVE_TRANSMIT;
@@ -702,7 +706,7 @@ slave_transmit ()
702} 706}
703 707
704 708
705void 709static void
706slave_remove_cb (void *cls, int64_t result, 710slave_remove_cb (void *cls, int64_t result,
707 const void *err_msg, uint16_t err_msg_size) 711 const void *err_msg, uint16_t err_msg_size)
708{ 712{
@@ -714,7 +718,7 @@ slave_remove_cb (void *cls, int64_t result,
714} 718}
715 719
716 720
717void 721static void
718slave_remove () 722slave_remove ()
719{ 723{
720 test = TEST_SLAVE_REMOVE; 724 test = TEST_SLAVE_REMOVE;
@@ -724,7 +728,7 @@ slave_remove ()
724} 728}
725 729
726 730
727void 731static void
728slave_add_cb (void *cls, int64_t result, 732slave_add_cb (void *cls, int64_t result,
729 const void *err_msg, uint16_t err_msg_size) 733 const void *err_msg, uint16_t err_msg_size)
730{ 734{
@@ -735,7 +739,7 @@ slave_add_cb (void *cls, int64_t result,
735} 739}
736 740
737 741
738void 742static void
739slave_add () 743slave_add ()
740{ 744{
741 test = TEST_SLAVE_ADD; 745 test = TEST_SLAVE_ADD;
@@ -744,7 +748,8 @@ slave_add ()
744} 748}
745 749
746 750
747void first_slave_parted (void *cls) 751static void
752first_slave_parted (void *cls)
748{ 753{
749 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "First slave parted.\n"); 754 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "First slave parted.\n");
750 slave_join (TEST_SLAVE_JOIN_ACCEPT); 755 slave_join (TEST_SLAVE_JOIN_ACCEPT);
@@ -754,7 +759,7 @@ void first_slave_parted (void *cls)
754static void 759static void
755schedule_slave_part (void *cls) 760schedule_slave_part (void *cls)
756{ 761{
757 GNUNET_PSYC_slave_part (slv, GNUNET_NO, first_slave_parted, NULL); 762 GNUNET_PSYC_slave_part (slv, GNUNET_NO, &first_slave_parted, NULL);
758} 763}
759 764
760 765
@@ -772,7 +777,7 @@ join_decision_cb (void *cls,
772 case TEST_SLAVE_JOIN_REJECT: 777 case TEST_SLAVE_JOIN_REJECT:
773 GNUNET_assert (0 == is_admitted); 778 GNUNET_assert (0 == is_admitted);
774 GNUNET_assert (1 == join_req_count); 779 GNUNET_assert (1 == join_req_count);
775 GNUNET_SCHEDULER_add_now (schedule_slave_part, NULL); 780 GNUNET_SCHEDULER_add_now (&schedule_slave_part, NULL);
776 break; 781 break;
777 782
778 case TEST_SLAVE_JOIN_ACCEPT: 783 case TEST_SLAVE_JOIN_ACCEPT:
@@ -844,7 +849,7 @@ slave_join (int t)
844} 849}
845 850
846 851
847void 852static void
848master_transmit () 853master_transmit ()
849{ 854{
850 test = TEST_MASTER_TRANSMIT; 855 test = TEST_MASTER_TRANSMIT;
@@ -899,7 +904,7 @@ master_transmit ()
899} 904}
900 905
901 906
902void 907static void
903master_start_cb (void *cls, int result, uint64_t max_message_id) 908master_start_cb (void *cls, int result, uint64_t max_message_id)
904{ 909{
905 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 910 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -911,7 +916,7 @@ master_start_cb (void *cls, int result, uint64_t max_message_id)
911} 916}
912 917
913 918
914void 919static void
915master_start () 920master_start ()
916{ 921{
917 test = TEST_MASTER_START; 922 test = TEST_MASTER_START;
@@ -931,7 +936,7 @@ schedule_master_start (void *cls)
931} 936}
932 937
933 938
934void 939static void
935core_connected (void *cls, const struct GNUNET_PeerIdentity *my_identity) 940core_connected (void *cls, const struct GNUNET_PeerIdentity *my_identity)
936{ 941{
937 this_peer = *my_identity; 942 this_peer = *my_identity;
@@ -953,7 +958,7 @@ core_connected (void *cls, const struct GNUNET_PeerIdentity *my_identity)
953 * @param cfg configuration we use (also to connect to PSYC service) 958 * @param cfg configuration we use (also to connect to PSYC service)
954 * @param peer handle to access more of the peer (not used) 959 * @param peer handle to access more of the peer (not used)
955 */ 960 */
956void 961static void
957#if DEBUG_TEST_PSYC 962#if DEBUG_TEST_PSYC
958run (void *cls, char *const *args, const char *cfgfile, 963run (void *cls, char *const *args, const char *cfgfile,
959 const struct GNUNET_CONFIGURATION_Handle *c) 964 const struct GNUNET_CONFIGURATION_Handle *c)