aboutsummaryrefslogtreecommitdiff
path: root/src/peerinfo/test_peerinfo_api_notify_friend_only.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/peerinfo/test_peerinfo_api_notify_friend_only.c')
-rw-r--r--src/peerinfo/test_peerinfo_api_notify_friend_only.c40
1 files changed, 28 insertions, 12 deletions
diff --git a/src/peerinfo/test_peerinfo_api_notify_friend_only.c b/src/peerinfo/test_peerinfo_api_notify_friend_only.c
index 3afd50e68..700bac755 100644
--- a/src/peerinfo/test_peerinfo_api_notify_friend_only.c
+++ b/src/peerinfo/test_peerinfo_api_notify_friend_only.c
@@ -57,6 +57,8 @@ static int res_cb_w_fo;
57 */ 57 */
58static int res_cb_wo_fo; 58static int res_cb_wo_fo;
59 59
60struct GNUNET_PeerIdentity pid;
61
60GNUNET_SCHEDULER_TaskIdentifier timeout_task; 62GNUNET_SCHEDULER_TaskIdentifier timeout_task;
61 63
62 64
@@ -142,6 +144,10 @@ process_w_fo (void *cls, const struct GNUNET_PeerIdentity *peer,
142 144
143 if (NULL != peer) 145 if (NULL != peer)
144 { 146 {
147 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Received callback for peer `%s' %s HELLO\n",
148 GNUNET_i2s (peer),
149 (NULL != hello) ? "with" : "without");
150
145 if (NULL == hello) 151 if (NULL == hello)
146 return; 152 return;
147 153
@@ -151,10 +157,14 @@ process_w_fo (void *cls, const struct GNUNET_PeerIdentity *peer,
151 return; 157 return;
152 } 158 }
153 159
154 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Received %s HELLO\n", 160 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Received %s HELLO for peer `%s'\n",
155 (GNUNET_YES == GNUNET_HELLO_is_friend_only (hello)) ? "friend only" : "public"); 161 (GNUNET_YES == GNUNET_HELLO_is_friend_only (hello)) ? "friend only" : "public",
156 res_cb_w_fo = GNUNET_YES; 162 GNUNET_i2s (peer));
157 GNUNET_SCHEDULER_add_now(&done, NULL); 163 if (0 == memcmp (&pid, peer, sizeof (pid)))
164 {
165 res_cb_w_fo = GNUNET_YES;
166 GNUNET_SCHEDULER_add_now(&done, NULL);
167 }
158 return; 168 return;
159 } 169 }
160} 170}
@@ -173,20 +183,27 @@ process_wo_fo (void *cls, const struct GNUNET_PeerIdentity *peer,
173 183
174 if (NULL != peer) 184 if (NULL != peer)
175 { 185 {
186 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Received callback for peer `%s' %s HELLO\n",
187 GNUNET_i2s (peer),
188 (NULL != hello) ? "with" : "without");
189
176 if (NULL == hello) 190 if (NULL == hello)
177 return; 191 return;
178 192
179 GNUNET_break (0);
180
181 if (GNUNET_YES == GNUNET_HELLO_is_friend_only(hello)) 193 if (GNUNET_YES == GNUNET_HELLO_is_friend_only(hello))
182 { 194 {
183 GNUNET_break (0); 195 GNUNET_break (0);
184 return; 196 return;
185 } 197 }
186 198
187 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Received %s HELLO\n", 199 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Received %s HELLO for peer `%s'\n",
188 (GNUNET_YES == GNUNET_HELLO_is_friend_only (hello)) ? "friend only" : "public"); 200 (GNUNET_YES == GNUNET_HELLO_is_friend_only (hello)) ? "friend only" : "public",
189 res_cb_wo_fo = GNUNET_YES; 201 GNUNET_i2s (peer));
202 if (0 == memcmp (&pid, peer, sizeof (pid)))
203 {
204 GNUNET_break (0);
205 res_cb_wo_fo = GNUNET_YES;
206 }
190 } 207 }
191} 208}
192 209
@@ -195,8 +212,6 @@ add_peer_done (void *cls, const char *emsg)
195{ 212{
196 if (NULL == emsg) 213 if (NULL == emsg)
197 { 214 {
198 pnc_w_fo = GNUNET_PEERINFO_notify (mycfg, GNUNET_YES, &process_w_fo, NULL);
199 pnc_wo_fo = GNUNET_PEERINFO_notify (mycfg, GNUNET_NO, &process_wo_fo, NULL);
200 return; 215 return;
201 } 216 }
202 else 217 else
@@ -213,7 +228,6 @@ static void
213add_peer () 228add_peer ()
214{ 229{
215 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pkey; 230 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pkey;
216 struct GNUNET_PeerIdentity pid;
217 struct GNUNET_HELLO_Message *h2; 231 struct GNUNET_HELLO_Message *h2;
218 size_t agc; 232 size_t agc;
219 233
@@ -235,6 +249,8 @@ run (void *cls,
235{ 249{
236 timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); 250 timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
237 mycfg = cfg; 251 mycfg = cfg;
252 pnc_w_fo = GNUNET_PEERINFO_notify (mycfg, GNUNET_YES, &process_w_fo, NULL);
253 pnc_wo_fo = GNUNET_PEERINFO_notify (mycfg, GNUNET_NO, &process_wo_fo, NULL);
238 h = GNUNET_PEERINFO_connect (cfg); 254 h = GNUNET_PEERINFO_connect (cfg);
239 GNUNET_assert (NULL != h); 255 GNUNET_assert (NULL != h);
240 add_peer (); 256 add_peer ();