*/
/**
- * @file mesh/test_mesh_local_1.c
- * @brief test mesh local: test of tunnels with just one peer
+ * @file mesh/test_mesh2_local.c
+ * @brief test mesh2 local: test of mesh2 tunnels with just one peer
* @author Bartlomiej Polot
*/
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: ABORT\n");
result = GNUNET_SYSERR;
- abort_task = 0;
+ abort_task = GNUNET_SCHEDULER_NO_TASK;
if (GNUNET_SCHEDULER_NO_TASK != shutdown_task)
{
GNUNET_SCHEDULER_cancel (shutdown_task);
shutdown_task =
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &do_shutdown,
NULL);
+ GNUNET_MESH_receive_done (tunnel);
return GNUNET_OK;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"test: received incoming tunnel on peer %d, port %u\n",
id, port);
- if (id != 1L)
+ if (id != 2L)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"test: wrong peer\n");
inbound_end (void *cls, const struct GNUNET_MESH_Tunnel *tunnel,
void *tunnel_ctx)
{
- unsigned int id = *(unsigned int *) cls;
+ long id = (long) cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: incoming tunnel closed\n");
- if (id != 1)
+ if (id != 2)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "test: received closing tunnel on peer 2\n");
+ "test: received closing tunnel on peer != 2\n");
result = GNUNET_SYSERR;
}
}
/**
* Handler array for traffic received on peer2 (none expected)
*/
-static struct GNUNET_MESH_MessageHandler handlers2[] = { {NULL, 0, 0} };
+static struct GNUNET_MESH_MessageHandler handlers2[] = {
+ {&data_callback, 1, 0},
+ {NULL, 0, 0}
+};
+
+static size_t
+do_send (void *cls, size_t size, void *buf)
+{
+ struct GNUNET_MessageHeader *m = buf;
+ if (NULL == buf)
+ {
+ GNUNET_break (0);
+ result = GNUNET_SYSERR;
+ return 0;
+ }
+ m->size = htons (sizeof (struct GNUNET_MessageHeader));
+ m->type = htons (1);
+ GNUNET_assert (size >= sizeof (struct GNUNET_MessageHeader));
+ return sizeof (struct GNUNET_MessageHeader);
+}
/**
* Start looking for a peer by type
struct GNUNET_PeerIdentity id;
GNUNET_TESTING_peer_get_identity (me, &id);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: CONNECT BY TYPE\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: CONNECT BY PORT\n");
t = GNUNET_MESH_tunnel_create (mesh_peer_1, NULL, &id, 1);
+ GNUNET_MESH_notify_transmit_ready (t, GNUNET_NO,
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ sizeof (struct GNUNET_MessageHeader),
+ &do_send, NULL);
}
me = peer;
abort_task =
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
- (GNUNET_TIME_UNIT_SECONDS, 20), &do_abort,
+ (GNUNET_TIME_UNIT_SECONDS, 15), &do_abort,
NULL);
mesh_peer_1 = GNUNET_MESH_connect (cfg, /* configuration */
(void *) 1L, /* cls */