Skip to content

Commit

Permalink
test: use mustSucceed instead of mustCall
Browse files Browse the repository at this point in the history
  • Loading branch information
tniessen committed Oct 13, 2020
1 parent 4b8676e commit 476d930
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 41 deletions.
33 changes: 16 additions & 17 deletions test/parallel/test-crypto-pbkdf2.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ const expected =
const key = crypto.pbkdf2Sync('password', 'salt', 32, 32, 'sha256');
assert.strictEqual(key.toString('hex'), expected);

crypto.pbkdf2('password', 'salt', 32, 32, 'sha256', common.mustCall(ondone));
function ondone(err, key) {
assert.ifError(err);
crypto.pbkdf2('password', 'salt', 32, 32, 'sha256', common.mustSucceed(ondone));
function ondone(key) {
assert.strictEqual(key.toString('hex'), expected);
}

Expand Down Expand Up @@ -199,22 +198,22 @@ assert.throws(
});

// Any TypedArray should work for password and salt
crypto.pbkdf2(new Uint8Array(10), 'salt', 8, 8, 'sha256', common.mustCall());
crypto.pbkdf2('pass', new Uint8Array(10), 8, 8, 'sha256', common.mustCall());
crypto.pbkdf2(new Uint16Array(10), 'salt', 8, 8, 'sha256', common.mustCall());
crypto.pbkdf2('pass', new Uint16Array(10), 8, 8, 'sha256', common.mustCall());
crypto.pbkdf2(new Uint32Array(10), 'salt', 8, 8, 'sha256', common.mustCall());
crypto.pbkdf2('pass', new Uint32Array(10), 8, 8, 'sha256', common.mustCall());
crypto.pbkdf2(new Float32Array(10), 'salt', 8, 8, 'sha256', common.mustCall());
crypto.pbkdf2('pass', new Float32Array(10), 8, 8, 'sha256', common.mustCall());
crypto.pbkdf2(new Float64Array(10), 'salt', 8, 8, 'sha256', common.mustCall());
crypto.pbkdf2('pass', new Float64Array(10), 8, 8, 'sha256', common.mustCall());
crypto.pbkdf2(new ArrayBuffer(10), 'salt', 8, 8, 'sha256', common.mustCall());
crypto.pbkdf2('pass', new ArrayBuffer(10), 8, 8, 'sha256', common.mustCall());
crypto.pbkdf2(new Uint8Array(10), 'salt', 8, 8, 'sha256', common.mustSucceed());
crypto.pbkdf2('pass', new Uint8Array(10), 8, 8, 'sha256', common.mustSucceed());
crypto.pbkdf2(new Uint16Array(10), 'salt', 8, 8, 'sha1', common.mustSucceed());
crypto.pbkdf2('pass', new Uint16Array(10), 8, 8, 'sha1', common.mustSucceed());
crypto.pbkdf2(new Uint32Array(10), 'salt', 8, 8, 'sha1', common.mustSucceed());
crypto.pbkdf2('pass', new Uint32Array(10), 8, 8, 'sha1', common.mustSucceed());
crypto.pbkdf2(new Float32Array(10), 'salt', 8, 8, 'sha1', common.mustSucceed());
crypto.pbkdf2('pass', new Float32Array(10), 8, 8, 'sha1', common.mustSucceed());
crypto.pbkdf2(new Float64Array(10), 'salt', 8, 8, 'sha1', common.mustSucceed());
crypto.pbkdf2('pass', new Float64Array(10), 8, 8, 'sha1', common.mustSucceed());
crypto.pbkdf2(new ArrayBuffer(10), 'salt', 8, 8, 'sha1', common.mustSucceed());
crypto.pbkdf2('pass', new ArrayBuffer(10), 8, 8, 'sha1', common.mustSucceed());
crypto.pbkdf2(new SharedArrayBuffer(10), 'salt', 8, 8, 'sha256',
common.mustCall());
common.mustSucceed());
crypto.pbkdf2('pass', new SharedArrayBuffer(10), 8, 8, 'sha256',
common.mustCall());
common.mustSucceed());

