diff options
Diffstat (limited to 'src/peerstore/test_peerstore_api_sync.c')
-rw-r--r-- | src/peerstore/test_peerstore_api_sync.c | 96 |
1 files changed, 48 insertions, 48 deletions
diff --git a/src/peerstore/test_peerstore_api_sync.c b/src/peerstore/test_peerstore_api_sync.c index 6fe12335e..7df4778be 100644 --- a/src/peerstore/test_peerstore_api_sync.c +++ b/src/peerstore/test_peerstore_api_sync.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 peerstore/test_peerstore_api_sync.c | 21 | * @file peerstore/test_peerstore_api_sync.c |
22 | * @brief testcase for peerstore sync-on-disconnect feature. Stores | 22 | * @brief testcase for peerstore sync-on-disconnect feature. Stores |
@@ -80,22 +80,22 @@ static const char *val = "test_peerstore_api_store_val"; | |||
80 | * @return #GNUNET_YES (all good, continue) | 80 | * @return #GNUNET_YES (all good, continue) |
81 | */ | 81 | */ |
82 | static void | 82 | static void |
83 | iterate_cb (void *cls, | 83 | iterate_cb(void *cls, |
84 | const struct GNUNET_PEERSTORE_Record *record, | 84 | const struct GNUNET_PEERSTORE_Record *record, |
85 | const char *emsg) | 85 | const char *emsg) |
86 | { | 86 | { |
87 | const char *rec_val; | 87 | const char *rec_val; |
88 | 88 | ||
89 | GNUNET_break (NULL == emsg); | 89 | GNUNET_break(NULL == emsg); |
90 | if (NULL == record) | 90 | if (NULL == record) |
91 | { | 91 | { |
92 | GNUNET_PEERSTORE_disconnect (h, | 92 | GNUNET_PEERSTORE_disconnect(h, |
93 | GNUNET_NO); | 93 | GNUNET_NO); |
94 | GNUNET_SCHEDULER_shutdown (); | 94 | GNUNET_SCHEDULER_shutdown(); |
95 | return; | 95 | return; |
96 | } | 96 | } |
97 | rec_val = record->value; | 97 | rec_val = record->value; |
98 | GNUNET_break (0 == strcmp (rec_val, val)); | 98 | GNUNET_break(0 == strcmp(rec_val, val)); |
99 | ok = 0; | 99 | ok = 0; |
100 | } | 100 | } |
101 | 101 | ||
@@ -107,14 +107,14 @@ iterate_cb (void *cls, | |||
107 | * @param cls NULL | 107 | * @param cls NULL |
108 | */ | 108 | */ |
109 | static void | 109 | static void |
110 | test_cont (void *cls) | 110 | test_cont(void *cls) |
111 | { | 111 | { |
112 | h = GNUNET_PEERSTORE_connect (cfg); | 112 | h = GNUNET_PEERSTORE_connect(cfg); |
113 | GNUNET_PEERSTORE_iterate (h, | 113 | GNUNET_PEERSTORE_iterate(h, |
114 | subsystem, | 114 | subsystem, |
115 | &pid, key, | 115 | &pid, key, |
116 | &iterate_cb, | 116 | &iterate_cb, |
117 | NULL); | 117 | NULL); |
118 | } | 118 | } |
119 | 119 | ||
120 | 120 | ||
@@ -122,28 +122,28 @@ test_cont (void *cls) | |||
122 | * Actually run the test. | 122 | * Actually run the test. |
123 | */ | 123 | */ |
124 | static void | 124 | static void |
125 | test1 () | 125 | test1() |
126 | { | 126 | { |
127 | h = GNUNET_PEERSTORE_connect (cfg); | 127 | h = GNUNET_PEERSTORE_connect(cfg); |
128 | GNUNET_PEERSTORE_store (h, | 128 | GNUNET_PEERSTORE_store(h, |
129 | subsystem, | 129 | subsystem, |
130 | &pid, | 130 | &pid, |
131 | key, | 131 | key, |
132 | val, strlen (val) + 1, | 132 | val, strlen(val) + 1, |
133 | GNUNET_TIME_UNIT_FOREVER_ABS, | 133 | GNUNET_TIME_UNIT_FOREVER_ABS, |
134 | GNUNET_PEERSTORE_STOREOPTION_REPLACE, | 134 | GNUNET_PEERSTORE_STOREOPTION_REPLACE, |
135 | NULL, NULL); | 135 | NULL, NULL); |
136 | GNUNET_PEERSTORE_disconnect (h, | 136 | GNUNET_PEERSTORE_disconnect(h, |
137 | GNUNET_YES); | 137 | GNUNET_YES); |
138 | h = NULL; | 138 | h = NULL; |
139 | /* We need to wait a little bit to give the disconnect | 139 | /* We need to wait a little bit to give the disconnect |
140 | a chance to actually finish the operation; otherwise, | 140 | a chance to actually finish the operation; otherwise, |
141 | the test may fail non-deterministically if the new | 141 | the test may fail non-deterministically if the new |
142 | connection is faster than the cleanup routine of the | 142 | connection is faster than the cleanup routine of the |
143 | old one. */ | 143 | old one. */ |
144 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | 144 | GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_SECONDS, |
145 | &test_cont, | 145 | &test_cont, |
146 | NULL); | 146 | NULL); |
147 | } | 147 | } |
148 | 148 | ||
149 | 149 | ||
@@ -155,29 +155,29 @@ test1 () | |||
155 | * @param peer handle to our peer (unused) | 155 | * @param peer handle to our peer (unused) |
156 | */ | 156 | */ |
157 | static void | 157 | static void |
158 | run (void *cls, | 158 | run(void *cls, |
159 | const struct GNUNET_CONFIGURATION_Handle *c, | 159 | const struct GNUNET_CONFIGURATION_Handle *c, |
160 | struct GNUNET_TESTING_Peer *peer) | 160 | struct GNUNET_TESTING_Peer *peer) |
161 | { | 161 | { |
162 | cfg = c; | 162 | cfg = c; |
163 | memset (&pid, 1, sizeof (pid)); | 163 | memset(&pid, 1, sizeof(pid)); |
164 | test1 (); | 164 | test1(); |
165 | } | 165 | } |
166 | 166 | ||
167 | 167 | ||
168 | int | 168 | int |
169 | main (int argc, char *argv[]) | 169 | main(int argc, char *argv[]) |
170 | { | 170 | { |
171 | if (0 != | 171 | if (0 != |
172 | GNUNET_TESTING_service_run ("test-gnunet-peerstore-sync", | 172 | GNUNET_TESTING_service_run("test-gnunet-peerstore-sync", |
173 | "peerstore", | 173 | "peerstore", |
174 | "test_peerstore_api_data.conf", | 174 | "test_peerstore_api_data.conf", |
175 | &run, NULL)) | 175 | &run, NULL)) |
176 | return 1; | 176 | return 1; |
177 | if (0 != ok) | 177 | if (0 != ok) |
178 | fprintf (stderr, | 178 | fprintf(stderr, |
179 | "Test failed: %d\n", | 179 | "Test failed: %d\n", |
180 | ok); | 180 | ok); |
181 | return ok; | 181 | return ok; |
182 | } | 182 | } |
183 | 183 | ||