aboutsummaryrefslogtreecommitdiff
path: root/src/namestore/test_namestore_api_store.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-10-16 21:52:04 +0000
committerChristian Grothoff <christian@grothoff.org>2013-10-16 21:52:04 +0000
commitdbc823a07a03e1085172038125b0edf15b0dc6fe (patch)
tree4e7c3bf60ce83e801c69a6566ea36d514b571cba /src/namestore/test_namestore_api_store.c
parenteec0e5088ec9437f5c0cf9d3ffef87603ad2777a (diff)
downloadgnunet-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_store.c')
-rw-r--r--src/namestore/test_namestore_api_store.c69
1 files changed, 5 insertions, 64 deletions
diff --git a/src/namestore/test_namestore_api_store.c b/src/namestore/test_namestore_api_store.c
index 99d245d00..711a160d6 100644
--- a/src/namestore/test_namestore_api_store.c
+++ b/src/namestore/test_namestore_api_store.c
@@ -18,8 +18,8 @@
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20/** 20/**
21 * @file namestore/test_namestore_api.c 21 * @file namestore/test_namestore_api_store.c
22 * @brief testcase for namestore_api.c: store a record and perform a lookup 22 * @brief testcase for namestore_api.c: store a record
23 */ 23 */
24#include "platform.h" 24#include "platform.h"
25#include "gnunet_namestore_service.h" 25#include "gnunet_namestore_service.h"
@@ -92,76 +92,17 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
92 92
93 93
94static void 94static void
95rd_decrypt_cb (void *cls,
96 unsigned int rd_count,
97 const struct GNUNET_GNSRECORD_Data *rd)
98{
99 char rd_cmp_data[TEST_RECORD_DATALEN];
100
101 GNUNET_assert (1 == rd_count);
102 GNUNET_assert (NULL != rd);
103
104 memset (rd_cmp_data, 'a', TEST_RECORD_DATALEN);
105
106 GNUNET_assert (TEST_RECORD_TYPE == rd[0].record_type);
107 GNUNET_assert (TEST_RECORD_DATALEN == rd[0].data_size);
108 GNUNET_assert (0 == memcmp (&rd_cmp_data, rd[0].data, TEST_RECORD_DATALEN));
109
110 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
111 "Block was decrypted successfully \n");
112
113 GNUNET_SCHEDULER_add_now (&end, NULL);
114}
115
116static void
117name_lookup_proc (void *cls,
118 const struct GNUNET_GNSRECORD_Block *block)
119{
120 const char *name = cls;
121 nsqe = NULL;
122
123 GNUNET_assert (NULL != cls);
124
125 if (endbadly_task != GNUNET_SCHEDULER_NO_TASK)
126 {
127 GNUNET_SCHEDULER_cancel (endbadly_task);
128 endbadly_task = GNUNET_SCHEDULER_NO_TASK;
129 }
130
131 if (NULL == block)
132 {
133 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
134 _("Namestore returned no block\n"));
135 if (endbadly_task != GNUNET_SCHEDULER_NO_TASK)
136 GNUNET_SCHEDULER_cancel (endbadly_task);
137 endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL);
138 return;
139 }
140
141 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
142 "Namestore returned block, decrypting \n");
143 GNUNET_assert (GNUNET_OK == GNUNET_GNSRECORD_block_decrypt(block,
144 &pubkey, name, &rd_decrypt_cb, (void *) name));
145}
146
147static void
148put_cont (void *cls, int32_t success, const char *emsg) 95put_cont (void *cls, int32_t success, const char *emsg)
149{ 96{
150 const char *name = cls; 97 const char *name = cls;
151 struct GNUNET_HashCode derived_hash;
152 98
99 nsqe = NULL;
153 GNUNET_assert (NULL != cls); 100 GNUNET_assert (NULL != cls);
154
155 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 101 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
156 "Name store added record for `%s': %s\n", 102 "Name store added record for `%s': %s\n",
157 name, 103 name,
158 (success == GNUNET_OK) ? "SUCCESS" : "FAIL"); 104 (success == GNUNET_OK) ? "SUCCESS" : "FAIL");
159 105 GNUNET_SCHEDULER_add_now (&end, NULL);
160 /* Create derived hash */
161 GNUNET_GNSRECORD_query_from_private_key (privkey, name, &derived_hash);
162
163 nsqe = GNUNET_NAMESTORE_lookup_block (nsh, &derived_hash,
164 &name_lookup_proc, (void *) name);
165} 106}
166 107
167 108
@@ -222,4 +163,4 @@ main (int argc, char *argv[])
222} 163}
223 164
224 165
225/* end of test_namestore_api.c */ 166/* end of test_namestore_api_store.c */