diff options
Diffstat (limited to 'src/set/test_set_intersection_result_full.c')
-rw-r--r-- | src/set/test_set_intersection_result_full.c | 97 |
1 files changed, 74 insertions, 23 deletions
diff --git a/src/set/test_set_intersection_result_full.c b/src/set/test_set_intersection_result_full.c index f78a03eaf..a36aae4d5 100644 --- a/src/set/test_set_intersection_result_full.c +++ b/src/set/test_set_intersection_result_full.c | |||
@@ -56,10 +56,14 @@ static struct GNUNET_SET_OperationHandle *oh2; | |||
56 | static void | 56 | static void |
57 | result_cb_set1 (void *cls, | 57 | result_cb_set1 (void *cls, |
58 | const struct GNUNET_SET_Element *element, | 58 | const struct GNUNET_SET_Element *element, |
59 | uint64_t current_size, | ||
59 | enum GNUNET_SET_Status status) | 60 | enum GNUNET_SET_Status status) |
60 | { | 61 | { |
61 | static int count; | 62 | static int count; |
62 | 63 | ||
64 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
65 | "Processing result set 1 (%d)\n", | ||
66 | status); | ||
63 | switch (status) | 67 | switch (status) |
64 | { | 68 | { |
65 | case GNUNET_SET_STATUS_OK: | 69 | case GNUNET_SET_STATUS_OK: |
@@ -74,6 +78,8 @@ result_cb_set1 (void *cls, | |||
74 | GNUNET_assert (1 == count); | 78 | GNUNET_assert (1 == count); |
75 | GNUNET_SET_destroy (set1); | 79 | GNUNET_SET_destroy (set1); |
76 | set1 = NULL; | 80 | set1 = NULL; |
81 | if (NULL == set2) | ||
82 | GNUNET_SCHEDULER_shutdown (); | ||
77 | break; | 83 | break; |
78 | default: | 84 | default: |
79 | GNUNET_assert (0); | 85 | GNUNET_assert (0); |
@@ -84,10 +90,14 @@ result_cb_set1 (void *cls, | |||
84 | static void | 90 | static void |
85 | result_cb_set2 (void *cls, | 91 | result_cb_set2 (void *cls, |
86 | const struct GNUNET_SET_Element *element, | 92 | const struct GNUNET_SET_Element *element, |
93 | uint64_t current_size, | ||
87 | enum GNUNET_SET_Status status) | 94 | enum GNUNET_SET_Status status) |
88 | { | 95 | { |
89 | static int count; | 96 | static int count; |
90 | 97 | ||
98 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
99 | "Processing result set 2 (%d)\n", | ||
100 | status); | ||
91 | switch (status) | 101 | switch (status) |
92 | { | 102 | { |
93 | case GNUNET_SET_STATUS_OK: | 103 | case GNUNET_SET_STATUS_OK: |
@@ -102,6 +112,8 @@ result_cb_set2 (void *cls, | |||
102 | GNUNET_assert (1 == count); | 112 | GNUNET_assert (1 == count); |
103 | GNUNET_SET_destroy (set2); | 113 | GNUNET_SET_destroy (set2); |
104 | set2 = NULL; | 114 | set2 = NULL; |
115 | if (NULL == set1) | ||
116 | GNUNET_SCHEDULER_shutdown (); | ||
105 | break; | 117 | break; |
106 | default: | 118 | default: |
107 | GNUNET_assert (0); | 119 | GNUNET_assert (0); |
@@ -115,14 +127,17 @@ listen_cb (void *cls, | |||
115 | const struct GNUNET_MessageHeader *context_msg, | 127 | const struct GNUNET_MessageHeader *context_msg, |
116 | struct GNUNET_SET_Request *request) | 128 | struct GNUNET_SET_Request *request) |
117 | { | 129 | { |
130 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
131 | "starting intersection by accepting and committing\n"); | ||
118 | GNUNET_assert (NULL != context_msg); | 132 | GNUNET_assert (NULL != context_msg); |
119 | GNUNET_assert (ntohs (context_msg->type) == GNUNET_MESSAGE_TYPE_DUMMY); | 133 | GNUNET_assert (ntohs (context_msg->type) == GNUNET_MESSAGE_TYPE_DUMMY); |
120 | GNUNET_SET_listen_cancel (listen_handle); | 134 | GNUNET_SET_listen_cancel (listen_handle); |
121 | listen_handle = NULL; | 135 | listen_handle = NULL; |
122 | oh2 = GNUNET_SET_accept (request, | 136 | oh2 = GNUNET_SET_accept (request, |
123 | GNUNET_SET_RESULT_FULL, | 137 | GNUNET_SET_RESULT_FULL, |
124 | &result_cb_set2, | 138 | (struct GNUNET_SET_Option[]) { 0 }, |
125 | NULL); | 139 | &result_cb_set2, |
140 | NULL); | ||
126 | GNUNET_SET_commit (oh2, | 141 | GNUNET_SET_commit (oh2, |
127 | set2); | 142 | set2); |
128 | } | 143 | } |
@@ -138,17 +153,21 @@ start (void *cls) | |||
138 | { | 153 | { |
139 | struct GNUNET_MessageHeader context_msg; | 154 | struct GNUNET_MessageHeader context_msg; |
140 | 155 | ||
156 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
157 | "starting listener\n"); | ||
141 | context_msg.size = htons (sizeof context_msg); | 158 | context_msg.size = htons (sizeof context_msg); |
142 | context_msg.type = htons (GNUNET_MESSAGE_TYPE_DUMMY); | 159 | context_msg.type = htons (GNUNET_MESSAGE_TYPE_DUMMY); |
143 | listen_handle = GNUNET_SET_listen (config, | 160 | listen_handle = GNUNET_SET_listen (config, |
144 | GNUNET_SET_OPERATION_INTERSECTION, | 161 | GNUNET_SET_OPERATION_INTERSECTION, |
145 | &app_id, | 162 | &app_id, |
146 | &listen_cb, NULL); | 163 | &listen_cb, |
164 | NULL); | ||
147 | oh1 = GNUNET_SET_prepare (&local_id, | 165 | oh1 = GNUNET_SET_prepare (&local_id, |
148 | &app_id, | 166 | &app_id, |
149 | &context_msg, | 167 | &context_msg, |
150 | GNUNET_SET_RESULT_FULL, | 168 | GNUNET_SET_RESULT_FULL, |
151 | &result_cb_set1, | 169 | (struct GNUNET_SET_Option[]) { 0 }, |
170 | &result_cb_set1, | ||
152 | NULL); | 171 | NULL); |
153 | GNUNET_SET_commit (oh1, | 172 | GNUNET_SET_commit (oh1, |
154 | set1); | 173 | set1); |
@@ -170,13 +189,22 @@ init_set2 (void *cls) | |||
170 | element.element_type = 0; | 189 | element.element_type = 0; |
171 | element.data = "hello"; | 190 | element.data = "hello"; |
172 | element.size = strlen(element.data); | 191 | element.size = strlen(element.data); |
173 | GNUNET_SET_add_element (set2, &element, NULL, NULL); | 192 | GNUNET_SET_add_element (set2, |
193 | &element, | ||
194 | NULL, | ||
195 | NULL); | ||
174 | element.data = "quux"; | 196 | element.data = "quux"; |
175 | element.size = strlen(element.data); | 197 | element.size = strlen(element.data); |
176 | GNUNET_SET_add_element (set2, &element, NULL, NULL); | 198 | GNUNET_SET_add_element (set2, |
199 | &element, | ||
200 | NULL, | ||
201 | NULL); | ||
177 | element.data = "baz"; | 202 | element.data = "baz"; |
178 | element.size = strlen(element.data); | 203 | element.size = strlen(element.data); |
179 | GNUNET_SET_add_element (set2, &element, &start, NULL); | 204 | GNUNET_SET_add_element (set2, |
205 | &element, | ||
206 | &start, | ||
207 | NULL); | ||
180 | } | 208 | } |
181 | 209 | ||
182 | 210 | ||
@@ -188,13 +216,21 @@ init_set1 (void) | |||
188 | { | 216 | { |
189 | struct GNUNET_SET_Element element; | 217 | struct GNUNET_SET_Element element; |
190 | 218 | ||
219 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
220 | "initializing set 1\n"); | ||
191 | element.element_type = 0; | 221 | element.element_type = 0; |
192 | element.data = "hello"; | 222 | element.data = "hello"; |
193 | element.size = strlen(element.data); | 223 | element.size = strlen(element.data); |
194 | GNUNET_SET_add_element (set1, &element, NULL, NULL); | 224 | GNUNET_SET_add_element (set1, |
225 | &element, | ||
226 | NULL, | ||
227 | NULL); | ||
195 | element.data = "bar"; | 228 | element.data = "bar"; |
196 | element.size = strlen(element.data); | 229 | element.size = strlen(element.data); |
197 | GNUNET_SET_add_element (set1, &element, &init_set2, NULL); | 230 | GNUNET_SET_add_element (set1, |
231 | &element, | ||
232 | &init_set2, | ||
233 | NULL); | ||
198 | } | 234 | } |
199 | 235 | ||
200 | 236 | ||
@@ -219,17 +255,27 @@ test_iter () | |||
219 | struct GNUNET_SET_Element element; | 255 | struct GNUNET_SET_Element element; |
220 | struct GNUNET_SET_Handle *iter_set; | 256 | struct GNUNET_SET_Handle *iter_set; |
221 | 257 | ||
222 | iter_set = GNUNET_SET_create (config, GNUNET_SET_OPERATION_INTERSECTION); | 258 | iter_set = GNUNET_SET_create (config, |
259 | GNUNET_SET_OPERATION_INTERSECTION); | ||
223 | element.element_type = 0; | 260 | element.element_type = 0; |
224 | element.data = "hello"; | 261 | element.data = "hello"; |
225 | element.size = strlen(element.data); | 262 | element.size = strlen(element.data); |
226 | GNUNET_SET_add_element (iter_set, &element, NULL, NULL); | 263 | GNUNET_SET_add_element (iter_set, |
264 | &element, | ||
265 | NULL, | ||
266 | NULL); | ||
227 | element.data = "bar"; | 267 | element.data = "bar"; |
228 | element.size = strlen(element.data); | 268 | element.size = strlen(element.data); |
229 | GNUNET_SET_add_element (iter_set, &element, NULL, NULL); | 269 | GNUNET_SET_add_element (iter_set, |
270 | &element, | ||
271 | NULL, | ||
272 | NULL); | ||
230 | element.data = "quux"; | 273 | element.data = "quux"; |
231 | element.size = strlen(element.data); | 274 | element.size = strlen(element.data); |
232 | GNUNET_SET_add_element (iter_set, &element, NULL, NULL); | 275 | GNUNET_SET_add_element (iter_set, |
276 | &element, | ||
277 | NULL, | ||
278 | NULL); | ||
233 | GNUNET_SET_iterate (iter_set, | 279 | GNUNET_SET_iterate (iter_set, |
234 | &iter_cb, | 280 | &iter_cb, |
235 | iter_set); | 281 | iter_set); |
@@ -307,8 +353,10 @@ run (void *cls, | |||
307 | struct GNUNET_TESTING_Peer *peer) | 353 | struct GNUNET_TESTING_Peer *peer) |
308 | { | 354 | { |
309 | config = cfg; | 355 | config = cfg; |
310 | GNUNET_TESTING_peer_get_identity (peer, &local_id); | 356 | GNUNET_TESTING_peer_get_identity (peer, |
311 | if (0) test_iter (); | 357 | &local_id); |
358 | if (0) | ||
359 | test_iter (); | ||
312 | 360 | ||
313 | tt = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5), | 361 | tt = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5), |
314 | &timeout_fail, | 362 | &timeout_fail, |
@@ -316,8 +364,10 @@ run (void *cls, | |||
316 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, | 364 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, |
317 | NULL); | 365 | NULL); |
318 | 366 | ||
319 | set1 = GNUNET_SET_create (cfg, GNUNET_SET_OPERATION_INTERSECTION); | 367 | set1 = GNUNET_SET_create (cfg, |
320 | set2 = GNUNET_SET_create (cfg, GNUNET_SET_OPERATION_INTERSECTION); | 368 | GNUNET_SET_OPERATION_INTERSECTION); |
369 | set2 = GNUNET_SET_create (cfg, | ||
370 | GNUNET_SET_OPERATION_INTERSECTION); | ||
321 | GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, | 371 | GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, |
322 | &app_id); | 372 | &app_id); |
323 | 373 | ||
@@ -327,9 +377,10 @@ run (void *cls, | |||
327 | 377 | ||
328 | 378 | ||
329 | int | 379 | int |
330 | main (int argc, char **argv) | 380 | main (int argc, |
381 | char **argv) | ||
331 | { | 382 | { |
332 | if (0 != GNUNET_TESTING_peer_run ("test_set_api", | 383 | if (0 != GNUNET_TESTING_peer_run ("test_set_intersection_result_full", |
333 | "test_set.conf", | 384 | "test_set.conf", |
334 | &run, NULL)) | 385 | &run, NULL)) |
335 | return 1; | 386 | return 1; |