diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2012-03-19 16:41:50 +0000 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2012-03-19 16:41:50 +0000 |
commit | ea62d4e33f400571313c1f1397e6f7d9fe5d214b (patch) | |
tree | ae5555d6da2db0e531063ec1215e9ccca5e113e3 /src | |
parent | a463e3a27305a5b2568145b63b68c90a55643be2 (diff) | |
download | gnunet-ea62d4e33f400571313c1f1397e6f7d9fe5d214b.tar.gz gnunet-ea62d4e33f400571313c1f1397e6f7d9fe5d214b.zip |
-test for zkey resolver
Diffstat (limited to 'src')
-rw-r--r-- | src/gns/Makefile.am | 14 | ||||
-rw-r--r-- | src/gns/gns.h | 3 | ||||
-rw-r--r-- | src/gns/gnunet-service-gns_resolver.c | 13 | ||||
-rw-r--r-- | src/gns/gnunet-service-gns_resolver.h | 2 | ||||
-rw-r--r-- | src/gns/test_gns_simple_zkey_lookup.c | 356 |
5 files changed, 384 insertions, 4 deletions
diff --git a/src/gns/Makefile.am b/src/gns/Makefile.am index a13296ea7..f41de7e3c 100644 --- a/src/gns/Makefile.am +++ b/src/gns/Makefile.am | |||
@@ -36,6 +36,7 @@ check_PROGRAMS = \ | |||
36 | test_gns_simple_lookup \ | 36 | test_gns_simple_lookup \ |
37 | test_gns_simple_delegated_lookup \ | 37 | test_gns_simple_delegated_lookup \ |
38 | test_gns_simple_mx_lookup \ | 38 | test_gns_simple_mx_lookup \ |
39 | test_gns_simple_zkey_lookup \ | ||
39 | test_gns_dht_delegated_lookup \ | 40 | test_gns_dht_delegated_lookup \ |
40 | test_gns_pseu_shorten | 41 | test_gns_pseu_shorten |
41 | 42 | ||
@@ -98,6 +99,19 @@ test_gns_simple_mx_lookup_DEPENDENCIES = \ | |||
98 | $(top_builddir)/src/gns/libgnunetgns.la \ | 99 | $(top_builddir)/src/gns/libgnunetgns.la \ |
99 | $(top_builddir)/src/testing/libgnunettesting.la | 100 | $(top_builddir)/src/testing/libgnunettesting.la |
100 | 101 | ||
102 | test_gns_simple_zkey_lookup_SOURCES = \ | ||
103 | test_gns_simple_zkey_lookup.c | ||
104 | test_gns_simple_zkey_lookup_LDADD = \ | ||
105 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
106 | $(top_builddir)/src/namestore/libgnunetnamestore.la \ | ||
107 | $(top_builddir)/src/gns/libgnunetgns.la \ | ||
108 | $(top_builddir)/src/testing/libgnunettesting.la | ||
109 | test_gns_simple_zkey_lookup_DEPENDENCIES = \ | ||
110 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
111 | $(top_builddir)/src/namestore/libgnunetnamestore.la \ | ||
112 | $(top_builddir)/src/gns/libgnunetgns.la \ | ||
113 | $(top_builddir)/src/testing/libgnunettesting.la | ||
114 | |||
101 | test_gns_dht_delegated_lookup_SOURCES = \ | 115 | test_gns_dht_delegated_lookup_SOURCES = \ |
102 | test_gns_dht_delegated_lookup.c | 116 | test_gns_dht_delegated_lookup.c |
103 | test_gns_dht_delegated_lookup_LDADD = \ | 117 | test_gns_dht_delegated_lookup_LDADD = \ |
diff --git a/src/gns/gns.h b/src/gns/gns.h index 0f9d77537..5950c460b 100644 --- a/src/gns/gns.h +++ b/src/gns/gns.h | |||
@@ -32,6 +32,9 @@ | |||
32 | #define GNUNET_GNS_TLD_ZKEY "zkey" | 32 | #define GNUNET_GNS_TLD_ZKEY "zkey" |
33 | #define GNUNET_GNS_DHT_MAX_UPDATE_INTERVAL 3600 | 33 | #define GNUNET_GNS_DHT_MAX_UPDATE_INTERVAL 3600 |
34 | 34 | ||
35 | #define MAX_DNS_LABEL_LENGTH 63 | ||
36 | #define MAX_DNS_NAME_LENGTH 253 | ||
37 | |||
35 | GNUNET_NETWORK_STRUCT_BEGIN | 38 | GNUNET_NETWORK_STRUCT_BEGIN |
36 | 39 | ||
37 | /** | 40 | /** |
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c index 13c903806..1bbb431e0 100644 --- a/src/gns/gnunet-service-gns_resolver.c +++ b/src/gns/gnunet-service-gns_resolver.c | |||
@@ -1544,7 +1544,7 @@ gns_resolver_lookup_record(GNUNET_HashCode zone, | |||
1544 | { | 1544 | { |
1545 | struct ResolverHandle *rh; | 1545 | struct ResolverHandle *rh; |
1546 | struct RecordLookupHandle* rlh; | 1546 | struct RecordLookupHandle* rlh; |
1547 | char* string_hash = ""; | 1547 | char string_hash[MAX_DNS_NAME_LENGTH]; //FIXME name len as soon as shorthash |
1548 | 1548 | ||
1549 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1549 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1550 | "Starting resolution for %s (type=%d)!\n", | 1550 | "Starting resolution for %s (type=%d)!\n", |
@@ -1575,8 +1575,12 @@ gns_resolver_lookup_record(GNUNET_HashCode zone, | |||
1575 | } | 1575 | } |
1576 | else | 1576 | else |
1577 | { | 1577 | { |
1578 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1579 | "Checking for TLD...\n"); | ||
1578 | if (is_zkey_tld(name) == GNUNET_YES) | 1580 | if (is_zkey_tld(name) == GNUNET_YES) |
1579 | { | 1581 | { |
1582 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1583 | "TLD is zkey\n"); | ||
1580 | /** | 1584 | /** |
1581 | * This is a zkey tld | 1585 | * This is a zkey tld |
1582 | * build hash and use as initial authority | 1586 | * build hash and use as initial authority |
@@ -1587,6 +1591,9 @@ gns_resolver_lookup_record(GNUNET_HashCode zone, | |||
1587 | strlen(name)-strlen(GNUNET_GNS_TLD_ZKEY) - 1); | 1591 | strlen(name)-strlen(GNUNET_GNS_TLD_ZKEY) - 1); |
1588 | pop_tld(rh->name, string_hash); | 1592 | pop_tld(rh->name, string_hash); |
1589 | 1593 | ||
1594 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1595 | "ZKEY is %s!\n", string_hash); | ||
1596 | |||
1590 | if (GNUNET_OK != GNUNET_CRYPTO_hash_from_string(string_hash, | 1597 | if (GNUNET_OK != GNUNET_CRYPTO_hash_from_string(string_hash, |
1591 | &rh->authority)) | 1598 | &rh->authority)) |
1592 | { | 1599 | { |
@@ -1601,6 +1608,8 @@ gns_resolver_lookup_record(GNUNET_HashCode zone, | |||
1601 | } | 1608 | } |
1602 | else | 1609 | else |
1603 | { | 1610 | { |
1611 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1612 | "TLD is gnunet\n"); | ||
1604 | /** | 1613 | /** |
1605 | * Presumably GNUNET tld | 1614 | * Presumably GNUNET tld |
1606 | */ | 1615 | */ |
@@ -1772,7 +1781,7 @@ handle_delegation_ns_shorten(void* cls, | |||
1772 | * This is our zone append .gnunet unless name is empty | 1781 | * This is our zone append .gnunet unless name is empty |
1773 | * (it shouldn't be, usually FIXME what happens if we | 1782 | * (it shouldn't be, usually FIXME what happens if we |
1774 | * shorten to our zone to a "" record??) | 1783 | * shorten to our zone to a "" record??) |
1775 | **/ | 1784 | */ |
1776 | 1785 | ||
1777 | answer_len = strlen(rh->name) + strlen(GNUNET_GNS_TLD) + 2; | 1786 | answer_len = strlen(rh->name) + strlen(GNUNET_GNS_TLD) + 2; |
1778 | memset(result, 0, answer_len); | 1787 | memset(result, 0, answer_len); |
diff --git a/src/gns/gnunet-service-gns_resolver.h b/src/gns/gnunet-service-gns_resolver.h index ecd059765..fb612d72d 100644 --- a/src/gns/gnunet-service-gns_resolver.h +++ b/src/gns/gnunet-service-gns_resolver.h | |||
@@ -7,8 +7,6 @@ | |||
7 | #define DHT_OPERATION_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3) | 7 | #define DHT_OPERATION_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3) |
8 | #define DHT_LOOKUP_TIMEOUT DHT_OPERATION_TIMEOUT | 8 | #define DHT_LOOKUP_TIMEOUT DHT_OPERATION_TIMEOUT |
9 | #define DHT_GNS_REPLICATION_LEVEL 5 | 9 | #define DHT_GNS_REPLICATION_LEVEL 5 |
10 | #define MAX_DNS_LABEL_LENGTH 63 | ||
11 | #define MAX_DNS_NAME_LENGTH 253 | ||
12 | 10 | ||
13 | /* | 11 | /* |
14 | * DLL to hold the authority chain | 12 | * DLL to hold the authority chain |
diff --git a/src/gns/test_gns_simple_zkey_lookup.c b/src/gns/test_gns_simple_zkey_lookup.c new file mode 100644 index 000000000..f8db33973 --- /dev/null +++ b/src/gns/test_gns_simple_zkey_lookup.c | |||
@@ -0,0 +1,356 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2009 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
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 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | /** | ||
21 | * @file gns/test_gns_simple_zkey_lookup.c | ||
22 | * @brief base testcase for testing zkey lookup | ||
23 | * | ||
24 | */ | ||
25 | #include "platform.h" | ||
26 | #include "gnunet_testing_lib.h" | ||
27 | #include "gnunet_core_service.h" | ||
28 | #include "block_dns.h" | ||
29 | #include "gnunet_signatures.h" | ||
30 | #include "gnunet_namestore_service.h" | ||
31 | #include "../namestore/namestore.h" | ||
32 | #include "gnunet_dnsparser_lib.h" | ||
33 | #include "gnunet_gns_service.h" | ||
34 | #include "gns.h" | ||
35 | |||
36 | /* DEFINES */ | ||
37 | #define VERBOSE GNUNET_YES | ||
38 | |||
39 | /* Timeout for entire testcase */ | ||
40 | #define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5) | ||
41 | |||
42 | /* If number of peers not in config file, use this number */ | ||
43 | #define DEFAULT_NUM_PEERS 2 | ||
44 | |||
45 | /* test records to resolve */ | ||
46 | #define TEST_IP "127.0.0.1" | ||
47 | #define TEST_RECORD_NAME "www" | ||
48 | |||
49 | #define TEST_AUTHORITY_NAME "bob" | ||
50 | |||
51 | /* Globals */ | ||
52 | |||
53 | /** | ||
54 | * Directory to store temp data in, defined in config file | ||
55 | */ | ||
56 | static char *test_directory; | ||
57 | |||
58 | struct GNUNET_TESTING_Daemon *d1; | ||
59 | |||
60 | |||
61 | /* Task handle to use to schedule test failure */ | ||
62 | GNUNET_SCHEDULER_TaskIdentifier die_task; | ||
63 | |||
64 | /* Global return value (0 for success, anything else for failure) */ | ||
65 | static int ok; | ||
66 | |||
67 | static struct GNUNET_NAMESTORE_Handle *namestore_handle; | ||
68 | |||
69 | static struct GNUNET_GNS_Handle *gns_handle; | ||
70 | |||
71 | const struct GNUNET_CONFIGURATION_Handle *cfg; | ||
72 | |||
73 | GNUNET_HashCode bob_hash; | ||
74 | |||
75 | /** | ||
76 | * Check whether peers successfully shut down. | ||
77 | */ | ||
78 | void | ||
79 | shutdown_callback (void *cls, const char *emsg) | ||
80 | { | ||
81 | if (emsg != NULL) | ||
82 | { | ||
83 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error on shutdown! ret=%d\n", ok); | ||
84 | if (ok == 0) | ||
85 | ok = 2; | ||
86 | } | ||
87 | |||
88 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "done(ret=%d)!\n", ok); | ||
89 | } | ||
90 | |||
91 | static void | ||
92 | on_lookup_result(void *cls, uint32_t rd_count, | ||
93 | const struct GNUNET_NAMESTORE_RecordData *rd) | ||
94 | { | ||
95 | struct in_addr a; | ||
96 | int i; | ||
97 | char* addr; | ||
98 | |||
99 | if (rd_count == 0) | ||
100 | { | ||
101 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
102 | "Lookup failed, rp_filtering?\n"); | ||
103 | ok = 2; | ||
104 | } | ||
105 | else | ||
106 | { | ||
107 | ok = 1; | ||
108 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "name: %s\n", (char*)cls); | ||
109 | for (i=0; i<rd_count; i++) | ||
110 | { | ||
111 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "type: %d\n", rd[i].record_type); | ||
112 | if (rd[i].record_type == GNUNET_GNS_RECORD_TYPE_A) | ||
113 | { | ||
114 | memcpy(&a, rd[i].data, sizeof(a)); | ||
115 | addr = inet_ntoa(a); | ||
116 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "address: %s\n", addr); | ||
117 | if (0 == strcmp(addr, TEST_IP)) | ||
118 | { | ||
119 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
120 | "ZKEY correctly resolved to %s!\n", addr); | ||
121 | ok = 0; | ||
122 | } | ||
123 | } | ||
124 | else | ||
125 | { | ||
126 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No resolution!\n"); | ||
127 | } | ||
128 | } | ||
129 | } | ||
130 | GNUNET_GNS_disconnect(gns_handle); | ||
131 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down peer1!\n"); | ||
132 | GNUNET_TESTING_daemon_stop (d1, TIMEOUT, &shutdown_callback, NULL, | ||
133 | GNUNET_YES, GNUNET_NO); | ||
134 | } | ||
135 | |||
136 | |||
137 | /** | ||
138 | * Function scheduled to be run on the successful start of services | ||
139 | * tries to look up the dns record for TEST_DOMAIN | ||
140 | */ | ||
141 | static void | ||
142 | commence_testing (void *cls, int32_t success, const char *emsg) | ||
143 | { | ||
144 | char name[MAX_DNS_NAME_LENGTH]; | ||
145 | char* pos; | ||
146 | struct GNUNET_CRYPTO_HashAsciiEncoded hash_str; | ||
147 | |||
148 | GNUNET_NAMESTORE_disconnect(namestore_handle, GNUNET_YES); | ||
149 | |||
150 | gns_handle = GNUNET_GNS_connect(cfg); | ||
151 | |||
152 | if (NULL == gns_handle) | ||
153 | { | ||
154 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
155 | "Failed to connect to GNS!\n"); | ||
156 | } | ||
157 | |||
158 | pos = name; | ||
159 | strcpy(pos, TEST_RECORD_NAME); | ||
160 | pos += strlen(TEST_RECORD_NAME); | ||
161 | strcpy(pos, "."); | ||
162 | pos++; | ||
163 | GNUNET_CRYPTO_hash_to_enc(&bob_hash, &hash_str); | ||
164 | strcpy(pos, (char*)&hash_str); | ||
165 | pos += strlen((char*)&hash_str); | ||
166 | strcpy(pos, "."); | ||
167 | pos++; | ||
168 | strcpy(pos, GNUNET_GNS_TLD_ZKEY); | ||
169 | |||
170 | GNUNET_GNS_lookup(gns_handle, name, GNUNET_GNS_RECORD_TYPE_A, | ||
171 | &on_lookup_result, NULL); | ||
172 | } | ||
173 | |||
174 | /** | ||
175 | * Continuation for the GNUNET_DHT_get_stop call, so that we don't shut | ||
176 | * down the peers without freeing memory associated with GET request. | ||
177 | */ | ||
178 | static void | ||
179 | end_badly_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
180 | { | ||
181 | |||
182 | if (d1 != NULL) | ||
183 | GNUNET_TESTING_daemon_stop (d1, TIMEOUT, &shutdown_callback, NULL, | ||
184 | GNUNET_YES, GNUNET_NO); | ||
185 | GNUNET_SCHEDULER_cancel (die_task); | ||
186 | } | ||
187 | |||
188 | /** | ||
189 | * Check if the get_handle is being used, if so stop the request. Either | ||
190 | * way, schedule the end_badly_cont function which actually shuts down the | ||
191 | * test. | ||
192 | */ | ||
193 | static void | ||
194 | end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
195 | { | ||
196 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failing test with error: `%s'!\n", | ||
197 | (char *) cls); | ||
198 | GNUNET_SCHEDULER_add_now (&end_badly_cont, NULL); | ||
199 | ok = 1; | ||
200 | } | ||
201 | |||
202 | static void | ||
203 | do_lookup(void *cls, const struct GNUNET_PeerIdentity *id, | ||
204 | const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
205 | struct GNUNET_TESTING_Daemon *d, const char *emsg) | ||
206 | { | ||
207 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded alice_pkey; | ||
208 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded bob_pkey; | ||
209 | struct GNUNET_CRYPTO_RsaPrivateKey *alice_key; | ||
210 | struct GNUNET_CRYPTO_RsaPrivateKey *bob_key; | ||
211 | struct GNUNET_CRYPTO_RsaSignature *sig; | ||
212 | char* alice_keyfile; | ||
213 | |||
214 | GNUNET_SCHEDULER_cancel (die_task); | ||
215 | |||
216 | /* put records into namestore */ | ||
217 | namestore_handle = GNUNET_NAMESTORE_connect(cfg); | ||
218 | if (NULL == namestore_handle) | ||
219 | { | ||
220 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to connect to namestore\n"); | ||
221 | ok = -1; | ||
222 | return; | ||
223 | } | ||
224 | |||
225 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", | ||
226 | "ZONEKEY", | ||
227 | &alice_keyfile)) | ||
228 | { | ||
229 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to get key from cfg\n"); | ||
230 | ok = -1; | ||
231 | return; | ||
232 | } | ||
233 | |||
234 | alice_key = GNUNET_CRYPTO_rsa_key_create_from_file (alice_keyfile); | ||
235 | bob_key = GNUNET_CRYPTO_rsa_key_create (); | ||
236 | |||
237 | GNUNET_CRYPTO_rsa_key_get_public (alice_key, &alice_pkey); | ||
238 | GNUNET_CRYPTO_rsa_key_get_public (bob_key, &bob_pkey); | ||
239 | |||
240 | struct GNUNET_NAMESTORE_RecordData rd; | ||
241 | char* ip = TEST_IP; | ||
242 | struct in_addr *web = GNUNET_malloc(sizeof(struct in_addr)); | ||
243 | rd.expiration = GNUNET_TIME_absolute_get_forever (); | ||
244 | GNUNET_assert(1 == inet_pton (AF_INET, ip, web)); | ||
245 | |||
246 | GNUNET_CRYPTO_hash(&bob_pkey, sizeof(bob_pkey), &bob_hash); | ||
247 | |||
248 | rd.data_size = sizeof(GNUNET_HashCode); | ||
249 | rd.data = &bob_hash; | ||
250 | rd.record_type = GNUNET_GNS_RECORD_PKEY; | ||
251 | |||
252 | GNUNET_NAMESTORE_record_create (namestore_handle, | ||
253 | alice_key, | ||
254 | TEST_AUTHORITY_NAME, | ||
255 | &rd, | ||
256 | NULL, | ||
257 | NULL); | ||
258 | |||
259 | rd.data_size = sizeof(struct in_addr); | ||
260 | rd.data = web; | ||
261 | rd.record_type = GNUNET_DNSPARSER_TYPE_A; | ||
262 | sig = GNUNET_NAMESTORE_create_signature(bob_key, | ||
263 | GNUNET_TIME_absolute_get_forever(), | ||
264 | TEST_RECORD_NAME, | ||
265 | &rd, 1); | ||
266 | |||
267 | GNUNET_NAMESTORE_record_put (namestore_handle, | ||
268 | &bob_pkey, | ||
269 | TEST_RECORD_NAME, | ||
270 | rd.expiration, | ||
271 | 1, | ||
272 | &rd, | ||
273 | sig, | ||
274 | &commence_testing, | ||
275 | NULL); | ||
276 | GNUNET_free(sig); | ||
277 | GNUNET_CRYPTO_rsa_key_free(bob_key); | ||
278 | GNUNET_CRYPTO_rsa_key_free(alice_key); | ||
279 | } | ||
280 | |||
281 | static void | ||
282 | run (void *cls, char *const *args, const char *cfgfile, | ||
283 | const struct GNUNET_CONFIGURATION_Handle *c) | ||
284 | { | ||
285 | cfg = c; | ||
286 | /* Get path from configuration file */ | ||
287 | if (GNUNET_YES != | ||
288 | GNUNET_CONFIGURATION_get_value_string (cfg, "paths", "servicehome", | ||
289 | &test_directory)) | ||
290 | { | ||
291 | ok = 404; | ||
292 | return; | ||
293 | } | ||
294 | |||
295 | |||
296 | /* Set up a task to end testing if peer start fails */ | ||
297 | die_task = | ||
298 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, | ||
299 | "didn't start all daemons in reasonable amount of time!!!"); | ||
300 | |||
301 | /* Start alice */ | ||
302 | d1 = GNUNET_TESTING_daemon_start(cfg, TIMEOUT, GNUNET_NO, NULL, NULL, 0, | ||
303 | NULL, NULL, NULL, &do_lookup, NULL); | ||
304 | } | ||
305 | |||
306 | static int | ||
307 | check () | ||
308 | { | ||
309 | int ret; | ||
310 | |||
311 | /* Arguments for GNUNET_PROGRAM_run */ | ||
312 | char *const argv[] = { "test-gns-simple-delegated-lookup", /* Name to give running binary */ | ||
313 | "-c", | ||
314 | "test_gns_simple_lookup.conf", /* Config file to use */ | ||
315 | #if VERBOSE | ||
316 | "-L", "DEBUG", | ||
317 | #endif | ||
318 | NULL | ||
319 | }; | ||
320 | struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
321 | GNUNET_GETOPT_OPTION_END | ||
322 | }; | ||
323 | /* Run the run function as a new program */ | ||
324 | ret = | ||
325 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, | ||
326 | "test-gns-simple-delegated-lookup", "nohelp", options, &run, | ||
327 | &ok); | ||
328 | if (ret != GNUNET_OK) | ||
329 | { | ||
330 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
331 | "`test-gns-simple-delegated-lookup': Failed with error code %d\n", ret); | ||
332 | } | ||
333 | return ok; | ||
334 | } | ||
335 | |||
336 | int | ||
337 | main (int argc, char *argv[]) | ||
338 | { | ||
339 | int ret; | ||
340 | |||
341 | GNUNET_log_setup ("test-gns-simple-lookup", | ||
342 | #if VERBOSE | ||
343 | "DEBUG", | ||
344 | #else | ||
345 | "WARNING", | ||
346 | #endif | ||
347 | NULL); | ||
348 | ret = check (); | ||
349 | /** | ||
350 | * Need to remove base directory, subdirectories taken care | ||
351 | * of by the testing framework. | ||
352 | */ | ||
353 | return ret; | ||
354 | } | ||
355 | |||
356 | /* end of test_gns_twopeer.c */ | ||