diff options
author | xrs <xrs@mail36.net> | 2020-02-29 18:39:43 +0100 |
---|---|---|
committer | xrs <xrs@mail36.net> | 2020-05-21 22:46:48 +0200 |
commit | 57fd0d7212f6dfc8ae5e158ba2b21253a2b88099 (patch) | |
tree | 06b46111237c19ff8f613cb181689e02b4abaa3c | |
parent | b74a439892768274c39349e4c6974074e7e1203a (diff) | |
download | gnunet-57fd0d7212f6dfc8ae5e158ba2b21253a2b88099.tar.gz gnunet-57fd0d7212f6dfc8ae5e158ba2b21253a2b88099.zip |
setup channel
-rw-r--r-- | src/cadet/test_cadeT.c | 53 |
1 files changed, 38 insertions, 15 deletions
diff --git a/src/cadet/test_cadeT.c b/src/cadet/test_cadeT.c index cf335a948..1c4a32791 100644 --- a/src/cadet/test_cadeT.c +++ b/src/cadet/test_cadeT.c | |||
@@ -56,6 +56,7 @@ | |||
56 | #define REQUESTED_PEERS 2 | 56 | #define REQUESTED_PEERS 2 |
57 | #define CONFIG "test_cadet.conf" | 57 | #define CONFIG "test_cadet.conf" |
58 | #define TESTPROGAM_NAME "test-cadet-channel-resumption" | 58 | #define TESTPROGAM_NAME "test-cadet-channel-resumption" |
59 | #define TIMEOUT_IN_SEC 5 | ||
59 | #define PORTNAME "cadet_port" | 60 | #define PORTNAME "cadet_port" |
60 | 61 | ||
61 | /** | 62 | /** |
@@ -78,9 +79,6 @@ static struct GNUNET_HashCode hashed_portname; | |||
78 | */ | 79 | */ |
79 | static int test_result = 0; | 80 | static int test_result = 0; |
80 | 81 | ||
81 | // FIXME: temp cnt | ||
82 | static int cnt = 0; | ||
83 | |||
84 | /** | 82 | /** |
85 | * Counter for gathering peerinformation. | 83 | * Counter for gathering peerinformation. |
86 | */ | 84 | */ |
@@ -101,10 +99,26 @@ struct TEST_PEERS | |||
101 | */ | 99 | */ |
102 | struct GNUNET_PeerIdentity id; | 100 | struct GNUNET_PeerIdentity id; |
103 | 101 | ||
102 | /** | ||
103 | * Handle of TESTBED peer. | ||
104 | */ | ||
104 | struct GNUNET_TESTBED_Peer *testbed_peer; | 105 | struct GNUNET_TESTBED_Peer *testbed_peer; |
105 | 106 | ||
107 | /** | ||
108 | * Testbed management is finished and test peer is ready for test logic. | ||
109 | */ | ||
106 | int ready; | 110 | int ready; |
107 | 111 | ||
112 | /** | ||
113 | * Channel of initiating peer. | ||
114 | */ | ||
115 | struct GNUNET_CADET_Channel *channel; | ||
116 | |||
117 | /** | ||
118 | * CADET handle. | ||
119 | */ | ||
120 | struct GNUNET_CADET_Handle *cadet; | ||
121 | |||
108 | } test_peers[2]; | 122 | } test_peers[2]; |
109 | 123 | ||
110 | 124 | ||
@@ -117,11 +131,19 @@ struct TEST_PEERS | |||
117 | static void | 131 | static void |
118 | shutdown_task (void *cls) | 132 | shutdown_task (void *cls) |
119 | { | 133 | { |
134 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__); | ||
135 | |||
120 | for (int i=0; i<REQUESTED_PEERS; i++) | 136 | for (int i=0; i<REQUESTED_PEERS; i++) |
121 | GNUNET_TESTBED_operation_done (testbed_to_svc[i]); | 137 | GNUNET_TESTBED_operation_done (testbed_to_svc[i]); |
122 | } | 138 | } |
123 | 139 | ||
124 | static void | 140 | static void |
141 | timeout () | ||
142 | { | ||
143 | GNUNET_SCHEDULER_shutdown (); | ||
144 | } | ||
145 | |||
146 | static void | ||
125 | disconnect_from_peer (void *cls, | 147 | disconnect_from_peer (void *cls, |
126 | void *op_result) | 148 | void *op_result) |
127 | { | 149 | { |
@@ -133,34 +155,35 @@ disconnect_from_peer (void *cls, | |||
133 | } | 155 | } |
134 | 156 | ||
135 | static void | 157 | static void |
136 | handle_channel_destroy (void *cls, | 158 | disconnect_channel (void *cls, |
137 | const struct GNUNET_CADET_Channel *channel) | 159 | const struct GNUNET_CADET_Channel *channel) |
138 | { | 160 | { |
161 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__); | ||
139 | } | 162 | } |
140 | 163 | ||
141 | static void * | 164 | static void * |
142 | setup_initiating_peer (void *cls, | 165 | setup_initiating_peer (void *cls, |
143 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 166 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
144 | { | 167 | { |
145 | |||
146 | struct GNUNET_CADET_Handle *cadet; | 168 | struct GNUNET_CADET_Handle *cadet; |
147 | struct GNUNET_PeerIdentity *destination; | ||
148 | struct GNUNET_CADET_Channel *channel; | 169 | struct GNUNET_CADET_Channel *channel; |
149 | 170 | ||
150 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__); | 171 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__); |
151 | 172 | ||
152 | cadet = GNUNET_CADET_connect (cfg); | 173 | cadet = GNUNET_CADET_connect (cfg); |
174 | test_peers[0].cadet = cadet; | ||
175 | |||
176 | if (NULL == cadet) | ||
177 | GNUNET_SCHEDULER_shutdown (); | ||
153 | 178 | ||
154 | channel = GNUNET_CADET_channel_create (cadet, | 179 | channel = GNUNET_CADET_channel_create (cadet, |
155 | NULL, | 180 | NULL, |
156 | destination, | 181 | &test_peers[1].id, |
157 | &hashed_portname, | 182 | &hashed_portname, |
158 | NULL, | 183 | NULL, |
159 | &handle_channel_destroy, | 184 | &disconnect_channel, |
160 | NULL); | 185 | NULL); |
161 | 186 | test_peers[0].channel = channel; | |
162 | if (NULL == cadet) | ||
163 | GNUNET_SCHEDULER_shutdown (); | ||
164 | 187 | ||
165 | return cadet; | 188 | return cadet; |
166 | } | 189 | } |
@@ -189,6 +212,7 @@ setup_listening_peer (void *cls, | |||
189 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__); | 212 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__); |
190 | 213 | ||
191 | cadet = GNUNET_CADET_connect (cfg); | 214 | cadet = GNUNET_CADET_connect (cfg); |
215 | test_peers[1].cadet = cadet; | ||
192 | 216 | ||
193 | if (NULL == cadet) | 217 | if (NULL == cadet) |
194 | GNUNET_SCHEDULER_shutdown (); | 218 | GNUNET_SCHEDULER_shutdown (); |
@@ -211,9 +235,6 @@ check_test_readyness (void *cls, | |||
211 | const char *emsg) | 235 | const char *emsg) |
212 | { | 236 | { |
213 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__); | 237 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__); |
214 | |||
215 | if (2 == ++cnt) | ||
216 | GNUNET_SCHEDULER_shutdown (); | ||
217 | } | 238 | } |
218 | 239 | ||
219 | 240 | ||
@@ -280,6 +301,8 @@ connect_to_peers (void *cls, | |||
280 | &test_peers[1]); | 301 | &test_peers[1]); |
281 | 302 | ||
282 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); | 303 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); |
304 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, TIMEOUT_IN_SEC), | ||
305 | &timeout, NULL); | ||
283 | } | 306 | } |
284 | 307 | ||
285 | int | 308 | int |