diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-11-27 12:28:49 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-11-27 12:28:49 +0000 |
commit | 7f2fbbdb0027a16e8de322e40d346cb70809af8f (patch) | |
tree | d0c9b491017897f4290bfe4474009f5c62330289 /src/revocation/test_revocation.c | |
parent | 800ac5056afa9fb4b5add0e503ecd150e594151d (diff) | |
download | gnunet-7f2fbbdb0027a16e8de322e40d346cb70809af8f.tar.gz gnunet-7f2fbbdb0027a16e8de322e40d346cb70809af8f.zip |
minor corrections to revocation service
revocation testtest now passes
Diffstat (limited to 'src/revocation/test_revocation.c')
-rw-r--r-- | src/revocation/test_revocation.c | 76 |
1 files changed, 69 insertions, 7 deletions
diff --git a/src/revocation/test_revocation.c b/src/revocation/test_revocation.c index a04e1ecd5..c1278c650 100644 --- a/src/revocation/test_revocation.c +++ b/src/revocation/test_revocation.c | |||
@@ -18,8 +18,8 @@ | |||
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @file dv/test_transport_dv.c | 21 | * @file revocation/test_revocation.c |
22 | * @brief base testcase for testing distance vector transport | 22 | * @brief base testcase for revocation exchange |
23 | */ | 23 | */ |
24 | #include "platform.h" | 24 | #include "platform.h" |
25 | #include "gnunet_core_service.h" | 25 | #include "gnunet_core_service.h" |
@@ -33,6 +33,7 @@ struct TestPeer | |||
33 | { | 33 | { |
34 | struct GNUNET_TESTBED_Peer *p; | 34 | struct GNUNET_TESTBED_Peer *p; |
35 | struct GNUNET_TESTBED_Operation *identity_op; | 35 | struct GNUNET_TESTBED_Operation *identity_op; |
36 | struct GNUNET_TESTBED_Operation *core_op; | ||
36 | struct GNUNET_IDENTITY_Handle *idh; | 37 | struct GNUNET_IDENTITY_Handle *idh; |
37 | const struct GNUNET_CONFIGURATION_Handle *cfg; | 38 | const struct GNUNET_CONFIGURATION_Handle *cfg; |
38 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey; | 39 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey; |
@@ -41,6 +42,7 @@ struct TestPeer | |||
41 | struct GNUNET_IDENTITY_Operation *create_id_op; | 42 | struct GNUNET_IDENTITY_Operation *create_id_op; |
42 | struct GNUNET_IDENTITY_EgoLookup *ego_lookup; | 43 | struct GNUNET_IDENTITY_EgoLookup *ego_lookup; |
43 | struct GNUNET_REVOCATION_Handle *revok_handle; | 44 | struct GNUNET_REVOCATION_Handle *revok_handle; |
45 | struct GNUNET_CORE_Handle *ch; | ||
44 | uint64_t pow; | 46 | uint64_t pow; |
45 | }; | 47 | }; |
46 | 48 | ||
@@ -87,6 +89,11 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
87 | GNUNET_TESTBED_operation_done (testpeers[c].identity_op); | 89 | GNUNET_TESTBED_operation_done (testpeers[c].identity_op); |
88 | testpeers[c].identity_op = NULL; | 90 | testpeers[c].identity_op = NULL; |
89 | } | 91 | } |
92 | if (NULL != testpeers[c].core_op) | ||
93 | { | ||
94 | GNUNET_TESTBED_operation_done (testpeers[c].core_op); | ||
95 | testpeers[c].core_op = NULL; | ||
96 | } | ||
90 | } | 97 | } |
91 | GNUNET_SCHEDULER_shutdown (); | 98 | GNUNET_SCHEDULER_shutdown (); |
92 | ok = 0; | 99 | ok = 0; |
@@ -101,6 +108,7 @@ do_shutdown_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
101 | ok = 1; | 108 | ok = 1; |
102 | } | 109 | } |
103 | 110 | ||
111 | |||
104 | static void * | 112 | static void * |
105 | identity_connect_adapter (void *cls, | 113 | identity_connect_adapter (void *cls, |
106 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 114 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
@@ -249,6 +257,61 @@ identity_completion_cb (void *cls, struct GNUNET_TESTBED_Operation *op, | |||
249 | } | 257 | } |
250 | } | 258 | } |
251 | 259 | ||
260 | void static connect_cb (void *cls, const struct GNUNET_PeerIdentity *peer) | ||
261 | { | ||
262 | static int connects = 0; | ||
263 | connects++; | ||
264 | if (4 == connects) | ||
265 | { | ||
266 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "All peers connected ...\n"); | ||
267 | |||
268 | /* Connect to identity service */ | ||
269 | testpeers[0].identity_op = GNUNET_TESTBED_service_connect (NULL, | ||
270 | testpeers[0].p, "identity", identity_completion_cb, NULL, | ||
271 | &identity_connect_adapter, &identity_disconnect_adapter, | ||
272 | &testpeers[0]); | ||
273 | testpeers[1].identity_op = GNUNET_TESTBED_service_connect (NULL, | ||
274 | testpeers[1].p, "identity", identity_completion_cb, NULL, | ||
275 | &identity_connect_adapter, &identity_disconnect_adapter, | ||
276 | &testpeers[1]); | ||
277 | } | ||
278 | } | ||
279 | |||
280 | |||
281 | static void | ||
282 | core_completion_cb (void *cls, struct GNUNET_TESTBED_Operation *op, | ||
283 | void *ca_result, const char *emsg) | ||
284 | { | ||
285 | static int completed = 0; | ||
286 | completed++; | ||
287 | if (NUM_TEST_PEERS == completed) | ||
288 | { | ||
289 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Connected to CORE\n"); | ||
290 | } | ||
291 | } | ||
292 | |||
293 | |||
294 | static void * | ||
295 | core_connect_adapter (void *cls, | ||
296 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
297 | { | ||
298 | struct TestPeer *me = cls; | ||
299 | me->cfg = cfg; | ||
300 | me->ch = GNUNET_CORE_connect (cfg, me, NULL, &connect_cb, NULL, NULL, GNUNET_NO, NULL, GNUNET_NO, NULL); | ||
301 | if (NULL == me->ch) | ||
302 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to create CORE handle \n"); | ||
303 | return me->ch; | ||
304 | } | ||
305 | |||
306 | |||
307 | static void | ||
308 | core_disconnect_adapter (void *cls, void *op_result) | ||
309 | { | ||
310 | struct TestPeer *me = cls; | ||
311 | GNUNET_CORE_disconnect (me->ch); | ||
312 | me->ch = NULL; | ||
313 | } | ||
314 | |||
252 | static void | 315 | static void |
253 | test_connection (void *cls, struct GNUNET_TESTBED_RunHandle *h, | 316 | test_connection (void *cls, struct GNUNET_TESTBED_RunHandle *h, |
254 | unsigned int num_peers, struct GNUNET_TESTBED_Peer **peers, | 317 | unsigned int num_peers, struct GNUNET_TESTBED_Peer **peers, |
@@ -271,10 +334,9 @@ test_connection (void *cls, struct GNUNET_TESTBED_RunHandle *h, | |||
271 | { | 334 | { |
272 | testpeers[c].p = peers[c]; | 335 | testpeers[c].p = peers[c]; |
273 | 336 | ||
274 | /* Connect to identity service */ | 337 | testpeers[c].core_op = GNUNET_TESTBED_service_connect (NULL, |
275 | testpeers[c].identity_op = GNUNET_TESTBED_service_connect (NULL, | 338 | testpeers[c].p, "core", &core_completion_cb, NULL, |
276 | testpeers[c].p, "identity", identity_completion_cb, NULL, | 339 | &core_connect_adapter, &core_disconnect_adapter, |
277 | &identity_connect_adapter, &identity_disconnect_adapter, | ||
278 | &testpeers[c]); | 340 | &testpeers[c]); |
279 | } | 341 | } |
280 | } | 342 | } |
@@ -290,4 +352,4 @@ main (int argc, char *argv[]) | |||
290 | return ok; | 352 | return ok; |
291 | } | 353 | } |
292 | 354 | ||
293 | /* end of test_transport_dv.c */ | 355 | /* end of test_revocation.c */ |