aboutsummaryrefslogtreecommitdiff
path: root/src/transport/transport-testing2.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/transport-testing2.h')
-rw-r--r--src/transport/transport-testing2.h941
1 files changed, 0 insertions, 941 deletions
diff --git a/src/transport/transport-testing2.h b/src/transport/transport-testing2.h
deleted file mode 100644
index 8f1071e8f..000000000
--- a/src/transport/transport-testing2.h
+++ /dev/null
@@ -1,941 +0,0 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2006, 2009, 2015, 2016 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
21/**
22 * @file transport-testing.h
23 * @brief testing lib for transport service
24 * @author Matthias Wachs
25 * @author Christian Grothoff
26 */
27#ifndef TRANSPORT_TESTING_H
28#define TRANSPORT_TESTING_H
29#include "platform.h"
30#include "gnunet_util_lib.h"
31#include "gnunet_hello_lib.h"
32#include "gnunet_peerstore_service.h"
33#include "gnunet_transport_core_service.h"
34#include "gnunet_transport_application_service.h"
35#include "gnunet_testing_lib.h"
36
37
38/* ************* Basic functions for starting/stopping/connecting *********** */
39
40/**
41 * Context for a single peer
42 */
43struct GNUNET_TRANSPORT_TESTING_PeerContext;
44
45/**
46 * Definition for a transport testing handle
47 */
48struct GNUNET_TRANSPORT_TESTING_Handle;
49
50
51/**
52 * Context for a single peer
53 */
54struct GNUNET_TRANSPORT_TESTING_PeerContext
55{
56 /**
57 * Next element in the DLL
58 */
59 struct GNUNET_TRANSPORT_TESTING_PeerContext *next;
60
61 /**
62 * Previous element in the DLL
63 */
64 struct GNUNET_TRANSPORT_TESTING_PeerContext *prev;
65
66 /**
67 * Transport testing handle this peer belongs to
68 */
69 struct GNUNET_TRANSPORT_TESTING_Handle *tth;
70
71 /**
72 * Application handle
73 */
74 struct GNUNET_TRANSPORT_ApplicationHandle *ah;
75
76 /**
77 * Peer's configuration
78 */
79 struct GNUNET_CONFIGURATION_Handle *cfg;
80
81 /**
82 * Peer's transport service handle
83 */
84 struct GNUNET_TRANSPORT_CoreHandle *th;
85
86 /**
87 * Peer's PEERSTORE Handle
88 */
89 struct GNUNET_PEERSTORE_Handle *ph;
90
91 /**
92 * Peer's transport get hello handle to retrieve peer's HELLO message
93 */
94 struct GNUNET_PEERSTORE_IterateContext *pic;
95
96 /**
97 * Hello
98 */
99 char *hello;
100
101 /**
102 * Hello size
103 */
104 size_t hello_size;
105
106 /**
107 * Peer's testing handle
108 */
109 struct GNUNET_TESTING_Peer *peer;
110
111 /**
112 * Peer identity
113 */
114 struct GNUNET_PeerIdentity id;
115
116 /**
117 * Handle for the peer's ARM process
118 */
119 struct GNUNET_OS_Process *arm_proc;
120
121 /**
122 * Receive callback
123 */
124 struct GNUNET_MQ_MessageHandler *handlers;
125
126 /**
127 * Notify connect callback
128 */
129 GNUNET_TRANSPORT_NotifyConnect nc;
130
131 /**
132 * Notify disconnect callback
133 */
134 GNUNET_TRANSPORT_NotifyDisconnect nd;
135
136 /**
137 * Startup completed callback
138 */
139 GNUNET_SCHEDULER_TaskCallback start_cb;
140
141 /**
142 * Hello get task
143 */
144 struct GNUNET_SCHEDULER_Task *rh_task;
145
146 /**
147 * Closure for the @a nc and @a nd callbacks
148 */
149 void *cb_cls;
150
151 /**
152 * Closure for @e start_cb.
153 */
154 void *start_cb_cls;
155
156 /**
157 * An unique number to identify the peer
158 */
159 unsigned int no;
160};
161
162
163/**
164 * Handle for a request to connect two peers.
165 */
166struct GNUNET_TRANSPORT_TESTING_ConnectRequest
167{
168 /**
169 * Kept in a DLL.
170 */
171 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *next;
172
173 /**
174 * Kept in a DLL.
175 */
176 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *prev;
177
178 /**
179 * Peer we want to connect.
180 */
181 struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
182
183 /**
184 * Peer we want to connect.
185 */
186 struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
187
188 /**
189 * Task by which we accomplish the connection.
190 */
191 struct GNUNET_SCHEDULER_Task *tct;
192
193 /**
194 * Handle by which we ask TNG to facilitate the connection.
195 */
196 struct GNUNET_TRANSPORT_ApplicationSuggestHandle *ah_sh;
197
198 /**
199 * Function to call upon completion.
200 */
201 GNUNET_SCHEDULER_TaskCallback cb;
202
203 /**
204 * Closure for @e cb.
205 */
206 void *cb_cls;
207
208 /**
209 * Message queue for sending from @a p1 to @a p2.
210 */
211 struct GNUNET_MQ_Handle *mq;
212
213 /**
214 * Set if peer1 says the connection is up to peer2.
215 */
216 int p1_c;
217
218 /**
219 * Set if peer2 says the connection is up to peer1.
220 */
221 int p2_c;
222
223 /**
224 * #GNUNET_YES if both @e p1_c and @e p2_c are #GNUNET_YES.
225 */
226 int connected;
227};
228
229
230/**
231 * Handle for a test run.
232 */
233struct GNUNET_TRANSPORT_TESTING_Handle
234{
235 /**
236 * Testing library system handle
237 */
238 struct GNUNET_TESTING_System *tl_system;
239
240 /**
241 * head DLL of connect contexts
242 */
243 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc_head;
244
245 /**
246 * head DLL of connect contexts
247 */
248 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc_tail;
249
250 /**
251 * head DLL of peers
252 */
253 struct GNUNET_TRANSPORT_TESTING_PeerContext *p_head;
254
255 /**
256 * tail DLL of peers
257 */
258 struct GNUNET_TRANSPORT_TESTING_PeerContext *p_tail;
259};
260
261
262/**
263 * Initialize the transport testing
264 *
265 * @return transport testing handle
266 */
267struct GNUNET_TRANSPORT_TESTING_Handle *
268GNUNET_TRANSPORT_TESTING_init (void);
269
270
271/**
272 * Clean up the transport testing
273 *
274 * @param tth transport testing handle
275 */
276void
277GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_Handle *tth);
278
279
280/**
281 * Start a peer with the given configuration
282 *
283 * @param tth the testing handle
284 * @param cfgname configuration file
285 * @param peer_id an identification number for the peer
286 * @param handlers functions for receiving messages
287 * @param nc connect callback
288 * @param nd disconnect callback
289 * @param cb_cls closure for @a nc and @a nd callback
290 * @param start_cb start callback
291 * @param start_cb_cls closure for @a start_cb
292 * @return the peer context
293 */
294struct GNUNET_TRANSPORT_TESTING_PeerContext *
295GNUNET_TRANSPORT_TESTING_start_peer (
296 struct GNUNET_TRANSPORT_TESTING_Handle *tth,
297 const char *cfgname,
298 int peer_id,
299 const struct GNUNET_MQ_MessageHandler *handlers,
300 GNUNET_TRANSPORT_NotifyConnect nc,
301 GNUNET_TRANSPORT_NotifyDisconnect nd,
302 void *cb_cls,
303 GNUNET_SCHEDULER_TaskCallback start_cb,
304 void *start_cb_cls);
305
306
307/**
308 * Shutdown the given peer
309 *
310 * @param p the peer
311 */
312void
313GNUNET_TRANSPORT_TESTING_stop_peer (
314 struct GNUNET_TRANSPORT_TESTING_PeerContext *pc);
315
316
317/**
318 * Stops and restarts the given peer, sleeping (!) for 5s in between.
319 *
320 * @param p the peer
321 * @param restart_cb restart callback
322 * @param restart_cb_cls callback closure
323 * @return #GNUNET_OK in success otherwise #GNUNET_SYSERR
324 */
325int
326GNUNET_TRANSPORT_TESTING_restart_peer (
327 struct GNUNET_TRANSPORT_TESTING_PeerContext *p,
328 GNUNET_SCHEDULER_TaskCallback restart_cb,
329 void *restart_cb_cls);
330
331
332/**
333 * Connect the given peers and call the callback when both peers
334 * report the inbound connection. Remarks: start_peer's notify_connect
335 * callback can be called before.
336 *
337 * @param p1 peer 1
338 * @param p2 peer 2
339 * @param cb the callback to call when both peers notified that they are
340 * connected
341 * @param cls callback cls
342 * @return a connect request handle
343 */
344struct GNUNET_TRANSPORT_TESTING_ConnectRequest *
345GNUNET_TRANSPORT_TESTING_connect_peers (
346 struct GNUNET_TRANSPORT_TESTING_PeerContext *p1,
347 struct GNUNET_TRANSPORT_TESTING_PeerContext *p2,
348 GNUNET_SCHEDULER_TaskCallback cb,
349 void *cls);
350
351
352/**
353 * Cancel the request to connect two peers. You MUST cancel the
354 * request if you stop the peers before the peers connected
355 * successfully.
356 *
357 * @param cc a connect request handle
358 */
359void
360GNUNET_TRANSPORT_TESTING_connect_peers_cancel (
361 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc);
362
363
364/**
365 * Function called on matching connect requests.
366 *
367 * @param cls closure
368 * @param cc request matching the query
369 */
370typedef void (*GNUNET_TRANSPORT_TESTING_ConnectContextCallback) (
371 void *cls,
372 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc);
373
374
375/**
376 * Find any connecting context matching the given pair of peers.
377 *
378 * @param p1 first peer
379 * @param p2 second peer
380 * @param cb function to call
381 * @param cb_cls closure for @a cb
382 */
383void
384GNUNET_TRANSPORT_TESTING_find_connecting_context (
385 struct GNUNET_TRANSPORT_TESTING_PeerContext *p1,
386 struct GNUNET_TRANSPORT_TESTING_PeerContext *p2,
387 GNUNET_TRANSPORT_TESTING_ConnectContextCallback cb,
388 void *cb_cls);
389
390
391/* ********************** high-level process functions *************** */
392
393
394/**
395 * Function called once the peers have been launched and
396 * connected by #GNUNET_TRANSPORT_TESTING_connect_check().
397 *
398 * @param cls closure
399 * @param num_peers size of the @a p array
400 * @param p the peers that were launched
401 */
402typedef void (*GNUNET_TRANSPORT_TESTING_ConnectContinuation) (
403 void *cls,
404 unsigned int num_peers,
405 struct GNUNET_TRANSPORT_TESTING_PeerContext *p[]);
406
407
408/**
409 * Internal data structure.
410 */
411struct GNUNET_TRANSPORT_TESTING_ConnectRequestList;
412
413/**
414 * Internal data structure.
415 */
416struct GNUNET_TRANSPORT_TESTING_InternalPeerContext;
417
418
419GNUNET_NETWORK_STRUCT_BEGIN
420struct GNUNET_TRANSPORT_TESTING_TestMessage
421{
422 /**
423 * Type is (usually) #GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE.
424 */
425 struct GNUNET_MessageHeader header;
426
427 /**
428 * Monotonically increasing counter throughout the test.
429 */
430 uint32_t num GNUNET_PACKED;
431};
432
433struct GNUNET_TRANSPORT_TESTING_PerformanceTestMessage
434{
435 /**
436 * Type is (usually) #GNUNET_TRANSPORT_TESTING_SIMPLE_PERFORMANCE_MTYPE.
437 */
438 struct GNUNET_MessageHeader header;
439
440 /**
441 * Time this message was send via transport api.
442 */
443 struct GNUNET_TIME_AbsoluteNBO time_send;
444
445 /**
446 * Monotonically increasing counter throughout the test.
447 */
448 uint32_t num GNUNET_PACKED;
449};
450
451GNUNET_NETWORK_STRUCT_END
452
453
454/**
455 * Function called by the transport for each received message.
456 *
457 * @param cls closure
458 * @param receiver receiver of the message
459 * @param sender sender of the message
460 * @param message the message
461 */
462typedef void (*GNUNET_TRANSPORT_TESTING_ReceiveCallback) (
463 void *cls,
464 struct GNUNET_TRANSPORT_TESTING_PeerContext *receiver,
465 const struct GNUNET_PeerIdentity *sender,
466 const struct GNUNET_TRANSPORT_TESTING_TestMessage *message);
467
468
469/**
470 * Function called to notify transport users that another
471 * peer connected to us.
472 *
473 * @param cls closure
474 * @param me peer experiencing the event
475 * @param other peer that connected to @a me
476 */
477typedef void (*GNUNET_TRANSPORT_TESTING_NotifyConnect) (
478 void *cls,
479 struct GNUNET_TRANSPORT_TESTING_PeerContext *me,
480 const struct GNUNET_PeerIdentity *other);
481
482
483/**
484 * Function called to notify transport users that another
485 * peer disconnected from us.
486 *
487 * @param cls closure
488 * @param me peer experiencing the event
489 * @param other peer that disconnected from @a me
490 */
491typedef void (*GNUNET_TRANSPORT_TESTING_NotifyDisconnect) (
492 void *cls,
493 struct GNUNET_TRANSPORT_TESTING_PeerContext *me,
494 const struct GNUNET_PeerIdentity *other);
495
496
497/**
498 * Closure that must be passed to
499 * #GNUNET_TRANSPORT_TESTING_connect_check.
500 */
501struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext
502{
503 /**
504 * How should we continue after the connect?
505 */
506 GNUNET_SCHEDULER_TaskCallback connect_continuation;
507
508 /**
509 * Closure for @e connect_continuation.
510 */
511 void *connect_continuation_cls;
512
513 /**
514 * Which configuration file should we pass to the
515 * #GNUNET_PROGRAM_run() of the testcase?
516 */
517 const char *config_file;
518
519 /**
520 * Receiver argument to give for peers we start.
521 */
522 GNUNET_TRANSPORT_TESTING_ReceiveCallback rec;
523
524 /**
525 * Notify connect argument to give for peers we start.
526 */
527 GNUNET_TRANSPORT_TESTING_NotifyConnect nc;
528
529 /**
530 * Notify disconnect argument to give for peers we start.
531 */
532 GNUNET_TRANSPORT_TESTING_NotifyDisconnect nd;
533
534 /**
535 * Closure for @e rec, @e nc and @e nd.
536 */
537 void *cls;
538
539 /**
540 * Custom task to run on shutdown.
541 */
542 GNUNET_SCHEDULER_TaskCallback shutdown_task;
543
544 /**
545 * Closure for @e shutdown_task.
546 */
547 void *shutdown_task_cls;
548
549 /**
550 * Custom task to run after peers were started but before we try to
551 * connect them. If this function is set, we wait ONE second after
552 * running this function until we continue with connecting the
553 * peers.
554 */
555 GNUNET_SCHEDULER_TaskCallback pre_connect_task;
556
557 /**
558 * Closure for @e shutdown_task.
559 */
560 void *pre_connect_task_cls;
561
562 /**
563 * When should the testcase time out?
564 */
565 struct GNUNET_TIME_Relative timeout;
566
567 /**
568 * Should we try to create connections in both directions?
569 */
570 int bi_directional;
571
572 /* ******* fields set by #GNUNET_TRANSPORT_TESTING_connect_check **** */
573
574 /**
575 * Number of peers involved in the test.
576 */
577 unsigned int num_peers;
578
579 /**
580 * Configuration files we have, array with @e num_peers entries.
581 */
582 char **cfg_files;
583
584 /**
585 * Array with @e num_peers entries.
586 */
587 struct GNUNET_TRANSPORT_TESTING_PeerContext **p;
588
589 /**
590 * Name of the plugin.
591 */
592 const char *test_plugin;
593
594 /**
595 * Name of the testcase.
596 */
597 const char *test_name;
598
599 /**
600 * Configuration object for the testcase.
601 */
602 const struct GNUNET_CONFIGURATION_Handle *cfg;
603
604 /**
605 * Main testing handle.
606 */
607 struct GNUNET_TRANSPORT_TESTING_Handle *tth;
608
609 /**
610 * Result from the main function, set to #GNUNET_OK on success.
611 * Clients should set to #GNUNET_SYSERR to indicate test failure.
612 */
613 int global_ret;
614
615 /**
616 * Generator for the `num` field in test messages. Incremented each
617 * time #GNUNET_TRANSPORT_TESTING_simple_send or
618 * #GNUNET_TRANSPORT_TESTING_large_send are used to transmit a
619 * message.
620 */
621 uint32_t send_num_gen;
622
623 /* ******* internal state, clients should not mess with this **** */
624
625 /**
626 * Task run on timeout.
627 */
628 struct GNUNET_SCHEDULER_Task *timeout_task;
629
630 /**
631 * Task run to connect peers.
632 */
633 struct GNUNET_SCHEDULER_Task *connect_task;
634
635 /**
636 * Number of peers that have been started.
637 */
638 unsigned int started;
639
640 /**
641 * DLL of active connect requests.
642 */
643 struct GNUNET_TRANSPORT_TESTING_ConnectRequestList *crl_head;
644
645 /**
646 * DLL of active connect requests.
647 */
648 struct GNUNET_TRANSPORT_TESTING_ConnectRequestList *crl_tail;
649
650 /**
651 * Array with @e num_peers entries.
652 */
653 struct GNUNET_TRANSPORT_TESTING_InternalPeerContext *ip;
654};
655
656
657/**
658 * Find peer by peer ID.
659 *
660 * @param ccc context to search
661 * @param peer peer to look for
662 * @return NULL if @a peer was not found
663 */
664struct GNUNET_TRANSPORT_TESTING_PeerContext *
665GNUNET_TRANSPORT_TESTING_find_peer (
666 struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *ccc,
667 const struct GNUNET_PeerIdentity *peer);
668
669
670/**
671 * Common implementation of the #GNUNET_TRANSPORT_TESTING_CheckCallback.
672 * Starts and connects the two peers, then invokes the
673 * `connect_continuation` from @a cls. Sets up a timeout to
674 * abort the test, and a shutdown handler to clean up properly
675 * on exit.
676 *
677 * @param cls closure of type `struct
678 * GNUNET_TRANSPORT_TESTING_ConnectCheckContext`
679 * @param tth_ initialized testing handle
680 * @param test_plugin_ name of the plugin
681 * @param test_name_ name of the test
682 * @param num_peers number of entries in the @a cfg_file array
683 * @param cfg_files array of names of configuration files for the peers
684 * @return #GNUNET_SYSERR on error
685 */
686int
687GNUNET_TRANSPORT_TESTING_connect_check (
688 void *cls,
689 struct GNUNET_TRANSPORT_TESTING_Handle *tth_,
690 const char *test_plugin_,
691 const char *test_name_,
692 unsigned int num_peers,
693 char *cfg_files[]);
694
695
696/**
697 * Main function of a testcase. Called with the initial setup data
698 * for the test as derived from the source name and the binary name.
699 *
700 * @param cls closure
701 * @param tth_ initialized testing handle
702 * @param test_plugin_ name of the plugin
703 * @param test_name_ name of the test
704 * @param num_peers number of entries in the @a cfg_file array
705 * @param cfg_files array of names of configuration files for the peers
706 * @return #GNUNET_SYSERR on error
707 */
708typedef int (*GNUNET_TRANSPORT_TESTING_CheckCallback) (
709 void *cls,
710 struct GNUNET_TRANSPORT_TESTING_Handle *tth_,
711 const char *test_plugin_,
712 const char *test_name_,
713 unsigned int num_peers,
714 char *cfg_files[]);
715
716
717/**
718 * Setup testcase. Calls @a check with the data the test needs.
719 *
720 * @param argv0 binary name (argv[0])
721 * @param filename source file name (__FILE__)
722 * @param num_peers number of peers to start
723 * @param check main function to run
724 * @param check_cls closure for @a check
725 * @return #GNUNET_OK on success
726 */
727int
728GNUNET_TRANSPORT_TESTING_main_ (const char *argv0,
729 const char *filename,
730 unsigned int num_peers,
731 GNUNET_TRANSPORT_TESTING_CheckCallback check,
732 void *check_cls);
733
734
735/**
736 * Setup testcase. Calls @a check with the data the test needs.
737 *
738 * @param num_peers number of peers to start
739 * @param check main function to run
740 * @param check_cls closure for @a check
741 * @return #GNUNET_OK on success
742 */
743#define GNUNET_TRANSPORT_TESTING_main(num_peers, check, check_cls) \
744 GNUNET_TRANSPORT_TESTING_main_ (argv[0], \
745 __FILE__, \
746 num_peers, \
747 check, \
748 check_cls)
749
750/* ***************** Convenience functions for sending ********* */
751
752/**
753 * Send a test message of type @a mtype and size @a msize from
754 * peer @a sender to peer @a receiver. The peers should be
755 * connected when this function is called.
756 *
757 * @param sender the sending peer
758 * @param receiver the receiving peer
759 * @param mtype message type to use
760 * @param msize size of the message, at least `sizeof (struct
761 * GNUNET_TRANSPORT_TESTING_TestMessage)`
762 * @param num unique message number
763 * @param cont continuation to call after transmission
764 * @param cont_cls closure for @a cont
765 * @return #GNUNET_OK if message was queued,
766 * #GNUNET_NO if peers are not connected
767 * #GNUNET_SYSERR if @a msize is illegal
768 */
769int
770GNUNET_TRANSPORT_TESTING_send (
771 struct GNUNET_TRANSPORT_TESTING_PeerContext *sender,
772 struct GNUNET_TRANSPORT_TESTING_PeerContext *receiver,
773 uint16_t mtype,
774 uint16_t msize,
775 uint32_t num,
776 GNUNET_SCHEDULER_TaskCallback cont,
777 void *cont_cls);
778
779
780/**
781 * Message type used by #GNUNET_TRANSPORT_TESTING_simple_send().
782 */
783#define GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE 12345
784
785/**
786 * Alternative message type for tests.
787 */
788#define GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE2 12346
789
790/**
791 * Message type used by #().
792 */
793#define GNUNET_TRANSPORT_TESTING_SIMPLE_PERFORMANCE_MTYPE 12347
794
795/**
796 * Type of the closure argument to pass to
797 * #GNUNET_TRANSPORT_TESTING_simple_send() and
798 * #GNUNET_TRANSPORT_TESTING_large_send().
799 */
800struct GNUNET_TRANSPORT_TESTING_SendClosure
801{
802 /**
803 * Context for the transmission.
804 */
805 struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *ccc;
806
807 /**
808 * Function that returns the desired message size. Overrides
809 * the message size, can be NULL in which case the message
810 * size is the default.
811 */
812 size_t (*get_size_cb) (unsigned int n);
813
814 /**
815 * Number of messages to be transmitted in a loop.
816 * Use zero for "forever" (until external shutdown).
817 */
818 unsigned int num_messages;
819
820 /**
821 * Function to call after all transmissions, can be NULL.
822 */
823 GNUNET_SCHEDULER_TaskCallback cont;
824
825 /**
826 * Closure for @e cont.
827 */
828 void *cont_cls;
829};
830
831
832/**
833 * Task that sends a minimalistic test message from the
834 * first peer to the second peer.
835 *
836 * @param cls the `struct GNUNET_TRANSPORT_TESTING_SendClosure`
837 * which should contain at least two peers, the first two
838 * of which should be currently connected
839 */
840void
841GNUNET_TRANSPORT_TESTING_simple_send (void *cls);
842
843/**
844 * Size of a message sent with
845 * #GNUNET_TRANSPORT_TESTING_large_send(). Big enough
846 * to usually force defragmentation.
847 */
848#define GNUNET_TRANSPORT_TESTING_LARGE_MESSAGE_SIZE 2600
849
850/**
851 * Task that sends a large test message from the
852 * first peer to the second peer.
853 *
854 * @param cls the `struct GNUNET_TRANSPORT_TESTING_SendClosure`
855 * which should contain at least two peers, the first two
856 * of which should be currently connected
857 */
858void
859GNUNET_TRANSPORT_TESTING_large_send (void *cls);
860
861
862/* ********************** log-only convenience functions ************* */
863
864
865/**
866 * Log a connect event.
867 *
868 * @param cls NULL
869 * @param me peer that had the event
870 * @param other peer that connected.
871 */
872void
873GNUNET_TRANSPORT_TESTING_log_connect (
874 void *cls,
875 struct GNUNET_TRANSPORT_TESTING_PeerContext *me,
876 const struct GNUNET_PeerIdentity *other);
877
878
879/**
880 * Log a disconnect event.
881 *
882 * @param cls NULL
883 * @param me peer that had the event
884 * @param other peer that disconnected.
885 */
886void
887GNUNET_TRANSPORT_TESTING_log_disconnect (
888 void *cls,
889 struct GNUNET_TRANSPORT_TESTING_PeerContext *me,
890 const struct GNUNET_PeerIdentity *other);
891
892
893/* ********************** low-level filename functions *************** */
894
895
896/**
897 * Extracts the test filename from an absolute file name and removes
898 * the extension.
899 *
900 * @param file absolute file name
901 * @return resulting test name
902 */
903char *
904GNUNET_TRANSPORT_TESTING_get_test_name (const char *file);
905
906
907/**
908 * This function takes the filename (e.g. argv[0), removes a "lt-"-prefix and
909 * if existing ".exe"-prefix and adds the peer-number
910 *
911 * @param file filename of the test, e.g. argv[0]
912 * @param count peer number
913 * @return configuration name to use
914 */
915char *
916GNUNET_TRANSPORT_TESTING_get_config_name (const char *file, int count);
917
918
919/**
920 * Extracts the plugin anme from an absolute file name and the test name
921 * @param file absolute file name
922 * @param test test name
923 * @return the plugin name
924 */
925char *
926GNUNET_TRANSPORT_TESTING_get_test_plugin_name (const char *executable,
927 const char *testname);
928
929
930/**
931 * Extracts the filename from an absolute file name and removes the
932 * extension
933 *
934 * @param file absolute file name
935 * @return the source name
936 */
937char *
938GNUNET_TRANSPORT_TESTING_get_test_source_name (const char *file);
939
940#endif
941/* end of transport_testing.h */