diff options
Diffstat (limited to 'src/transport/test_transport_testing.c')
-rw-r--r-- | src/transport/test_transport_testing.c | 68 |
1 files changed, 32 insertions, 36 deletions
diff --git a/src/transport/test_transport_testing.c b/src/transport/test_transport_testing.c index 266933580..996ea0543 100644 --- a/src/transport/test_transport_testing.c +++ b/src/transport/test_transport_testing.c | |||
@@ -55,7 +55,7 @@ static struct PeerContext *p2; | |||
55 | 55 | ||
56 | static GNUNET_TRANSPORT_TESTING_ConnectRequest cc; | 56 | static GNUNET_TRANSPORT_TESTING_ConnectRequest cc; |
57 | 57 | ||
58 | struct GNUNET_TRANSPORT_TESTING_handle * tth; | 58 | struct GNUNET_TRANSPORT_TESTING_handle *tth; |
59 | 59 | ||
60 | static int connected = GNUNET_NO; | 60 | static int connected = GNUNET_NO; |
61 | 61 | ||
@@ -94,9 +94,10 @@ end_badly () | |||
94 | static void | 94 | static void |
95 | testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) | 95 | testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) |
96 | { | 96 | { |
97 | char * ps = strdup (GNUNET_i2s(&p1->id)); | 97 | char *ps = strdup (GNUNET_i2s (&p1->id)); |
98 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%4s') connected to peer %u (`%s')!\n", | 98 | |
99 | p1->no, ps, | 99 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
100 | "Peer %u (`%4s') connected to peer %u (`%s')!\n", p1->no, ps, | ||
100 | p2->no, GNUNET_i2s (&p2->id)); | 101 | p2->no, GNUNET_i2s (&p2->id)); |
101 | GNUNET_free (ps); | 102 | GNUNET_free (ps); |
102 | GNUNET_SCHEDULER_add_now (&end, NULL); | 103 | GNUNET_SCHEDULER_add_now (&end, NULL); |
@@ -104,8 +105,7 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) | |||
104 | 105 | ||
105 | static void | 106 | static void |
106 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, | 107 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, |
107 | const struct GNUNET_ATS_Information *ats, | 108 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count) |
108 | uint32_t ats_count) | ||
109 | { | 109 | { |
110 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%s' connected \n", | 110 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%s' connected \n", |
111 | GNUNET_i2s (peer)); | 111 | GNUNET_i2s (peer)); |
@@ -122,29 +122,29 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
122 | static void | 122 | static void |
123 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | 123 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, |
124 | const struct GNUNET_MessageHeader *message, | 124 | const struct GNUNET_MessageHeader *message, |
125 | const struct GNUNET_ATS_Information *ats, | 125 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count) |
126 | uint32_t ats_count) | ||
127 | { | 126 | { |
128 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving\n"); | 127 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving\n"); |
129 | } | 128 | } |
130 | 129 | ||
131 | void start_cb (struct PeerContext * p, | 130 | void |
132 | void *cls) | 131 | start_cb (struct PeerContext *p, void *cls) |
133 | { | 132 | { |
134 | static int started; | 133 | static int started; |
134 | |||
135 | started++; | 135 | started++; |
136 | 136 | ||
137 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", | 137 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", p->no, |
138 | p->no, | 138 | GNUNET_i2s (&p->id)); |
139 | GNUNET_i2s (&p->id)); | ||
140 | 139 | ||
141 | if (started != 2) | 140 | if (started != 2) |
142 | return; | 141 | return; |
143 | 142 | ||
144 | char *sender_c = strdup (GNUNET_i2s (&p1->id)); | 143 | char *sender_c = strdup (GNUNET_i2s (&p1->id)); |
145 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test tries to connect peer %u (`%s') -> peer %u (`%s')\n", | 144 | |
146 | p1->no, sender_c, | 145 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
147 | p2->no, GNUNET_i2s (&p2->id)); | 146 | "Test tries to connect peer %u (`%s') -> peer %u (`%s')\n", |
147 | p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id)); | ||
148 | 148 | ||
149 | cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, | 149 | cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, |
150 | NULL); | 150 | NULL); |
@@ -161,34 +161,30 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
161 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, &end_badly, NULL); | 161 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, &end_badly, NULL); |
162 | 162 | ||
163 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting peer\n"); | 163 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting peer\n"); |
164 | p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, "test_transport_api_tcp_peer1.conf", | 164 | p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, |
165 | 1, | 165 | "test_transport_api_tcp_peer1.conf", |
166 | ¬ify_receive, ¬ify_connect, | 166 | 1, ¬ify_receive, ¬ify_connect, |
167 | ¬ify_disconnect, | 167 | ¬ify_disconnect, &start_cb, p1); |
168 | &start_cb, | 168 | p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, |
169 | p1); | 169 | "test_transport_api_tcp_peer2.conf", |
170 | p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, "test_transport_api_tcp_peer2.conf", | 170 | 2, ¬ify_receive, ¬ify_connect, |
171 | 2, | 171 | ¬ify_disconnect, &start_cb, p2); |
172 | ¬ify_receive, ¬ify_connect, | ||
173 | ¬ify_disconnect, | ||
174 | &start_cb, | ||
175 | p2); | ||
176 | 172 | ||
177 | if (p1 == NULL) | 173 | if (p1 == NULL) |
178 | { | 174 | { |
179 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer1 was not started successfully\n"); | 175 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
176 | "Peer1 was not started successfully\n"); | ||
180 | if (timeout_task != GNUNET_SCHEDULER_NO_TASK) | 177 | if (timeout_task != GNUNET_SCHEDULER_NO_TASK) |
181 | GNUNET_SCHEDULER_cancel(timeout_task); | 178 | GNUNET_SCHEDULER_cancel (timeout_task); |
182 | timeout_task = | 179 | timeout_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); |
183 | GNUNET_SCHEDULER_add_now (&end_badly, NULL); | ||
184 | } | 180 | } |
185 | if (p2 == NULL) | 181 | if (p2 == NULL) |
186 | { | 182 | { |
187 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer2 was not started successfully\n"); | 183 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
184 | "Peer2 was not started successfully\n"); | ||
188 | if (timeout_task != GNUNET_SCHEDULER_NO_TASK) | 185 | if (timeout_task != GNUNET_SCHEDULER_NO_TASK) |
189 | GNUNET_SCHEDULER_cancel(timeout_task); | 186 | GNUNET_SCHEDULER_cancel (timeout_task); |
190 | timeout_task = | 187 | timeout_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); |
191 | GNUNET_SCHEDULER_add_now (&end_badly, NULL); | ||
192 | } | 188 | } |
193 | } | 189 | } |
194 | 190 | ||