indentation
[oweals/gnunet.git] / src / fs / fs_test_lib.h
1 /*
2      This file is part of GNUnet.
3      (C) 2010 Christian Grothoff (and other contributing authors)
4
5      GNUnet is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published
7      by the Free Software Foundation; either version 3, or (at your
8      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      General Public License for more details.
14
15      You should have received a copy of the GNU General Public License
16      along with GNUnet; see the file COPYING.  If not, write to the
17      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18      Boston, MA 02111-1307, USA.
19 */
20
21 /**
22  * @file fs/fs_test_lib.h
23  * @brief library routines for testing FS publishing and downloading
24  *        with multiple peers; this code is limited to flat files
25  *        and no keywords (those functions can be tested with
26  *        single-peer setups; this is for testing routing).
27  * @author Christian Grothoff
28  */
29 #ifndef FS_TEST_LIB_H
30 #define FS_TEST_LIB_H
31
32 #include "gnunet_util_lib.h"
33 #include "gnunet_fs_service.h"
34
35 /**
36  * Handle for a daemon started for testing FS.
37  */
38 struct GNUNET_FS_TestDaemon;
39
40
41 /**
42  * Start daemons for testing.
43  *
44  * @param template_cfg_file configuration template to use
45  * @param timeout if this operation cannot be completed within the
46  *                given period, call the continuation with an error code
47  * @param total number of daemons to start
48  * @param daemons array of 'total' entries to be initialized
49  *                (array must already be allocated, will be filled)
50  * @param cont function to call when done; note that if 'cont'
51  *             is called with reason "TIMEOUT", then starting the
52  *             daemons has failed and the client MUST NOT call
53  *             'GNUNET_FS_TEST_daemons_stop'!
54  * @param cont_cls closure for cont
55  */
56 void
57 GNUNET_FS_TEST_daemons_start (const char *template_cfg_file,
58                               struct GNUNET_TIME_Relative timeout,
59                               unsigned int total,
60                               struct GNUNET_FS_TestDaemon **daemons,
61                               GNUNET_SCHEDULER_Task cont, void *cont_cls);
62
63
64 /**
65  * Connect two daemons for testing.
66  *
67  * @param daemon1 first daemon to connect
68  * @param daemon2 second first daemon to connect
69  * @param timeout if this operation cannot be completed within the
70  *                given period, call the continuation with an error code
71  * @param cont function to call when done
72  * @param cont_cls closure for cont
73  */
74 void
75 GNUNET_FS_TEST_daemons_connect (struct GNUNET_FS_TestDaemon *daemon1,
76                                 struct GNUNET_FS_TestDaemon *daemon2,
77                                 struct GNUNET_TIME_Relative timeout,
78                                 GNUNET_SCHEDULER_Task cont, void *cont_cls);
79
80
81 /**
82  * Obtain peer group used for testing.
83  *
84  * @param daemons array with the daemons (must contain at least one)
85  * @return peer group
86  */
87 struct GNUNET_TESTING_PeerGroup *GNUNET_FS_TEST_get_group (struct
88                                                            GNUNET_FS_TestDaemon
89                                                            **daemons);
90
91
92
93 /**
94  * Obtain peer configuration used for testing.
95  *
96  * @param daemons array with the daemons
97  * @param off which configuration to get
98  * @return peer configuration
99  */
100 const struct GNUNET_CONFIGURATION_Handle
101     *GNUNET_FS_TEST_get_configuration (struct GNUNET_FS_TestDaemon **daemons,
102                                        unsigned int off);
103
104 /**
105  * Stop daemons used for testing.
106  *
107  * @param total number of daemons to stop
108  * @param daemons array with the daemons (values will be clobbered)
109  */
110 void
111 GNUNET_FS_TEST_daemons_stop (unsigned int total,
112                              struct GNUNET_FS_TestDaemon **daemons);
113
114
115 /**
116  * Function signature.
117  *
118  * @param cls closure (user defined)
119  * @param uri a URI, NULL for errors
120  */
121 typedef void
122     (*GNUNET_FS_TEST_UriContinuation) (void *cls,
123                                        const struct GNUNET_FS_Uri * uri);
124
125
126 /**
127  * Publish a file at the given daemon.
128  *
129  * @param daemon where to publish
130  * @param timeout if this operation cannot be completed within the
131  *                given period, call the continuation with an error code
132  * @param anonymity option for publication
133  * @param do_index GNUNET_YES for index, GNUNET_NO for insertion,
134  *                GNUNET_SYSERR for simulation
135  * @param size size of the file to publish
136  * @param seed seed to use for file generation
137  * @param verbose how verbose to be in reporting
138  * @param cont function to call when done
139  * @param cont_cls closure for cont
140  */
141 void
142 GNUNET_FS_TEST_publish (struct GNUNET_FS_TestDaemon *daemon,
143                         struct GNUNET_TIME_Relative timeout,
144                         uint32_t anonymity,
145                         int do_index,
146                         uint64_t size,
147                         uint32_t seed,
148                         unsigned int verbose,
149                         GNUNET_FS_TEST_UriContinuation cont, void *cont_cls);
150
151
152 /**
153  * Perform test download.
154  *
155  * @param daemon which peer to download from
156  * @param timeout if this operation cannot be completed within the
157  *                given period, call the continuation with an error code
158  * @param anonymity option for download
159  * @param seed used for file validation
160  * @param uri URI of file to download (CHK/LOC only)
161  * @param verbose how verbose to be in reporting
162  * @param cont function to call when done
163  * @param cont_cls closure for cont
164  */
165 void
166 GNUNET_FS_TEST_download (struct GNUNET_FS_TestDaemon *daemon,
167                          struct GNUNET_TIME_Relative timeout,
168                          uint32_t anonymity,
169                          uint32_t seed,
170                          const struct GNUNET_FS_Uri *uri,
171                          unsigned int verbose,
172                          GNUNET_SCHEDULER_Task cont, void *cont_cls);
173
174
175
176 #endif