Files
node/test/parallel/test-crypto-domain.js
Griffith Tchenpan a284ee6129 test: invoke callback with common.mustCall()
* invoke callback with `common.mustCall()` in test-crypto-hash
* order module declarations aphabetically per test-writing-guide

PR-URL: https://github.com/nodejs/node/pull/8597
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2017-09-20 11:18:52 -04:00

29 lines
583 B
JavaScript

'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const assert = require('assert');
const crypto = require('crypto');
const domain = require('domain');
function test(fn) {
const ex = new Error('BAM');
const d = domain.create();
d.on('error', common.mustCall(function(err) {
assert.strictEqual(err, ex);
}));
const cb = common.mustCall(function() {
throw ex;
});
d.run(cb);
}
test(function(cb) {
crypto.pbkdf2('password', 'salt', 1, 8, cb);
});
test(function(cb) {
crypto.randomBytes(32, cb);
});