Skip to content

Commit b379d8d

Browse files
LekoMylesBorins
authored andcommitted
test: improve crypto/random.js coverage
- Call randomBytes with a non-function callback - Call randomFill with a non-function callback PR-URL: #17555 Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 316da5e commit b379d8d

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

test/parallel/test-crypto-random.js

+19
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,7 @@ common.expectsError(
488488
);
489489

490490
[1, true, NaN, null, undefined, {}, []].forEach((i) => {
491+
const buf = Buffer.alloc(10);
491492
common.expectsError(
492493
() => crypto.randomFillSync(i),
493494
{
@@ -502,4 +503,22 @@ common.expectsError(
502503
type: TypeError
503504
}
504505
);
506+
common.expectsError(
507+
() => crypto.randomFill(buf, 0, 10, i),
508+
{
509+
code: 'ERR_INVALID_CALLBACK',
510+
type: TypeError,
511+
message: 'Callback must be a function',
512+
});
513+
});
514+
515+
[1, true, NaN, null, {}, []].forEach((i) => {
516+
common.expectsError(
517+
() => crypto.randomBytes(1, i),
518+
{
519+
code: 'ERR_INVALID_CALLBACK',
520+
type: TypeError,
521+
message: 'Callback must be a function',
522+
}
523+
);
505524
});

0 commit comments

Comments
 (0)