aboutsummaryrefslogtreecommitdiff
path: root/src/peerstore/test_peerstore_api_iterate.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/peerstore/test_peerstore_api_iterate.c')
-rw-r--r--src/peerstore/test_peerstore_api_iterate.c194
1 files changed, 97 insertions, 97 deletions
diff --git a/src/peerstore/test_peerstore_api_iterate.c b/src/peerstore/test_peerstore_api_iterate.c
index a19aad121..185fc8225 100644
--- a/src/peerstore/test_peerstore_api_iterate.c
+++ b/src/peerstore/test_peerstore_api_iterate.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_iterate.c 21 * @file peerstore/test_peerstore_api_iterate.c
22 * @brief testcase for peerstore iteration operation 22 * @brief testcase for peerstore iteration operation
@@ -42,132 +42,132 @@ static int count = 0;
42 42
43 43
44static void 44static void
45iter3_cb (void *cls, 45iter3_cb(void *cls,
46 const struct GNUNET_PEERSTORE_Record *record, 46 const struct GNUNET_PEERSTORE_Record *record,
47 const char *emsg) 47 const char *emsg)
48{ 48{
49 if (NULL != emsg) 49 if (NULL != emsg)
50 { 50 {
51 GNUNET_PEERSTORE_iterate_cancel (ic); 51 GNUNET_PEERSTORE_iterate_cancel(ic);
52 return; 52 return;
53 } 53 }
54 if (NULL != record) 54 if (NULL != record)
55 { 55 {
56 count++; 56 count++;
57 return; 57 return;
58 } 58 }
59 GNUNET_assert (count == 3); 59 GNUNET_assert(count == 3);
60 ok = 0; 60 ok = 0;
61 GNUNET_PEERSTORE_disconnect (h, GNUNET_NO); 61 GNUNET_PEERSTORE_disconnect(h, GNUNET_NO);
62 GNUNET_SCHEDULER_shutdown (); 62 GNUNET_SCHEDULER_shutdown();
63} 63}
64 64
65 65
66static void 66static void
67iter2_cb (void *cls, 67iter2_cb(void *cls,
68 const struct GNUNET_PEERSTORE_Record *record, 68 const struct GNUNET_PEERSTORE_Record *record,
69 const char *emsg) 69 const char *emsg)
70{ 70{
71 if (NULL != emsg) 71 if (NULL != emsg)
72 { 72 {
73 GNUNET_PEERSTORE_iterate_cancel (ic); 73 GNUNET_PEERSTORE_iterate_cancel(ic);
74 return; 74 return;
75 } 75 }
76 if (NULL != record) 76 if (NULL != record)
77 { 77 {
78 count++; 78 count++;
79 return; 79 return;
80 } 80 }
81 GNUNET_assert (count == 2); 81 GNUNET_assert(count == 2);
82 count = 0; 82 count = 0;
83 ic = GNUNET_PEERSTORE_iterate (h, 83 ic = GNUNET_PEERSTORE_iterate(h,
84 ss, 84 ss,
85 NULL, 85 NULL,
86 NULL, 86 NULL,
87 &iter3_cb, 87 &iter3_cb,
88 NULL); 88 NULL);
89} 89}
90 90
91 91
92static void 92static void
93iter1_cb (void *cls, 93iter1_cb(void *cls,
94 const struct GNUNET_PEERSTORE_Record *record, 94 const struct GNUNET_PEERSTORE_Record *record,
95 const char *emsg) 95 const char *emsg)
96{ 96{
97 if (NULL != emsg) 97 if (NULL != emsg)
98 { 98 {
99 GNUNET_PEERSTORE_iterate_cancel (ic); 99 GNUNET_PEERSTORE_iterate_cancel(ic);
100 return; 100 return;
101 } 101 }
102 if (NULL != record) 102 if (NULL != record)
103 { 103 {
104 count++; 104 count++;
105 return; 105 return;
106 } 106 }
107 GNUNET_assert (count == 1); 107 GNUNET_assert(count == 1);
108 count = 0; 108 count = 0;
109 ic = GNUNET_PEERSTORE_iterate (h, 109 ic = GNUNET_PEERSTORE_iterate(h,
110 ss, 110 ss,
111 &p1, 111 &p1,
112 NULL, 112 NULL,
113 &iter2_cb, 113 &iter2_cb,
114 NULL); 114 NULL);
115} 115}
116 116
117 117
118static void 118static void
119run (void *cls, 119run(void *cls,
120 const struct GNUNET_CONFIGURATION_Handle *cfg, 120 const struct GNUNET_CONFIGURATION_Handle *cfg,
121 struct GNUNET_TESTING_Peer *peer) 121 struct GNUNET_TESTING_Peer *peer)
122{ 122{
123 h = GNUNET_PEERSTORE_connect (cfg); 123 h = GNUNET_PEERSTORE_connect(cfg);
124 GNUNET_assert (NULL != h); 124 GNUNET_assert(NULL != h);
125 memset (&p1, 1, sizeof (p1)); 125 memset(&p1, 1, sizeof(p1));
126 memset (&p2, 2, sizeof (p2)); 126 memset(&p2, 2, sizeof(p2));
127 GNUNET_PEERSTORE_store (h, 127 GNUNET_PEERSTORE_store(h,
128 ss, 128 ss,
129 &p1, 129 &p1,
130 k1, 130 k1,
131 val, 131 val,
132 strlen (val) + 1, 132 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, 135 NULL,
136 NULL); 136 NULL);
137 GNUNET_PEERSTORE_store (h, 137 GNUNET_PEERSTORE_store(h,
138 ss, 138 ss,
139 &p1, 139 &p1,
140 k2, 140 k2,
141 val, 141 val,
142 strlen (val) + 1, 142 strlen(val) + 1,
143 GNUNET_TIME_UNIT_FOREVER_ABS, 143 GNUNET_TIME_UNIT_FOREVER_ABS,
144 GNUNET_PEERSTORE_STOREOPTION_REPLACE, 144 GNUNET_PEERSTORE_STOREOPTION_REPLACE,
145 NULL, 145 NULL,
146 NULL); 146 NULL);
147 GNUNET_PEERSTORE_store (h, 147 GNUNET_PEERSTORE_store(h,
148 ss, 148 ss,
149 &p2, 149 &p2,
150 k3, 150 k3,
151 val, 151 val,
152 strlen (val) + 1, 152 strlen(val) + 1,
153 GNUNET_TIME_UNIT_FOREVER_ABS, 153 GNUNET_TIME_UNIT_FOREVER_ABS,
154 GNUNET_PEERSTORE_STOREOPTION_REPLACE, 154 GNUNET_PEERSTORE_STOREOPTION_REPLACE,
155 NULL, 155 NULL,
156 NULL); 156 NULL);
157 ic = GNUNET_PEERSTORE_iterate (h, 157 ic = GNUNET_PEERSTORE_iterate(h,
158 ss, 158 ss,
159 &p1, 159 &p1,
160 k1, 160 k1,
161 &iter1_cb, NULL); 161 &iter1_cb, NULL);
162} 162}
163 163
164 164
165int 165int
166main (int argc, char *argv[]) 166main(int argc, char *argv[])
167{ 167{
168 if (0 != 168 if (0 !=
169 GNUNET_TESTING_service_run ("test-gnunet-peerstore", "peerstore", 169 GNUNET_TESTING_service_run("test-gnunet-peerstore", "peerstore",
170 "test_peerstore_api_data.conf", &run, NULL)) 170 "test_peerstore_api_data.conf", &run, NULL))
171 return 1; 171 return 1;
172 return ok; 172 return ok;
173} 173}