diff options
Diffstat (limited to 'src/transport/test_quota_compliance.c')
-rw-r--r-- | src/transport/test_quota_compliance.c | 74 |
1 files changed, 14 insertions, 60 deletions
diff --git a/src/transport/test_quota_compliance.c b/src/transport/test_quota_compliance.c index e1dbc17b6..d73b9584c 100644 --- a/src/transport/test_quota_compliance.c +++ b/src/transport/test_quota_compliance.c | |||
@@ -39,7 +39,7 @@ | |||
39 | */ | 39 | */ |
40 | #define TIMEOUT_TRANSMIT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 20) | 40 | #define TIMEOUT_TRANSMIT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 20) |
41 | 41 | ||
42 | #define DURATION GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) | 42 | #define DURATION GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) |
43 | 43 | ||
44 | static char *test_source; | 44 | static char *test_source; |
45 | 45 | ||
@@ -100,8 +100,6 @@ GNUNET_NETWORK_STRUCT_END | |||
100 | 100 | ||
101 | static int msg_scheduled; | 101 | static int msg_scheduled; |
102 | static int msg_sent; | 102 | static int msg_sent; |
103 | static int msg_recv_expected; | ||
104 | static int msg_recv; | ||
105 | 103 | ||
106 | static int test_failed; | 104 | static int test_failed; |
107 | static int test_connected; | 105 | static int test_connected; |
@@ -215,65 +213,20 @@ static void | |||
215 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | 213 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, |
216 | const struct GNUNET_MessageHeader *message) | 214 | const struct GNUNET_MessageHeader *message) |
217 | { | 215 | { |
218 | static int n; | ||
219 | unsigned int s; | ||
220 | char cbuf[GNUNET_SERVER_MAX_MESSAGE_SIZE - 1]; | ||
221 | const struct TestMessage *hdr; | 216 | const struct TestMessage *hdr; |
222 | 217 | ||
223 | hdr = (const struct TestMessage *) message; | 218 | hdr = (const struct TestMessage *) message; |
224 | s = get_size (n); | ||
225 | if (MTYPE != ntohs (message->type)) | 219 | if (MTYPE != ntohs (message->type)) |
226 | return; | 220 | return; |
227 | msg_recv_expected = n; | ||
228 | msg_recv = ntohl (hdr->num); | ||
229 | if (ntohs (message->size) != (s)) | ||
230 | { | ||
231 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
232 | "Expected message %u of size %u, got %u bytes of message %u\n", | ||
233 | n, s, ntohs (message->size), ntohl (hdr->num)); | ||
234 | if (die_task != GNUNET_SCHEDULER_NO_TASK) | ||
235 | GNUNET_SCHEDULER_cancel (die_task); | ||
236 | test_failed = GNUNET_YES; | ||
237 | die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); | ||
238 | return; | ||
239 | } | ||
240 | if (ntohl (hdr->num) != n) | ||
241 | { | ||
242 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
243 | "Expected message %u of size %u, got %u bytes of message %u\n", | ||
244 | n, s, ntohs (message->size), ntohl (hdr->num)); | ||
245 | if (die_task != GNUNET_SCHEDULER_NO_TASK) | ||
246 | GNUNET_SCHEDULER_cancel (die_task); | ||
247 | test_failed = GNUNET_YES; | ||
248 | die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); | ||
249 | return; | ||
250 | } | ||
251 | memset (cbuf, n, s - sizeof (struct TestMessage)); | ||
252 | if (0 != memcmp (cbuf, &hdr[1], s - sizeof (struct TestMessage))) | ||
253 | { | ||
254 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
255 | "Expected message %u with bits %u, but body did not match\n", n, | ||
256 | (unsigned char) n); | ||
257 | if (die_task != GNUNET_SCHEDULER_NO_TASK) | ||
258 | GNUNET_SCHEDULER_cancel (die_task); | ||
259 | test_failed = GNUNET_YES; | ||
260 | die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); | ||
261 | return; | ||
262 | } | ||
263 | #if VERBOSE | ||
264 | if (ntohl (hdr->num) % 5000 == 0) | ||
265 | { | ||
266 | struct PeerContext *p = cls; | ||
267 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); | ||
268 | 221 | ||
269 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 222 | struct PeerContext *p = cls; |
270 | "Peer %u (`%s') got message %u of size %u from peer (`%s')\n", | 223 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); |
271 | p->no, ps, ntohl (hdr->num), ntohs (message->size), | 224 | |
272 | GNUNET_i2s (peer)); | 225 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
273 | GNUNET_free (ps); | 226 | "Peer %u (`%s') got message %u of size %u from peer (`%s')\n", |
274 | } | 227 | p->no, ps, ntohl (hdr->num), ntohs (message->size), |
275 | #endif | 228 | GNUNET_i2s (peer)); |
276 | n++; | 229 | GNUNET_free (ps); |
277 | } | 230 | } |
278 | 231 | ||
279 | 232 | ||
@@ -317,14 +270,15 @@ notify_ready (void *cls, size_t size, void *buf) | |||
317 | #if VERBOSE | 270 | #if VERBOSE |
318 | if (n % 5000 == 0) | 271 | if (n % 5000 == 0) |
319 | { | 272 | { |
320 | 273 | #endif | |
321 | char *receiver_s = GNUNET_strdup (GNUNET_i2s (&receiver->id)); | 274 | char *receiver_s = GNUNET_strdup (GNUNET_i2s (&receiver->id)); |
322 | 275 | ||
323 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 276 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
324 | "Sending message of size %u from peer %u (`%4s') -> peer %u (`%s') !\n", | 277 | "Sending message %u of size %u from peer %u (`%4s') -> peer %u (`%s') !\n", |
325 | n, sender->no, GNUNET_i2s (&sender->id), receiver->no, | 278 | n, s, sender->no, GNUNET_i2s (&sender->id), receiver->no, |
326 | receiver_s); | 279 | receiver_s); |
327 | GNUNET_free (receiver_s); | 280 | GNUNET_free (receiver_s); |
281 | #if 0 | ||
328 | } | 282 | } |
329 | #endif | 283 | #endif |
330 | n++; | 284 | n++; |