modified termination condition
[oweals/gnunet.git] / src / ats / test_ats_api_common.h
1 /*
2      This file is part of GNUnet.
3      (C) 2010,2011 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  * @file ats/test_ats_api_common.h
22  * @brief shared definitions for ats testcases
23  * @author Christian Grothoff
24  * @author Matthias Wachs
25  */
26
27 #include "platform.h"
28 #include "gnunet_common.h"
29 #include "gnunet_ats_service.h"
30 #include "gnunet-service-ats_addresses.h"
31
32 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
33
34 #define PEERID0 "2AK99KD8RM9UA9LC3QKA0IQ5UBFC0FBB50EBGCFQT8448DGGACNAC4CJQDD1CPFS494O41U88DJD1FLIG8VA5CQR9IN4L96GP104MVO"
35 #define PEERID1 "5ED7I0AR3MSTAL7FQN04S22E0EQ3CR9RLASCDLVMM1BNFPUPTCT46DLKNJ4DACASJ6U0DR5J8S3R2UJL49682JS7MOVRAB8P8A4PJH0"
36
37 struct Test_Address
38 {
39   char *plugin;
40   size_t plugin_len;
41
42   void *addr;
43   size_t addr_len;
44
45   struct GNUNET_ATS_Information *ats;
46   int ats_count;
47
48   void *session;
49 };
50
51 struct PeerContext
52 {
53   struct GNUNET_PeerIdentity id;
54
55   struct Test_Address *addr;
56
57   unsigned long long bw_out_assigned;
58
59   unsigned long long bw_in_assigned;
60 };
61
62 void
63 free_test_address (struct Test_Address *dest);
64
65 void
66 create_test_address (struct Test_Address *dest, char * plugin, void *session, void *addr, size_t addrlen);
67
68 int
69 compare_addresses (const struct GNUNET_HELLO_Address *address1, void *session1,
70                    const struct GNUNET_HELLO_Address *address2, void *session2);
71
72 int
73 compare_ats (const struct GNUNET_ATS_Information *ats_is, uint32_t ats_count_is,
74              const struct GNUNET_ATS_Information *ats_should, uint32_t ats_count_should);
75
76 struct ATS_Address *
77 create_address (const struct GNUNET_PeerIdentity *peer,
78                 const char *plugin_name,
79                 const void *plugin_addr, size_t plugin_addr_len,
80                 uint32_t session_id);
81
82 /**
83  * Load quotas for networks from configuration
84  *
85  * @param cfg configuration handle
86  * @param out_dest where to write outbound quotas
87  * @param in_dest where to write inbound quotas
88  * @param dest_length length of inbound and outbound arrays
89  * @return number of networks loaded
90  */
91 unsigned int
92 load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg,
93                                                  unsigned long long *out_dest,
94                                                  unsigned long long *in_dest,
95                                                  int dest_length);
96
97 /* end of file test_ats_api_common.h */