diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2012-03-22 18:20:49 +0000 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2012-03-22 18:20:49 +0000 |
commit | 287d9eaf1a821d763b51cac14e526ddc7ebdbe12 (patch) | |
tree | 8bc06464a5802f99e6e79510e0b50b8bfaf08b86 /src | |
parent | f948a3c0a1b817e3920f58b2b6b19281fa090913 (diff) | |
download | gnunet-287d9eaf1a821d763b51cac14e526ddc7ebdbe12.tar.gz gnunet-287d9eaf1a821d763b51cac14e526ddc7ebdbe12.zip |
-add correct file
Diffstat (limited to 'src')
-rw-r--r-- | src/gns/test_gns_max_queries.c (renamed from src/gns/test_gns_max_queries_test.c) | 48 |
1 files changed, 42 insertions, 6 deletions
diff --git a/src/gns/test_gns_max_queries_test.c b/src/gns/test_gns_max_queries.c index a244b3f02..304ec68be 100644 --- a/src/gns/test_gns_max_queries_test.c +++ b/src/gns/test_gns_max_queries.c | |||
@@ -18,7 +18,7 @@ | |||
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @file gns/test_gns_max_queries_test.c | 21 | * @file gns/test_gns_max_queries.c |
22 | * @brief base testcase for testing GNS background queries | 22 | * @brief base testcase for testing GNS background queries |
23 | * in particular query replacement and clean shutdown | 23 | * in particular query replacement and clean shutdown |
24 | */ | 24 | */ |
@@ -26,6 +26,7 @@ | |||
26 | #include "gnunet_testing_lib.h" | 26 | #include "gnunet_testing_lib.h" |
27 | #include "gnunet_core_service.h" | 27 | #include "gnunet_core_service.h" |
28 | #include "block_dns.h" | 28 | #include "block_dns.h" |
29 | #include "gns.h" | ||
29 | #include "gnunet_signatures.h" | 30 | #include "gnunet_signatures.h" |
30 | #include "gnunet_namestore_service.h" | 31 | #include "gnunet_namestore_service.h" |
31 | #include "gnunet_dnsparser_lib.h" | 32 | #include "gnunet_dnsparser_lib.h" |
@@ -42,10 +43,11 @@ | |||
42 | 43 | ||
43 | /* test records to resolve */ | 44 | /* test records to resolve */ |
44 | #define TEST_DOMAIN "www.gnunet" | 45 | #define TEST_DOMAIN "www.gnunet" |
45 | #define TEST_DOMAIN_NACK "doesnotexist.gnunet" | 46 | #define TEST_DOMAIN_NACK "doesnotexist.bob.gnunet" |
46 | #define TEST_IP "127.0.0.1" | 47 | #define TEST_IP "127.0.0.1" |
47 | #define TEST_RECORD_NAME "www" | 48 | #define TEST_RECORD_NAME "www" |
48 | #define TEST_ADDITIONAL_LOOKUPS 10 | 49 | #define TEST_ADDITIONAL_LOOKUPS 5 |
50 | #define TEST_AUTHORITY_NAME "bob" | ||
49 | 51 | ||
50 | /* Globals */ | 52 | /* Globals */ |
51 | 53 | ||
@@ -87,6 +89,18 @@ shutdown_callback (void *cls, const char *emsg) | |||
87 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "done(ret=%d)!\n", ok); | 89 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "done(ret=%d)!\n", ok); |
88 | } | 90 | } |
89 | 91 | ||
92 | static void | ||
93 | on_lookup_result_dummy(void *cls, uint32_t rd_count, | ||
94 | const struct GNUNET_NAMESTORE_RecordData *rd) | ||
95 | { | ||
96 | if (rd_count != 0) | ||
97 | { | ||
98 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | ||
99 | "Got %d results from dummy lookup! Wanted: 0\n", | ||
100 | rd_count); | ||
101 | ok = -1; | ||
102 | } | ||
103 | } | ||
90 | 104 | ||
91 | static void | 105 | static void |
92 | on_lookup_result(void *cls, uint32_t rd_count, | 106 | on_lookup_result(void *cls, uint32_t rd_count, |
@@ -142,6 +156,7 @@ static void | |||
142 | commence_testing (void *cls, int32_t success, const char *emsg) | 156 | commence_testing (void *cls, int32_t success, const char *emsg) |
143 | { | 157 | { |
144 | int i; | 158 | int i; |
159 | char lookup_name[MAX_DNS_NAME_LENGTH]; | ||
145 | 160 | ||
146 | GNUNET_NAMESTORE_disconnect(namestore_handle, GNUNET_YES); | 161 | GNUNET_NAMESTORE_disconnect(namestore_handle, GNUNET_YES); |
147 | 162 | ||
@@ -160,7 +175,10 @@ commence_testing (void *cls, int32_t success, const char *emsg) | |||
160 | /* Now lookup some non existing records */ | 175 | /* Now lookup some non existing records */ |
161 | for (i=0; i<max_parallel_lookups+TEST_ADDITIONAL_LOOKUPS; i++) | 176 | for (i=0; i<max_parallel_lookups+TEST_ADDITIONAL_LOOKUPS; i++) |
162 | { | 177 | { |
163 | GNUNET_GNS_lookup(gns_handle, TEST_DOMAIN_NACK, GNUNET_GNS_RECORD_TYPE_A, | 178 | GNUNET_snprintf(lookup_name, |
179 | MAX_DNS_NAME_LENGTH, | ||
180 | "doesnotexist-%d.bob.gnunet", i); | ||
181 | GNUNET_GNS_lookup(gns_handle, lookup_name, GNUNET_GNS_RECORD_TYPE_A, | ||
164 | &on_lookup_result_dummy, NULL); | 182 | &on_lookup_result_dummy, NULL); |
165 | } | 183 | } |
166 | } | 184 | } |
@@ -200,8 +218,11 @@ do_lookup(void *cls, const struct GNUNET_PeerIdentity *id, | |||
200 | struct GNUNET_TESTING_Daemon *d, const char *emsg) | 218 | struct GNUNET_TESTING_Daemon *d, const char *emsg) |
201 | { | 219 | { |
202 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded alice_pkey; | 220 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded alice_pkey; |
221 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded bob_pkey; | ||
203 | struct GNUNET_CRYPTO_RsaPrivateKey *alice_key; | 222 | struct GNUNET_CRYPTO_RsaPrivateKey *alice_key; |
223 | struct GNUNET_CRYPTO_RsaPrivateKey *bob_key; | ||
204 | char* alice_keyfile; | 224 | char* alice_keyfile; |
225 | struct GNUNET_CRYPTO_ShortHashCode bob_hash; | ||
205 | 226 | ||
206 | GNUNET_SCHEDULER_cancel (die_task); | 227 | GNUNET_SCHEDULER_cancel (die_task); |
207 | 228 | ||
@@ -233,8 +254,10 @@ do_lookup(void *cls, const struct GNUNET_PeerIdentity *id, | |||
233 | } | 254 | } |
234 | 255 | ||
235 | alice_key = GNUNET_CRYPTO_rsa_key_create_from_file (alice_keyfile); | 256 | alice_key = GNUNET_CRYPTO_rsa_key_create_from_file (alice_keyfile); |
257 | bob_key = GNUNET_CRYPTO_rsa_key_create (); | ||
236 | 258 | ||
237 | GNUNET_CRYPTO_rsa_key_get_public (alice_key, &alice_pkey); | 259 | GNUNET_CRYPTO_rsa_key_get_public (alice_key, &alice_pkey); |
260 | GNUNET_CRYPTO_rsa_key_get_public (bob_key, &bob_pkey); | ||
238 | 261 | ||
239 | GNUNET_free(alice_keyfile); | 262 | GNUNET_free(alice_keyfile); |
240 | 263 | ||
@@ -251,10 +274,23 @@ do_lookup(void *cls, const struct GNUNET_PeerIdentity *id, | |||
251 | alice_key, | 274 | alice_key, |
252 | TEST_RECORD_NAME, | 275 | TEST_RECORD_NAME, |
253 | &rd, | 276 | &rd, |
277 | NULL, | ||
278 | NULL); | ||
279 | |||
280 | GNUNET_CRYPTO_short_hash(&bob_pkey, sizeof(bob_pkey), &bob_hash); | ||
281 | rd.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode); | ||
282 | rd.data = &bob_hash; | ||
283 | rd.record_type = GNUNET_GNS_RECORD_PKEY; | ||
284 | |||
285 | GNUNET_NAMESTORE_record_create (namestore_handle, | ||
286 | alice_key, | ||
287 | TEST_AUTHORITY_NAME, | ||
288 | &rd, | ||
254 | &commence_testing, | 289 | &commence_testing, |
255 | NULL); | 290 | NULL); |
256 | 291 | ||
257 | GNUNET_CRYPTO_rsa_key_free(alice_key); | 292 | GNUNET_CRYPTO_rsa_key_free(alice_key); |
293 | GNUNET_CRYPTO_rsa_key_free(bob_key); | ||
258 | GNUNET_free(web); | 294 | GNUNET_free(web); |
259 | 295 | ||
260 | } | 296 | } |
@@ -290,7 +326,7 @@ check () | |||
290 | int ret; | 326 | int ret; |
291 | 327 | ||
292 | /* Arguments for GNUNET_PROGRAM_run */ | 328 | /* Arguments for GNUNET_PROGRAM_run */ |
293 | char *const argv[] = { "test-gns-simple-lookup", /* Name to give running binary */ | 329 | char *const argv[] = { "test-gns-max-queries", /* Name to give running binary */ |
294 | "-c", | 330 | "-c", |
295 | "test_gns_simple_lookup.conf", /* Config file to use */ | 331 | "test_gns_simple_lookup.conf", /* Config file to use */ |
296 | #if VERBOSE | 332 | #if VERBOSE |
@@ -304,7 +340,7 @@ check () | |||
304 | /* Run the run function as a new program */ | 340 | /* Run the run function as a new program */ |
305 | ret = | 341 | ret = |
306 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, | 342 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, |
307 | "test-gns-simple-lookup", "nohelp", options, &run, | 343 | "test-gns-max-queries", "nohelp", options, &run, |
308 | &ok); | 344 | &ok); |
309 | if (ret != GNUNET_OK) | 345 | if (ret != GNUNET_OK) |
310 | { | 346 | { |