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