2 This file is part of GNUnet.
3 (C) 2010 Christian Grothoff (and other contributing authors)
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.
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.
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.
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
32 #include "gnunet_util_lib.h"
33 #include "gnunet_fs_service.h"
36 * Handle for a daemon started for testing FS.
38 struct GNUNET_FS_TestDaemon;
42 * Start daemons for testing.
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
57 GNUNET_FS_TEST_daemons_start (const char *template_cfg_file,
58 struct GNUNET_TIME_Relative timeout,
60 struct GNUNET_FS_TestDaemon **daemons,
61 GNUNET_SCHEDULER_Task cont, void *cont_cls);
64 struct GNUNET_FS_TEST_ConnectContext;
68 * Connect two daemons for testing.
70 * @param daemon1 first daemon to connect
71 * @param daemon2 second first daemon to connect
72 * @param timeout if this operation cannot be completed within the
73 * given period, call the continuation with an error code
74 * @param cont function to call when done
75 * @param cont_cls closure for cont
77 struct GNUNET_FS_TEST_ConnectContext *
78 GNUNET_FS_TEST_daemons_connect (struct GNUNET_FS_TestDaemon *daemon1,
79 struct GNUNET_FS_TestDaemon *daemon2,
80 struct GNUNET_TIME_Relative timeout,
81 GNUNET_SCHEDULER_Task cont, void *cont_cls);
85 * Cancel connect operation.
87 * @param cc operation to cancel
90 GNUNET_FS_TEST_daemons_connect_cancel (struct GNUNET_FS_TEST_ConnectContext *cc);
94 * Obtain peer group used for testing.
96 * @param daemons array with the daemons (must contain at least one)
99 struct GNUNET_TESTING_PeerGroup *
100 GNUNET_FS_TEST_get_group (struct GNUNET_FS_TestDaemon **daemons);
105 * Obtain peer configuration used for testing.
107 * @param daemons array with the daemons
108 * @param off which configuration to get
109 * @return peer configuration
111 const struct GNUNET_CONFIGURATION_Handle *
112 GNUNET_FS_TEST_get_configuration (struct GNUNET_FS_TestDaemon **daemons,
116 * Stop daemons used for testing.
118 * @param total number of daemons to stop
119 * @param daemons array with the daemons (values will be clobbered)
122 GNUNET_FS_TEST_daemons_stop (unsigned int total,
123 struct GNUNET_FS_TestDaemon **daemons);
127 * Function signature.
129 * @param cls closure (user defined)
130 * @param uri a URI, NULL for errors
132 typedef void (*GNUNET_FS_TEST_UriContinuation) (void *cls,
133 const struct GNUNET_FS_Uri *
138 * Publish a file at the given daemon.
140 * @param daemon where to publish
141 * @param timeout if this operation cannot be completed within the
142 * given period, call the continuation with an error code
143 * @param anonymity option for publication
144 * @param do_index GNUNET_YES for index, GNUNET_NO for insertion,
145 * GNUNET_SYSERR for simulation
146 * @param size size of the file to publish
147 * @param seed seed to use for file generation
148 * @param verbose how verbose to be in reporting
149 * @param cont function to call when done
150 * @param cont_cls closure for cont
153 GNUNET_FS_TEST_publish (struct GNUNET_FS_TestDaemon *daemon,
154 struct GNUNET_TIME_Relative timeout, uint32_t anonymity,
155 int do_index, uint64_t size, uint32_t seed,
156 unsigned int verbose,
157 GNUNET_FS_TEST_UriContinuation cont, void *cont_cls);
161 * Perform test download.
163 * @param daemon which peer to download from
164 * @param timeout if this operation cannot be completed within the
165 * given period, call the continuation with an error code
166 * @param anonymity option for download
167 * @param seed used for file validation
168 * @param uri URI of file to download (CHK/LOC only)
169 * @param verbose how verbose to be in reporting
170 * @param cont function to call when done
171 * @param cont_cls closure for cont
174 GNUNET_FS_TEST_download (struct GNUNET_FS_TestDaemon *daemon,
175 struct GNUNET_TIME_Relative timeout,
176 uint32_t anonymity, uint32_t seed,
177 const struct GNUNET_FS_Uri *uri, unsigned int verbose,
178 GNUNET_SCHEDULER_Task cont, void *cont_cls);