aboutsummaryrefslogtreecommitdiff
path: root/src/transport/test_transport_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/test_transport_api.c')
-rw-r--r--src/transport/test_transport_api.c64
1 files changed, 33 insertions, 31 deletions
diff --git a/src/transport/test_transport_api.c b/src/transport/test_transport_api.c
index b7e34f810..a43f971a0 100644
--- a/src/transport/test_transport_api.c
+++ b/src/transport/test_transport_api.c
@@ -81,7 +81,7 @@ static void
81end () 81end ()
82{ 82{
83 /* do work here */ 83 /* do work here */
84 GNUNET_assert (ok == 8); 84 GNUNET_assert (ok == 6);
85 GNUNET_SCHEDULER_cancel (sched, die_task); 85 GNUNET_SCHEDULER_cancel (sched, die_task);
86 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from transports!\n"); 86 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from transports!\n");
87 GNUNET_TRANSPORT_disconnect (p1.th); 87 GNUNET_TRANSPORT_disconnect (p1.th);
@@ -132,7 +132,7 @@ notify_receive (void *cls,
132 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received message of type %d from peer (%p)!\n", 132 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received message of type %d from peer (%p)!\n",
133 ntohs(message->type), cls); 133 ntohs(message->type), cls);
134 134
135 GNUNET_assert (ok == 7); 135 GNUNET_assert (ok == 5);
136 OKPP; 136 OKPP;
137 137
138 GNUNET_assert (MTYPE == ntohs (message->type)); 138 GNUNET_assert (MTYPE == ntohs (message->type));
@@ -144,23 +144,51 @@ notify_receive (void *cls,
144} 144}
145 145
146 146
147static size_t
148notify_ready (void *cls, size_t size, void *buf)
149{
150 struct GNUNET_MessageHeader *hdr;
151
152 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
153 "Transmitting message to peer (%p) - %u!\n", cls, size);
154 GNUNET_assert (size >= 256);
155 GNUNET_assert (ok == 4);
156 OKPP;
157 if (buf != NULL)
158 {
159 hdr = buf;
160 hdr->size = htons (sizeof (struct GNUNET_MessageHeader));
161 hdr->type = htons (MTYPE);
162 }
163
164 return sizeof (struct GNUNET_MessageHeader);
165}
166
167
147static void 168static void
148notify_connect (void *cls, 169notify_connect (void *cls,
149 const struct GNUNET_PeerIdentity *peer, 170 const struct GNUNET_PeerIdentity *peer,
150 struct GNUNET_TIME_Relative latency, 171 struct GNUNET_TIME_Relative latency,
151 uint32_t distance) 172 uint32_t distance)
152{ 173{
174 if (cls == &p1)
175 {
176 GNUNET_TRANSPORT_notify_transmit_ready (p1.th,
177 &p2.id,
178 256, 0, TIMEOUT, &notify_ready,
179 &p1);
180 }
153 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 181 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
154 "Peer `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls); 182 "Peer `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls);
155 GNUNET_assert ((ok >= 1) && (ok <= 6));
156 OKPP;
157} 183}
158 184
159 185
160static void 186static void
161notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) 187notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
162{ 188{
163 ok--; 189 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
190 "Peer `%4s' disconnected (%p)!\n",
191 GNUNET_i2s (peer), cls);
164} 192}
165 193
166 194
@@ -186,27 +214,6 @@ setup_peer (struct PeerContext *p, const char *cfgname)
186} 214}
187 215
188 216
189static size_t
190notify_ready (void *cls, size_t size, void *buf)
191{
192 struct GNUNET_MessageHeader *hdr;
193
194 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
195 "Transmitting message to peer (%p) - %u!\n", cls, size);
196 GNUNET_assert (size >= 256);
197 GNUNET_assert ((ok >= 5) && (ok <= 6));
198 OKPP;
199 if (buf != NULL)
200 {
201 hdr = buf;
202 hdr->size = htons (sizeof (struct GNUNET_MessageHeader));
203 hdr->type = htons (MTYPE);
204 }
205
206 return sizeof (struct GNUNET_MessageHeader);
207}
208
209
210static void 217static void
211exchange_hello_last (void *cls, 218exchange_hello_last (void *cls,
212 const struct GNUNET_MessageHeader *message) 219 const struct GNUNET_MessageHeader *message)
@@ -231,11 +238,6 @@ exchange_hello_last (void *cls,
231 /* both HELLOs exchanged, get ready to test transmission! */ 238 /* both HELLOs exchanged, get ready to test transmission! */
232 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 239 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
233 "Finished exchanging HELLOs, now waiting for transmission!\n"); 240 "Finished exchanging HELLOs, now waiting for transmission!\n");
234
235 GNUNET_TRANSPORT_notify_transmit_ready (p1.th,
236 &p2.id,
237 256, 0, TIMEOUT, &notify_ready,
238 &p1);
239} 241}
240 242
241static void 243static void