diff options
Diffstat (limited to 'src/peerinfo/test_peerinfo_api.c')
-rw-r--r-- | src/peerinfo/test_peerinfo_api.c | 44 |
1 files changed, 20 insertions, 24 deletions
diff --git a/src/peerinfo/test_peerinfo_api.c b/src/peerinfo/test_peerinfo_api.c index e740f1fc9..bbdc591f4 100644 --- a/src/peerinfo/test_peerinfo_api.c +++ b/src/peerinfo/test_peerinfo_api.c | |||
@@ -45,9 +45,7 @@ static struct GNUNET_PEERINFO_Handle *h; | |||
45 | static unsigned int retries; | 45 | static unsigned int retries; |
46 | 46 | ||
47 | static int | 47 | static int |
48 | check_it (void *cls, | 48 | check_it (void *cls, const char *tname, struct GNUNET_TIME_Absolute expiration, |
49 | const char *tname, | ||
50 | struct GNUNET_TIME_Absolute expiration, | ||
51 | const void *addr, uint16_t addrlen) | 49 | const void *addr, uint16_t addrlen) |
52 | { | 50 | { |
53 | unsigned int *agc = cls; | 51 | unsigned int *agc = cls; |
@@ -70,10 +68,11 @@ address_generator (void *cls, size_t max, void *buf) | |||
70 | 68 | ||
71 | if (0 == *agc) | 69 | if (0 == *agc) |
72 | return 0; | 70 | return 0; |
73 | ret = GNUNET_HELLO_add_address ("peerinfotest", | 71 | ret = |
74 | GNUNET_TIME_relative_to_absolute | 72 | GNUNET_HELLO_add_address ("peerinfotest", |
75 | (GNUNET_TIME_UNIT_HOURS), "Address", *agc, | 73 | GNUNET_TIME_relative_to_absolute |
76 | buf, max); | 74 | (GNUNET_TIME_UNIT_HOURS), "Address", *agc, buf, |
75 | max); | ||
77 | (*agc)--; | 76 | (*agc)--; |
78 | return ret; | 77 | return ret; |
79 | } | 78 | } |
@@ -98,8 +97,7 @@ add_peer () | |||
98 | 97 | ||
99 | 98 | ||
100 | static void | 99 | static void |
101 | process (void *cls, | 100 | process (void *cls, const struct GNUNET_PeerIdentity *peer, |
102 | const struct GNUNET_PeerIdentity *peer, | ||
103 | const struct GNUNET_HELLO_Message *hello, const char *err_msg) | 101 | const struct GNUNET_HELLO_Message *hello, const char *err_msg) |
104 | { | 102 | { |
105 | int *ok = cls; | 103 | int *ok = cls; |
@@ -119,11 +117,10 @@ process (void *cls, | |||
119 | /* try again */ | 117 | /* try again */ |
120 | retries++; | 118 | retries++; |
121 | add_peer (); | 119 | add_peer (); |
122 | ic = GNUNET_PEERINFO_iterate (h, | 120 | ic = GNUNET_PEERINFO_iterate (h, NULL, |
123 | NULL, | ||
124 | GNUNET_TIME_relative_multiply | 121 | GNUNET_TIME_relative_multiply |
125 | (GNUNET_TIME_UNIT_SECONDS, 15), | 122 | (GNUNET_TIME_UNIT_SECONDS, 15), &process, |
126 | &process, cls); | 123 | cls); |
127 | return; | 124 | return; |
128 | } | 125 | } |
129 | GNUNET_assert (peer == NULL); | 126 | GNUNET_assert (peer == NULL); |
@@ -145,16 +142,14 @@ process (void *cls, | |||
145 | 142 | ||
146 | 143 | ||
147 | static void | 144 | static void |
148 | run (void *cls, | 145 | run (void *cls, char *const *args, const char *cfgfile, |
149 | char *const *args, | 146 | const struct GNUNET_CONFIGURATION_Handle *c) |
150 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) | ||
151 | { | 147 | { |
152 | cfg = c; | 148 | cfg = c; |
153 | h = GNUNET_PEERINFO_connect (cfg); | 149 | h = GNUNET_PEERINFO_connect (cfg); |
154 | GNUNET_assert (h != NULL); | 150 | GNUNET_assert (h != NULL); |
155 | add_peer (); | 151 | add_peer (); |
156 | ic = GNUNET_PEERINFO_iterate (h, | 152 | ic = GNUNET_PEERINFO_iterate (h, NULL, |
157 | NULL, | ||
158 | GNUNET_TIME_relative_multiply | 153 | GNUNET_TIME_relative_multiply |
159 | (GNUNET_TIME_UNIT_SECONDS, 15), &process, cls); | 154 | (GNUNET_TIME_UNIT_SECONDS, 15), &process, cls); |
160 | } | 155 | } |
@@ -177,15 +172,16 @@ check () | |||
177 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 172 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
178 | GNUNET_GETOPT_OPTION_END | 173 | GNUNET_GETOPT_OPTION_END |
179 | }; | 174 | }; |
180 | proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-peerinfo", | 175 | proc = |
181 | "gnunet-service-peerinfo", | 176 | GNUNET_OS_start_process (NULL, NULL, "gnunet-service-peerinfo", |
177 | "gnunet-service-peerinfo", | ||
182 | #if DEBUG_PEERINFO | 178 | #if DEBUG_PEERINFO |
183 | "-L", "DEBUG", | 179 | "-L", "DEBUG", |
184 | #endif | 180 | #endif |
185 | "-c", "test_peerinfo_api_data.conf", NULL); | 181 | "-c", "test_peerinfo_api_data.conf", NULL); |
186 | GNUNET_assert (NULL != proc); | 182 | GNUNET_assert (NULL != proc); |
187 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, | 183 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, |
188 | argv, "test-peerinfo-api", "nohelp", options, &run, &ok); | 184 | "test-peerinfo-api", "nohelp", options, &run, &ok); |
189 | if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) | 185 | if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) |
190 | { | 186 | { |
191 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | 187 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); |