add simple fuzz test

This commit is contained in:
Asraelite 2016-03-27 20:26:53 +01:00
parent 0a90b6b77a
commit 27520842e3
59 changed files with 191 additions and 34 deletions

26
tests/fuzz.js Normal file
View file

@ -0,0 +1,26 @@
'use strict';
const assert = require('assert');
function fuzz(socket) {
let types = ['setName', 'chat', 'inputs'];
// Heh, they align.
let msg = Array(25).fill().map(v => {
let rndstr = Math.random().toString(36).substr(Math.random() * -5 - 1);
return Array(Math.random() * 20 | 0).fill().map(v => {
return Math.random() > 0.5 ? Math.random() * 10 : rndstr;
});
}).concat(Array(75).fill().map(v => {
return Math.random() * 50;
}));
for (var i = 0; i < 100; i++) {
let type = types[Math.random() * types.length | 0];
socket.send(type, msg[i]);
}
wingbase.debug('Sent 100 random messages.');
}
module.exports = fuzz;

17
tests/index.js Normal file
View file

@ -0,0 +1,17 @@
'use strict';
const io = require('socket.io-client');
const fuzz = require('./fuzz.js');
let socket = io('http://localhost:' + process.env.PORT);
socket.on('connect', test);
function test() {
wingbase.debug('Running fuzz test.');
fuzz(socket);
wingbase.debug('Ending tests.');
wingbase.stop();
}