2 This file is part of GNUnet.
3 Copyright (C) 2004, 2009 GNUnet e.V.
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.
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.
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/>.
20 * @file peerinfo/test_peerinfo_api_friend_only.c
21 * @brief testcase friend only HELLO restrictions in for peerinfo
22 * @author Christian Grothoff
23 * @author Matthias Wachs
26 * - test merging of HELLOs (add same peer twice...)
29 #include "gnunet_hello_lib.h"
30 #include "gnunet_util_lib.h"
31 #include "gnunet_peerinfo_service.h"
32 #include "gnunet_testing_lib.h"
35 static struct GNUNET_PEERINFO_IteratorContext *ic;
37 static struct GNUNET_PEERINFO_Handle *h;
39 static struct GNUNET_PeerIdentity pid;
41 static unsigned int retries;
43 static int global_ret;
47 address_generator (void *cls,
53 struct GNUNET_HELLO_Address address;
56 return GNUNET_SYSERR; /* Done */
57 memset (&address.peer,
59 sizeof (struct GNUNET_PeerIdentity));
60 address.address = "Address";
61 address.transport_name = "peerinfotest";
62 address.address_length = *agc;
63 ret = GNUNET_HELLO_add_address (&address,
64 GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS),
75 struct GNUNET_HELLO_Message *h2;
79 memset (&pid, 32, sizeof (pid));
80 h2 = GNUNET_HELLO_create (&pid.public_key,
84 GNUNET_PEERINFO_add_peer (h,
95 const struct GNUNET_PeerIdentity *peer,
96 const struct GNUNET_HELLO_Message *hello,
101 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
102 "Error in communication with PEERINFO service: %s\n",
108 if ((3 == global_ret) && (retries < 50))
113 ic = GNUNET_PEERINFO_iterate (h,
120 GNUNET_assert (peer == NULL);
121 GNUNET_PEERINFO_disconnect (h);
127 if ( (NULL != hello) &&
128 (GNUNET_YES == GNUNET_HELLO_is_friend_only (hello)) )
131 "Received friend-only HELLO\n");
133 GNUNET_PEERINFO_disconnect (h);
142 const struct GNUNET_CONFIGURATION_Handle *cfg,
143 struct GNUNET_TESTING_Peer *peer)
145 h = GNUNET_PEERINFO_connect (cfg);
146 GNUNET_assert (NULL != h);
148 ic = GNUNET_PEERINFO_iterate (h,
161 if (0 != GNUNET_TESTING_service_run ("test-peerinfo-api-friend-only",
163 "test_peerinfo_api_data.conf",
169 /* end of test_peerinfo_api_friend_only */