aboutsummaryrefslogtreecommitdiff
path: root/src/transport/test_transport_testing.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/test_transport_testing.c')
-rw-r--r--src/transport/test_transport_testing.c45
1 files changed, 22 insertions, 23 deletions
diff --git a/src/transport/test_transport_testing.c b/src/transport/test_transport_testing.c
index e8d829d37..2f11b5a1a 100644
--- a/src/transport/test_transport_testing.c
+++ b/src/transport/test_transport_testing.c
@@ -36,13 +36,13 @@
36 36
37static struct GNUNET_SCHEDULER_Task * timeout_task; 37static struct GNUNET_SCHEDULER_Task * timeout_task;
38 38
39static struct PeerContext *p1; 39static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
40 40
41static struct PeerContext *p2; 41static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
42 42
43static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc; 43static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
44 44
45struct GNUNET_TRANSPORT_TESTING_handle *tth; 45struct GNUNET_TRANSPORT_TESTING_Handle *tth;
46 46
47static int connected = GNUNET_NO; 47static int connected = GNUNET_NO;
48 48
@@ -52,14 +52,14 @@ static int ret = 0;
52static void 52static void
53end () 53end ()
54{ 54{
55 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 55 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
56 "Stopping peers\n"); 56 "Stopping peers\n");
57 57
58 if (timeout_task != NULL) 58 if (timeout_task != NULL)
59 GNUNET_SCHEDULER_cancel (timeout_task); 59 GNUNET_SCHEDULER_cancel (timeout_task);
60 60
61 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); 61 GNUNET_TRANSPORT_TESTING_stop_peer (p1);
62 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); 62 GNUNET_TRANSPORT_TESTING_stop_peer (p2);
63 63
64 GNUNET_TRANSPORT_TESTING_done (tth); 64 GNUNET_TRANSPORT_TESTING_done (tth);
65} 65}
@@ -69,19 +69,19 @@ static void
69end_badly () 69end_badly ()
70{ 70{
71 timeout_task = NULL; 71 timeout_task = NULL;
72 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 72 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
73 "Timeout! Stopping peers\n"); 73 "Timeout! Stopping peers\n");
74 74
75 if (NULL != cc) 75 if (NULL != cc)
76 { 76 {
77 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc); 77 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
78 cc = NULL; 78 cc = NULL;
79 } 79 }
80 80
81 if (p1 != NULL) 81 if (p1 != NULL)
82 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); 82 GNUNET_TRANSPORT_TESTING_stop_peer (p1);
83 if (p2 != NULL) 83 if (p2 != NULL)
84 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); 84 GNUNET_TRANSPORT_TESTING_stop_peer (p2);
85 85
86 if (NULL != tth) 86 if (NULL != tth)
87 GNUNET_TRANSPORT_TESTING_done (tth); 87 GNUNET_TRANSPORT_TESTING_done (tth);
@@ -91,9 +91,7 @@ end_badly ()
91 91
92 92
93static void 93static void
94testing_connect_cb (struct PeerContext *p1, 94testing_connect_cb (void *cls)
95 struct PeerContext *p2,
96 void *cls)
97{ 95{
98 char *ps = GNUNET_strdup (GNUNET_i2s (&p1->id)); 96 char *ps = GNUNET_strdup (GNUNET_i2s (&p1->id));
99 97
@@ -109,7 +107,7 @@ static void
109notify_connect (void *cls, 107notify_connect (void *cls,
110 const struct GNUNET_PeerIdentity *peer) 108 const struct GNUNET_PeerIdentity *peer)
111{ 109{
112 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 110 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
113 "Peer `%s' connected \n", 111 "Peer `%s' connected \n",
114 GNUNET_i2s (peer)); 112 GNUNET_i2s (peer));
115 connected++; 113 connected++;
@@ -117,33 +115,33 @@ notify_connect (void *cls,
117 115
118 116
119static void 117static void
120notify_disconnect (void *cls, 118notify_disconnect (void *cls,
121 const struct GNUNET_PeerIdentity *peer) 119 const struct GNUNET_PeerIdentity *peer)
122{ 120{
123 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 121 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
124 "Peer `%s' disconnected \n", 122 "Peer `%s' disconnected \n",
125 GNUNET_i2s (peer)); 123 GNUNET_i2s (peer));
126} 124}
127 125
128 126
129static void 127static void
130notify_receive (void *cls, 128notify_receive (void *cls,
131 const struct GNUNET_PeerIdentity *peer, 129 const struct GNUNET_PeerIdentity *peer,
132 const struct GNUNET_MessageHeader *message) 130 const struct GNUNET_MessageHeader *message)
133{ 131{
134 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 132 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
135 "Receiving\n"); 133 "Receiving\n");
136} 134}
137 135
138 136
139static void 137static void
140start_cb (struct PeerContext *p, void *cls) 138start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
141{ 139{
142 static int started; 140 static int started;
143 141
144 started++; 142 started++;
145 143
146 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 144 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
147 "Peer %u (`%s') started\n", p->no, 145 "Peer %u (`%s') started\n", p->no,
148 GNUNET_i2s (&p->id)); 146 GNUNET_i2s (&p->id));
149 147
@@ -157,7 +155,8 @@ start_cb (struct PeerContext *p, void *cls)
157 p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id)); 155 p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id));
158 GNUNET_free (sender_c); 156 GNUNET_free (sender_c);
159 157
160 cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, 158 cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1,
159 p2,
161 &testing_connect_cb, 160 &testing_connect_cb,
162 NULL); 161 NULL);
163} 162}
@@ -201,7 +200,7 @@ run (void *cls, char *const *args, const char *cfgfile,
201int 200int
202main (int argc, char *argv[]) 201main (int argc, char *argv[])
203{ 202{
204 char *const argv_1[] = { 203 char *const argv_1[] = {
205 "test_transport_testing", 204 "test_transport_testing",
206 "-c", 205 "-c",
207 "test_transport_api_data.conf", 206 "test_transport_api_data.conf",
@@ -215,7 +214,7 @@ main (int argc, char *argv[])
215 "WARNING", 214 "WARNING",
216 NULL); 215 NULL);
217 GNUNET_PROGRAM_run ((sizeof (argv_1) / sizeof (char *)) - 1, argv_1, 216 GNUNET_PROGRAM_run ((sizeof (argv_1) / sizeof (char *)) - 1, argv_1,
218 "test_transport_testing", "nohelp", options, 217 "test_transport_testing", "nohelp", options,
219 &run, &ret); 218 &run, &ret);
220 219
221 return ret; 220 return ret;