meshlink_node_t *b = meshlink_get_node(mesh_a, "b");
assert(b);
- meshlink_channel_t *channel = meshlink_channel_open_ex(mesh_a, b, 1, NULL, NULL, 0, MESHLINK_CHANNEL_NO_PARTIAL);
+ meshlink_channel_t *channel = meshlink_channel_open_ex(mesh_a, b, 1, NULL, NULL, 0, MESHLINK_CHANNEL_TCP | MESHLINK_CHANNEL_NO_PARTIAL);
assert(channel);
+ // Stop a to ensure we get deterministic behaviour for the channel send queue.
+
+ meshlink_stop(mesh_a);
+
// Verify that no partial sends succeed.
// If rejected sends would fit an empty send buffer, 0 should be returned, otherwise -1.
- char buf[256] = "";
+ char buf[512] = "data";
meshlink_set_channel_sndbuf(mesh_a, channel, 256);
assert(meshlink_channel_send(mesh_a, channel, buf, 257) == -1);
assert(meshlink_channel_send(mesh_a, channel, buf, 29) == 0);
assert(meshlink_channel_send(mesh_a, channel, buf, 513) == -1);
+ // Restart a to ensure it gets to flush the channel send queue.
+
+ meshlink_start(mesh_a);
+
assert_after(!meshlink_channel_get_sendq(mesh_a, channel), 30);
assert(meshlink_channel_send(mesh_a, channel, buf, 512) == 512);