* @brief tests for mq with connection client
*/
#include "platform.h"
-#include "gnunet_common.h"
#include "gnunet_util_lib.h"
#define PORT 23336
const struct GNUNET_MessageHeader *message)
{
received++;
-
- printf ("received\n");
-
-
- if ((received == 2) && (GNUNET_YES == notify))
+ if (received == 2)
{
- printf ("done\n");
GNUNET_SERVER_receive_done (argclient, GNUNET_NO);
return;
}
+ /* can happen if notify does not work */
+ GNUNET_assert (received < 2);
+
GNUNET_SERVER_receive_done (argclient, GNUNET_YES);
}
{NULL, NULL, 0, 0}
};
-void send_cb (void *cls)
+
+static void
+send_cb (void *cls)
{
- printf ("notify sent\n");
+ /* the notify should only be called once */
+ GNUNET_assert (GNUNET_NO == notify);
notify = GNUNET_YES;
}
-void test_mq (struct GNUNET_CLIENT_Connection *client)
+
+static void
+test_mq (struct GNUNET_CLIENT_Connection *client)
{
- struct GNUNET_MQ_MessageQueue *mq;
- struct GNUNET_MQ_Message *mqm;
+ struct GNUNET_MQ_Handle *mq;
+ struct GNUNET_MQ_Envelope *mqm;
/* FIXME: test handling responses */
- mq = GNUNET_MQ_queue_for_connection_client (client, NULL, NULL);
+ mq = GNUNET_MQ_queue_for_connection_client (client, NULL, NULL, NULL);
mqm = GNUNET_MQ_msg_header (MY_TYPE);
GNUNET_MQ_send (mq, mqm);
NULL);
ok = 1;
GNUNET_SCHEDULER_run (&task, NULL);
+ GNUNET_assert (GNUNET_YES == notify);
return ok;
}