aboutsummaryrefslogtreecommitdiff
path: root/src/testing/testing_api_cmd_block_until_all_peers_started.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/testing_api_cmd_block_until_all_peers_started.c')
-rw-r--r--src/testing/testing_api_cmd_block_until_all_peers_started.c66
1 files changed, 17 insertions, 49 deletions
diff --git a/src/testing/testing_api_cmd_block_until_all_peers_started.c b/src/testing/testing_api_cmd_block_until_all_peers_started.c
index e9d3f0ed3..763713e15 100644
--- a/src/testing/testing_api_cmd_block_until_all_peers_started.c
+++ b/src/testing/testing_api_cmd_block_until_all_peers_started.c
@@ -39,6 +39,11 @@
39struct BlockState 39struct BlockState
40{ 40{
41 /** 41 /**
42 * Context for our asynchronous completion.
43 */
44 struct GNUNET_TESTING_AsyncContext ac;
45
46 /**
42 * Flag to indicate if all peers have started. 47 * Flag to indicate if all peers have started.
43 * 48 *
44 */ 49 */
@@ -47,26 +52,11 @@ struct BlockState
47 52
48 53
49/** 54/**
50 * Trait function of this cmd does nothing.
51 *
52 */
53static int
54block_until_all_peers_started_traits (void *cls,
55 const void **ret,
56 const char *trait,
57 unsigned int index)
58{
59 return GNUNET_OK;
60}
61
62
63/**
64 * The cleanup function of this cmd frees resources the cmd allocated. 55 * The cleanup function of this cmd frees resources the cmd allocated.
65 * 56 *
66 */ 57 */
67static void 58static void
68block_until_all_peers_started_cleanup (void *cls, 59block_until_all_peers_started_cleanup (void *cls)
69 const struct GNUNET_TESTING_Command *cmd)
70{ 60{
71 struct BlockState *bs = cls; 61 struct BlockState *bs = cls;
72 62
@@ -80,7 +70,6 @@ block_until_all_peers_started_cleanup (void *cls,
80 */ 70 */
81static void 71static void
82block_until_all_peers_started_run (void *cls, 72block_until_all_peers_started_run (void *cls,
83 const struct GNUNET_TESTING_Command *cmd,
84 struct GNUNET_TESTING_Interpreter *is) 73 struct GNUNET_TESTING_Interpreter *is)
85{ 74{
86 LOG (GNUNET_ERROR_TYPE_DEBUG, 75 LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -89,27 +78,6 @@ block_until_all_peers_started_run (void *cls,
89 78
90 79
91/** 80/**
92 * Function to check if BlockState#all_peers_started is GNUNET_YES. In that case interpreter_next will be called.
93 *
94 */
95static int
96block_until_all_peers_started_finish (void *cls,
97 GNUNET_SCHEDULER_TaskCallback cont,
98 void *cont_cls)
99{
100 struct BlockState *bs = cls;
101 unsigned int *ret = bs->all_peers_started;
102
103 if (GNUNET_YES == *ret)
104 {
105 cont (cont_cls);
106 }
107
108 return *ret;
109}
110
111
112/**
113 * Create command. 81 * Create command.
114 * 82 *
115 * @param label name for command. 83 * @param label name for command.
@@ -125,15 +93,15 @@ GNUNET_TESTING_cmd_block_until_all_peers_started (const char *label,
125 93
126 bs = GNUNET_new (struct BlockState); 94 bs = GNUNET_new (struct BlockState);
127 bs->all_peers_started = all_peers_started; 95 bs->all_peers_started = all_peers_started;
128 96 {
129 struct GNUNET_TESTING_Command cmd = { 97 struct GNUNET_TESTING_Command cmd = {
130 .cls = bs, 98 .cls = bs,
131 .label = label, 99 .label = label,
132 .run = &block_until_all_peers_started_run, 100 .run = &block_until_all_peers_started_run,
133 .finish = &block_until_all_peers_started_finish, 101 .ac = &bs->ac,
134 .cleanup = &block_until_all_peers_started_cleanup, 102 .cleanup = &block_until_all_peers_started_cleanup
135 .traits = &block_until_all_peers_started_traits 103 };
136 }; 104
137 105 return cmd;
138 return cmd; 106 }
139} 107}