warning fix
[oweals/gnunet.git] / src / peerstore / test_peerstore_api.c
1 /*
2      This file is part of GNUnet.
3      (C)
4
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.
9
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.
14
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.
19 */
20 /**
21  * @file peerstore/test_peerstore_api.c
22  * @brief testcase for peerstore_api.c
23  */
24 #include "platform.h"
25 #include "gnunet_util_lib.h"
26 #include "gnunet_testing_lib.h"
27 #include "gnunet_peerstore_service.h"
28
29 static int ok = 1;
30
31 struct GNUNET_PEERSTORE_Handle *h;
32
33 void store_cont(void *cls, const char *emsg)
34 {
35   GNUNET_PEERSTORE_disconnect(h);
36 }
37
38 static void
39 run (void *cls,
40     const struct GNUNET_CONFIGURATION_Handle *cfg,
41     struct GNUNET_TESTING_Peer *peer)
42 {
43   struct GNUNET_PeerIdentity pid;
44   char *val = "peerstore-test-value";
45   size_t val_size = strlen(val);
46
47   ok = 0;
48   memset (&pid, 32, sizeof (pid));
49   h = GNUNET_PEERSTORE_connect(cfg);
50   GNUNET_assert(NULL != h);
51   GNUNET_PEERSTORE_store(h,
52       &pid,
53       "peerstore-test",
54       val,
55       val_size,
56       GNUNET_TIME_UNIT_FOREVER_REL,
57       &store_cont,
58       NULL);
59
60 }
61
62 int
63 main (int argc, char *argv[])
64 {
65   if (0 != GNUNET_TESTING_service_run ("test-gnunet-peerstore",
66                  "peerstore",
67                  "test_peerstore_api_data.conf",
68                  &run, NULL))
69     return 1;
70   return ok;
71 }
72
73 /* end of test_peerstore_api.c */