aboutsummaryrefslogtreecommitdiff
path: root/src/peerstore/test_peerstore_api_store.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-03-14 00:31:02 +0100
committerChristian Grothoff <christian@grothoff.org>2017-03-14 00:31:02 +0100
commit8d71f909cb22fbf6774e4042309a8eb133af3bfc (patch)
tree0efc19ac24a6521f927772364f1379154d2d0cad /src/peerstore/test_peerstore_api_store.c
parent6e01dc4d91d072e8e58ba0140fb7f4ddd5109358 (diff)
downloadgnunet-8d71f909cb22fbf6774e4042309a8eb133af3bfc.tar.gz
gnunet-8d71f909cb22fbf6774e4042309a8eb133af3bfc.zip
convert sqlite peerstore to using libgnunetsq
Diffstat (limited to 'src/peerstore/test_peerstore_api_store.c')
-rw-r--r--src/peerstore/test_peerstore_api_store.c55
1 files changed, 42 insertions, 13 deletions
diff --git a/src/peerstore/test_peerstore_api_store.c b/src/peerstore/test_peerstore_api_store.c
index bfe1b5b55..978009dbb 100644
--- a/src/peerstore/test_peerstore_api_store.c
+++ b/src/peerstore/test_peerstore_api_store.c
@@ -39,6 +39,7 @@ static char *val3 = "test_peerstore_api_store_val3--";
39 39
40static int count = 0; 40static int count = 0;
41 41
42
42static void 43static void
43test3_cont2 (void *cls, 44test3_cont2 (void *cls,
44 const struct GNUNET_PEERSTORE_Record *record, 45 const struct GNUNET_PEERSTORE_Record *record,
@@ -49,7 +50,8 @@ test3_cont2 (void *cls,
49 if (NULL != record) 50 if (NULL != record)
50 { 51 {
51 GNUNET_assert ((strlen (val3) + 1) == record->value_size); 52 GNUNET_assert ((strlen (val3) + 1) == record->value_size);
52 GNUNET_assert (0 == strcmp ((char *) val3, (char *) record->value)); 53 GNUNET_assert (0 == strcmp ((char *) val3,
54 (char *) record->value));
53 count++; 55 count++;
54 return; 56 return;
55 } 57 }
@@ -61,7 +63,8 @@ test3_cont2 (void *cls,
61 63
62 64
63static void 65static void
64test3_cont (void *cls, int success) 66test3_cont (void *cls,
67 int success)
65{ 68{
66 if (GNUNET_YES != success) 69 if (GNUNET_YES != success)
67 return; 70 return;
@@ -71,7 +74,8 @@ test3_cont (void *cls, int success)
71 &pid, 74 &pid,
72 key, 75 key,
73 GNUNET_TIME_UNIT_SECONDS, 76 GNUNET_TIME_UNIT_SECONDS,
74 &test3_cont2, NULL); 77 &test3_cont2,
78 NULL);
75} 79}
76 80
77 81
@@ -81,9 +85,15 @@ test3_cont (void *cls, int success)
81static void 85static void
82test3 () 86test3 ()
83{ 87{
84 GNUNET_PEERSTORE_store (h, subsystem, &pid, key, val3, strlen (val3) + 1, 88 GNUNET_PEERSTORE_store (h,
89 subsystem,
90 &pid,
91 key,
92 val3,
93 strlen (val3) + 1,
85 GNUNET_TIME_UNIT_FOREVER_ABS, 94 GNUNET_TIME_UNIT_FOREVER_ABS,
86 GNUNET_PEERSTORE_STOREOPTION_REPLACE, &test3_cont, 95 GNUNET_PEERSTORE_STOREOPTION_REPLACE,
96 &test3_cont,
87 NULL); 97 NULL);
88} 98}
89 99
@@ -130,9 +140,15 @@ test2_cont (void *cls, int success)
130void 140void
131test2 () 141test2 ()
132{ 142{
133 GNUNET_PEERSTORE_store (h, subsystem, &pid, key, val2, strlen (val2) + 1, 143 GNUNET_PEERSTORE_store (h,
144 subsystem,
145 &pid,
146 key,
147 val2,
148 strlen (val2) + 1,
134 GNUNET_TIME_UNIT_FOREVER_ABS, 149 GNUNET_TIME_UNIT_FOREVER_ABS,
135 GNUNET_PEERSTORE_STOREOPTION_MULTIPLE, &test2_cont, 150 GNUNET_PEERSTORE_STOREOPTION_MULTIPLE,
151 &test2_cont,
136 NULL); 152 NULL);
137} 153}
138 154
@@ -163,8 +179,13 @@ test1_cont (void *cls, int success)
163 if (GNUNET_YES != success) 179 if (GNUNET_YES != success)
164 return; 180 return;
165 count = 0; 181 count = 0;
166 GNUNET_PEERSTORE_iterate (h, subsystem, &pid, key, GNUNET_TIME_UNIT_SECONDS, 182 GNUNET_PEERSTORE_iterate (h,
167 &test1_cont2, NULL); 183 subsystem,
184 &pid,
185 key,
186 GNUNET_TIME_UNIT_SECONDS,
187 &test1_cont2,
188 NULL);
168} 189}
169 190
170 191
@@ -174,9 +195,15 @@ test1_cont (void *cls, int success)
174static void 195static void
175test1 () 196test1 ()
176{ 197{
177 GNUNET_PEERSTORE_store (h, subsystem, &pid, key, val1, strlen (val1) + 1, 198 GNUNET_PEERSTORE_store (h,
199 subsystem,
200 &pid,
201 key,
202 val1,
203 strlen (val1) + 1,
178 GNUNET_TIME_UNIT_FOREVER_ABS, 204 GNUNET_TIME_UNIT_FOREVER_ABS,
179 GNUNET_PEERSTORE_STOREOPTION_REPLACE, &test1_cont, 205 GNUNET_PEERSTORE_STOREOPTION_REPLACE,
206 &test1_cont,
180 NULL); 207 NULL);
181} 208}
182 209
@@ -196,8 +223,10 @@ int
196main (int argc, char *argv[]) 223main (int argc, char *argv[])
197{ 224{
198 if (0 != 225 if (0 !=
199 GNUNET_TESTING_service_run ("test-gnunet-peerstore", "peerstore", 226 GNUNET_TESTING_service_run ("test-gnunet-peerstore",
200 "test_peerstore_api_data.conf", &run, NULL)) 227 "peerstore",
228 "test_peerstore_api_data.conf",
229 &run, NULL))
201 return 1; 230 return 1;
202 return ok; 231 return ok;
203} 232}