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/>.
18 SPDX-License-Identifier: AGPL3.0-or-later
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 */
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,
96 const struct GNUNET_PeerIdentity *peer,
97 const struct GNUNET_HELLO_Message *hello,
102 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
103 "Error in communication with PEERINFO service: %s\n",
109 if ((3 == global_ret) && (retries < 50))
114 ic = GNUNET_PEERINFO_iterate(h,
121 GNUNET_assert(peer == NULL);
122 GNUNET_PEERINFO_disconnect(h);
128 if ((NULL != hello) &&
129 (GNUNET_YES == GNUNET_HELLO_is_friend_only(hello)))
132 "Received friend-only HELLO\n");
134 GNUNET_PEERINFO_disconnect(h);
143 const struct GNUNET_CONFIGURATION_Handle *cfg,
144 struct GNUNET_TESTING_Peer *peer)
146 h = GNUNET_PEERINFO_connect(cfg);
147 GNUNET_assert(NULL != h);
149 ic = GNUNET_PEERINFO_iterate(h,
162 if (0 != GNUNET_TESTING_service_run("test-peerinfo-api-friend-only",
164 "test_peerinfo_api_data.conf",
170 /* end of test_peerinfo_api_friend_only */