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_remove.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_remove.c')
-rw-r--r-- | src/namestore/test_namestore_api_remove.c | 90 |
1 files changed, 3 insertions, 87 deletions
diff --git a/src/namestore/test_namestore_api_remove.c b/src/namestore/test_namestore_api_remove.c index 8605a3a00..7e3af8290 100644 --- a/src/namestore/test_namestore_api_remove.c +++ b/src/namestore/test_namestore_api_remove.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2009 Christian Grothoff (and other contributing authors) | 3 | (C) 2013 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 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 | 6 | it under the terms of the GNU General Public License as published |
@@ -42,8 +42,6 @@ static struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey; | |||
42 | 42 | ||
43 | static struct GNUNET_CRYPTO_EcdsaPublicKey pubkey; | 43 | static struct GNUNET_CRYPTO_EcdsaPublicKey pubkey; |
44 | 44 | ||
45 | static struct GNUNET_HashCode derived_hash; | ||
46 | |||
47 | static int res; | 45 | static int res; |
48 | 46 | ||
49 | static int removed; | 47 | static int removed; |
@@ -119,72 +117,6 @@ remove_cont (void *cls, | |||
119 | 117 | ||
120 | 118 | ||
121 | static void | 119 | static void |
122 | rd_decrypt_cb (void *cls, | ||
123 | unsigned int rd_count, | ||
124 | const struct GNUNET_GNSRECORD_Data *rd) | ||
125 | { | ||
126 | const char *name = cls; | ||
127 | char rd_cmp_data[TEST_RECORD_DATALEN]; | ||
128 | |||
129 | GNUNET_assert (GNUNET_NO == removed); | ||
130 | GNUNET_assert (1 == rd_count); | ||
131 | GNUNET_assert (NULL != rd); | ||
132 | memset (rd_cmp_data, 'a', TEST_RECORD_DATALEN); | ||
133 | |||
134 | GNUNET_assert (TEST_RECORD_TYPE == rd[0].record_type); | ||
135 | GNUNET_assert (TEST_RECORD_DATALEN == rd[0].data_size); | ||
136 | GNUNET_assert (0 == memcmp (&rd_cmp_data, rd[0].data, TEST_RECORD_DATALEN)); | ||
137 | |||
138 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
139 | "Block was decrypted successfully, removing records \n"); | ||
140 | |||
141 | nsqe = GNUNET_NAMESTORE_records_store (nsh, privkey, name, | ||
142 | 0, NULL, &remove_cont, (void *) name); | ||
143 | } | ||
144 | |||
145 | |||
146 | static void | ||
147 | name_lookup_proc (void *cls, | ||
148 | const struct GNUNET_GNSRECORD_Block *block) | ||
149 | { | ||
150 | const char *name = cls; | ||
151 | nsqe = NULL; | ||
152 | |||
153 | if (removed && (NULL == block)) | ||
154 | { | ||
155 | if (endbadly_task != GNUNET_SCHEDULER_NO_TASK) | ||
156 | { | ||
157 | GNUNET_SCHEDULER_cancel (endbadly_task); | ||
158 | endbadly_task = GNUNET_SCHEDULER_NO_TASK; | ||
159 | } | ||
160 | GNUNET_SCHEDULER_add_now (&end, NULL); | ||
161 | return; | ||
162 | } | ||
163 | GNUNET_assert (NULL != cls); | ||
164 | if (endbadly_task != GNUNET_SCHEDULER_NO_TASK) | ||
165 | { | ||
166 | GNUNET_SCHEDULER_cancel (endbadly_task); | ||
167 | endbadly_task = GNUNET_SCHEDULER_NO_TASK; | ||
168 | } | ||
169 | |||
170 | if (NULL == block) | ||
171 | { | ||
172 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
173 | _("Namestore returned no block\n")); | ||
174 | if (endbadly_task != GNUNET_SCHEDULER_NO_TASK) | ||
175 | GNUNET_SCHEDULER_cancel (endbadly_task); | ||
176 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); | ||
177 | return; | ||
178 | } | ||
179 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
180 | "Namestore returned block, decrypting \n"); | ||
181 | GNUNET_assert (GNUNET_OK == | ||
182 | GNUNET_GNSRECORD_block_decrypt (block, | ||
183 | &pubkey, name, &rd_decrypt_cb, (void *) name)); | ||
184 | } | ||
185 | |||
186 | |||
187 | static void | ||
188 | put_cont (void *cls, int32_t success, | 120 | put_cont (void *cls, int32_t success, |
189 | const char *emsg) | 121 | const char *emsg) |
190 | { | 122 | { |
@@ -207,24 +139,8 @@ put_cont (void *cls, int32_t success, | |||
207 | "Name store added record for `%s': %s\n", | 139 | "Name store added record for `%s': %s\n", |
208 | name, | 140 | name, |
209 | (success == GNUNET_OK) ? "SUCCESS" : "FAIL"); | 141 | (success == GNUNET_OK) ? "SUCCESS" : "FAIL"); |
210 | 142 | nsqe = GNUNET_NAMESTORE_records_store (nsh, privkey, name, | |
211 | /* Create derived hash */ | 143 | 0, NULL, &remove_cont, (void *) name); |
212 | GNUNET_GNSRECORD_query_from_private_key (privkey, | ||
213 | name, | ||
214 | &derived_hash); | ||
215 | |||
216 | nsqe = GNUNET_NAMESTORE_lookup_block (nsh, &derived_hash, | ||
217 | &name_lookup_proc, (void *) name); | ||
218 | if (NULL == nsqe) | ||
219 | { | ||
220 | GNUNET_break (0); | ||
221 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
222 | _("Namestore cannot perform lookup\n")); | ||
223 | if (endbadly_task != GNUNET_SCHEDULER_NO_TASK) | ||
224 | GNUNET_SCHEDULER_cancel (endbadly_task); | ||
225 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); | ||
226 | return; | ||
227 | } | ||
228 | } | 144 | } |
229 | 145 | ||
230 | 146 | ||