summaryrefslogtreecommitdiff
path: root/src/peerinfo/test_peerinfo_shipped_hellos.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/peerinfo/test_peerinfo_shipped_hellos.c')
-rw-r--r--src/peerinfo/test_peerinfo_shipped_hellos.c134
1 files changed, 67 insertions, 67 deletions
diff --git a/src/peerinfo/test_peerinfo_shipped_hellos.c b/src/peerinfo/test_peerinfo_shipped_hellos.c
index 4da6ef0ac..36deade1e 100644
--- a/src/peerinfo/test_peerinfo_shipped_hellos.c
+++ b/src/peerinfo/test_peerinfo_shipped_hellos.c
@@ -11,12 +11,12 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 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/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19*/ 19 */
20 20
21/** 21/**
22 * @file peerinfo/test_peerinfo_shipped_hellos.c 22 * @file peerinfo/test_peerinfo_shipped_hellos.c
@@ -40,102 +40,102 @@ static int global_ret;
40 40
41 41
42static int 42static int
43addr_cb (void *cls, 43addr_cb(void *cls,
44 const struct GNUNET_HELLO_Address *address, 44 const struct GNUNET_HELLO_Address *address,
45 struct GNUNET_TIME_Absolute expiration) 45 struct GNUNET_TIME_Absolute expiration)
46{ 46{
47 unsigned int *addr = cls; 47 unsigned int *addr = cls;
48 48
49 (*addr) ++; 49 (*addr)++;
50 return GNUNET_OK; 50 return GNUNET_OK;
51} 51}
52 52
53 53
54static void 54static void
55process (void *cls, 55process(void *cls,
56 const struct GNUNET_PeerIdentity *peer, 56 const struct GNUNET_PeerIdentity *peer,
57 const struct GNUNET_HELLO_Message *hello, 57 const struct GNUNET_HELLO_Message *hello,
58 const char *err_msg) 58 const char *err_msg)
59{ 59{
60 static unsigned int calls = 0; 60 static unsigned int calls = 0;
61 unsigned int addr; 61 unsigned int addr;
62 62
63 if (NULL != err_msg) 63 if (NULL != err_msg)
64 {
65 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
66 "Error in communication with PEERINFO service: %s\n",
67 err_msg);
68 }
69 if (NULL != peer)
70 {
71 addr = 0;
72 if (NULL != hello)
73 { 64 {
74 GNUNET_HELLO_iterate_addresses (hello, 65 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
75 GNUNET_NO, 66 "Error in communication with PEERINFO service: %s\n",
76 &addr_cb, 67 err_msg);
77 &addr);
78 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
79 "Got information about peer %s with %u addresses\n",
80 GNUNET_i2s (peer),
81 addr);
82 calls++;
83 } 68 }
84 else 69 if (NULL != peer)
85 { 70 {
86 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 71 addr = 0;
87 "Got no HELLP for peer %s\n", 72 if (NULL != hello)
88 GNUNET_i2s (peer)); 73 {
74 GNUNET_HELLO_iterate_addresses(hello,
75 GNUNET_NO,
76 &addr_cb,
77 &addr);
78 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
79 "Got information about peer %s with %u addresses\n",
80 GNUNET_i2s(peer),
81 addr);
82 calls++;
83 }
84 else
85 {
86 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
87 "Got no HELLP for peer %s\n",
88 GNUNET_i2s(peer));
89 }
89 } 90 }
90 }
91 else 91 else
92 {
93 if (0 == calls)
94 {
95 fprintf (stderr,
96 "Failed: got no callbacks!\n");
97 global_ret = 1;
98 GNUNET_PEERINFO_disconnect (h);
99 h = NULL;
100 }
101 else
102 { 92 {
103 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 93 if (0 == calls)
104 "Got %u HELLOs in total\n", 94 {
105 calls); 95 fprintf(stderr,
106 global_ret = 0; 96 "Failed: got no callbacks!\n");
107 GNUNET_PEERINFO_disconnect (h); 97 global_ret = 1;
108 h = NULL; 98 GNUNET_PEERINFO_disconnect(h);
99 h = NULL;
100 }
101 else
102 {
103 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
104 "Got %u HELLOs in total\n",
105 calls);
106 global_ret = 0;
107 GNUNET_PEERINFO_disconnect(h);
108 h = NULL;
109 }
109 } 110 }
110 }
111} 111}
112 112
113 113
114static void 114static void
115run (void *cls, 115run(void *cls,
116 const struct GNUNET_CONFIGURATION_Handle *cfg, 116 const struct GNUNET_CONFIGURATION_Handle *cfg,
117 struct GNUNET_TESTING_Peer *peer) 117 struct GNUNET_TESTING_Peer *peer)
118{ 118{
119 h = GNUNET_PEERINFO_connect (cfg); 119 h = GNUNET_PEERINFO_connect(cfg);
120 GNUNET_assert (NULL != h); 120 GNUNET_assert(NULL != h);
121 ic = GNUNET_PEERINFO_iterate (h, 121 ic = GNUNET_PEERINFO_iterate(h,
122 GNUNET_YES, 122 GNUNET_YES,
123 NULL, 123 NULL,
124 &process, 124 &process,
125 cls); 125 cls);
126 GNUNET_assert (NULL != ic); 126 GNUNET_assert(NULL != ic);
127} 127}
128 128
129 129
130int 130int
131main (int argc, 131main(int argc,
132 char *argv[]) 132 char *argv[])
133{ 133{
134 global_ret = 3; 134 global_ret = 3;
135 if (0 != GNUNET_TESTING_service_run ("test_peerinfo_shipped_hellos", 135 if (0 != GNUNET_TESTING_service_run("test_peerinfo_shipped_hellos",
136 "peerinfo", 136 "peerinfo",
137 "test_peerinfo_api_data.conf", 137 "test_peerinfo_api_data.conf",
138 &run, NULL)) 138 &run, NULL))
139 return 1; 139 return 1;
140 return global_ret; 140 return global_ret;
141} 141}