diff options
author | ng0 <ng0@n0.is> | 2019-09-08 12:33:09 +0000 |
---|---|---|
committer | ng0 <ng0@n0.is> | 2019-09-08 12:33:09 +0000 |
commit | d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb (patch) | |
tree | 9efd18ea7d425652085ed0bd5e8e45604bc5f6b9 /src/namestore/test_namestore_api_remove_not_existing_record.c | |
parent | a0fce305c565c0937d917a92712f15e9c5736260 (diff) | |
download | gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.tar.gz gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.zip |
uncrustify as demanded.
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.c | 144 |
1 files changed, 73 insertions, 71 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 c8110fe6b..fee06e3af 100644 --- a/src/namestore/test_namestore_api_remove_not_existing_record.c +++ b/src/namestore/test_namestore_api_remove_not_existing_record.c | |||
@@ -11,12 +11,12 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @file namestore/test_namestore_api_remove_not_existing_record.c | 21 | * @file namestore/test_namestore_api_remove_not_existing_record.c |
22 | * @brief testcase for namestore_api.c | 22 | * @brief testcase for namestore_api.c |
@@ -31,7 +31,7 @@ | |||
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 | ||
37 | static struct GNUNET_NAMESTORE_Handle *nsh; | 37 | static struct GNUNET_NAMESTORE_Handle *nsh; |
@@ -48,19 +48,19 @@ static struct GNUNET_NAMESTORE_QueueEntry *nsqe; | |||
48 | 48 | ||
49 | 49 | ||
50 | static void | 50 | static void |
51 | cleanup () | 51 | cleanup() |
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,85 +70,87 @@ cleanup () | |||
70 | * @param cls handle to use to re-connect. | 70 | * @param cls handle to use to re-connect. |
71 | */ | 71 | */ |
72 | static void | 72 | static void |
73 | endbadly (void *cls) | 73 | endbadly(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 | ||
85 | static void | 85 | static void |
86 | end (void *cls) | 86 | end(void *cls) |
87 | { | 87 | { |
88 | cleanup (); | 88 | cleanup(); |
89 | res = 0; | 89 | res = 0; |
90 | } | 90 | } |
91 | 91 | ||
92 | 92 | ||
93 | static void | 93 | static void |
94 | put_cont (void *cls, | 94 | put_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 | case GNUNET_OK: | 112 | case GNUNET_OK: |
112 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 113 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
113 | "Namestore could remove non-existing record: `%s'\n", | 114 | "Namestore could remove non-existing record: `%s'\n", |
114 | (NULL !=emsg) ? emsg : ""); | 115 | (NULL != emsg) ? emsg : ""); |
115 | GNUNET_SCHEDULER_add_now (&endbadly, NULL); | 116 | GNUNET_SCHEDULER_add_now(&endbadly, NULL); |
116 | break; | 117 | break; |
118 | |||
117 | case GNUNET_SYSERR: | 119 | case GNUNET_SYSERR: |
118 | default: | 120 | default: |
119 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 121 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
120 | "Namestore failed: `%s'\n", | 122 | "Namestore failed: `%s'\n", |
121 | (NULL !=emsg) ? emsg : ""); | 123 | (NULL != emsg) ? emsg : ""); |
122 | GNUNET_SCHEDULER_add_now (&endbadly, NULL); | 124 | GNUNET_SCHEDULER_add_now(&endbadly, NULL); |
123 | break; | 125 | break; |
124 | } | 126 | } |
125 | } | 127 | } |
126 | 128 | ||
127 | 129 | ||
128 | static void | 130 | static void |
129 | run (void *cls, | 131 | run(void *cls, |
130 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 132 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
131 | struct GNUNET_TESTING_Peer *peer) | 133 | struct GNUNET_TESTING_Peer *peer) |
132 | { | 134 | { |
133 | const char * name = "dummy.dummy.gnunet"; | 135 | const char * name = "dummy.dummy.gnunet"; |
134 | 136 | ||
135 | endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 137 | endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT, |
136 | &endbadly, | 138 | &endbadly, |
137 | NULL); | 139 | NULL); |
138 | privkey = GNUNET_CRYPTO_ecdsa_key_create (); | 140 | privkey = GNUNET_CRYPTO_ecdsa_key_create(); |
139 | GNUNET_assert (privkey != NULL); | 141 | GNUNET_assert(privkey != NULL); |
140 | GNUNET_CRYPTO_ecdsa_key_get_public (privkey, &pubkey); | 142 | GNUNET_CRYPTO_ecdsa_key_get_public(privkey, &pubkey); |
141 | 143 | ||
142 | nsh = GNUNET_NAMESTORE_connect (cfg); | 144 | nsh = GNUNET_NAMESTORE_connect(cfg); |
143 | GNUNET_break (NULL != nsh); | 145 | GNUNET_break(NULL != nsh); |
144 | nsqe = GNUNET_NAMESTORE_records_store (nsh, privkey, name, | 146 | nsqe = GNUNET_NAMESTORE_records_store(nsh, privkey, name, |
145 | 0, NULL, | 147 | 0, NULL, |
146 | &put_cont, (void *) name); | 148 | &put_cont, (void *)name); |
147 | if (NULL == nsqe) | 149 | if (NULL == nsqe) |
148 | { | 150 | { |
149 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 151 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
150 | _("Namestore cannot store no block\n")); | 152 | _("Namestore cannot store no block\n")); |
151 | } | 153 | } |
152 | } | 154 | } |
153 | 155 | ||
154 | 156 | ||
@@ -156,24 +158,24 @@ run (void *cls, | |||
156 | 158 | ||
157 | 159 | ||
158 | int | 160 | int |
159 | main (int argc, char *argv[]) | 161 | main(int argc, char *argv[]) |
160 | { | 162 | { |
161 | const char *plugin_name; | 163 | const char *plugin_name; |
162 | char *cfg_name; | 164 | char *cfg_name; |
163 | 165 | ||
164 | SETUP_CFG (plugin_name, cfg_name); | 166 | SETUP_CFG(plugin_name, cfg_name); |
165 | res = 1; | 167 | res = 1; |
166 | if (0 != | 168 | if (0 != |
167 | GNUNET_TESTING_peer_run ("test-namestore-api-remove-non-existing-record", | 169 | GNUNET_TESTING_peer_run("test-namestore-api-remove-non-existing-record", |
168 | cfg_name, | 170 | cfg_name, |
169 | &run, | 171 | &run, |
170 | NULL)) | 172 | NULL)) |
171 | { | 173 | { |
172 | res = 1; | 174 | res = 1; |
173 | } | 175 | } |
174 | GNUNET_DISK_purge_cfg_dir (cfg_name, | 176 | GNUNET_DISK_purge_cfg_dir(cfg_name, |
175 | "GNUNET_TEST_HOME"); | 177 | "GNUNET_TEST_HOME"); |
176 | GNUNET_free (cfg_name); | 178 | GNUNET_free(cfg_name); |
177 | return res; | 179 | return res; |
178 | } | 180 | } |
179 | 181 | ||