summaryrefslogtreecommitdiff
path: root/src/transport/test_transport_api.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-07-09 22:34:49 +0000
committerChristian Grothoff <christian@grothoff.org>2016-07-09 22:34:49 +0000
commitc0b81510ffe194dc662c3a6267d5e66a69873c4b (patch)
tree5ad5cc473d6993523be80bcf1430230e224d9216 /src/transport/test_transport_api.c
parenta7345f7436c421fd15e18e87ec399ea93b6dde03 (diff)
-start to refactor testcases for sanity
Diffstat (limited to 'src/transport/test_transport_api.c')
-rw-r--r--src/transport/test_transport_api.c58
1 files changed, 25 insertions, 33 deletions
diff --git a/src/transport/test_transport_api.c b/src/transport/test_transport_api.c
index 91d129e24..9983356de 100644
--- a/src/transport/test_transport_api.c
+++ b/src/transport/test_transport_api.c
@@ -62,15 +62,15 @@ static struct GNUNET_SCHEDULER_Task * die_task;
static struct GNUNET_SCHEDULER_Task * send_task;
-static struct PeerContext *p1;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
-static struct PeerContext *p2;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
static struct GNUNET_TRANSPORT_TransmitHandle *th;
-static struct GNUNET_TRANSPORT_TESTING_handle *tth;
+static struct GNUNET_TRANSPORT_TESTING_Handle *tth;
static char *cfg_file_p1;
@@ -92,8 +92,8 @@ end ()
GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
th = NULL;
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
}
@@ -111,7 +111,7 @@ end_badly (void *cls)
if (cc != NULL)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Fail! Could not connect peers\n"));
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
cc = NULL;
}
@@ -138,11 +138,11 @@ end_badly (void *cls)
th = NULL;
if (p1 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
else
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 1 was not started\n"));
if (p2 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
else
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 2 was not started\n"));
@@ -154,8 +154,8 @@ static void
notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message)
{
- struct PeerContext *p = cls;
- struct PeerContext *t = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
t = p1;
@@ -189,7 +189,7 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
static size_t
notify_ready (void *cls, size_t size, void *buf)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
struct GNUNET_MessageHeader *hdr;
th = NULL;
@@ -249,8 +249,8 @@ notify_connect (void *cls,
static int c;
c++;
- struct PeerContext *p = cls;
- struct PeerContext *t = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
t = p1;
@@ -271,7 +271,7 @@ static void
notify_disconnect (void *cls,
const struct GNUNET_PeerIdentity *peer)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -290,9 +290,7 @@ notify_disconnect (void *cls,
static void
-testing_connect_cb (struct PeerContext *p1,
- struct PeerContext *p2,
- void *cls)
+testing_connect_cb (void *cls)
{
cc = NULL;
char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
@@ -307,7 +305,7 @@ testing_connect_cb (struct PeerContext *p1,
static void
-start_cb (struct PeerContext *p,
+start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p,
void *cls)
{
static int started;
@@ -329,8 +327,7 @@ start_cb (struct PeerContext *p,
p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id));
GNUNET_free (sender_c);
}
- cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth,
- p1,
+ cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1,
p2,
&testing_connect_cb,
NULL);
@@ -406,25 +403,20 @@ main (int argc, char *argv[])
{
int ret;
- GNUNET_TRANSPORT_TESTING_get_test_name (argv[0],
- &test_name);
- GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__,
- &test_source);
- GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0],
- test_source,
- &test_plugin);
+ test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]);
+ test_source = GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__);
+ test_plugin = GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0],
+ test_source);
GNUNET_log_setup (test_name,
"WARNING",
NULL);
tth = GNUNET_TRANSPORT_TESTING_init ();
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0],
- &cfg_file_p1,
- 1);
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0],
- &cfg_file_p2,
- 2);
+ cfg_file_p1 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0],
+ 1);
+ cfg_file_p2 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0],
+ 2);
ret = check ();