aboutsummaryrefslogtreecommitdiff
path: root/src/namestore/test_namestore_api_remove_not_existing_record.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/namestore/test_namestore_api_remove_not_existing_record.c')
-rw-r--r--src/namestore/test_namestore_api_remove_not_existing_record.c164
1 files changed, 82 insertions, 82 deletions
diff --git a/src/namestore/test_namestore_api_remove_not_existing_record.c b/src/namestore/test_namestore_api_remove_not_existing_record.c
index fee06e3af..5558696a8 100644
--- a/src/namestore/test_namestore_api_remove_not_existing_record.c
+++ b/src/namestore/test_namestore_api_remove_not_existing_record.c
@@ -31,12 +31,12 @@
31 31
32#define TEST_RECORD_DATA 'a' 32#define TEST_RECORD_DATA 'a'
33 33
34#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 100) 34#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 100)
35 35
36 36
37static struct GNUNET_NAMESTORE_Handle *nsh; 37static struct GNUNET_NAMESTORE_Handle *nsh;
38 38
39static struct GNUNET_SCHEDULER_Task * endbadly_task; 39static struct GNUNET_SCHEDULER_Task *endbadly_task;
40 40
41static struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey; 41static struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey;
42 42
@@ -48,19 +48,19 @@ static struct GNUNET_NAMESTORE_QueueEntry *nsqe;
48 48
49 49
50static void 50static void
51cleanup() 51cleanup ()
52{ 52{
53 if (NULL != nsh) 53 if (NULL != nsh)
54 { 54 {
55 GNUNET_NAMESTORE_disconnect(nsh); 55 GNUNET_NAMESTORE_disconnect (nsh);
56 nsh = NULL; 56 nsh = NULL;
57 } 57 }
58 if (NULL != privkey) 58 if (NULL != privkey)
59 { 59 {
60 GNUNET_free(privkey); 60 GNUNET_free (privkey);
61 privkey = NULL; 61 privkey = NULL;
62 } 62 }
63 GNUNET_SCHEDULER_shutdown(); 63 GNUNET_SCHEDULER_shutdown ();
64} 64}
65 65
66 66
@@ -70,87 +70,87 @@ cleanup()
70 * @param cls handle to use to re-connect. 70 * @param cls handle to use to re-connect.
71 */ 71 */
72static void 72static void
73endbadly(void *cls) 73endbadly (void *cls)
74{ 74{
75 if (NULL != nsqe) 75 if (NULL != nsqe)
76 { 76 {
77 GNUNET_NAMESTORE_cancel(nsqe); 77 GNUNET_NAMESTORE_cancel (nsqe);
78 nsqe = NULL; 78 nsqe = NULL;
79 } 79 }
80 cleanup(); 80 cleanup ();
81 res = 1; 81 res = 1;
82} 82}
83 83
84 84
85static void 85static void
86end(void *cls) 86end (void *cls)
87{ 87{
88 cleanup(); 88 cleanup ();
89 res = 0; 89 res = 0;
90} 90}
91 91
92 92
93static void 93static void
94put_cont(void *cls, 94put_cont (void *cls,
95 int32_t success, 95 int32_t success,
96 const char *emsg) 96 const char *emsg)
97{ 97{
98 GNUNET_assert(NULL != cls); 98 GNUNET_assert (NULL != cls);
99 nsqe = NULL; 99 nsqe = NULL;
100 if (endbadly_task != NULL) 100 if (endbadly_task != NULL)
101 { 101 {
102 GNUNET_SCHEDULER_cancel(endbadly_task); 102 GNUNET_SCHEDULER_cancel (endbadly_task);
103 endbadly_task = NULL; 103 endbadly_task = NULL;
104 } 104 }
105 switch (success) 105 switch (success)
106 { 106 {
107 case GNUNET_NO: 107 case GNUNET_NO:
108 /* We expected GNUNET_NO, since record was not found */ 108 /* We expected GNUNET_NO, since record was not found */
109 GNUNET_SCHEDULER_add_now(&end, NULL); 109 GNUNET_SCHEDULER_add_now (&end, NULL);
110 break; 110 break;
111 111
112 case GNUNET_OK: 112 case GNUNET_OK:
113 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 113 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
114 "Namestore could remove non-existing record: `%s'\n", 114 "Namestore could remove non-existing record: `%s'\n",
115 (NULL != emsg) ? emsg : ""); 115 (NULL != emsg) ? emsg : "");
116 GNUNET_SCHEDULER_add_now(&endbadly, NULL); 116 GNUNET_SCHEDULER_add_now (&endbadly, NULL);
117 break; 117 break;
118 118
119 case GNUNET_SYSERR: 119 case GNUNET_SYSERR:
120 default: 120 default:
121 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 121 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
122 "Namestore failed: `%s'\n", 122 "Namestore failed: `%s'\n",
123 (NULL != emsg) ? emsg : ""); 123 (NULL != emsg) ? emsg : "");
124 GNUNET_SCHEDULER_add_now(&endbadly, NULL); 124 GNUNET_SCHEDULER_add_now (&endbadly, NULL);
125 break; 125 break;
126 } 126 }
127} 127}
128 128
129 129
130static void 130static void
131run(void *cls, 131run (void *cls,
132 const struct GNUNET_CONFIGURATION_Handle *cfg, 132 const struct GNUNET_CONFIGURATION_Handle *cfg,
133 struct GNUNET_TESTING_Peer *peer) 133 struct GNUNET_TESTING_Peer *peer)
134{ 134{
135 const char * name = "dummy.dummy.gnunet"; 135 const char *name = "dummy.dummy.gnunet";
136 136
137 endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT, 137 endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
138 &endbadly, 138 &endbadly,
139 NULL); 139 NULL);
140 privkey = GNUNET_CRYPTO_ecdsa_key_create(); 140 privkey = GNUNET_CRYPTO_ecdsa_key_create ();
141 GNUNET_assert(privkey != NULL); 141 GNUNET_assert (privkey != NULL);
142 GNUNET_CRYPTO_ecdsa_key_get_public(privkey, &pubkey); 142 GNUNET_CRYPTO_ecdsa_key_get_public (privkey, &pubkey);
143 143
144 nsh = GNUNET_NAMESTORE_connect(cfg); 144 nsh = GNUNET_NAMESTORE_connect (cfg);
145 GNUNET_break(NULL != nsh); 145 GNUNET_break (NULL != nsh);
146 nsqe = GNUNET_NAMESTORE_records_store(nsh, privkey, name, 146 nsqe = GNUNET_NAMESTORE_records_store (nsh, privkey, name,
147 0, NULL, 147 0, NULL,
148 &put_cont, (void *)name); 148 &put_cont, (void *) name);
149 if (NULL == nsqe) 149 if (NULL == nsqe)
150 { 150 {
151 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 151 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
152 _("Namestore cannot store no block\n")); 152 _ ("Namestore cannot store no block\n"));
153 } 153 }
154} 154}
155 155
156 156
@@ -158,24 +158,24 @@ run(void *cls,
158 158
159 159
160int 160int
161main(int argc, char *argv[]) 161main (int argc, char *argv[])
162{ 162{
163 const char *plugin_name; 163 const char *plugin_name;
164 char *cfg_name; 164 char *cfg_name;
165 165
166 SETUP_CFG(plugin_name, cfg_name); 166 SETUP_CFG (plugin_name, cfg_name);
167 res = 1; 167 res = 1;
168 if (0 != 168 if (0 !=
169 GNUNET_TESTING_peer_run("test-namestore-api-remove-non-existing-record", 169 GNUNET_TESTING_peer_run ("test-namestore-api-remove-non-existing-record",
170 cfg_name, 170 cfg_name,
171 &run, 171 &run,
172 NULL)) 172 NULL))
173 { 173 {
174 res = 1; 174 res = 1;
175 } 175 }
176 GNUNET_DISK_purge_cfg_dir(cfg_name, 176 GNUNET_DISK_purge_cfg_dir (cfg_name,
177 "GNUNET_TEST_HOME"); 177 "GNUNET_TEST_HOME");
178 GNUNET_free(cfg_name); 178 GNUNET_free (cfg_name);
179 return res; 179 return res;
180} 180}
181 181