summaryrefslogtreecommitdiff
path: root/src/transport/test_transport_api_restart_1peer.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-02-16 14:28:37 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-02-16 14:28:37 +0000
commit8ecbb9f14d1cdfc614ef832ebd40145d4f9a5b7e (patch)
tree780eceea192c05f03c26b2b543d8764facbc8a32 /src/transport/test_transport_api_restart_1peer.c
parentbd742f26f08fed45b48eeb1567447acd7a77d350 (diff)
downloadgnunet-8ecbb9f14d1cdfc614ef832ebd40145d4f9a5b7e.tar.gz
gnunet-8ecbb9f14d1cdfc614ef832ebd40145d4f9a5b7e.zip
fix test for peer restart
Diffstat (limited to 'src/transport/test_transport_api_restart_1peer.c')
-rw-r--r--src/transport/test_transport_api_restart_1peer.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/src/transport/test_transport_api_restart_1peer.c b/src/transport/test_transport_api_restart_1peer.c
index 22c603565..b005cbe06 100644
--- a/src/transport/test_transport_api_restart_1peer.c
+++ b/src/transport/test_transport_api_restart_1peer.c
@@ -65,8 +65,12 @@ static GNUNET_SCHEDULER_TaskIdentifier reconnect_task;
65 65
66struct PeerContext *p1; 66struct PeerContext *p1;
67 67
68int p1_connected;
69
68struct PeerContext *p2; 70struct PeerContext *p2;
69 71
72int p2_connected;
73
70static GNUNET_TRANSPORT_TESTING_ConnectRequest cc; 74static GNUNET_TRANSPORT_TESTING_ConnectRequest cc;
71 75
72struct GNUNET_TRANSPORT_TransmitHandle *th; 76struct GNUNET_TRANSPORT_TransmitHandle *th;
@@ -217,8 +221,8 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
217 } 221 }
218 else 222 else
219 { 223 {
220 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 224 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
221 "Restarted peers connected, stopping test...\n"); 225 "Restarted peers connected and message was sent, stopping test...\n");
222 ok = 0; 226 ok = 0;
223 end (); 227 end ();
224 } 228 }
@@ -303,9 +307,15 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
303 struct PeerContext *t = NULL; 307 struct PeerContext *t = NULL;
304 308
305 if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity))) 309 if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
310 {
311 p1_connected = GNUNET_YES;
306 t = p1; 312 t = p1;
313 }
307 if (0 == memcmp (peer, &p2->id, sizeof (struct GNUNET_PeerIdentity))) 314 if (0 == memcmp (peer, &p2->id, sizeof (struct GNUNET_PeerIdentity)))
315 {
316 p2_connected = GNUNET_YES;
308 t = p2; 317 t = p2;
318 }
309 GNUNET_assert (t != NULL); 319 GNUNET_assert (t != NULL);
310 320
311 char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); 321 char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
@@ -315,8 +325,9 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
315 t->no, GNUNET_i2s (peer)); 325 t->no, GNUNET_i2s (peer));
316 GNUNET_free (ps); 326 GNUNET_free (ps);
317 327
318 if ((restarted == GNUNET_YES) && (c == 4)) 328 if ((restarted == GNUNET_YES) && ((p1_connected == GNUNET_YES) && (p2_connected == GNUNET_YES)))
319 { 329 {
330 /* Peer was restarted and we received 3 connect messages (2 from first connect, 1 from reconnect) */
320 send_task = GNUNET_SCHEDULER_add_now (&sendtask, NULL); 331 send_task = GNUNET_SCHEDULER_add_now (&sendtask, NULL);
321 } 332 }
322} 333}
@@ -327,6 +338,15 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
327{ 338{
328 struct PeerContext *p = cls; 339 struct PeerContext *p = cls;
329 340
341 if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
342 {
343 p1_connected = GNUNET_NO;
344 }
345 if (0 == memcmp (peer, &p2->id, sizeof (struct GNUNET_PeerIdentity)))
346 {
347 p2_connected = GNUNET_NO;
348 }
349
330 350
331 char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); 351 char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
332 352
@@ -385,7 +405,8 @@ run (void *cls, char *const *args, const char *cfgfile,
385 const struct GNUNET_CONFIGURATION_Handle *cfg) 405 const struct GNUNET_CONFIGURATION_Handle *cfg)
386{ 406{
387 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); 407 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
388 408 p1_connected = GNUNET_NO;
409 p2_connected = GNUNET_NO;
389 p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1, 410 p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1,
390 &notify_receive, &notify_connect, 411 &notify_receive, &notify_connect,
391 &notify_disconnect, &start_cb, 412 &notify_disconnect, &start_cb,