diff options
author | Gabor X Toth <*@tg-x.net> | 2013-09-25 17:46:06 +0000 |
---|---|---|
committer | Gabor X Toth <*@tg-x.net> | 2013-09-25 17:46:06 +0000 |
commit | 7bec38c1bf3572bd01ddd064f69d1b744f7725a8 (patch) | |
tree | e875e7dd3920d201e1e16fc046e8070fed7bd875 /src/psyc/test_psyc.c | |
parent | 303d6a97bc552a337c992944c3151ea53c1f74dc (diff) | |
download | gnunet-7bec38c1bf3572bd01ddd064f69d1b744f7725a8.tar.gz gnunet-7bec38c1bf3572bd01ddd064f69d1b744f7725a8.zip |
psyc service: start/stop, join/part, message transmission: lib -> psyc -> mcast; psyc API: stop/resume transmission
Diffstat (limited to 'src/psyc/test_psyc.c')
-rw-r--r-- | src/psyc/test_psyc.c | 74 |
1 files changed, 70 insertions, 4 deletions
diff --git a/src/psyc/test_psyc.c b/src/psyc/test_psyc.c index b37b3ceb1..84c9840f5 100644 --- a/src/psyc/test_psyc.c +++ b/src/psyc/test_psyc.c | |||
@@ -28,12 +28,12 @@ | |||
28 | #include "platform.h" | 28 | #include "platform.h" |
29 | #include "gnunet_common.h" | 29 | #include "gnunet_common.h" |
30 | #include "gnunet_util_lib.h" | 30 | #include "gnunet_util_lib.h" |
31 | #include "gnunet_psycstore_service.h" | ||
32 | #include "gnunet_testing_lib.h" | 31 | #include "gnunet_testing_lib.h" |
32 | #include "gnunet_psyc_service.h" | ||
33 | 33 | ||
34 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) | 34 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) |
35 | 35 | ||
36 | #define DEBUG_SERVICE 0 | 36 | #define DEBUG_SERVICE 1 |
37 | 37 | ||
38 | 38 | ||
39 | /** | 39 | /** |
@@ -41,11 +41,22 @@ | |||
41 | */ | 41 | */ |
42 | static int res; | 42 | static int res; |
43 | 43 | ||
44 | static const struct GNUNET_CONFIGURATION_Handle *cfg; | ||
45 | |||
44 | /** | 46 | /** |
45 | * Handle for task for timeout termination. | 47 | * Handle for task for timeout termination. |
46 | */ | 48 | */ |
47 | static GNUNET_SCHEDULER_TaskIdentifier end_badly_task; | 49 | static GNUNET_SCHEDULER_TaskIdentifier end_badly_task; |
48 | 50 | ||
51 | static struct GNUNET_PSYC_Master *mst; | ||
52 | static struct GNUNET_PSYC_Slave *slv; | ||
53 | static struct GNUNET_PSYC_Channel *ch; | ||
54 | |||
55 | static struct GNUNET_CRYPTO_EccPrivateKey *channel_key; | ||
56 | static struct GNUNET_CRYPTO_EccPrivateKey *slave_key; | ||
57 | |||
58 | static struct GNUNET_CRYPTO_EccPublicSignKey channel_pub_key; | ||
59 | static struct GNUNET_CRYPTO_EccPublicSignKey slave_pub_key; | ||
49 | 60 | ||
50 | /** | 61 | /** |
51 | * Clean up all resources used. | 62 | * Clean up all resources used. |
@@ -53,6 +64,11 @@ static GNUNET_SCHEDULER_TaskIdentifier end_badly_task; | |||
53 | static void | 64 | static void |
54 | cleanup () | 65 | cleanup () |
55 | { | 66 | { |
67 | if (master != NULL) | ||
68 | { | ||
69 | GNUNET_PSYC_master_stop (master); | ||
70 | master = NULL; | ||
71 | } | ||
56 | GNUNET_SCHEDULER_shutdown (); | 72 | GNUNET_SCHEDULER_shutdown (); |
57 | } | 73 | } |
58 | 74 | ||
@@ -100,6 +116,42 @@ end () | |||
100 | &end_normally, NULL); | 116 | &end_normally, NULL); |
101 | } | 117 | } |
102 | 118 | ||
119 | |||
120 | static int | ||
121 | method (void *cls, const struct GNUNET_CRYPTO_EccPublicSignKey *slave_key, | ||
122 | uint64_t message_id, const char *method_name, | ||
123 | size_t modifier_count, const struct GNUNET_ENV_Modifier *modifiers, | ||
124 | uint64_t data_offset, const void *data, size_t data_size, | ||
125 | enum GNUNET_PSYC_MessageFlags flags) | ||
126 | { | ||
127 | return GNUNET_OK; | ||
128 | } | ||
129 | |||
130 | |||
131 | static int | ||
132 | join (void *cls, const struct GNUNET_CRYPTO_EccPublicSignKey *slave_key, | ||
133 | const char *method_name, | ||
134 | size_t variable_count, const struct GNUNET_ENV_Modifier *variables, | ||
135 | const void *data, size_t data_size, struct GNUNET_PSYC_JoinHandle *jh) | ||
136 | { | ||
137 | return GNUNET_OK; | ||
138 | } | ||
139 | |||
140 | |||
141 | void | ||
142 | master_started (void *cls, uint64_t max_message_id) | ||
143 | { | ||
144 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Master started: %lu\n", max_message_id); | ||
145 | } | ||
146 | |||
147 | |||
148 | void | ||
149 | slave_joined (void *cls, uint64_t max_message_id) | ||
150 | { | ||
151 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Slave joined: %lu\n", max_message_id); | ||
152 | } | ||
153 | |||
154 | |||
103 | /** | 155 | /** |
104 | * Main function of the test, run from scheduler. | 156 | * Main function of the test, run from scheduler. |
105 | * | 157 | * |
@@ -110,14 +162,28 @@ end () | |||
110 | static void | 162 | static void |
111 | #if DEBUG_SERVICE | 163 | #if DEBUG_SERVICE |
112 | run (void *cls, char *const *args, const char *cfgfile, | 164 | run (void *cls, char *const *args, const char *cfgfile, |
113 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 165 | const struct GNUNET_CONFIGURATION_Handle *c) |
114 | #else | 166 | #else |
115 | run (void *cls, | 167 | run (void *cls, |
116 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 168 | const struct GNUNET_CONFIGURATION_Handle *c, |
117 | struct GNUNET_TESTING_Peer *peer) | 169 | struct GNUNET_TESTING_Peer *peer) |
118 | #endif | 170 | #endif |
119 | { | 171 | { |
172 | cfg = c; | ||
120 | end_badly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); | 173 | end_badly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); |
174 | |||
175 | channel_key = GNUNET_CRYPTO_ecc_key_create (); | ||
176 | slave_key = GNUNET_CRYPTO_ecc_key_create (); | ||
177 | |||
178 | GNUNET_CRYPTO_ecc_key_get_public_for_signature (channel_key, &channel_pub_key); | ||
179 | GNUNET_CRYPTO_ecc_key_get_public_for_signature (slave_key, &slave_pub_key); | ||
180 | |||
181 | mst = GNUNET_PSYC_master_start (cfg, channel_key, | ||
182 | GNUNET_PSYC_CHANNEL_PRIVATE, | ||
183 | &method, &join, &master_started, NULL); | ||
184 | |||
185 | slv = GNUNET_PSYC_slave_join (cfg, &channel_pub_key, slave_key, | ||
186 | &method, &join, &slave_joined, NULL); | ||
121 | } | 187 | } |
122 | 188 | ||
123 | 189 | ||