aboutsummaryrefslogtreecommitdiff
path: root/src/psycstore/test_plugin_psycstore.c
diff options
context:
space:
mode:
authorGabor X Toth <*@tg-x.net>2014-07-30 21:18:13 +0000
committerGabor X Toth <*@tg-x.net>2014-07-30 21:18:13 +0000
commit40884377f3126bbecbfd3243d47224b3094914f9 (patch)
tree9f32aab9064b199178282a0c9918313e0aa30049 /src/psycstore/test_plugin_psycstore.c
parent831718fa44b2c56577aa4e36a479fef6debb8cea (diff)
downloadgnunet-40884377f3126bbecbfd3243d47224b3094914f9.tar.gz
gnunet-40884377f3126bbecbfd3243d47224b3094914f9.zip
psyc, psycstore: retrieve state and history
Diffstat (limited to 'src/psycstore/test_plugin_psycstore.c')
-rw-r--r--src/psycstore/test_plugin_psycstore.c48
1 files changed, 31 insertions, 17 deletions
diff --git a/src/psycstore/test_plugin_psycstore.c b/src/psycstore/test_plugin_psycstore.c
index 8267ddba8..a6c456fec 100644
--- a/src/psycstore/test_plugin_psycstore.c
+++ b/src/psycstore/test_plugin_psycstore.c
@@ -204,11 +204,17 @@ run (void *cls, char *const *args, const char *cfgfile,
204 msg->header.type = htons (GNUNET_MESSAGE_TYPE_MULTICAST_MESSAGE); 204 msg->header.type = htons (GNUNET_MESSAGE_TYPE_MULTICAST_MESSAGE);
205 msg->header.size = htons (sizeof (*msg) + sizeof (channel_pub_key)); 205 msg->header.size = htons (sizeof (*msg) + sizeof (channel_pub_key));
206 206
207 uint64_t fragment_id = INT64_MAX - 1;
208 msg->fragment_id = GNUNET_htonll (fragment_id);
209
210 uint64_t message_id = INT64_MAX - 10;
211 msg->message_id = GNUNET_htonll (message_id);
212
213 uint64_t group_generation = INT64_MAX - 3;
214 msg->group_generation = GNUNET_htonll (group_generation);
215
207 msg->hop_counter = htonl (9); 216 msg->hop_counter = htonl (9);
208 msg->fragment_id = GNUNET_htonll (INT64_MAX - 1);
209 msg->fragment_offset = GNUNET_htonll (0); 217 msg->fragment_offset = GNUNET_htonll (0);
210 msg->message_id = GNUNET_htonll (INT64_MAX - 10);
211 msg->group_generation = GNUNET_htonll (INT64_MAX - 3);
212 msg->flags = htonl (GNUNET_MULTICAST_MESSAGE_LAST_FRAGMENT); 218 msg->flags = htonl (GNUNET_MULTICAST_MESSAGE_LAST_FRAGMENT);
213 219
214 memcpy (&msg[1], &channel_pub_key, sizeof (channel_pub_key)); 220 memcpy (&msg[1], &channel_pub_key, sizeof (channel_pub_key));
@@ -225,14 +231,19 @@ run (void *cls, char *const *args, const char *cfgfile,
225 fcls.msg[0] = msg; 231 fcls.msg[0] = msg;
226 fcls.flags[0] = GNUNET_PSYCSTORE_MESSAGE_STATE; 232 fcls.flags[0] = GNUNET_PSYCSTORE_MESSAGE_STATE;
227 233
228 GNUNET_assert (GNUNET_OK == db->fragment_store (db->cls, &channel_pub_key, msg, 234 GNUNET_assert (
229 fcls.flags[0])); 235 GNUNET_OK == db->fragment_store (db->cls, &channel_pub_key, msg,
236 fcls.flags[0]));
230 237
231 GNUNET_assert (GNUNET_OK == db->fragment_get (db->cls, &channel_pub_key, 238 uint64_t ret_frags = 0;
232 GNUNET_ntohll (msg->fragment_id), 239 GNUNET_assert (
233 fragment_cb, &fcls)); 240 GNUNET_OK == db->fragment_get (db->cls, &channel_pub_key,
241 fragment_id, fragment_id,
242 &ret_frags, fragment_cb, &fcls));
234 GNUNET_assert (fcls.n == 1); 243 GNUNET_assert (fcls.n == 1);
235 244
245 // FIXME: test fragment_get_latest and message_get_latest
246
236 fcls.n = 0; 247 fcls.n = 0;
237 248
238 GNUNET_assert ( 249 GNUNET_assert (
@@ -250,9 +261,10 @@ run (void *cls, char *const *args, const char *cfgfile,
250 fcls.n = 0; 261 fcls.n = 0;
251 fcls.flags[0] |= GNUNET_PSYCSTORE_MESSAGE_STATE_APPLIED; 262 fcls.flags[0] |= GNUNET_PSYCSTORE_MESSAGE_STATE_APPLIED;
252 263
253 GNUNET_assert (GNUNET_OK == db->fragment_get (db->cls, &channel_pub_key, 264 GNUNET_assert (
254 GNUNET_ntohll (msg->fragment_id), 265 GNUNET_OK == db->fragment_get (db->cls, &channel_pub_key,
255 fragment_cb, &fcls)); 266 fragment_id, fragment_id,
267 &ret_frags, fragment_cb, &fcls));
256 GNUNET_assert (fcls.n == 1); 268 GNUNET_assert (fcls.n == 1);
257 269
258 struct GNUNET_MULTICAST_MessageHeader *msg1 270 struct GNUNET_MULTICAST_MessageHeader *msg1
@@ -270,15 +282,17 @@ run (void *cls, char *const *args, const char *cfgfile,
270 GNUNET_assert (GNUNET_OK == db->fragment_store (db->cls, &channel_pub_key, msg1, 282 GNUNET_assert (GNUNET_OK == db->fragment_store (db->cls, &channel_pub_key, msg1,
271 fcls.flags[1])); 283 fcls.flags[1]));
272 284
273 uint64_t retfrags = 0; 285 GNUNET_assert (
274 GNUNET_assert (GNUNET_OK == db->message_get (db->cls, &channel_pub_key, 286 GNUNET_OK == db->message_get (db->cls, &channel_pub_key,
275 GNUNET_ntohll (msg->message_id), 287 message_id, message_id,
276 &retfrags, fragment_cb, &fcls)); 288 &ret_frags, fragment_cb, &fcls));
277 GNUNET_assert (fcls.n == 2 && retfrags == 2); 289 GNUNET_assert (fcls.n == 2 && ret_frags == 2);
278 290
279 /* Message counters */ 291 /* Message counters */
280 292
281 uint64_t fragment_id = 0, message_id = 0, group_generation = 0; 293 fragment_id = 0;
294 message_id = 0;
295 group_generation = 0;
282 GNUNET_assert ( 296 GNUNET_assert (
283 GNUNET_OK == db->counters_message_get (db->cls, &channel_pub_key, 297 GNUNET_OK == db->counters_message_get (db->cls, &channel_pub_key,
284 &fragment_id, &message_id, 298 &fragment_id, &message_id,