File

spec/util_random_spec.lua @ 11673:3ab8496579f1

net.server_epoll: Start TLS handshake immediately on newly accepted connections Since TLS is a client-first protocol there is a chance that the ClientHello message is available already. TLS Fast Open and/or the TCP_DEFER_ACCEPT socket option would increase that chance.
author Kim Alvefur <zash@zash.se>
date Tue, 13 Jul 2021 14:20:26 +0200
parent 8450:3a9a3d90c44c
line wrap: on
line source


local random = require "util.random";

describe("util.random", function()
	describe("#bytes()", function()
		it("should return a string", function()
			assert.is_string(random.bytes(16));
		end);

		it("should return the requested number of bytes", function()
			-- Makes no attempt at testing how random the bytes are,
			-- just that it returns the number of bytes requested

			for i = 1, 20 do
				assert.are.equal(2^i, #random.bytes(2^i));
			end
		end);
	end);
end);