2 This file is part of GNUnet.
3 Copyright (C) 2013 GNUnet e.V.
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
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 Affero General Public License for more details.
16 * @file namestore/test_namestore_api_remove_not_existing_record.c
17 * @brief testcase for namestore_api.c
20 #include "gnunet_namestore_service.h"
21 #include "gnunet_testing_lib.h"
23 #define TEST_RECORD_TYPE 1234
25 #define TEST_RECORD_DATALEN 123
27 #define TEST_RECORD_DATA 'a'
29 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 100)
32 static struct GNUNET_NAMESTORE_Handle *nsh;
34 static struct GNUNET_SCHEDULER_Task * endbadly_task;
36 static struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey;
38 static struct GNUNET_CRYPTO_EcdsaPublicKey pubkey;
42 static struct GNUNET_NAMESTORE_QueueEntry *nsqe;
50 GNUNET_NAMESTORE_disconnect (nsh);
55 GNUNET_free (privkey);
58 GNUNET_SCHEDULER_shutdown ();
63 * Re-establish the connection to the service.
65 * @param cls handle to use to re-connect.
72 GNUNET_NAMESTORE_cancel (nsqe);
93 GNUNET_assert (NULL != cls);
95 if (endbadly_task != NULL)
97 GNUNET_SCHEDULER_cancel (endbadly_task);
103 /* We expected GNUNET_NO, since record was not found */
104 GNUNET_SCHEDULER_add_now (&end, NULL);
107 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
108 "Namestore could remove non-existing record: `%s'\n",
109 (NULL !=emsg) ? emsg : "");
110 GNUNET_SCHEDULER_add_now (&endbadly, NULL);
114 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
115 "Namestore failed: `%s'\n",
116 (NULL !=emsg) ? emsg : "");
117 GNUNET_SCHEDULER_add_now (&endbadly, NULL);
125 const struct GNUNET_CONFIGURATION_Handle *cfg,
126 struct GNUNET_TESTING_Peer *peer)
128 const char * name = "dummy.dummy.gnunet";
130 endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
133 privkey = GNUNET_CRYPTO_ecdsa_key_create ();
134 GNUNET_assert (privkey != NULL);
135 GNUNET_CRYPTO_ecdsa_key_get_public (privkey, &pubkey);
137 nsh = GNUNET_NAMESTORE_connect (cfg);
138 GNUNET_break (NULL != nsh);
139 nsqe = GNUNET_NAMESTORE_records_store (nsh, privkey, name,
141 &put_cont, (void *) name);
144 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
145 _("Namestore cannot store no block\n"));
151 main (int argc, char *argv[])
153 const char *plugin_name;
156 plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]);
157 GNUNET_asprintf (&cfg_name,
158 "test_namestore_api_%s.conf",
160 GNUNET_DISK_purge_cfg_dir (cfg_name,
164 GNUNET_TESTING_peer_run ("test-namestore-api-remove-non-existing-record",
171 GNUNET_DISK_purge_cfg_dir (cfg_name,
173 GNUNET_free (cfg_name);
177 /* end of test_namestore_api_remove_not_existing_record.c */