diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-09-24 11:58:31 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-09-24 11:58:31 +0000 |
commit | 3bca0a62abc14e5fe36e1c80ff487e0051dad562 (patch) | |
tree | 25a9dc36162d498910f6e41aa85a0d3863e0c1c0 /src/peerstore/test_peerstore_api_watch.c | |
parent | d02c15600b668a30e091d2c5c59d918bb1e4fee7 (diff) | |
download | gnunet-3bca0a62abc14e5fe36e1c80ff487e0051dad562.tar.gz gnunet-3bca0a62abc14e5fe36e1c80ff487e0051dad562.zip |
migrate peerstore to new service MQ API
Diffstat (limited to 'src/peerstore/test_peerstore_api_watch.c')
-rw-r--r-- | src/peerstore/test_peerstore_api_watch.c | 53 |
1 files changed, 40 insertions, 13 deletions
diff --git a/src/peerstore/test_peerstore_api_watch.c b/src/peerstore/test_peerstore_api_watch.c index 91902ba9e..1c9995c31 100644 --- a/src/peerstore/test_peerstore_api_watch.c +++ b/src/peerstore/test_peerstore_api_watch.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) | 3 | Copyright (C) 2013-2016 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 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 | 6 | it under the terms of the GNU General Public License as published |
@@ -26,47 +26,74 @@ | |||
26 | #include "gnunet_testing_lib.h" | 26 | #include "gnunet_testing_lib.h" |
27 | #include "gnunet_peerstore_service.h" | 27 | #include "gnunet_peerstore_service.h" |
28 | 28 | ||
29 | |||
29 | static int ok = 1; | 30 | static int ok = 1; |
30 | 31 | ||
31 | static struct GNUNET_PEERSTORE_Handle *h; | 32 | static struct GNUNET_PEERSTORE_Handle *h; |
32 | 33 | ||
33 | static char *ss = "test_peerstore_api_watch"; | 34 | static char *ss = "test_peerstore_api_watch"; |
34 | static struct GNUNET_PeerIdentity p; | 35 | |
35 | static char *k = "test_peerstore_api_watch_key"; | 36 | static char *k = "test_peerstore_api_watch_key"; |
37 | |||
36 | static char *val = "test_peerstore_api_watch_val"; | 38 | static char *val = "test_peerstore_api_watch_val"; |
37 | 39 | ||
40 | |||
38 | static void | 41 | static void |
39 | watch_cb (void *cls, const struct GNUNET_PEERSTORE_Record *record, | 42 | watch_cb (void *cls, |
43 | const struct GNUNET_PEERSTORE_Record *record, | ||
40 | const char *emsg) | 44 | const char *emsg) |
41 | { | 45 | { |
42 | GNUNET_assert (NULL == emsg); | 46 | GNUNET_assert (NULL == emsg); |
43 | GNUNET_assert (0 == strcmp (val, (char *) record->value)); | 47 | GNUNET_assert (0 == strcmp (val, |
48 | (char *) record->value)); | ||
44 | ok = 0; | 49 | ok = 0; |
45 | GNUNET_PEERSTORE_disconnect (h, GNUNET_NO); | 50 | GNUNET_PEERSTORE_disconnect (h, |
51 | GNUNET_NO); | ||
46 | GNUNET_SCHEDULER_shutdown (); | 52 | GNUNET_SCHEDULER_shutdown (); |
47 | } | 53 | } |
48 | 54 | ||
49 | 55 | ||
50 | static void | 56 | static void |
51 | run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, | 57 | run (void *cls, |
58 | const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
52 | struct GNUNET_TESTING_Peer *peer) | 59 | struct GNUNET_TESTING_Peer *peer) |
53 | { | 60 | { |
61 | struct GNUNET_PeerIdentity p; | ||
62 | |||
54 | h = GNUNET_PEERSTORE_connect (cfg); | 63 | h = GNUNET_PEERSTORE_connect (cfg); |
55 | GNUNET_assert (NULL != h); | 64 | GNUNET_assert (NULL != h); |
56 | memset (&p, 4, sizeof (p)); | 65 | memset (&p, |
57 | GNUNET_PEERSTORE_watch (h, ss, &p, k, &watch_cb, NULL); | 66 | 4, |
58 | GNUNET_PEERSTORE_store (h, ss, &p, k, val, strlen (val) + 1, | 67 | sizeof (p)); |
68 | GNUNET_PEERSTORE_watch (h, | ||
69 | ss, | ||
70 | &p, | ||
71 | k, | ||
72 | &watch_cb, | ||
73 | NULL); | ||
74 | GNUNET_PEERSTORE_store (h, | ||
75 | ss, | ||
76 | &p, | ||
77 | k, | ||
78 | val, | ||
79 | strlen (val) + 1, | ||
59 | GNUNET_TIME_UNIT_FOREVER_ABS, | 80 | GNUNET_TIME_UNIT_FOREVER_ABS, |
60 | GNUNET_PEERSTORE_STOREOPTION_REPLACE, NULL, NULL); | 81 | GNUNET_PEERSTORE_STOREOPTION_REPLACE, |
82 | NULL, | ||
83 | NULL); | ||
61 | } | 84 | } |
62 | 85 | ||
63 | 86 | ||
64 | int | 87 | int |
65 | main (int argc, char *argv[]) | 88 | main (int argc, |
89 | char *argv[]) | ||
66 | { | 90 | { |
67 | if (0 != | 91 | if (0 != |
68 | GNUNET_TESTING_service_run ("test-gnunet-peerstore", "peerstore", | 92 | GNUNET_TESTING_service_run ("test-gnunet-peerstore", |
69 | "test_peerstore_api_data.conf", &run, NULL)) | 93 | "peerstore", |
94 | "test_peerstore_api_data.conf", | ||
95 | &run, | ||
96 | NULL)) | ||
70 | return 1; | 97 | return 1; |
71 | return ok; | 98 | return ok; |
72 | } | 99 | } |