aboutsummaryrefslogtreecommitdiff
path: root/src/gns/test_gns_simple_zkey_lookup.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gns/test_gns_simple_zkey_lookup.c')
-rw-r--r--src/gns/test_gns_simple_zkey_lookup.c34
1 files changed, 14 insertions, 20 deletions
diff --git a/src/gns/test_gns_simple_zkey_lookup.c b/src/gns/test_gns_simple_zkey_lookup.c
index a1cef1828..4fbd6af72 100644
--- a/src/gns/test_gns_simple_zkey_lookup.c
+++ b/src/gns/test_gns_simple_zkey_lookup.c
@@ -33,15 +33,9 @@
33#include "gnunet_gns_service.h" 33#include "gnunet_gns_service.h"
34#include "gns.h" 34#include "gns.h"
35 35
36/* DEFINES */
37#define VERBOSE GNUNET_YES
38
39/* Timeout for entire testcase */ 36/* Timeout for entire testcase */
40#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 40) 37#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 40)
41 38
42/* If number of peers not in config file, use this number */
43#define DEFAULT_NUM_PEERS 2
44
45/* test records to resolve */ 39/* test records to resolve */
46#define TEST_IP "127.0.0.1" 40#define TEST_IP "127.0.0.1"
47#define TEST_RECORD_NAME "www" 41#define TEST_RECORD_NAME "www"
@@ -50,10 +44,8 @@
50 44
51#define KEYFILE_BOB "../namestore/zonefiles/HGU0A0VCU334DN7F2I9UIUMVQMM7JMSD142LIMNUGTTV9R0CF4EG.zkey" 45#define KEYFILE_BOB "../namestore/zonefiles/HGU0A0VCU334DN7F2I9UIUMVQMM7JMSD142LIMNUGTTV9R0CF4EG.zkey"
52 46
53/* Globals */
54
55/* Task handle to use to schedule test failure */ 47/* Task handle to use to schedule test failure */
56GNUNET_SCHEDULER_TaskIdentifier die_task; 48static GNUNET_SCHEDULER_TaskIdentifier die_task;
57 49
58/* Global return value (0 for success, anything else for failure) */ 50/* Global return value (0 for success, anything else for failure) */
59static int ok; 51static int ok;
@@ -62,9 +54,9 @@ static struct GNUNET_NAMESTORE_Handle *namestore_handle;
62 54
63static struct GNUNET_GNS_Handle *gns_handle; 55static struct GNUNET_GNS_Handle *gns_handle;
64 56
65const struct GNUNET_CONFIGURATION_Handle *cfg; 57static const struct GNUNET_CONFIGURATION_Handle *cfg;
66 58
67struct GNUNET_CRYPTO_ShortHashCode bob_hash; 59static struct GNUNET_CRYPTO_ShortHashCode bob_hash;
68 60
69 61
70/** 62/**
@@ -92,6 +84,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
92 ok = 1; 84 ok = 1;
93} 85}
94 86
87
95static void 88static void
96end_badly_now () 89end_badly_now ()
97{ 90{
@@ -99,14 +92,17 @@ end_badly_now ()
99 die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); 92 die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
100} 93}
101 94
102static void shutdown_task (void *cls, 95
103 const struct GNUNET_SCHEDULER_TaskContext *tc) 96static void
97shutdown_task (void *cls,
98 const struct GNUNET_SCHEDULER_TaskContext *tc)
104{ 99{
105 GNUNET_GNS_disconnect(gns_handle); 100 GNUNET_GNS_disconnect(gns_handle);
106 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down peer!\n"); 101 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down peer!\n");
107 GNUNET_SCHEDULER_shutdown (); 102 GNUNET_SCHEDULER_shutdown ();
108} 103}
109 104
105
110static void 106static void
111on_lookup_result(void *cls, uint32_t rd_count, 107on_lookup_result(void *cls, uint32_t rd_count,
112 const struct GNUNET_NAMESTORE_RecordData *rd) 108 const struct GNUNET_NAMESTORE_RecordData *rd)
@@ -157,6 +153,8 @@ on_lookup_result(void *cls, uint32_t rd_count,
157 153
158 GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); 154 GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
159} 155}
156
157
160/** 158/**
161 * Function scheduled to be run on the successful start of services 159 * Function scheduled to be run on the successful start of services
162 * tries to look up the dns record for TEST_DOMAIN 160 * tries to look up the dns record for TEST_DOMAIN
@@ -280,21 +278,17 @@ do_check (void *cls,
280} 278}
281 279
282 280
283
284
285int 281int
286main (int argc, char *argv[]) 282main (int argc, char *argv[])
287{ 283{
288 ok = 1; 284 ok = 1;
289 285
290 GNUNET_log_setup ("test-gns-simple-zkey-lookup", 286 GNUNET_log_setup ("test-gns-simple-zkey-lookup",
291#if VERBOSE
292 "DEBUG",
293#else
294 "WARNING", 287 "WARNING",
295#endif
296 NULL); 288 NULL);
297 GNUNET_TESTING_peer_run ("test-gns-simple-zkey-lookup", "test_gns_simple_lookup.conf", &do_check, NULL); 289 GNUNET_TESTING_peer_run ("test-gns-simple-zkey-lookup",
290 "test_gns_simple_lookup.conf",
291 &do_check, NULL);
298 return ok; 292 return ok;
299} 293}
300 294