diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2012-12-10 16:22:21 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2012-12-10 16:22:21 +0000 |
commit | d9a76929fee0ba3d159b754a5d04afbb4a712a9c (patch) | |
tree | d75eabe77db753ee9a4f73bc38933d74fe4799d7 | |
parent | 3d265c8806e4ffbd935c55c042124323e0674f75 (diff) | |
download | gnunet-d9a76929fee0ba3d159b754a5d04afbb4a712a9c.tar.gz gnunet-d9a76929fee0ba3d159b754a5d04afbb4a712a9c.zip |
changes
-rw-r--r-- | src/ats/test_ats_api_common.h | 7 | ||||
-rw-r--r-- | src/ats/test_ats_api_scheduling_add_address.c | 4 | ||||
-rw-r--r-- | src/ats/test_ats_api_scheduling_block_and_reset.c | 4 | ||||
-rw-r--r-- | src/ats/test_ats_api_scheduling_destroy_address.c | 2 | ||||
-rw-r--r-- | src/ats/test_ats_api_scheduling_destroy_session.c | 2 | ||||
-rw-r--r-- | src/ats/test_ats_api_scheduling_update_address.c | 4 | ||||
-rw-r--r-- | src/ats/test_ats_simplistic.c | 207 |
7 files changed, 176 insertions, 54 deletions
diff --git a/src/ats/test_ats_api_common.h b/src/ats/test_ats_api_common.h index f7e787fca..b406ecd3e 100644 --- a/src/ats/test_ats_api_common.h +++ b/src/ats/test_ats_api_common.h | |||
@@ -26,7 +26,8 @@ | |||
26 | 26 | ||
27 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) | 27 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) |
28 | 28 | ||
29 | #define PEERID "2AK99KD8RM9UA9LC3QKA0IQ5UBFC0FBB50EBGCFQT8448DGGACNAC4CJQDD1CPFS494O41U88DJD1FLIG8VA5CQR9IN4L96GP104MVO" | 29 | #define PEERID0 "2AK99KD8RM9UA9LC3QKA0IQ5UBFC0FBB50EBGCFQT8448DGGACNAC4CJQDD1CPFS494O41U88DJD1FLIG8VA5CQR9IN4L96GP104MVO" |
30 | #define PEERID1 "5ED7I0AR3MSTAL7FQN04S22E0EQ3CR9RLASCDLVMM1BNFPUPTCT46DLKNJ4DACASJ6U0DR5J8S3R2UJL49682JS7MOVRAB8P8A4PJH0" | ||
30 | 31 | ||
31 | struct Test_Address | 32 | struct Test_Address |
32 | { | 33 | { |
@@ -47,6 +48,10 @@ struct PeerContext | |||
47 | struct GNUNET_PeerIdentity id; | 48 | struct GNUNET_PeerIdentity id; |
48 | 49 | ||
49 | struct Test_Address *addr; | 50 | struct Test_Address *addr; |
51 | |||
52 | unsigned long long bw_out_assigned; | ||
53 | |||
54 | unsigned long long bw_in_assigned; | ||
50 | }; | 55 | }; |
51 | 56 | ||
52 | /* end of file test_ats_api_common.h */ | 57 | /* end of file test_ats_api_common.h */ |
diff --git a/src/ats/test_ats_api_scheduling_add_address.c b/src/ats/test_ats_api_scheduling_add_address.c index 2083293c5..771ebd8cf 100644 --- a/src/ats/test_ats_api_scheduling_add_address.c +++ b/src/ats/test_ats_api_scheduling_add_address.c | |||
@@ -246,7 +246,7 @@ run (void *cls, | |||
246 | } | 246 | } |
247 | 247 | ||
248 | /* Set up peer */ | 248 | /* Set up peer */ |
249 | if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID, &p.id.hashPubKey)) | 249 | if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID0, &p.id.hashPubKey)) |
250 | { | 250 | { |
251 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n"); | 251 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n"); |
252 | ret = GNUNET_SYSERR; | 252 | ret = GNUNET_SYSERR; |
@@ -254,7 +254,7 @@ run (void *cls, | |||
254 | return; | 254 | return; |
255 | } | 255 | } |
256 | 256 | ||
257 | GNUNET_assert (0 == strcmp (PEERID, GNUNET_i2s_full (&p.id))); | 257 | GNUNET_assert (0 == strcmp (PEERID0, GNUNET_i2s_full (&p.id))); |
258 | 258 | ||
259 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n", | 259 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n", |
260 | GNUNET_i2s_full(&p.id)); | 260 | GNUNET_i2s_full(&p.id)); |
diff --git a/src/ats/test_ats_api_scheduling_block_and_reset.c b/src/ats/test_ats_api_scheduling_block_and_reset.c index 874b96683..83e37e4ea 100644 --- a/src/ats/test_ats_api_scheduling_block_and_reset.c +++ b/src/ats/test_ats_api_scheduling_block_and_reset.c | |||
@@ -385,14 +385,14 @@ run (void *cls, | |||
385 | } | 385 | } |
386 | 386 | ||
387 | /* Set up peer */ | 387 | /* Set up peer */ |
388 | if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID, &p.id.hashPubKey)) | 388 | if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID0, &p.id.hashPubKey)) |
389 | { | 389 | { |
390 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n"); | 390 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n"); |
391 | ret = GNUNET_SYSERR; | 391 | ret = GNUNET_SYSERR; |
392 | end (); | 392 | end (); |
393 | return; | 393 | return; |
394 | } | 394 | } |
395 | GNUNET_assert (0 == strcmp (PEERID, GNUNET_i2s_full (&p.id))); | 395 | GNUNET_assert (0 == strcmp (PEERID0, GNUNET_i2s_full (&p.id))); |
396 | 396 | ||
397 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n", | 397 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n", |
398 | GNUNET_i2s_full(&p.id)); | 398 | GNUNET_i2s_full(&p.id)); |
diff --git a/src/ats/test_ats_api_scheduling_destroy_address.c b/src/ats/test_ats_api_scheduling_destroy_address.c index f904595a1..c0d804077 100644 --- a/src/ats/test_ats_api_scheduling_destroy_address.c +++ b/src/ats/test_ats_api_scheduling_destroy_address.c | |||
@@ -217,7 +217,7 @@ run (void *cls, | |||
217 | } | 217 | } |
218 | 218 | ||
219 | /* Set up peer */ | 219 | /* Set up peer */ |
220 | if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID, &p.id.hashPubKey)) | 220 | if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID0, &p.id.hashPubKey)) |
221 | { | 221 | { |
222 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n"); | 222 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n"); |
223 | ret = GNUNET_SYSERR; | 223 | ret = GNUNET_SYSERR; |
diff --git a/src/ats/test_ats_api_scheduling_destroy_session.c b/src/ats/test_ats_api_scheduling_destroy_session.c index 2984c5954..61737e9e3 100644 --- a/src/ats/test_ats_api_scheduling_destroy_session.c +++ b/src/ats/test_ats_api_scheduling_destroy_session.c | |||
@@ -251,7 +251,7 @@ run (void *cls, | |||
251 | } | 251 | } |
252 | 252 | ||
253 | /* Set up peer */ | 253 | /* Set up peer */ |
254 | if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID, &p.id.hashPubKey)) | 254 | if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID0, &p.id.hashPubKey)) |
255 | { | 255 | { |
256 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n"); | 256 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n"); |
257 | ret = GNUNET_SYSERR; | 257 | ret = GNUNET_SYSERR; |
diff --git a/src/ats/test_ats_api_scheduling_update_address.c b/src/ats/test_ats_api_scheduling_update_address.c index bf7f8f388..702fe3f9a 100644 --- a/src/ats/test_ats_api_scheduling_update_address.c +++ b/src/ats/test_ats_api_scheduling_update_address.c | |||
@@ -293,7 +293,7 @@ run (void *cls, | |||
293 | } | 293 | } |
294 | 294 | ||
295 | /* Set up peer */ | 295 | /* Set up peer */ |
296 | if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID, &p.id.hashPubKey)) | 296 | if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID0, &p.id.hashPubKey)) |
297 | { | 297 | { |
298 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n"); | 298 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n"); |
299 | ret = GNUNET_SYSERR; | 299 | ret = GNUNET_SYSERR; |
@@ -301,7 +301,7 @@ run (void *cls, | |||
301 | return; | 301 | return; |
302 | } | 302 | } |
303 | 303 | ||
304 | GNUNET_assert (0 == strcmp (PEERID, GNUNET_i2s_full (&p.id))); | 304 | GNUNET_assert (0 == strcmp (PEERID0, GNUNET_i2s_full (&p.id))); |
305 | 305 | ||
306 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n", | 306 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n", |
307 | GNUNET_i2s_full(&p.id)); | 307 | GNUNET_i2s_full(&p.id)); |
diff --git a/src/ats/test_ats_simplistic.c b/src/ats/test_ats_simplistic.c index 8da88cf60..cf047ff43 100644 --- a/src/ats/test_ats_simplistic.c +++ b/src/ats/test_ats_simplistic.c | |||
@@ -36,6 +36,8 @@ | |||
36 | #include "ats.h" | 36 | #include "ats.h" |
37 | #include "test_ats_api_common.h" | 37 | #include "test_ats_api_common.h" |
38 | 38 | ||
39 | #define DEBUG_ATS_INFO GNUNET_NO | ||
40 | |||
39 | static GNUNET_SCHEDULER_TaskIdentifier die_task; | 41 | static GNUNET_SCHEDULER_TaskIdentifier die_task; |
40 | 42 | ||
41 | /** | 43 | /** |
@@ -56,7 +58,8 @@ static struct Test_Address test_addr[2]; | |||
56 | /** | 58 | /** |
57 | * Test peer | 59 | * Test peer |
58 | */ | 60 | */ |
59 | static struct PeerContext p; | 61 | static struct PeerContext p[2]; |
62 | |||
60 | 63 | ||
61 | /** | 64 | /** |
62 | * HELLO address | 65 | * HELLO address |
@@ -189,22 +192,28 @@ compare_ats (const struct GNUNET_ATS_Information *ats_is, uint32_t ats_count_is, | |||
189 | type2 = ntohl(ats_should[c_i].type); | 192 | type2 = ntohl(ats_should[c_i].type); |
190 | if (type1 == type2) | 193 | if (type1 == type2) |
191 | { | 194 | { |
195 | #if DEBUG_ATS_INFO | ||
192 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS type `%s'\n", | 196 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS type `%s'\n", |
193 | prop[type1]); | 197 | prop[type1]); |
198 | #endif | ||
194 | val1 = ntohl(ats_is[c_o].value); | 199 | val1 = ntohl(ats_is[c_o].value); |
195 | val2 = ntohl(ats_should[c_i].value); | 200 | val2 = ntohl(ats_should[c_i].value); |
196 | if (val1 != val2) | 201 | if (val1 != val2) |
197 | { | 202 | { |
203 | #if DEBUG_ATS_INFO | ||
198 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ATS value `%s' not equal: %u != %u\n", | 204 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ATS value `%s' not equal: %u != %u\n", |
199 | prop[type1], | 205 | prop[type1], |
200 | val1, val2); | 206 | val1, val2); |
207 | #endif | ||
201 | res = GNUNET_SYSERR; | 208 | res = GNUNET_SYSERR; |
202 | } | 209 | } |
203 | else | 210 | else |
204 | { | 211 | { |
212 | #if DEBUG_ATS_INFO | ||
205 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS value `%s' equal: %u == %u\n", | 213 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS value `%s' equal: %u == %u\n", |
206 | prop[type1], | 214 | prop[type1], |
207 | val1, val2); | 215 | val1, val2); |
216 | #endif | ||
208 | } | 217 | } |
209 | } | 218 | } |
210 | } | 219 | } |
@@ -220,50 +229,144 @@ address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address, | |||
220 | const struct GNUNET_ATS_Information *atsi, | 229 | const struct GNUNET_ATS_Information *atsi, |
221 | uint32_t ats_count) | 230 | uint32_t ats_count) |
222 | { | 231 | { |
223 | if (GNUNET_OK == compare_addresses (address, session, &test_hello_address[0], test_session[0])) | 232 | static int stage = 0; |
224 | { | 233 | unsigned int bw_in = ntohl(bandwidth_in.value__); |
225 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage 0: Callback with correct address `%s'\n", | 234 | unsigned int bw_out = ntohl(bandwidth_out.value__); |
226 | GNUNET_i2s (&address->peer)); | 235 | if (0 == stage) |
227 | ret = 0; | ||
228 | } | ||
229 | else | ||
230 | { | 236 | { |
231 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage 0: Callback with invalid address `%s'\n", | 237 | if (GNUNET_OK == compare_addresses (address, session, &test_hello_address[0], test_session[0])) |
232 | GNUNET_i2s (&address->peer)); | 238 | { |
239 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage 0: Callback with correct address `%s'\n", | ||
240 | GNUNET_i2s (&address->peer)); | ||
241 | ret = 0; | ||
242 | } | ||
243 | else | ||
244 | { | ||
245 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage 0: Callback with invalid address `%s'\n", | ||
246 | GNUNET_i2s (&address->peer)); | ||
247 | ret = 1; | ||
248 | } | ||
249 | |||
250 | if (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info, test_ats_count)) | ||
251 | { | ||
252 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage 0: Callback with incorrect ats info \n"); | ||
233 | ret = 1; | 253 | ret = 1; |
234 | } | 254 | } |
235 | 255 | ||
236 | if (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info, test_ats_count)) | 256 | if (bw_in > wan_quota_in) |
237 | { | 257 | { |
238 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage 0: Callback with incorrect ats info \n"); | 258 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Suggested WAN inbound quota %u bigger than allowed quota %llu \n", |
239 | ret = 1; | 259 | bw_in, wan_quota_in); |
240 | } | 260 | ret = 1; |
261 | } | ||
262 | else | ||
263 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Suggested WAN inbound quota %u, allowed quota %llu \n", | ||
264 | bw_in, wan_quota_in); | ||
241 | 265 | ||
242 | if (ntohl(bandwidth_in.value__) > wan_quota_in) | 266 | if (bw_out > wan_quota_out) |
243 | { | 267 | { |
244 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Suggested WAN inbound quota %u bigger than allowed quota %llu \n", | 268 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Suggested WAN outbound quota %u bigger than allowed quota %llu \n", |
245 | (unsigned int) ntohl(bandwidth_in.value__), wan_quota_in); | 269 | bw_out, wan_quota_out); |
246 | ret = 1; | 270 | ret = 1; |
247 | } | 271 | } |
248 | else | 272 | else |
249 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Suggested WAN inbound quota %u, allowed quota %llu \n", | 273 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Suggested WAN outbound quota %u, allowed quota %llu \n", |
250 | (unsigned int) ntohl(bandwidth_in.value__), wan_quota_in); | 274 | bw_out, wan_quota_out); |
251 | 275 | ||
252 | if (ntohl(bandwidth_out.value__) > wan_quota_out) | 276 | if (1 == ret) |
277 | { | ||
278 | GNUNET_ATS_suggest_address_cancel (sched_ats, &p[0].id); | ||
279 | GNUNET_SCHEDULER_add_now (&end, NULL); | ||
280 | return; | ||
281 | } | ||
282 | p[0].bw_out_assigned = bw_out; | ||
283 | p[0].bw_in_assigned = bw_in; | ||
284 | stage ++; | ||
285 | |||
286 | /* Add a 2nd address */ | ||
287 | /* Prepare ATS Information */ | ||
288 | test_ats_info[0].type = htonl (GNUNET_ATS_NETWORK_TYPE); | ||
289 | test_ats_info[0].value = htonl(GNUNET_ATS_NET_WAN); | ||
290 | test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE); | ||
291 | test_ats_info[1].value = htonl(1); | ||
292 | test_ats_count = 2; | ||
293 | |||
294 | /* Adding address with session */ | ||
295 | test_session[1] = &test_addr[1]; | ||
296 | create_test_address (&test_addr[1], "test1", test_session[1], "test1", strlen ("test1") + 1); | ||
297 | test_hello_address[1].peer = p[1].id; | ||
298 | test_hello_address[1].transport_name = test_addr[1].plugin; | ||
299 | test_hello_address[1].address = test_addr[1].addr; | ||
300 | test_hello_address[1].address_length = test_addr[1].addr_len; | ||
301 | GNUNET_ATS_address_add (sched_ats, &test_hello_address[1], test_session[1], test_ats_info, test_ats_count); | ||
302 | } | ||
303 | if (1 == stage) | ||
253 | { | 304 | { |
254 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Suggested WAN outbound quota %u bigger than allowed quota %llu \n", | 305 | /* Expecting callback for address[0] with updated quota and no callback for address[1]*/ |
255 | (unsigned int) ntohl(bandwidth_out.value__), wan_quota_out); | 306 | if (GNUNET_OK == compare_addresses (address, session, &test_hello_address[0], test_session[0])) |
256 | ret = 1; | 307 | { |
308 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage 1: Callback with correct address `%s'\n", | ||
309 | GNUNET_i2s (&address->peer)); | ||
310 | ret = 0; | ||
311 | } | ||
312 | else | ||
313 | { | ||
314 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage 1: Callback with invalid address `%s'\n", | ||
315 | GNUNET_i2s (&address->peer)); | ||
316 | ret = 1; | ||
317 | } | ||
318 | |||
319 | if (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info, test_ats_count)) | ||
320 | { | ||
321 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage 1: Callback with incorrect ats info \n"); | ||
322 | ret = 1; | ||
323 | } | ||
324 | |||
325 | if (bw_in > wan_quota_in) | ||
326 | { | ||
327 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Suggested WAN inbound quota %u bigger than allowed quota %llu \n", | ||
328 | bw_in, wan_quota_in); | ||
329 | ret = 1; | ||
330 | } | ||
331 | else if (p[0].bw_in_assigned > bw_in) | ||
332 | { | ||
333 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Suggested WAN inbound quota %u bigger than last quota %llu \n", | ||
334 | bw_in, p[0].bw_in_assigned); | ||
335 | ret = 1; | ||
336 | } | ||
337 | else | ||
338 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Suggested WAN inbound quota %u, allowed quota %llu \n", | ||
339 | bw_in, wan_quota_in); | ||
340 | |||
341 | if (bw_out > wan_quota_out) | ||
342 | { | ||
343 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Suggested WAN outbound quota %u bigger than allowed quota %llu \n", | ||
344 | bw_out, wan_quota_out); | ||
345 | ret = 1; | ||
346 | } | ||
347 | else if (p[0].bw_out_assigned > bw_out) | ||
348 | { | ||
349 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Suggested WAN inbound quota %u bigger than last quota %llu \n", | ||
350 | bw_out, p[0].bw_out_assigned); | ||
351 | ret = 1; | ||
352 | } | ||
353 | else | ||
354 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Suggested WAN outbound quota %u, allowed quota %llu \n", | ||
355 | bw_out, wan_quota_out); | ||
356 | |||
357 | if (1 == ret) | ||
358 | { | ||
359 | GNUNET_ATS_suggest_address_cancel (sched_ats, &p[1].id); | ||
360 | GNUNET_SCHEDULER_add_now (&end, NULL); | ||
361 | return; | ||
362 | } | ||
363 | stage ++; | ||
364 | |||
365 | GNUNET_ATS_suggest_address_cancel (sched_ats, &p[1].id); | ||
366 | GNUNET_SCHEDULER_add_now (&end, NULL); | ||
367 | return; | ||
257 | } | 368 | } |
258 | else | ||
259 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Suggested WAN outbound quota %u, allowed quota %llu \n", | ||
260 | (unsigned int) ntohl(bandwidth_out.value__), wan_quota_out); | ||
261 | |||
262 | |||
263 | |||
264 | 369 | ||
265 | GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id); | ||
266 | GNUNET_SCHEDULER_add_now (&end, NULL); | ||
267 | } | 370 | } |
268 | 371 | ||
269 | static void | 372 | static void |
@@ -320,8 +423,22 @@ run (void *cls, | |||
320 | return; | 423 | return; |
321 | } | 424 | } |
322 | 425 | ||
323 | /* Set up peer */ | 426 | /* Set up peer 0 */ |
324 | if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID, &p.id.hashPubKey)) | 427 | if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID0, &p[0].id.hashPubKey)) |
428 | { | ||
429 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n"); | ||
430 | ret = GNUNET_SYSERR; | ||
431 | end (); | ||
432 | return; | ||
433 | } | ||
434 | |||
435 | GNUNET_assert (0 == strcmp (PEERID0, GNUNET_i2s_full (&p[0].id))); | ||
436 | |||
437 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n", | ||
438 | GNUNET_i2s(&p[0].id)); | ||
439 | |||
440 | /* Set up peer 1*/ | ||
441 | if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID1, &p[1].id.hashPubKey)) | ||
325 | { | 442 | { |
326 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n"); | 443 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n"); |
327 | ret = GNUNET_SYSERR; | 444 | ret = GNUNET_SYSERR; |
@@ -329,10 +446,10 @@ run (void *cls, | |||
329 | return; | 446 | return; |
330 | } | 447 | } |
331 | 448 | ||
332 | GNUNET_assert (0 == strcmp (PEERID, GNUNET_i2s_full (&p.id))); | 449 | GNUNET_assert (0 == strcmp (PEERID1, GNUNET_i2s_full (&p[1].id))); |
333 | 450 | ||
334 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n", | 451 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n", |
335 | GNUNET_i2s(&p.id)); | 452 | GNUNET_i2s(&p[1].id)); |
336 | 453 | ||
337 | /* Prepare ATS Information */ | 454 | /* Prepare ATS Information */ |
338 | test_ats_info[0].type = htonl (GNUNET_ATS_NETWORK_TYPE); | 455 | test_ats_info[0].type = htonl (GNUNET_ATS_NETWORK_TYPE); |
@@ -341,16 +458,16 @@ run (void *cls, | |||
341 | test_ats_info[1].value = htonl(1); | 458 | test_ats_info[1].value = htonl(1); |
342 | test_ats_count = 2; | 459 | test_ats_count = 2; |
343 | 460 | ||
344 | /* Adding address without session */ | 461 | /* Adding address with session */ |
345 | test_session[0] = &test_addr[0]; | 462 | test_session[0] = &test_addr[0]; |
346 | create_test_address (&test_addr[0], "test", test_session, "test", strlen ("test") + 1); | 463 | create_test_address (&test_addr[0], "test0", test_session[0], "test0", strlen ("test0") + 1); |
347 | test_hello_address[0].peer = p.id; | 464 | test_hello_address[0].peer = p[0].id; |
348 | test_hello_address[0].transport_name = test_addr[0].plugin; | 465 | test_hello_address[0].transport_name = test_addr[0].plugin; |
349 | test_hello_address[0].address = test_addr[0].addr; | 466 | test_hello_address[0].address = test_addr[0].addr; |
350 | test_hello_address[0].address_length = test_addr[0].addr_len; | 467 | test_hello_address[0].address_length = test_addr[0].addr_len; |
351 | GNUNET_ATS_address_add (sched_ats, &test_hello_address[0], test_session[0], test_ats_info, test_ats_count); | 468 | GNUNET_ATS_address_add (sched_ats, &test_hello_address[0], test_session[0], test_ats_info, test_ats_count); |
352 | 469 | ||
353 | GNUNET_ATS_suggest_address (sched_ats, &p.id); | 470 | GNUNET_ATS_suggest_address (sched_ats, &p[0].id); |
354 | } | 471 | } |
355 | 472 | ||
356 | 473 | ||