diff options
Diffstat (limited to 'src/transport/transport_api_cmd_connecting_peers.c')
-rw-r--r-- | src/transport/transport_api_cmd_connecting_peers.c | 55 |
1 files changed, 37 insertions, 18 deletions
diff --git a/src/transport/transport_api_cmd_connecting_peers.c b/src/transport/transport_api_cmd_connecting_peers.c index 3fef7d687..33faee296 100644 --- a/src/transport/transport_api_cmd_connecting_peers.c +++ b/src/transport/transport_api_cmd_connecting_peers.c | |||
@@ -91,17 +91,20 @@ connect_peers_run (void *cls, | |||
91 | { | 91 | { |
92 | addr = GNUNET_TESTING_get_address (pos_connection, | 92 | addr = GNUNET_TESTING_get_address (pos_connection, |
93 | pos_prefix->address_prefix); | 93 | pos_prefix->address_prefix); |
94 | peer = GNUNET_TESTING_get_pub_key (num, tl_system); | 94 | if (NULL != addr) |
95 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 95 | { |
96 | "validating peer number %u with identity %s\n", | 96 | peer = GNUNET_TESTING_get_pub_key (num, tl_system); |
97 | num, | 97 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
98 | GNUNET_i2s (peer)); | 98 | "validating peer number %u with identity %s\n", |
99 | GNUNET_TRANSPORT_application_validate (ah, | 99 | num, |
100 | peer, | 100 | GNUNET_i2s (peer)); |
101 | nt, | 101 | GNUNET_TRANSPORT_application_validate (ah, |
102 | addr); | 102 | peer, |
103 | GNUNET_free (peer); | 103 | nt, |
104 | GNUNET_free (addr); | 104 | addr); |
105 | GNUNET_free (peer); | ||
106 | GNUNET_free (addr); | ||
107 | } | ||
105 | } | 108 | } |
106 | } | 109 | } |
107 | cps->con_num = con_num; | 110 | cps->con_num = con_num; |
@@ -119,14 +122,15 @@ notify_connect (struct GNUNET_TESTING_Interpreter *is, | |||
119 | const struct GNUNET_TESTING_Command *cmd; | 122 | const struct GNUNET_TESTING_Command *cmd; |
120 | struct ConnectPeersState *cps; | 123 | struct ConnectPeersState *cps; |
121 | struct GNUNET_PeerIdentity *peer_connection; | 124 | struct GNUNET_PeerIdentity *peer_connection; |
122 | unsigned int con_num = 0; | ||
123 | struct GNUNET_TESTING_NodeConnection *pos_connection; | 125 | struct GNUNET_TESTING_NodeConnection *pos_connection; |
124 | unsigned int num; | 126 | unsigned int num; |
127 | unsigned int con_num; | ||
125 | void *ret = NULL; | 128 | void *ret = NULL; |
126 | 129 | ||
127 | cmd = GNUNET_TESTING_interpreter_lookup_command (is, | 130 | cmd = GNUNET_TESTING_interpreter_lookup_command_all (is, |
128 | "connect-peers"); | 131 | "connect-peers"); |
129 | cps = cmd->cls; | 132 | cps = cmd->cls; |
133 | con_num = cps->con_num; | ||
130 | for (pos_connection = cps->node_connections_head; NULL != pos_connection; | 134 | for (pos_connection = cps->node_connections_head; NULL != pos_connection; |
131 | pos_connection = pos_connection->next) | 135 | pos_connection = pos_connection->next) |
132 | { | 136 | { |
@@ -134,12 +138,14 @@ notify_connect (struct GNUNET_TESTING_Interpreter *is, | |||
134 | peer_connection = GNUNET_TESTING_get_pub_key (num, cps->tl_system); | 138 | peer_connection = GNUNET_TESTING_get_pub_key (num, cps->tl_system); |
135 | if (0 == GNUNET_memcmp (peer, | 139 | if (0 == GNUNET_memcmp (peer, |
136 | peer_connection)) | 140 | peer_connection)) |
137 | con_num++; | 141 | cps->con_num_notified++; |
138 | GNUNET_free (peer_connection); | 142 | GNUNET_free (peer_connection); |
139 | } | 143 | } |
140 | |||
141 | |||
142 | if (cps->con_num == con_num) | 144 | if (cps->con_num == con_num) |
145 | cps->additional_connects_notified++; | ||
146 | |||
147 | if (cps->con_num + cps->additional_connects == cps->con_num_notified | ||
148 | + cps->additional_connects_notified) | ||
143 | { | 149 | { |
144 | GNUNET_TESTING_async_finish (&cps->ac); | 150 | GNUNET_TESTING_async_finish (&cps->ac); |
145 | } | 151 | } |
@@ -205,13 +211,25 @@ GNUNET_TRANSPORT_get_trait_connect_peer_state ( | |||
205 | } | 211 | } |
206 | 212 | ||
207 | 213 | ||
214 | /** | ||
215 | * Create command | ||
216 | * | ||
217 | * @param label name for command | ||
218 | * @param start_peer_label Label of the cmd to start a peer. | ||
219 | * @param create_peer_label Label of the cmd which started the test system. | ||
220 | * @param num Number globally identifying the node. | ||
221 | * @param The topology for the test setup. | ||
222 | * @param additional_connects Number of additional connects this cmd will wait for not triggered by this cmd. | ||
223 | * @return command. | ||
224 | */ | ||
208 | struct GNUNET_TESTING_Command | 225 | struct GNUNET_TESTING_Command |
209 | GNUNET_TRANSPORT_cmd_connect_peers (const char *label, | 226 | GNUNET_TRANSPORT_cmd_connect_peers (const char *label, |
210 | const char *start_peer_label, | 227 | const char *start_peer_label, |
211 | const char *create_label, | 228 | const char *create_label, |
212 | uint32_t num, | 229 | uint32_t num, |
213 | struct GNUNET_TESTING_NetjailTopology * | 230 | struct GNUNET_TESTING_NetjailTopology * |
214 | topology) | 231 | topology, |
232 | unsigned int additional_connects) | ||
215 | { | 233 | { |
216 | struct ConnectPeersState *cps; | 234 | struct ConnectPeersState *cps; |
217 | 235 | ||
@@ -221,6 +239,7 @@ GNUNET_TRANSPORT_cmd_connect_peers (const char *label, | |||
221 | cps->create_label = create_label; | 239 | cps->create_label = create_label; |
222 | cps->topology = topology; | 240 | cps->topology = topology; |
223 | cps->notify_connect = notify_connect; | 241 | cps->notify_connect = notify_connect; |
242 | cps->additional_connects = additional_connects; | ||
224 | 243 | ||
225 | { | 244 | { |
226 | struct GNUNET_TESTING_Command cmd = { | 245 | struct GNUNET_TESTING_Command cmd = { |