diff --git a/test/parallel/test-crypto-random.js b/test/parallel/test-crypto-random.js index 320a4358ff3ccb..3926eb385044d9 100644 --- a/test/parallel/test-crypto-random.js +++ b/test/parallel/test-crypto-random.js @@ -488,6 +488,7 @@ common.expectsError( ); [1, true, NaN, null, undefined, {}, []].forEach((i) => { + const buf = Buffer.alloc(10); common.expectsError( () => crypto.randomFillSync(i), { @@ -502,4 +503,22 @@ common.expectsError( type: TypeError } ); + common.expectsError( + () => crypto.randomFill(buf, 0, 10, i), + { + code: 'ERR_INVALID_CALLBACK', + type: TypeError, + message: 'Callback must be a function', + }); +}); + +[1, true, NaN, null, {}, []].forEach((i) => { + common.expectsError( + () => crypto.randomBytes(1, i), + { + code: 'ERR_INVALID_CALLBACK', + type: TypeError, + message: 'Callback must be a function', + } + ); });