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
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., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
22 * @file peerinfo/test_peerinfo_api_friend_only.c
23 * @brief testcase friend only HELLO restrictions in for peerinfo
24 * @author Christian Grothoff
25 * @author Matthias Wachs
28 * - test merging of HELLOs (add same peer twice...)
31 #include "gnunet_hello_lib.h"
32 #include "gnunet_util_lib.h"
33 #include "gnunet_peerinfo_service.h"
34 #include "gnunet_testing_lib.h"
37 static struct GNUNET_PEERINFO_IteratorContext *ic;
39 static struct GNUNET_PEERINFO_Handle *h;
41 static struct GNUNET_PeerIdentity pid;
43 static unsigned int retries;
45 static int global_ret;
49 address_generator (void *cls,
55 struct GNUNET_HELLO_Address address;
58 return GNUNET_SYSERR; /* Done */
59 memset (&address.peer,
61 sizeof (struct GNUNET_PeerIdentity));
62 address.address = "Address";
63 address.transport_name = "peerinfotest";
64 address.address_length = *agc;
65 ret = GNUNET_HELLO_add_address (&address,
66 GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS),
77 struct GNUNET_HELLO_Message *h2;
81 memset (&pid, 32, sizeof (pid));
82 h2 = GNUNET_HELLO_create (&pid.public_key,
86 GNUNET_PEERINFO_add_peer (h,
97 const struct GNUNET_PeerIdentity *peer,
98 const struct GNUNET_HELLO_Message *hello,
103 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
104 "Error in communication with PEERINFO service: %s\n",
110 if ((3 == global_ret) && (retries < 50))
115 ic = GNUNET_PEERINFO_iterate (h,
122 GNUNET_assert (peer == NULL);
123 GNUNET_PEERINFO_disconnect (h);
129 if ( (NULL != hello) &&
130 (GNUNET_YES == GNUNET_HELLO_is_friend_only (hello)) )
133 "Received friend-only HELLO\n");
135 GNUNET_PEERINFO_disconnect (h);
144 const struct GNUNET_CONFIGURATION_Handle *cfg,
145 struct GNUNET_TESTING_Peer *peer)
147 h = GNUNET_PEERINFO_connect (cfg);
148 GNUNET_assert (NULL != h);
150 ic = GNUNET_PEERINFO_iterate (h,
163 if (0 != GNUNET_TESTING_service_run ("test-peerinfo-api-friend-only",
165 "test_peerinfo_api_data.conf",
171 /* end of test_peerinfo_api_friend_only */