summaryrefslogtreecommitdiff
path: root/test/parallel/test-crypto-domain.js
blob: fcbbcb8e0524f2aad140a3f38fbe3462fb3f784f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
'use strict';
const common = require('../common');
const assert = require('assert');
const domain = require('domain');

if (!common.hasCrypto) {
  common.skip('missing crypto');
  return;
}
const crypto = require('crypto');

function test(fn) {
  var ex = new Error('BAM');
  var d = domain.create();
  d.on('error', common.mustCall(function(err) {
    assert.strictEqual(err, ex);
  }));
  var 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);
});