aboutsummaryrefslogtreecommitdiff
path: root/src/transport/transport-testing.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-07-23 22:32:35 +0000
committerChristian Grothoff <christian@grothoff.org>2016-07-23 22:32:35 +0000
commit658c3cf583b0c09e55c41a78a9ec8dbe28cb515e (patch)
tree236759ed9a5b6a5e3493667c34f384279bc12bbe /src/transport/transport-testing.c
parent1d188d2b9437f8a7685d0d139da7a6b9fb1b7c9c (diff)
downloadgnunet-658c3cf583b0c09e55c41a78a9ec8dbe28cb515e.tar.gz
gnunet-658c3cf583b0c09e55c41a78a9ec8dbe28cb515e.zip
more refactoring of tests for new send API
Diffstat (limited to 'src/transport/transport-testing.c')
-rw-r--r--src/transport/transport-testing.c61
1 files changed, 59 insertions, 2 deletions
diff --git a/src/transport/transport-testing.c b/src/transport/transport-testing.c
index 50c297389..899ef7851 100644
--- a/src/transport/transport-testing.c
+++ b/src/transport/transport-testing.c
@@ -77,6 +77,10 @@ static void
77set_p1c (void *cls, 77set_p1c (void *cls,
78 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cx) 78 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cx)
79{ 79{
80 int *found = cls;
81
82 if (NULL != found)
83 *found = GNUNET_YES;
80 cx->p1_c = GNUNET_YES; 84 cx->p1_c = GNUNET_YES;
81} 85}
82 86
@@ -85,6 +89,10 @@ static void
85set_p2c (void *cls, 89set_p2c (void *cls,
86 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cx) 90 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cx)
87{ 91{
92 int *found = cls;
93
94 if (NULL != found)
95 *found = GNUNET_YES;
88 cx->p2_c = GNUNET_YES; 96 cx->p2_c = GNUNET_YES;
89} 97}
90 98
@@ -93,6 +101,10 @@ static void
93clear_p1c (void *cls, 101clear_p1c (void *cls,
94 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cx) 102 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cx)
95{ 103{
104 int *found = cls;
105
106 if (NULL != found)
107 *found = GNUNET_YES;
96 cx->p1_c = GNUNET_NO; 108 cx->p1_c = GNUNET_NO;
97} 109}
98 110
@@ -101,6 +113,10 @@ static void
101clear_p2c (void *cls, 113clear_p2c (void *cls,
102 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cx) 114 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cx)
103{ 115{
116 int *found = cls;
117
118 if (NULL != found)
119 *found = GNUNET_YES;
104 cx->p2_c = GNUNET_NO; 120 cx->p2_c = GNUNET_NO;
105} 121}
106 122
@@ -115,6 +131,7 @@ notify_connect (void *cls,
115 struct GNUNET_TRANSPORT_TESTING_PeerContext *p2; 131 struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
116 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc; 132 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc;
117 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *ccn; 133 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *ccn;
134 int found;
118 135
119 p2 = find_peer_context (p->tth, 136 p2 = find_peer_context (p->tth,
120 peer); 137 peer);
@@ -138,14 +155,36 @@ notify_connect (void *cls,
138 GNUNET_i2s (&p->id)); 155 GNUNET_i2s (&p->id));
139 GNUNET_free (p2_s); 156 GNUNET_free (p2_s);
140 /* update flags in connecting contexts */ 157 /* update flags in connecting contexts */
158 found = GNUNET_NO;
141 GNUNET_TRANSPORT_TESTING_find_connecting_context (p, 159 GNUNET_TRANSPORT_TESTING_find_connecting_context (p,
142 p2, 160 p2,
143 &set_p1c, 161 &set_p1c,
144 NULL); 162 &found);
163 if (GNUNET_NO == found)
164 {
165 cc = GNUNET_new (struct GNUNET_TRANSPORT_TESTING_ConnectRequest);
166 cc->p1 = p;
167 cc->p2 = p2;
168 cc->p1_c = GNUNET_YES;
169 GNUNET_CONTAINER_DLL_insert (tth->cc_head,
170 tth->cc_tail,
171 cc);
172 }
173 found = GNUNET_NO;
145 GNUNET_TRANSPORT_TESTING_find_connecting_context (p2, 174 GNUNET_TRANSPORT_TESTING_find_connecting_context (p2,
146 p, 175 p,
147 &set_p2c, 176 &set_p2c,
148 NULL); 177 &found);
178 if (GNUNET_NO == found)
179 {
180 cc = GNUNET_new (struct GNUNET_TRANSPORT_TESTING_ConnectRequest);
181 cc->p1 = p2;
182 cc->p2 = p;
183 cc->p1_c = GNUNET_YES;
184 GNUNET_CONTAINER_DLL_insert (tth->cc_head,
185 tth->cc_tail,
186 cc);
187 }
149 /* update set connected flag for all requests */ 188 /* update set connected flag for all requests */
150 for (cc = tth->cc_head; NULL != cc; cc = cc->next) 189 for (cc = tth->cc_head; NULL != cc; cc = cc->next)
151 { 190 {
@@ -703,7 +742,19 @@ GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_PeerCont
703{ 742{
704 struct GNUNET_TRANSPORT_TESTING_Handle *tth = p1->tth; 743 struct GNUNET_TRANSPORT_TESTING_Handle *tth = p1->tth;
705 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc; 744 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc;
745 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *ccn;
706 746
747 ccn = NULL;
748 for (cc = tth->cc_head; NULL != cc; cc = cc->next)
749 {
750 if ( (cc->p1 == p1) &&
751 (cc->p2 == p2) )
752 {
753 ccn = cc;
754 break;
755 }
756 }
757
707 cc = GNUNET_new (struct GNUNET_TRANSPORT_TESTING_ConnectRequest); 758 cc = GNUNET_new (struct GNUNET_TRANSPORT_TESTING_ConnectRequest);
708 cc->p1 = p1; 759 cc->p1 = p1;
709 cc->p2 = p2; 760 cc->p2 = p2;
@@ -712,6 +763,12 @@ GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_PeerCont
712 cc->cb_cls = cls; 763 cc->cb_cls = cls;
713 else 764 else
714 cc->cb_cls = cc; 765 cc->cb_cls = cc;
766 if (NULL != ccn)
767 {
768 cc->p1_c = ccn->p1_c;
769 cc->p2_c = ccn->p2_c;
770 cc->connected = ccn->connected;
771 }
715 GNUNET_CONTAINER_DLL_insert (tth->cc_head, 772 GNUNET_CONTAINER_DLL_insert (tth->cc_head,
716 tth->cc_tail, 773 tth->cc_tail,
717 cc); 774 cc);