diff options
author | xrs <xrs@mail36.net> | 2018-01-21 13:04:55 +0100 |
---|---|---|
committer | xrs <xrs@mail36.net> | 2018-01-21 13:04:55 +0100 |
commit | 1273c7df7d544cad2ab5202393aaf3b8e26e3ab1 (patch) | |
tree | ea99c55e980db241e3d59a1700897342c3ad5906 | |
parent | 2f51bb5218ebcfdc4f3b63952445098bd7cd6b04 (diff) | |
download | gnunet-1273c7df7d544cad2ab5202393aaf3b8e26e3ab1.tar.gz gnunet-1273c7df7d544cad2ab5202393aaf3b8e26e3ab1.zip |
update test_psyc_api_join
-rw-r--r-- | src/psyc/test_psyc.conf | 30 | ||||
-rw-r--r-- | src/psyc/test_psyc_api_join.c | 85 |
2 files changed, 57 insertions, 58 deletions
diff --git a/src/psyc/test_psyc.conf b/src/psyc/test_psyc.conf index e00a614d2..836255163 100644 --- a/src/psyc/test_psyc.conf +++ b/src/psyc/test_psyc.conf | |||
@@ -1,16 +1,28 @@ | |||
1 | @INLINE@ ../../contrib/no_forcestart.conf | 1 | @INLINE@ ../../contrib/no_forcestart.conf |
2 | 2 | ||
3 | [PATHS] | 3 | [testbed] |
4 | GNUNET_TEST_HOME = /tmp/gnunet-test-psyc/ | 4 | HOSTNAME = localhost |
5 | OVERLAY_TOPOLOGY = STAR | ||
5 | 6 | ||
6 | [transport] | 7 | [peerinfo] |
7 | PLUGINS = tcp | 8 | # Option to disable all disk IO; only useful for testbed runs |
9 | # (large-scale experiments); disables persistence of HELLOs! | ||
10 | NO_IO = YES | ||
11 | |||
12 | [cadet] | ||
13 | ID_ANNOUNCE_TIME = 5 s | ||
8 | 14 | ||
9 | [nat] | 15 | [nat] |
10 | DISABLEV6 = YES | ||
11 | ENABLE_UPNP = NO | 16 | ENABLE_UPNP = NO |
12 | BEHIND_NAT = NO | ||
13 | ALLOW_NAT = NO | ||
14 | INTERNAL_ADDRESS = 127.0.0.1 | ||
15 | EXTERNAL_ADDRESS = 127.0.0.1 | ||
16 | 17 | ||
18 | [psyc] | ||
19 | FORCESTART = YES | ||
20 | AUTOSTART = YES | ||
21 | |||
22 | [multicast] | ||
23 | FORCESTART = YES | ||
24 | AUTOSTART = YES | ||
25 | |||
26 | [psycstore] | ||
27 | FORCESTART = YES | ||
28 | AUTOSTART = YES | ||
diff --git a/src/psyc/test_psyc_api_join.c b/src/psyc/test_psyc_api_join.c index 690c94aea..ae019d42e 100644 --- a/src/psyc/test_psyc_api_join.c +++ b/src/psyc/test_psyc_api_join.c | |||
@@ -24,6 +24,14 @@ | |||
24 | * @author xrs | 24 | * @author xrs |
25 | */ | 25 | */ |
26 | 26 | ||
27 | /** | ||
28 | * Lessons Learned: | ||
29 | * - define topology in config | ||
30 | * - psyc slave join needs part to end (same with master) | ||
31 | * - GNUNET_SCHEDULER_add_delayed return value will outdate at call time | ||
32 | * - main can not contain GNUNET_log() | ||
33 | */ | ||
34 | |||
27 | #include "platform.h" | 35 | #include "platform.h" |
28 | #include "gnunet_crypto_lib.h" | 36 | #include "gnunet_crypto_lib.h" |
29 | #include "gnunet_common.h" | 37 | #include "gnunet_common.h" |
@@ -37,17 +45,6 @@ static struct pctx PEERS[2]; | |||
37 | 45 | ||
38 | static int pids; | 46 | static int pids; |
39 | 47 | ||
40 | static void | ||
41 | mst_stop_cb () | ||
42 | { | ||
43 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "master stopped\n"); | ||
44 | } | ||
45 | |||
46 | static void | ||
47 | slv_part_cb () | ||
48 | { | ||
49 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "slave parted\n"); | ||
50 | } | ||
51 | 48 | ||
52 | static void | 49 | static void |
53 | shutdown_task (void *cls) | 50 | shutdown_task (void *cls) |
@@ -61,10 +58,12 @@ shutdown_task (void *cls) | |||
61 | GNUNET_free (PEERS[i].channel_pub_key); | 58 | GNUNET_free (PEERS[i].channel_pub_key); |
62 | 59 | ||
63 | if (NULL != PEERS[i].psyc) | 60 | if (NULL != PEERS[i].psyc) |
61 | { | ||
64 | if (0 == i) | 62 | if (0 == i) |
65 | GNUNET_PSYC_master_stop (PEERS[i].psyc, GNUNET_NO, mst_stop_cb, NULL); | 63 | GNUNET_PSYC_master_stop (PEERS[i].psyc, GNUNET_NO, NULL, NULL); |
66 | else | 64 | else |
67 | GNUNET_PSYC_slave_part (PEERS[i].psyc, GNUNET_NO, slv_part_cb, NULL); | 65 | GNUNET_PSYC_slave_part (PEERS[i].psyc, GNUNET_NO, NULL, NULL); |
66 | } | ||
68 | } | 67 | } |
69 | 68 | ||
70 | for (int i=0;i<MAX_TESTBED_OPS;i++) | 69 | for (int i=0;i<MAX_TESTBED_OPS;i++) |
@@ -86,45 +85,34 @@ timeout_task (void *cls) | |||
86 | } | 85 | } |
87 | 86 | ||
88 | static void | 87 | static void |
89 | mst_connect_cb () | ||
90 | { | ||
91 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "mst_connect_cb()\n"); | ||
92 | } | ||
93 | |||
94 | static void | ||
95 | slv_connect_cb (void *cls, int result, uint64_t max_message_id) | ||
96 | { | ||
97 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "slv_connect_cb()\n"); | ||
98 | } | ||
99 | |||
100 | static void | ||
101 | join_decision_cb (void *cls, | 88 | join_decision_cb (void *cls, |
102 | const struct GNUNET_PSYC_JoinDecisionMessage *dcsn, | 89 | const struct GNUNET_PSYC_JoinDecisionMessage *dcsn, |
103 | int is_admitted, | 90 | int is_admitted, |
104 | const struct GNUNET_PSYC_Message *join_msg) | 91 | const struct GNUNET_PSYC_Message *join_msg) |
105 | { | 92 | { |
106 | result = GNUNET_OK; | ||
107 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 93 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
108 | "Slave got join decision: %d\n", is_admitted); | 94 | "slave: got join decision: %s\n", |
95 | (GNUNET_YES == is_admitted) ? "admitted":"rejected"); | ||
96 | |||
97 | result = (GNUNET_YES == is_admitted) ? GNUNET_OK : GNUNET_SYSERR; | ||
98 | |||
109 | GNUNET_SCHEDULER_shutdown (); | 99 | GNUNET_SCHEDULER_shutdown (); |
110 | } | 100 | } |
111 | 101 | ||
112 | static void | 102 | static void |
113 | join_request_cb () | 103 | join_request_cb (void *cls, |
104 | const struct GNUNET_PSYC_JoinRequestMessage *req, | ||
105 | const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key, | ||
106 | const struct GNUNET_PSYC_Message *join_msg, | ||
107 | struct GNUNET_PSYC_JoinHandle *jh) | ||
114 | { | 108 | { |
115 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "join_request_cb()\n"); | 109 | struct GNUNET_HashCode slave_key_hash; |
116 | } | ||
117 | 110 | ||
118 | static void | 111 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "master: got join request.\n"); |
119 | message_cb () | ||
120 | { | ||
121 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "message_cb()\n"); | ||
122 | } | ||
123 | 112 | ||
124 | static void | 113 | GNUNET_CRYPTO_hash (slave_key, sizeof (*slave_key), &slave_key_hash); |
125 | message_part_cb () | 114 | |
126 | { | 115 | GNUNET_PSYC_join_decision (jh, GNUNET_YES, 0, NULL, NULL); |
127 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "message_part_cb()\n"); | ||
128 | } | 116 | } |
129 | 117 | ||
130 | static void | 118 | static void |
@@ -146,10 +134,10 @@ psyc_ca (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
146 | GNUNET_PSYC_master_start (cfg, | 134 | GNUNET_PSYC_master_start (cfg, |
147 | peer->channel_key, | 135 | peer->channel_key, |
148 | GNUNET_PSYC_CHANNEL_PRIVATE, | 136 | GNUNET_PSYC_CHANNEL_PRIVATE, |
149 | mst_connect_cb, | 137 | NULL, |
150 | join_request_cb, | 138 | join_request_cb, |
151 | message_cb, | 139 | NULL, |
152 | message_part_cb, | 140 | NULL, |
153 | cls); | 141 | cls); |
154 | return peer->psyc; | 142 | return peer->psyc; |
155 | } | 143 | } |
@@ -163,8 +151,6 @@ psyc_ca (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
163 | struct GNUNET_PSYC_Message * | 151 | struct GNUNET_PSYC_Message * |
164 | join_msg = GNUNET_PSYC_message_create ("_request_join", env, "some data", 40); | 152 | join_msg = GNUNET_PSYC_message_create ("_request_join", env, "some data", 40); |
165 | 153 | ||
166 | // THOUGHT: It's possible, that psyc slave is to fast and can not connect | ||
167 | // to master! ask tg and grothoff about message queueing | ||
168 | peer->psyc = (struct GNUNET_PSYC_Slave *) | 154 | peer->psyc = (struct GNUNET_PSYC_Slave *) |
169 | GNUNET_PSYC_slave_join (cfg, | 155 | GNUNET_PSYC_slave_join (cfg, |
170 | peer->channel_pub_key, | 156 | peer->channel_pub_key, |
@@ -173,9 +159,9 @@ psyc_ca (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
173 | peer->peer_id_master, | 159 | peer->peer_id_master, |
174 | 0, | 160 | 0, |
175 | NULL, | 161 | NULL, |
176 | message_cb, | 162 | NULL, |
177 | message_part_cb, | 163 | NULL, |
178 | slv_connect_cb, | 164 | NULL, |
179 | join_decision_cb, | 165 | join_decision_cb, |
180 | cls, | 166 | cls, |
181 | join_msg); | 167 | join_msg); |
@@ -245,10 +231,11 @@ testbed_master (void *cls, | |||
245 | // Set up shutdown logic | 231 | // Set up shutdown logic |
246 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); | 232 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); |
247 | timeout_task_id = | 233 | timeout_task_id = |
248 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10), | 234 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 15), |
249 | &timeout_task, NULL); | 235 | &timeout_task, NULL); |
250 | GNUNET_assert (NULL != timeout_task_id); | 236 | GNUNET_assert (NULL != timeout_task_id); |
251 | 237 | ||
238 | // Set up channel key | ||
252 | channel_key = GNUNET_CRYPTO_eddsa_key_create (); | 239 | channel_key = GNUNET_CRYPTO_eddsa_key_create (); |
253 | GNUNET_assert (NULL != channel_key); | 240 | GNUNET_assert (NULL != channel_key); |
254 | 241 | ||
@@ -282,7 +269,7 @@ main (int argc, char *argv[]) | |||
282 | { | 269 | { |
283 | int ret; | 270 | int ret; |
284 | 271 | ||
285 | ret = GNUNET_TESTBED_test_run ("test-psyc-api-join", "test_psyc.conf", | 272 | ret = GNUNET_TESTBED_test_run ("test_psyc_api_join", "test_psyc.conf", |
286 | 2, 0LL, NULL, NULL, | 273 | 2, 0LL, NULL, NULL, |
287 | &testbed_master, NULL); | 274 | &testbed_master, NULL); |
288 | 275 | ||