]> git.meshlink.io Git - meshlink/commitdiff
Check that we can send up to 65536 bytes at a time on UDP-style channels.
authorGuus Sliepen <guus@meshlink.io>
Sat, 11 Apr 2020 22:14:23 +0000 (00:14 +0200)
committerGuus Sliepen <guus@meshlink.io>
Sat, 11 Apr 2020 22:55:45 +0000 (00:55 +0200)
test/channels-udp.c

index 0c24a9376e04f979fb80921154e1e7169f6ac863..8071d467f6a5ca8d3bbf82858b59a4d6eecd5b8d 100644 (file)
@@ -55,10 +55,10 @@ static void client_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *chann
        // We expect always the same amount of data from the server.
        assert(mesh->priv);
        struct client *client = mesh->priv;
-       assert(len == 512 || len == 2000);
+       assert(len == 512 || len == 65536);
        client->received += len;
 
-       if(len == 2000) {
+       if(len == 65536) {
                client->got_large_packet = true;
        }
 }
@@ -140,11 +140,12 @@ int main() {
                assert(clients[i].channel);
        }
 
-       // Send a packet larger than the MTU
+       // Check that we can send up to 65535 bytes without errors
 
-       char large_data[2000] = "";
+       char large_data[65536] = "";
 
        for(int i = 0; i < 3; i++) {
+               assert(meshlink_channel_send(server, channels[i], large_data, sizeof(large_data) + 1) == -1);
                assert(meshlink_channel_send(server, channels[i], large_data, sizeof(large_data)) == sizeof(large_data));
        }
 
@@ -183,7 +184,7 @@ int main() {
 
        for(int i = 0; i < 3; i++) {
                assert(clients[i].received >= 1000000);
-               assert(clients[i].received <= 1282000);
+               assert(clients[i].received <= 1345536);
                assert(clients[i].got_large_packet);
        }