aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-09-11 10:31:04 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-09-11 10:31:04 +0000
commit8ae2e9ef3b699ecae9ff004fa1dc34b26cd706b8 (patch)
tree920a6df1d1f6d3b90a7f79351304798863c78f64 /src
parent71b4381829495a32998ce5bbd38361a6f1a79836 (diff)
downloadgnunet-8ae2e9ef3b699ecae9ff004fa1dc34b26cd706b8.tar.gz
gnunet-8ae2e9ef3b699ecae9ff004fa1dc34b26cd706b8.zip
tests not required anymore due to removed functionality
Diffstat (limited to 'src')
-rw-r--r--src/namestore/Makefile.am17
-rw-r--r--src/namestore/test_namestore_api_create.c386
-rw-r--r--src/namestore/test_namestore_api_create_update.c277
3 files changed, 0 insertions, 680 deletions
diff --git a/src/namestore/Makefile.am b/src/namestore/Makefile.am
index cfc0b4d32..ca9c2f590 100644
--- a/src/namestore/Makefile.am
+++ b/src/namestore/Makefile.am
@@ -51,8 +51,6 @@ TESTING_TESTS = \
51 test_namestore_api_monitoring_existing 51 test_namestore_api_monitoring_existing
52# test_namestore_api_lookup 52# test_namestore_api_lookup
53#test_namestore_api_lookup_specific_type 53#test_namestore_api_lookup_specific_type
54#test_namestore_api_create
55#test_namestore_api_create_update
56#test_namestore_api_remove_not_existing_record 54#test_namestore_api_remove_not_existing_record
57#test_namestore_api_zone_to_name 55#test_namestore_api_zone_to_name
58endif 56endif
@@ -218,21 +216,6 @@ test_namestore_api_lookup_specific_type_LDADD = \
218 $(top_builddir)/src/namestore/libgnunetnamestore.la 216 $(top_builddir)/src/namestore/libgnunetnamestore.la
219 217
220 218
221test_namestore_api_create_SOURCES = \
222 test_namestore_api_create.c
223test_namestore_api_create_LDADD = \
224 $(top_builddir)/src/testing/libgnunettesting.la \
225 $(top_builddir)/src/util/libgnunetutil.la \
226 $(top_builddir)/src/namestore/libgnunetnamestore.la
227
228test_namestore_api_create_update_SOURCES = \
229 test_namestore_api_create_update.c
230test_namestore_api_create_update_LDADD = \
231 $(top_builddir)/src/testing/libgnunettesting.la \
232 $(top_builddir)/src/util/libgnunetutil.la \
233 $(top_builddir)/src/namestore/libgnunetnamestore.la
234
235
236test_namestore_api_remove_SOURCES = \ 219test_namestore_api_remove_SOURCES = \
237 test_namestore_api_remove.c 220 test_namestore_api_remove.c
238test_namestore_api_remove_LDADD = \ 221test_namestore_api_remove_LDADD = \
diff --git a/src/namestore/test_namestore_api_create.c b/src/namestore/test_namestore_api_create.c
deleted file mode 100644
index f004ffc31..000000000
--- a/src/namestore/test_namestore_api_create.c
+++ /dev/null
@@ -1,386 +0,0 @@
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 namestore/test_namestore_api.c
22 * @brief testcase for namestore_api.c
23 */
24#include "platform.h"
25#include "gnunet_common.h"
26#include "gnunet_namestore_service.h"
27#include "gnunet_testing_lib.h"
28#include "namestore.h"
29#include "gnunet_signatures.h"
30
31
32#define RECORDS 1
33
34#define TEST_RECORD_TYPE 1234
35
36#define TEST_RECORD_DATALEN 123
37
38#define TEST_RECORD_DATA 'a'
39
40#define TEST_CREATE_RECORD_TYPE 4321
41
42#define TEST_CREATE_RECORD_DATALEN 255
43
44#define TEST_CREATE_RECORD_DATA 'b'
45
46#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 100)
47
48
49static struct GNUNET_NAMESTORE_Handle * nsh;
50
51static GNUNET_SCHEDULER_TaskIdentifier endbadly_task;
52
53static struct GNUNET_CRYPTO_EccPrivateKey * privkey;
54
55static struct GNUNET_CRYPTO_EccPublicKey pubkey;
56
57static struct GNUNET_CRYPTO_ShortHashCode s_zone;
58
59static struct GNUNET_NAMESTORE_RecordData *s_first_record;
60
61static struct GNUNET_NAMESTORE_RecordData *s_second_record;
62
63static char *s_name;
64
65static int res;
66
67
68/**
69 * Re-establish the connection to the service.
70 *
71 * @param cls handle to use to re-connect.
72 * @param tc scheduler context
73 */
74static void
75endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
76{
77 if (nsh != NULL)
78 GNUNET_NAMESTORE_disconnect (nsh);
79 nsh = NULL;
80 if (privkey != NULL)
81 GNUNET_free (privkey);
82 privkey = NULL;
83 GNUNET_free_non_null (s_name);
84 res = 1;
85}
86
87
88static void
89end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
90{
91 if (endbadly_task != GNUNET_SCHEDULER_NO_TASK)
92 {
93 GNUNET_SCHEDULER_cancel (endbadly_task);
94 endbadly_task = GNUNET_SCHEDULER_NO_TASK;
95 }
96 GNUNET_free ((void *) s_first_record->data);
97 GNUNET_free (s_first_record);
98 GNUNET_free_non_null (s_second_record);
99 GNUNET_free_non_null (s_name);
100 if (privkey != NULL)
101 GNUNET_free (privkey);
102 privkey = NULL;
103 if (nsh != NULL)
104 GNUNET_NAMESTORE_disconnect (nsh);
105 nsh = NULL;
106}
107
108
109static void
110name_lookup_second_proc (void *cls,
111 const struct GNUNET_CRYPTO_EccPublicKey *zone_key,
112 struct GNUNET_TIME_Absolute expire,
113 const char *n,
114 unsigned int rd_count,
115 const struct GNUNET_NAMESTORE_RecordData *rd,
116 const struct GNUNET_CRYPTO_EccSignature *signature)
117{
118 static int found = GNUNET_NO;
119 int failed = GNUNET_NO;
120 int c;
121
122 if (n != NULL)
123 {
124 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Checking returned results\n");
125 if (0 != memcmp (zone_key, &pubkey, sizeof (struct GNUNET_CRYPTO_EccPublicKey)))
126 {
127 GNUNET_break (0);
128 failed = GNUNET_YES;
129 }
130
131 if (0 != strcmp(n, s_name))
132 {
133 GNUNET_break (0);
134 failed = GNUNET_YES;
135 }
136
137 if (2 != rd_count)
138 {
139 GNUNET_break (0);
140 failed = GNUNET_YES;
141 }
142
143 for (c = 0; c < rd_count; c++)
144 {
145 if ((GNUNET_NO == GNUNET_NAMESTORE_records_cmp(&rd[c], s_first_record)) &&
146 (GNUNET_NO == GNUNET_NAMESTORE_records_cmp(&rd[c], s_second_record)))
147 {
148 GNUNET_break (0);
149 failed = GNUNET_YES;
150 }
151 }
152
153 if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature (zone_key, expire, n, rd_count, rd, signature))
154 {
155 GNUNET_break (0);
156 failed = GNUNET_YES;
157 }
158
159 if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature (&pubkey, expire, n, rd_count, rd, signature))
160 {
161 GNUNET_break (0);
162 failed = GNUNET_YES;
163 }
164
165 found = GNUNET_YES;
166 if (failed == GNUNET_NO)
167 res = 0;
168 else
169 res = 1;
170 }
171 else
172 {
173 if (found != GNUNET_YES)
174 {
175 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to lookup records for name `%s'\n", s_name);
176 res = 1;
177 }
178 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Lookup done for name %s'\n", s_name);
179 }
180 GNUNET_SCHEDULER_add_now(&end, NULL);
181}
182
183
184static void
185create_second_cont (void *cls, int32_t success, const char *emsg)
186{
187 char *name = cls;
188
189 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Create second record for `%s': %s\n", name, (success == GNUNET_OK) ? "SUCCESS" : "FAIL");
190 if (success == GNUNET_OK)
191 {
192 res = 0;
193 GNUNET_NAMESTORE_lookup_record (nsh, &s_zone, name, 0, &name_lookup_second_proc, name);
194 }
195 else
196 {
197 res = 1;
198 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to put records for name `%s'\n", name);
199 GNUNET_SCHEDULER_add_now(&end, NULL);
200 }
201}
202
203
204static void
205name_lookup_initial_proc (void *cls,
206 const struct GNUNET_CRYPTO_EccPublicKey *zone_key,
207 struct GNUNET_TIME_Absolute expire,
208 const char *n,
209 unsigned int rd_count,
210 const struct GNUNET_NAMESTORE_RecordData *rd,
211 const struct GNUNET_CRYPTO_EccSignature *signature)
212{
213 struct GNUNET_NAMESTORE_RecordData both_records[2];
214 char * name = cls;
215 static int found = GNUNET_NO;
216 int failed = GNUNET_NO;
217 int c;
218
219 if (n != NULL)
220 {
221 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Checking returned results\n");
222 if (0 != memcmp (zone_key, &pubkey, sizeof (struct GNUNET_CRYPTO_EccPublicKey)))
223 {
224 GNUNET_break (0);
225 failed = GNUNET_YES;
226 }
227
228 if (0 != strcmp(n, s_name))
229 {
230 GNUNET_break (0);
231 failed = GNUNET_YES;
232 }
233
234 if (RECORDS != rd_count)
235 {
236 GNUNET_break (0);
237 failed = GNUNET_YES;
238 }
239
240 for (c = 0; c < RECORDS; c++)
241 {
242 if (GNUNET_NO == GNUNET_NAMESTORE_records_cmp (&rd[c], &s_first_record[c]))
243 {
244 GNUNET_break (0);
245 failed = GNUNET_YES;
246 }
247 }
248
249 if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature (&pubkey, expire, n, rd_count, rd, signature))
250 {
251 GNUNET_break (0);
252 failed = GNUNET_YES;
253 }
254
255 found = GNUNET_YES;
256 if (failed == GNUNET_NO)
257 res = 0;
258 else
259 res = 1;
260
261 /* create a second record */
262 s_second_record = GNUNET_malloc (sizeof (struct GNUNET_NAMESTORE_RecordData) + TEST_CREATE_RECORD_DATALEN);
263 s_second_record->expiration_time = UINT64_MAX;
264 s_second_record->record_type = TEST_CREATE_RECORD_TYPE;
265 s_second_record->flags = GNUNET_NAMESTORE_RF_NONE;
266 s_second_record->data = &s_second_record[1];
267 s_second_record->data_size = TEST_CREATE_RECORD_DATALEN;
268 memset ((char *) s_second_record->data, TEST_CREATE_RECORD_DATA, TEST_CREATE_RECORD_DATALEN);
269
270 both_records[0] = *s_first_record;
271 both_records[1] = *s_second_record;
272 GNUNET_NAMESTORE_record_put_by_authority (nsh, privkey, name,
273 2, both_records,
274 &create_second_cont, name);
275
276 }
277 else
278 {
279 if (found != GNUNET_YES)
280 {
281 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to lookup records for name `%s'\n", s_name);
282 res = 1;
283 }
284 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Lookup done for name %s'\n", s_name);
285 GNUNET_SCHEDULER_add_now (&end, NULL);
286 }
287}
288
289
290static void
291create_first_cont (void *cls, int32_t success, const char *emsg)
292{
293 char *name = cls;
294 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Create record for `%s': %s\n", name, (success == GNUNET_OK) ? "SUCCESS" : "FAIL");
295 if (success == GNUNET_OK)
296 {
297 res = 0;
298 /* check if record was created correct */
299 GNUNET_NAMESTORE_lookup_record (nsh, &s_zone, name, 0, &name_lookup_initial_proc, name);
300 }
301 else
302 {
303 res = 1;
304 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to put records for name `%s'\n", name);
305 GNUNET_SCHEDULER_add_now(&end, NULL);
306 }
307}
308
309
310static struct GNUNET_NAMESTORE_RecordData *
311create_record (unsigned int count)
312{
313 unsigned int c;
314 struct GNUNET_NAMESTORE_RecordData * rd;
315
316 rd = GNUNET_malloc (count * sizeof (struct GNUNET_NAMESTORE_RecordData));
317 for (c = 0; c < count; c++)
318 {
319 rd[c].expiration_time = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS).abs_value_us;
320 rd[c].record_type = TEST_RECORD_TYPE;
321 rd[c].data_size = TEST_RECORD_DATALEN;
322 rd[c].data = GNUNET_malloc(TEST_RECORD_DATALEN);
323 memset ((char *) rd[c].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN);
324 }
325 return rd;
326}
327
328
329static void
330run (void *cls,
331 const struct GNUNET_CONFIGURATION_Handle *cfg,
332 struct GNUNET_TESTING_Peer *peer)
333{
334 size_t rd_ser_len;
335 char *hostkey_file;
336
337 endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,endbadly, NULL);
338 /* load privat key */
339 GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR,
340 "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey");
341 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file);
342 privkey = GNUNET_CRYPTO_ecc_key_create_from_file(hostkey_file);
343 GNUNET_free (hostkey_file);
344 /* get public key */
345 GNUNET_CRYPTO_ecc_key_get_public(privkey, &pubkey);
346
347 /* create record */
348 s_name = GNUNET_NAMESTORE_normalize_string ("DUMMY.dummy.gnunet");
349 s_first_record = create_record (1);
350
351 rd_ser_len = GNUNET_NAMESTORE_records_get_size(1, s_first_record);
352 char rd_ser[rd_ser_len];
353 GNUNET_NAMESTORE_records_serialize(1, s_first_record, rd_ser_len, rd_ser);
354
355 /* create random zone hash */
356 GNUNET_CRYPTO_short_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_EccPublicKey), &s_zone);
357
358 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Name: `%s' Zone: `%s' \n", s_name, GNUNET_NAMESTORE_short_h2s (&s_zone));
359 nsh = GNUNET_NAMESTORE_connect (cfg);
360 GNUNET_break (NULL != nsh);
361
362 GNUNET_break (s_first_record != NULL);
363 GNUNET_break (s_name != NULL);
364
365 /* create initial record */
366 GNUNET_NAMESTORE_record_put_by_authority (nsh, privkey, s_name,
367 1, s_first_record,
368 &create_first_cont, s_name);
369}
370
371
372int
373main (int argc, char *argv[])
374{
375 res = 1;
376 if (0 !=
377 GNUNET_TESTING_service_run ("test-namestore-api-create",
378 "namestore",
379 "test_namestore_api.conf",
380 &run,
381 NULL))
382 return 1;
383 return res;
384}
385
386/* end of test_namestore_api_create.c */
diff --git a/src/namestore/test_namestore_api_create_update.c b/src/namestore/test_namestore_api_create_update.c
deleted file mode 100644
index 977b2cfcf..000000000
--- a/src/namestore/test_namestore_api_create_update.c
+++ /dev/null
@@ -1,277 +0,0 @@
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 namestore/test_namestore_api.c
22 * @brief testcase for namestore_api.c for updating an existing record
23 */
24#include "platform.h"
25#include "gnunet_common.h"
26#include "gnunet_namestore_service.h"
27#include "gnunet_testing_lib.h"
28#include "namestore.h"
29#include "gnunet_signatures.h"
30
31
32#define RECORDS 1
33
34#define TEST_RECORD_TYPE 1234
35
36#define TEST_RECORD_DATALEN 123
37
38#define TEST_RECORD_DATA 'a'
39
40#define TEST_CREATE_RECORD_TYPE 4321
41
42#define TEST_CREATE_RECORD_DATALEN 255
43
44#define TEST_CREATE_RECORD_DATA 'b'
45
46#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 100)
47
48
49static struct GNUNET_NAMESTORE_Handle * nsh;
50
51static GNUNET_SCHEDULER_TaskIdentifier endbadly_task;
52
53static struct GNUNET_CRYPTO_EccPrivateKey * privkey;
54
55static struct GNUNET_CRYPTO_EccPublicKey pubkey;
56
57static struct GNUNET_CRYPTO_EccSignature *s_signature;
58
59static struct GNUNET_CRYPTO_ShortHashCode s_zone;
60
61static struct GNUNET_NAMESTORE_RecordData *s_first_record;
62
63static struct GNUNET_NAMESTORE_RecordData *s_second_record;
64
65static char *s_name;
66
67static int res;
68
69
70/**
71 * Re-establish the connection to the service.
72 *
73 * @param cls handle to use to re-connect.
74 * @param tc scheduler context
75 */
76static void
77endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
78{
79 GNUNET_break (0);
80 if (nsh != NULL)
81 GNUNET_NAMESTORE_disconnect (nsh);
82 nsh = NULL;
83 if (privkey != NULL)
84 GNUNET_free (privkey);
85 privkey = NULL;
86 GNUNET_free_non_null (s_name);
87 res = 1;
88}
89
90
91static void
92end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
93{
94 if (endbadly_task != GNUNET_SCHEDULER_NO_TASK)
95 {
96 GNUNET_SCHEDULER_cancel (endbadly_task);
97 endbadly_task = GNUNET_SCHEDULER_NO_TASK;
98 }
99 GNUNET_free ((void *) s_first_record->data);
100 GNUNET_free (s_first_record);
101 GNUNET_free_non_null (s_second_record);
102 if (privkey != NULL)
103 GNUNET_free (privkey);
104 privkey = NULL;
105 if (nsh != NULL)
106 GNUNET_NAMESTORE_disconnect (nsh);
107 nsh = NULL;
108 GNUNET_free_non_null (s_name);
109}
110
111
112static void
113create_updated_cont (void *cls, int32_t success, const char *emsg)
114{
115 char *name = cls;
116 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating expiration for record `%s': %s `%s'\n", name, ((success == GNUNET_YES) || (success == GNUNET_NO)) ? "SUCCESS" : "FAIL", emsg);
117 if (success == GNUNET_OK)
118 {
119 res = 0;
120 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updated record for name `%s'\n", name);
121 }
122 else if (success == GNUNET_NO)
123 {
124 res = 1;
125 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed updating record for name `%s'\n", name);
126 }
127 else
128 {
129 res = 1;
130 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to create records for name `%s'\n", name);
131 }
132 GNUNET_SCHEDULER_add_now(&end, NULL);
133}
134
135
136static void
137create_identical_cont (void *cls, int32_t success, const char *emsg)
138{
139 char *name = cls;
140
141 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
142 "Updating identical record for `%s': %s `%s'\n",
143 name,
144 ((success == GNUNET_YES) || (success == GNUNET_NO)) ? "SUCCESS" : "FAIL",
145 emsg);
146 if (success == GNUNET_OK)
147 {
148 res = 0;
149 s_first_record->expiration_time = GNUNET_TIME_absolute_get ().abs_value_us;
150 GNUNET_NAMESTORE_record_put_by_authority (nsh, privkey, s_name,
151 1, s_first_record,
152 &create_updated_cont, s_name);
153 }
154 else
155 {
156 res = 1;
157 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
158 "Updating identical record for `%s': %s `%s'\n",
159 name,
160 ((success == GNUNET_YES) || (success == GNUNET_NO)) ? "SUCCESS" : "FAIL",
161 emsg);
162 GNUNET_SCHEDULER_add_now (&end, NULL);
163 }
164}
165
166
167static void
168create_first_cont (void *cls, int32_t success, const char *emsg)
169{
170 char *name = cls;
171 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
172 "Create record for `%s': %s `%s'\n",
173 name, (success == GNUNET_OK) ? "SUCCESS" : "FAIL",
174 emsg);
175 if (success == GNUNET_OK)
176 {
177 res = 0;
178 /* check if record was created correct */
179 GNUNET_NAMESTORE_record_put_by_authority (nsh, privkey, s_name,
180 1, s_first_record,
181 &create_identical_cont, s_name);
182 }
183 else
184 {
185 res = 1;
186 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
187 "Failed to put records for name `%s'\n", name);
188 GNUNET_SCHEDULER_add_now(&end, NULL);
189 }
190
191}
192
193
194static struct GNUNET_NAMESTORE_RecordData *
195create_record (unsigned int count)
196{
197 unsigned int c;
198 struct GNUNET_NAMESTORE_RecordData * rd;
199
200 rd = GNUNET_malloc (count * sizeof (struct GNUNET_NAMESTORE_RecordData));
201 for (c = 0; c < count; c++)
202 {
203 rd[c].expiration_time = 0;
204 rd[c].record_type = TEST_RECORD_TYPE;
205 rd[c].data_size = TEST_RECORD_DATALEN;
206 rd[c].data = GNUNET_malloc(TEST_RECORD_DATALEN);
207 memset ((char *) rd[c].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN);
208 }
209 return rd;
210}
211
212
213static void
214run (void *cls,
215 const struct GNUNET_CONFIGURATION_Handle *cfg,
216 struct GNUNET_TESTING_Peer *peer)
217{
218 size_t rd_ser_len;
219 char *hostkey_file;
220 struct GNUNET_TIME_Absolute et;
221
222 endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, endbadly, NULL);
223
224 /* load privat key */
225 GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR,
226 "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey");
227 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file);
228 privkey = GNUNET_CRYPTO_ecc_key_create_from_file(hostkey_file);
229 GNUNET_free (hostkey_file);
230 GNUNET_assert (privkey != NULL);
231 /* get public key */
232 GNUNET_CRYPTO_ecc_key_get_public(privkey, &pubkey);
233
234 /* create record */
235 s_name = GNUNET_NAMESTORE_normalize_string ("DUMMY.dummy.gnunet");
236 s_first_record = create_record (1);
237
238 rd_ser_len = GNUNET_NAMESTORE_records_get_size(1, s_first_record);
239 char rd_ser[rd_ser_len];
240 GNUNET_NAMESTORE_records_serialize(1, s_first_record, rd_ser_len, rd_ser);
241
242 et.abs_value_us = s_first_record->expiration_time;
243 s_signature = GNUNET_NAMESTORE_create_signature(privkey, et, s_name, s_first_record, 1);
244
245 /* create random zone hash */
246 GNUNET_CRYPTO_short_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_EccPublicKey), &s_zone);
247
248 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Name: `%s' Zone: `%s' \n", s_name, GNUNET_NAMESTORE_short_h2s (&s_zone));
249 nsh = GNUNET_NAMESTORE_connect (cfg);
250 GNUNET_break (NULL != nsh);
251
252 GNUNET_break (s_first_record != NULL);
253 GNUNET_break (s_name != NULL);
254
255 /* create initial record */
256 GNUNET_NAMESTORE_record_put_by_authority (nsh, privkey, s_name,
257 1, s_first_record,
258 &create_first_cont, s_name);
259}
260
261
262int
263main (int argc, char *argv[])
264{
265 res = 1;
266 if (0 !=
267 GNUNET_TESTING_service_run ("test-namestore-api-create-update",
268 "namestore",
269 "test_namestore_api.conf",
270 &run,
271 NULL))
272 return 1;
273 GNUNET_free_non_null (s_signature);
274 return res;
275}
276
277/* end of test_namestore_api_create_update.c */