2 This file is part of GNUnet.
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
21 * @file peerstore/test_peerstore_api_iterate.c
22 * @brief testcase for peerstore iteration operation
25 #include "gnunet_util_lib.h"
26 #include "gnunet_testing_lib.h"
27 #include "gnunet_peerstore_service.h"
31 static struct GNUNET_PEERSTORE_Handle *h;
33 static char *ss = "test_peerstore_api_iterate";
34 static struct GNUNET_PeerIdentity p1;
35 static struct GNUNET_PeerIdentity p2;
36 static char *k1 = "test_peerstore_api_iterate_key1";
37 static char *k2 = "test_peerstore_api_iterate_key2";
38 static char *k3 = "test_peerstore_api_iterate_key3";
39 static char *val = "test_peerstore_api_iterate_val";
44 struct GNUNET_PEERSTORE_Record *record,
54 GNUNET_assert(count == 3);
56 GNUNET_PEERSTORE_disconnect(h, GNUNET_NO);
57 GNUNET_SCHEDULER_shutdown();
63 struct GNUNET_PEERSTORE_Record *record,
73 GNUNET_assert(count == 2);
75 GNUNET_PEERSTORE_iterate(h,
79 GNUNET_TIME_UNIT_FOREVER_REL,
87 struct GNUNET_PEERSTORE_Record *record,
97 GNUNET_assert(count == 1);
99 GNUNET_PEERSTORE_iterate(h,
103 GNUNET_TIME_UNIT_FOREVER_REL,
111 const struct GNUNET_CONFIGURATION_Handle *cfg,
112 struct GNUNET_TESTING_Peer *peer)
114 h = GNUNET_PEERSTORE_connect(cfg);
115 GNUNET_assert(NULL != h);
116 memset (&p1, 1, sizeof (p1));
117 memset (&p2, 2, sizeof (p2));
118 GNUNET_PEERSTORE_store(h,
124 GNUNET_TIME_UNIT_FOREVER_ABS,
125 GNUNET_PEERSTORE_STOREOPTION_REPLACE,
128 GNUNET_PEERSTORE_store(h,
134 GNUNET_TIME_UNIT_FOREVER_ABS,
135 GNUNET_PEERSTORE_STOREOPTION_REPLACE,
138 GNUNET_PEERSTORE_store(h,
144 GNUNET_TIME_UNIT_FOREVER_ABS,
145 GNUNET_PEERSTORE_STOREOPTION_REPLACE,
148 GNUNET_PEERSTORE_iterate(h,
152 GNUNET_TIME_UNIT_FOREVER_REL,
158 main (int argc, char *argv[])
160 if (0 != GNUNET_TESTING_service_run ("test-gnunet-peerstore",
162 "test_peerstore_api_data.conf",
168 /* end of test_peerstore_api_iterate.c */