X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Ftransport%2Ftest_transport_api_blacklisting.c;h=76780a48a621186f37fccf1a5945cdd264d3781b;hb=5a7cef0202631204485cbcb1e36671e4321a936f;hp=72f8a71a377e37493a5d0605fa548ec33765a7a2;hpb=c6444a089a860da694842942283079a25bc1e957;p=oweals%2Fgnunet.git diff --git a/src/transport/test_transport_api_blacklisting.c b/src/transport/test_transport_api_blacklisting.c index 72f8a71a3..76780a48a 100644 --- a/src/transport/test_transport_api_blacklisting.c +++ b/src/transport/test_transport_api_blacklisting.c @@ -30,13 +30,6 @@ #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) -#define TEST_MESSAGE_SIZE 2600 - -#define TEST_MESSAGE_TYPE 12345 - - -static struct GNUNET_TRANSPORT_TransmitHandle *th; - static struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *ccc; static int connected; @@ -49,8 +42,6 @@ static struct GNUNET_TRANSPORT_Blacklist *blacklist_p1; static struct GNUNET_TRANSPORT_Blacklist *blacklist_p2; -static struct GNUNET_SCHEDULER_Task *send_task; - static struct GNUNET_SCHEDULER_Task *shutdown_task; @@ -81,21 +72,11 @@ end (void *cls) static void custom_shutdown (void *cls) { - if (NULL != send_task) - { - GNUNET_SCHEDULER_cancel (send_task); - send_task = NULL; - } if (NULL != shutdown_task) { GNUNET_SCHEDULER_cancel (shutdown_task); shutdown_task = NULL; } - if (NULL != th) - { - GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); - th = NULL; - } if (NULL != blacklist_p1) { GNUNET_TRANSPORT_blacklist_cancel (blacklist_p1); @@ -113,46 +94,13 @@ static void notify_receive (void *cls, struct GNUNET_TRANSPORT_TESTING_PeerContext *receiver, const struct GNUNET_PeerIdentity *sender, - const struct GNUNET_MessageHeader *message) + const struct GNUNET_TRANSPORT_TESTING_TestMessage *message) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unexpectedly even received the message despite blacklist\n"); - GNUNET_SCHEDULER_shutdown (); -} - - -static size_t -notify_ready (void *cls, - size_t size, - void *buf) -{ - struct GNUNET_MessageHeader *hdr; - - th = NULL; - if (NULL == buf) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Timeout occurred while waiting for transmit_ready\n"); - GNUNET_SCHEDULER_shutdown (); - return 0; - } - GNUNET_assert (size >= TEST_MESSAGE_SIZE); - hdr = buf; - hdr->size = htons (TEST_MESSAGE_SIZE); - hdr->type = htons (TEST_MESSAGE_TYPE); - return TEST_MESSAGE_SIZE; -} - - -static void -sendtask (void *cls) -{ - th = GNUNET_TRANSPORT_notify_transmit_ready (ccc->p[1]->th, - &ccc->p[0]->id, - TEST_MESSAGE_SIZE, - TIMEOUT, - ¬ify_ready, - ccc->p[0]); + connected = GNUNET_YES; + GNUNET_SCHEDULER_cancel (shutdown_task); + end (NULL); } @@ -172,22 +120,6 @@ notify_connect (void *cls, } -static void -notify_disconnect (void *cls, - struct GNUNET_TRANSPORT_TESTING_PeerContext *me, - const struct GNUNET_PeerIdentity *other) -{ - GNUNET_TRANSPORT_TESTING_log_disconnect (cls, - me, - other); - if (NULL != th) - { - GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); - th = NULL; - } -} - - static int blacklist_cb (void *cls, const struct GNUNET_PeerIdentity *pid) @@ -244,13 +176,17 @@ int main (int argc, char *argv[]) { + struct GNUNET_TRANSPORT_TESTING_SendClosure sc = { + .num_messages = 1 + }; struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext my_ccc = { .pre_connect_task = &start_blacklist, - .connect_continuation = &sendtask, + .connect_continuation = &GNUNET_TRANSPORT_TESTING_simple_send, + .connect_continuation_cls = &sc, .config_file = "test_transport_api_data.conf", .rec = ¬ify_receive, .nc = ¬ify_connect, - .nd = ¬ify_disconnect, + .nd = &GNUNET_TRANSPORT_TESTING_log_disconnect, .shutdown_task = &custom_shutdown, .timeout = TIMEOUT, .bi_directional = GNUNET_YES