Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
server.on('message', ([type, port]) => {
test.plan(EXPECTED_ATTEMPTS_TO_RECONNECT);
if (type !== 'listening') {
test.fail('must not receive unknown messages');
}
jstp.net.connect(
APP_NAME,
null,
port,
'localhost',
(error, connection) => {
test.assertNot(error, 'must connect to server and perform handshake');
connection.on('error', () => {
// dismiss
});
server.kill('SIGTERM');
child.on('exit', function (exitCode, signal) {
// almost certainly won't get an 'exit' event if we've already
// unrefed the child, but avoid a false failure anyway.
/* istanbul ignore else */
if (!unrefed) {
t.fail('child process exited early', {
exitCode: exitCode,
signal: signal
})
}
})
}
client.on('message', ([message, ...args]) => {
switch (message) {
case 'error':
console.error(args[0].message);
test.fail('must not encounter an error');
break;
case 'session':
session(...args);
break;
}
});
'use strict'
const t = require('tap')
const test = t.test
const Fastify = require('../..')
const h2url = require('h2url')
const msg = { hello: 'world' }
var fastify
try {
fastify = Fastify({
http2: true
})
t.pass('http2 successfully loaded')
} catch (e) {
t.fail('http2 loading failed', e)
}
fastify.get('/', function (req, reply) {
reply.code(200).send(msg)
})
fastify.listen(0, err => {
t.error(err)
fastify.server.unref()
test('http get request', async (t) => {
t.plan(3)
const url = `http://localhost:${fastify.server.address().port}`
const res = await h2url.concat({ url })
p.on('version', function (v) {
t.fail('should not see version event')
})
var lines = []
method: (connection, callback) => {
callsReceivedByClient++;
if (callsReceivedByClient === 1) {
test.pass('Client must receive first call message');
reconnect();
} else if (callsReceivedByClient === 2) {
test.pass('Client must receive second call message');
callback(null);
} else {
test.fail('Client must not receive more than two call messages');
}
},
},
method: (connection, callback) => {
callsReceivedByServer++;
if (callsReceivedByServer === 1) {
test.pass('Server must receive first call message');
reconnect();
} else if (callsReceivedByServer === 2) {
test.pass('Server must receive second call message');
callback(null);
} else {
test.fail('Server must not receive more than two call messages');
}
},
},
const checkJson = (data, name) => {
try {
JSON.parse(data);
} catch (e) {
tap.fail(name + ' has invalid Json.\n');
}
};
yj.stringifyAsync(obj, 0, 2, (err, str) => {
if (!err) {
tap.ok(flag >= 1, 'Async function was expected to yield at least' +
` once, but got ${flag}!`);
} else
tap.fail(err);
});
const noMissingStrings = (fileName, missingMessageId, pagesMissingIds) => {
if (Object.keys(missingMessageId).length === 0) {
tap.pass();
} else {
tap.fail(fileName + ' is missing string IDs');
pagesMissingIds[fileName] = [];
pagesMissingIds[fileName].push(missingMessageId);
}
};