aboutsummaryrefslogtreecommitdiff
path: root/src/set/test_set_api.c
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2013-05-22 10:29:15 +0000
committerFlorian Dold <florian.dold@gmail.com>2013-05-22 10:29:15 +0000
commit4289fca5aeefd0652ae60bc16f90ed911c7e1c60 (patch)
treeda266c48ada44f11ce88a38833960b0eb08c1c5d /src/set/test_set_api.c
parent3418f171c455980c99ac6363a74116243bddede6 (diff)
downloadgnunet-4289fca5aeefd0652ae60bc16f90ed911c7e1c60.tar.gz
gnunet-4289fca5aeefd0652ae60bc16f90ed911c7e1c60.zip
- moved MQ to util
- MQ support for stream - set api - starting to use set for consensus
Diffstat (limited to 'src/set/test_set_api.c')
-rw-r--r--src/set/test_set_api.c48
1 files changed, 40 insertions, 8 deletions
diff --git a/src/set/test_set_api.c b/src/set/test_set_api.c
index 0ab02cad7..66e7a81d1 100644
--- a/src/set/test_set_api.c
+++ b/src/set/test_set_api.c
@@ -29,26 +29,57 @@
29 29
30 30
31static struct GNUNET_PeerIdentity local_id; 31static struct GNUNET_PeerIdentity local_id;
32
32static struct GNUNET_HashCode app_id; 33static struct GNUNET_HashCode app_id;
33static struct GNUNET_SET_Handle *set1; 34static struct GNUNET_SET_Handle *set1;
34static struct GNUNET_SET_Handle *set2; 35static struct GNUNET_SET_Handle *set2;
35static struct GNUNET_SET_ListenHandle *listen_handle; 36static struct GNUNET_SET_ListenHandle *listen_handle;
36const static struct GNUNET_CONFIGURATION_Handle *config; 37const static struct GNUNET_CONFIGURATION_Handle *config;
37 38
39int num_done;
40
38 41
39static void 42static void
40result_cb_set1 (void *cls, struct GNUNET_SET_Element *element, 43result_cb_set1 (void *cls, const struct GNUNET_SET_Element *element,
41 enum GNUNET_SET_Status status) 44 enum GNUNET_SET_Status status)
42{ 45{
43 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "got result (set 1)\n"); 46 switch (status)
47 {
48 case GNUNET_SET_STATUS_OK:
49 printf ("set 1: got element\n");
50 break;
51 case GNUNET_SET_STATUS_FAILURE:
52 printf ("set 1: failure\n");
53 break;
54 case GNUNET_SET_STATUS_DONE:
55 printf ("set 1: done\n");
56 GNUNET_SET_destroy (set1);
57 break;
58 default:
59 GNUNET_assert (0);
60 }
44} 61}
45 62
46 63
47static void 64static void
48result_cb_set2 (void *cls, struct GNUNET_SET_Element *element, 65result_cb_set2 (void *cls, const struct GNUNET_SET_Element *element,
49 enum GNUNET_SET_Status status) 66 enum GNUNET_SET_Status status)
50{ 67{
51 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "got result (set 2)\n"); 68 switch (status)
69 {
70 case GNUNET_SET_STATUS_OK:
71 printf ("set 2: got element\n");
72 break;
73 case GNUNET_SET_STATUS_FAILURE:
74 printf ("set 2: failure\n");
75 break;
76 case GNUNET_SET_STATUS_DONE:
77 printf ("set 2: done\n");
78 GNUNET_SET_destroy (set2);
79 break;
80 default:
81 GNUNET_assert (0);
82 }
52} 83}
53 84
54 85
@@ -59,7 +90,9 @@ listen_cb (void *cls,
59 struct GNUNET_SET_Request *request) 90 struct GNUNET_SET_Request *request)
60{ 91{
61 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "listen cb called\n"); 92 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "listen cb called\n");
62 GNUNET_SET_accept (request, set2, GNUNET_TIME_UNIT_FOREVER_REL, 93 GNUNET_SET_listen_cancel (listen_handle);
94
95 GNUNET_SET_accept (request, set2,
63 GNUNET_SET_RESULT_ADDED, result_cb_set2, NULL); 96 GNUNET_SET_RESULT_ADDED, result_cb_set2, NULL);
64} 97}
65 98
@@ -75,7 +108,7 @@ start (void *cls)
75 listen_handle = GNUNET_SET_listen (config, GNUNET_SET_OPERATION_UNION, 108 listen_handle = GNUNET_SET_listen (config, GNUNET_SET_OPERATION_UNION,
76 &app_id, listen_cb, NULL); 109 &app_id, listen_cb, NULL);
77 GNUNET_SET_evaluate (set1, &local_id, &app_id, NULL, 42, 110 GNUNET_SET_evaluate (set1, &local_id, &app_id, NULL, 42,
78 GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_SET_RESULT_ADDED, 111 GNUNET_SET_RESULT_ADDED,
79 result_cb_set1, NULL); 112 result_cb_set1, NULL);
80} 113}
81 114
@@ -120,7 +153,6 @@ init_set1 (void)
120 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "initialized set 1\n"); 153 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "initialized set 1\n");
121} 154}
122 155
123
124/** 156/**
125 * Signature of the 'main' function for a (single-peer) testcase that 157 * Signature of the 'main' function for a (single-peer) testcase that
126 * is run using 'GNUNET_TESTING_peer_run'. 158 * is run using 'GNUNET_TESTING_peer_run'.