summaryrefslogtreecommitdiff
path: root/src/transport/transport-testing.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-07-10 16:41:45 +0000
committerChristian Grothoff <christian@grothoff.org>2016-07-10 16:41:45 +0000
commitc6444a089a860da694842942283079a25bc1e957 (patch)
treed35d30bc35acf05681f7f89057ffdc2e774b33ec /src/transport/transport-testing.c
parent4f77ea5b2b3d53a21f70237f8b92a9a2273c21bf (diff)
fold bidirectional test into main test_ats_api
Diffstat (limited to 'src/transport/transport-testing.c')
-rw-r--r--src/transport/transport-testing.c45
1 files changed, 18 insertions, 27 deletions
diff --git a/src/transport/transport-testing.c b/src/transport/transport-testing.c
index 95f4eb671..ae878a79e 100644
--- a/src/transport/transport-testing.c
+++ b/src/transport/transport-testing.c
@@ -44,23 +44,30 @@ find_peer_context (struct GNUNET_TRANSPORT_TESTING_Handle *tth,
}
-static struct GNUNET_TRANSPORT_TESTING_ConnectRequest *
-find_connecting_context (struct GNUNET_TRANSPORT_TESTING_Handle *tth,
- struct GNUNET_TRANSPORT_TESTING_PeerContext *p1,
- struct GNUNET_TRANSPORT_TESTING_PeerContext *p2)
+static void
+notify_connecting_context (struct GNUNET_TRANSPORT_TESTING_Handle *tth,
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p1,
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p2)
{
struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc;
+ struct GNUNET_TRANSPORT_TESTING_ConnectRequest *ccn;
- for (cc = tth->cc_head; NULL != cc; cc = cc->next)
+ for (cc = tth->cc_head; NULL != cc; cc = ccn)
{
+ ccn = cc->next;
if ( (cc->p1 == p1) &&
(cc->p2 == p2) )
- return cc;
+ cc->p1_c = GNUNET_YES;
if ( (cc->p1 == p2) &&
(cc->p2 == p1) )
- return cc;
+ cc->p2_c = GNUNET_YES;
+ if ( (cc->p1_c == GNUNET_YES) &&
+ (cc->p2_c == GNUNET_YES) )
+ {
+ cc->cb (cc->cb_cls);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
+ }
}
- return NULL;
}
@@ -71,7 +78,6 @@ notify_connect (void *cls,
struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
char *p2_s;
struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
- struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc;
p2 = find_peer_context (p->tth,
peer);
@@ -94,24 +100,9 @@ notify_connect (void *cls,
p->no,
GNUNET_i2s (&p->id));
GNUNET_free (p2_s);
-
- /* Find ConnectingContext */
- cc = find_connecting_context (p->tth,
- p,
- p2);
- if (NULL == cc)
- return;
- if (p == cc->p1)
- cc->p1_c = GNUNET_YES;
- if (p == cc->p2)
- cc->p2_c = GNUNET_YES;
-
- if ( (cc->p1_c == GNUNET_YES) &&
- (cc->p2_c == GNUNET_YES) )
- {
- cc->cb (cc->cb_cls);
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
- }
+ notify_connecting_context (p->tth,
+ p,
+ p2);
}