diff options
Diffstat (limited to 'src/peerinfo/test_peerinfo_api_notify_friend_only.c')
-rw-r--r-- | src/peerinfo/test_peerinfo_api_notify_friend_only.c | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/src/peerinfo/test_peerinfo_api_notify_friend_only.c b/src/peerinfo/test_peerinfo_api_notify_friend_only.c index d0322713c..403ed4b71 100644 --- a/src/peerinfo/test_peerinfo_api_notify_friend_only.c +++ b/src/peerinfo/test_peerinfo_api_notify_friend_only.c | |||
@@ -127,15 +127,18 @@ address_generator (void *cls, size_t max, void *buf) | |||
127 | return ret; | 127 | return ret; |
128 | } | 128 | } |
129 | 129 | ||
130 | |||
130 | static void | 131 | static void |
131 | process_w_fo (void *cls, const struct GNUNET_PeerIdentity *peer, | 132 | process_w_fo (void *cls, |
132 | const struct GNUNET_HELLO_Message *hello, const char *err_msg) | 133 | const struct GNUNET_PeerIdentity *peer, |
134 | const struct GNUNET_HELLO_Message *hello, | ||
135 | const char *err_msg) | ||
133 | { | 136 | { |
134 | if (err_msg != NULL ) | 137 | if (err_msg != NULL) |
135 | { | 138 | { |
136 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 139 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
137 | _("Error in communication with PEERINFO service\n")); | 140 | _("Error in communication with PEERINFO service\n")); |
138 | GNUNET_SCHEDULER_add_now (&done, NULL ); | 141 | GNUNET_SCHEDULER_add_now (&done, NULL); |
139 | return; | 142 | return; |
140 | } | 143 | } |
141 | 144 | ||
@@ -160,7 +163,7 @@ process_w_fo (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
160 | if (0 == memcmp (&pid, peer, sizeof(pid))) | 163 | if (0 == memcmp (&pid, peer, sizeof(pid))) |
161 | { | 164 | { |
162 | res_cb_w_fo = GNUNET_YES; | 165 | res_cb_w_fo = GNUNET_YES; |
163 | GNUNET_SCHEDULER_add_now (&done, NULL ); | 166 | GNUNET_SCHEDULER_add_now (&done, NULL); |
164 | } | 167 | } |
165 | return; | 168 | return; |
166 | } | 169 | } |
@@ -170,11 +173,11 @@ static void | |||
170 | process_wo_fo (void *cls, const struct GNUNET_PeerIdentity *peer, | 173 | process_wo_fo (void *cls, const struct GNUNET_PeerIdentity *peer, |
171 | const struct GNUNET_HELLO_Message *hello, const char *err_msg) | 174 | const struct GNUNET_HELLO_Message *hello, const char *err_msg) |
172 | { | 175 | { |
173 | if (err_msg != NULL ) | 176 | if (err_msg != NULL) |
174 | { | 177 | { |
175 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 178 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
176 | _("Error in communication with PEERINFO service\n")); | 179 | _("Error in communication with PEERINFO service\n")); |
177 | GNUNET_SCHEDULER_add_now (&done, NULL ); | 180 | GNUNET_SCHEDULER_add_now (&done, NULL); |
178 | return; | 181 | return; |
179 | } | 182 | } |
180 | 183 | ||
@@ -204,6 +207,7 @@ process_wo_fo (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
204 | } | 207 | } |
205 | } | 208 | } |
206 | 209 | ||
210 | |||
207 | static void | 211 | static void |
208 | add_peer_done (void *cls, const char *emsg) | 212 | add_peer_done (void *cls, const char *emsg) |
209 | { | 213 | { |
@@ -215,10 +219,11 @@ add_peer_done (void *cls, const char *emsg) | |||
215 | { | 219 | { |
216 | GNUNET_break(0); | 220 | GNUNET_break(0); |
217 | GNUNET_SCHEDULER_cancel (timeout_task); | 221 | GNUNET_SCHEDULER_cancel (timeout_task); |
218 | timeout_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL ); | 222 | timeout_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); |
219 | } | 223 | } |
220 | } | 224 | } |
221 | 225 | ||
226 | |||
222 | static void | 227 | static void |
223 | add_peer () | 228 | add_peer () |
224 | { | 229 | { |
@@ -229,33 +234,37 @@ add_peer () | |||
229 | memset (&pid, 32, sizeof(pid)); | 234 | memset (&pid, 32, sizeof(pid)); |
230 | h2 = GNUNET_HELLO_create (&pid.public_key, &address_generator, &agc, | 235 | h2 = GNUNET_HELLO_create (&pid.public_key, &address_generator, &agc, |
231 | GNUNET_YES); | 236 | GNUNET_YES); |
232 | GNUNET_PEERINFO_add_peer (h, h2, &add_peer_done, NULL ); | 237 | GNUNET_PEERINFO_add_peer (h, h2, &add_peer_done, NULL); |
233 | GNUNET_free(h2); | 238 | GNUNET_free(h2); |
234 | 239 | ||
235 | } | 240 | } |
236 | 241 | ||
242 | |||
237 | static void | 243 | static void |
238 | run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, | 244 | run (void *cls, |
239 | struct GNUNET_TESTING_Peer *peer) | 245 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
246 | struct GNUNET_TESTING_Peer *peer) | ||
240 | { | 247 | { |
241 | timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL ); | 248 | timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); |
242 | mycfg = cfg; | 249 | mycfg = cfg; |
243 | pnc_w_fo = GNUNET_PEERINFO_notify (mycfg, GNUNET_YES, &process_w_fo, NULL ); | 250 | pnc_w_fo = GNUNET_PEERINFO_notify (mycfg, GNUNET_YES, &process_w_fo, NULL); |
244 | pnc_wo_fo = GNUNET_PEERINFO_notify (mycfg, GNUNET_NO, &process_wo_fo, NULL ); | 251 | pnc_wo_fo = GNUNET_PEERINFO_notify (mycfg, GNUNET_NO, &process_wo_fo, NULL); |
245 | h = GNUNET_PEERINFO_connect (cfg); | 252 | h = GNUNET_PEERINFO_connect (cfg); |
246 | GNUNET_assert(NULL != h); | 253 | GNUNET_assert(NULL != h); |
247 | add_peer (); | 254 | add_peer (); |
248 | } | 255 | } |
249 | 256 | ||
257 | |||
250 | int | 258 | int |
251 | main (int argc, char *argv[]) | 259 | main (int argc, char *argv[]) |
252 | { | 260 | { |
253 | res_cb_w_fo = GNUNET_NO; | 261 | res_cb_w_fo = GNUNET_NO; |
254 | res_cb_wo_fo = GNUNET_NO; | 262 | res_cb_wo_fo = GNUNET_NO; |
255 | global_ret = 3; | 263 | global_ret = 3; |
256 | if (0 | 264 | if (0 != GNUNET_TESTING_service_run ("test-peerinfo-api-friend-only", |
257 | != GNUNET_TESTING_service_run ("test-peerinfo-api-friend-only", | 265 | "peerinfo", |
258 | "peerinfo", "test_peerinfo_api_data.conf", &run, NULL )) | 266 | "test_peerinfo_api_data.conf", |
267 | &run, NULL)) | ||
259 | return 1; | 268 | return 1; |
260 | return global_ret; | 269 | return global_ret; |
261 | } | 270 | } |