diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-10-16 21:52:04 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-10-16 21:52:04 +0000 |
commit | dbc823a07a03e1085172038125b0edf15b0dc6fe (patch) | |
tree | 4e7c3bf60ce83e801c69a6566ea36d514b571cba /src/namestore/test_namestore_api_lookup_public.c | |
parent | eec0e5088ec9437f5c0cf9d3ffef87603ad2777a (diff) | |
download | gnunet-dbc823a07a03e1085172038125b0edf15b0dc6fe.tar.gz gnunet-dbc823a07a03e1085172038125b0edf15b0dc6fe.zip |
-finishing split of namestore into namestore and namecache (#3065) -- in theory; in practice, somehow something broke badly, so the tests are now failing
Diffstat (limited to 'src/namestore/test_namestore_api_lookup_public.c')
-rw-r--r-- | src/namestore/test_namestore_api_lookup_public.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/namestore/test_namestore_api_lookup_public.c b/src/namestore/test_namestore_api_lookup_public.c index 97de58a6c..10bfefbed 100644 --- a/src/namestore/test_namestore_api_lookup_public.c +++ b/src/namestore/test_namestore_api_lookup_public.c | |||
@@ -22,6 +22,7 @@ | |||
22 | * @brief testcase for namestore_api.c: store a record and perform a lookup | 22 | * @brief testcase for namestore_api.c: store a record and perform a lookup |
23 | */ | 23 | */ |
24 | #include "platform.h" | 24 | #include "platform.h" |
25 | #include "gnunet_namecache_service.h" | ||
25 | #include "gnunet_namestore_service.h" | 26 | #include "gnunet_namestore_service.h" |
26 | #include "gnunet_testing_lib.h" | 27 | #include "gnunet_testing_lib.h" |
27 | 28 | ||
@@ -36,6 +37,8 @@ | |||
36 | 37 | ||
37 | static struct GNUNET_NAMESTORE_Handle *nsh; | 38 | static struct GNUNET_NAMESTORE_Handle *nsh; |
38 | 39 | ||
40 | static struct GNUNET_NAMECACHE_Handle *nch; | ||
41 | |||
39 | static GNUNET_SCHEDULER_TaskIdentifier endbadly_task; | 42 | static GNUNET_SCHEDULER_TaskIdentifier endbadly_task; |
40 | 43 | ||
41 | static struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey; | 44 | static struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey; |
@@ -46,6 +49,8 @@ static int res; | |||
46 | 49 | ||
47 | static struct GNUNET_NAMESTORE_QueueEntry *nsqe; | 50 | static struct GNUNET_NAMESTORE_QueueEntry *nsqe; |
48 | 51 | ||
52 | static struct GNUNET_NAMECACHE_QueueEntry *ncqe; | ||
53 | |||
49 | 54 | ||
50 | static void | 55 | static void |
51 | cleanup () | 56 | cleanup () |
@@ -55,6 +60,11 @@ cleanup () | |||
55 | GNUNET_NAMESTORE_disconnect (nsh); | 60 | GNUNET_NAMESTORE_disconnect (nsh); |
56 | nsh = NULL; | 61 | nsh = NULL; |
57 | } | 62 | } |
63 | if (NULL != nch) | ||
64 | { | ||
65 | GNUNET_NAMECACHE_disconnect (nch); | ||
66 | nch = NULL; | ||
67 | } | ||
58 | if (NULL != privkey) | 68 | if (NULL != privkey) |
59 | { | 69 | { |
60 | GNUNET_free (privkey); | 70 | GNUNET_free (privkey); |
@@ -78,6 +88,11 @@ endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
78 | GNUNET_NAMESTORE_cancel (nsqe); | 88 | GNUNET_NAMESTORE_cancel (nsqe); |
79 | nsqe = NULL; | 89 | nsqe = NULL; |
80 | } | 90 | } |
91 | if (NULL != ncqe) | ||
92 | { | ||
93 | GNUNET_NAMECACHE_cancel (ncqe); | ||
94 | ncqe = NULL; | ||
95 | } | ||
81 | cleanup (); | 96 | cleanup (); |
82 | res = 1; | 97 | res = 1; |
83 | } | 98 | } |
@@ -113,13 +128,14 @@ rd_decrypt_cb (void *cls, | |||
113 | GNUNET_SCHEDULER_add_now (&end, NULL); | 128 | GNUNET_SCHEDULER_add_now (&end, NULL); |
114 | } | 129 | } |
115 | 130 | ||
131 | |||
116 | static void | 132 | static void |
117 | name_lookup_proc (void *cls, | 133 | name_lookup_proc (void *cls, |
118 | const struct GNUNET_GNSRECORD_Block *block) | 134 | const struct GNUNET_GNSRECORD_Block *block) |
119 | { | 135 | { |
120 | const char *name = cls; | 136 | const char *name = cls; |
121 | nsqe = NULL; | ||
122 | 137 | ||
138 | ncqe = NULL; | ||
123 | GNUNET_assert (NULL != cls); | 139 | GNUNET_assert (NULL != cls); |
124 | 140 | ||
125 | if (endbadly_task != GNUNET_SCHEDULER_NO_TASK) | 141 | if (endbadly_task != GNUNET_SCHEDULER_NO_TASK) |
@@ -144,6 +160,7 @@ name_lookup_proc (void *cls, | |||
144 | &pubkey, name, &rd_decrypt_cb, (void *) name)); | 160 | &pubkey, name, &rd_decrypt_cb, (void *) name)); |
145 | } | 161 | } |
146 | 162 | ||
163 | |||
147 | static void | 164 | static void |
148 | put_cont (void *cls, int32_t success, const char *emsg) | 165 | put_cont (void *cls, int32_t success, const char *emsg) |
149 | { | 166 | { |
@@ -151,8 +168,8 @@ put_cont (void *cls, int32_t success, const char *emsg) | |||
151 | struct GNUNET_HashCode derived_hash; | 168 | struct GNUNET_HashCode derived_hash; |
152 | struct GNUNET_CRYPTO_EcdsaPublicKey pubkey; | 169 | struct GNUNET_CRYPTO_EcdsaPublicKey pubkey; |
153 | 170 | ||
171 | nsqe = NULL; | ||
154 | GNUNET_assert (NULL != cls); | 172 | GNUNET_assert (NULL != cls); |
155 | |||
156 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 173 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
157 | "Name store added record for `%s': %s\n", | 174 | "Name store added record for `%s': %s\n", |
158 | name, | 175 | name, |
@@ -162,8 +179,8 @@ put_cont (void *cls, int32_t success, const char *emsg) | |||
162 | GNUNET_CRYPTO_ecdsa_key_get_public (privkey, &pubkey); | 179 | GNUNET_CRYPTO_ecdsa_key_get_public (privkey, &pubkey); |
163 | GNUNET_GNSRECORD_query_from_public_key (&pubkey, name, &derived_hash); | 180 | GNUNET_GNSRECORD_query_from_public_key (&pubkey, name, &derived_hash); |
164 | 181 | ||
165 | nsqe = GNUNET_NAMESTORE_lookup_block (nsh, &derived_hash, | 182 | ncqe = GNUNET_NAMECACHE_lookup_block (nch, &derived_hash, |
166 | &name_lookup_proc, (void *) name); | 183 | &name_lookup_proc, (void *) name); |
167 | } | 184 | } |
168 | 185 | ||
169 | 186 | ||
@@ -196,7 +213,9 @@ run (void *cls, | |||
196 | memset ((char *) rd.data, 'a', TEST_RECORD_DATALEN); | 213 | memset ((char *) rd.data, 'a', TEST_RECORD_DATALEN); |
197 | 214 | ||
198 | nsh = GNUNET_NAMESTORE_connect (cfg); | 215 | nsh = GNUNET_NAMESTORE_connect (cfg); |
216 | nch = GNUNET_NAMECACHE_connect (cfg); | ||
199 | GNUNET_break (NULL != nsh); | 217 | GNUNET_break (NULL != nsh); |
218 | GNUNET_break (NULL != nch); | ||
200 | nsqe = GNUNET_NAMESTORE_records_store (nsh, privkey, name, | 219 | nsqe = GNUNET_NAMESTORE_records_store (nsh, privkey, name, |
201 | 1, &rd, &put_cont, (void *) name); | 220 | 1, &rd, &put_cont, (void *) name); |
202 | if (NULL == nsqe) | 221 | if (NULL == nsqe) |