crypto.pbkdf2Sync(new Uint8Array(10), 'salt', 8, 8, 'sha256');
crypto.pbkdf2Sync('pass', new Uint8Array(10), 8, 8, 'sha256');
Expand Down
12 changes: 6 additions & 6 deletions test/parallel/test-crypto-random.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,8 @@ assert.throws(
const maxInt = Number.MAX_SAFE_INTEGER;
const minInt = Number.MIN_SAFE_INTEGER;

crypto.randomInt(minInt, minInt + 5, common.mustCall());
crypto.randomInt(maxInt - 5, maxInt, common.mustCall());
crypto.randomInt(minInt, minInt + 5, common.mustSucceed());
crypto.randomInt(maxInt - 5, maxInt, common.mustSucceed());

assert.throws(
() => crypto.randomInt(minInt - 1, minInt + 5, common.mustNotCall()),
Expand All @@ -483,8 +483,8 @@ assert.throws(
}
);

crypto.randomInt(1, common.mustCall());
crypto.randomInt(0, 1, common.mustCall());
crypto.randomInt(1, common.mustSucceed());
crypto.randomInt(0, 1, common.mustSucceed());
for (const arg of [[0], [1, 1], [3, 2], [-5, -5], [11, -10]]) {
assert.throws(() => crypto.randomInt(...arg, common.mustNotCall()), {
code: 'ERR_OUT_OF_RANGE',
Expand All @@ -496,8 +496,8 @@ assert.throws(
}

const MAX_RANGE = 0xFFFF_FFFF_FFFF;
crypto.randomInt(MAX_RANGE, common.mustCall());
crypto.randomInt(1, MAX_RANGE + 1, common.mustCall());
crypto.randomInt(MAX_RANGE, common.mustSucceed());
crypto.randomInt(1, MAX_RANGE + 1, common.mustSucceed());
assert.throws(
() => crypto.randomInt(1, MAX_RANGE + 2, common.mustNotCall()),
{
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-dgram-connect-send-empty-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ client.bind(0, common.mustCall(function() {
const port = this.address().port;
client.connect(port, common.mustCall(() => {
const buf = Buffer.alloc(0);
client.send(buf, 0, 0, common.mustCall());
client.send(buf, 0, 0, common.mustSucceed());
}));

client.on('message', common.mustCall((buffer) => {
Expand Down
6 changes: 3 additions & 3 deletions test/parallel/test-domain-crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ global.domain = require('domain');

// Should not throw a 'TypeError: undefined is not a function' exception
crypto.randomBytes(8);
crypto.randomBytes(8, common.mustCall());
crypto.randomBytes(8, common.mustSucceed());
const buf = Buffer.alloc(8);
crypto.randomFillSync(buf);
crypto.pseudoRandomBytes(8);
crypto.pseudoRandomBytes(8, common.mustCall());
crypto.pbkdf2('password', 'salt', 8, 8, 'sha1', common.mustCall());
crypto.pseudoRandomBytes(8, common.mustSucceed());
crypto.pbkdf2('password', 'salt', 8, 8, 'sha1', common.mustSucceed());
2 changes: 1 addition & 1 deletion test/parallel/test-http-outgoing-finish.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function write(out) {
let endCb = false;

// First, write until it gets some backpressure
while (out.write(buf, common.mustCall())) {}
while (out.write(buf, common.mustSucceed())) {}

// Now end, and make sure that we don't get the 'finish' event
// before the tick where the cb gets called. We give it until
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-http2-buffersize.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const { mustCall, hasCrypto, skip } = require('../common');
const { mustCall, mustSucceed, hasCrypto, skip } = require('../common');
if (!hasCrypto)
skip('missing crypto');
const assert = require('assert');
Expand Down Expand Up @@ -42,7 +42,7 @@ const { once } = require('events');
stream.on('data', () => {});

for (let i = 0; i < kTimes; i += 1) {
stream.write(Buffer.allocUnsafe(kBufferSize), mustCall());
stream.write(Buffer.allocUnsafe(kBufferSize), mustSucceed());
const expectedSocketBufferSize = kBufferSize * (i + 1);
assert.strictEqual(stream.bufferSize, expectedSocketBufferSize);
}
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-http2-create-client-secure-session.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function verifySecureSession(key, cert, ca, opts) {
assert.strictEqual(jsonData.servername,
opts.servername || 'localhost');
assert.strictEqual(jsonData.alpnProtocol, 'h2');
server.close(common.mustCall());
server.close(common.mustSucceed());
client[kSocket].destroy();
}));
}));
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-http2-respond-file-error-pipe-offset.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ server.listen(0, () => {
req.end();
});

fs.writeFile(pipeName, 'Hello, world!\n', common.mustCall());
fs.writeFile(pipeName, 'Hello, world!\n', common.mustSucceed());
2 changes: 1 addition & 1 deletion test/parallel/test-http2-server-close-callback.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const server = http2.createServer();
let session;

const countdown = new Countdown(2, () => {
server.close(common.mustCall());
server.close(common.mustSucceed());
session.destroy();
});

Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-https-close.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ server.on('connection', (connection) => {
});

function shutdown() {
server.close(common.mustCall());
server.close(common.mustSucceed());

for (const key in connections) {
connections[key].destroy();
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-quic-simple-client-migrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const server = createQuicSocket({ server: options });
(async function() {
server.on('session', common.mustCall((session) => {
session.on('stream', common.mustCall(async (stream) => {
pipeline(stream, stream, common.mustCall());
pipeline(stream, stream, common.mustSucceed());
(await session.openStream({ halfOpen: true }))
.end('Hello from the server');
}));
Expand Down
10 changes: 5 additions & 5 deletions test/parallel/test-stream-pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ const net = require('net');

{
const server = http.createServer((req, res) => {
pipeline(req, res, common.mustCall());
pipeline(req, res, common.mustSucceed());
});

server.listen(0, () => {
Expand Down Expand Up @@ -1109,7 +1109,7 @@ const net = require('net');
{
const server = net.createServer(common.mustCall((socket) => {
// echo server
pipeline(socket, socket, common.mustCall());
pipeline(socket, socket, common.mustSucceed());
// 13 force destroys the socket before it has a chance to emit finish
socket.on('finish', common.mustCall(() => {
server.close();
Expand Down Expand Up @@ -1145,7 +1145,7 @@ const net = require('net');
})
});

pipeline(d, sink, common.mustCall());
pipeline(d, sink, common.mustSucceed());

d.write('test');
d.end();
Expand All @@ -1154,7 +1154,7 @@ const net = require('net');
{
const server = net.createServer(common.mustCall((socket) => {
// echo server
pipeline(socket, socket, common.mustCall());
pipeline(socket, socket, common.mustSucceed());
socket.on('finish', common.mustCall(() => {
server.close();
}));
Expand Down Expand Up @@ -1192,7 +1192,7 @@ const net = require('net');
})
});

pipeline(d, sink, common.mustCall());
pipeline(d, sink, common.mustSucceed());

d.write('test');
d.end();
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-worker-no-stdin-stdout-interaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ if (isMainThread) {
process.stdin.on('data', () => {});

for (let i = 0; i < 10; ++i) {
process.stdout.write(`processing(${i})\n`, common.mustCall());
process.stdout.write(`processing(${i})\n`, common.mustSucceed());
}
}

0 comments on commit 476d930

Please sign in to comment.