Ramez
Ramez

Reputation: 31

How to make crypto.randomBytes cause error

crypto.randomBytes(48, function (err, buffer) {
            if (err) {
              x = false;
              return;
            }

I need to create a test code where err is true. How to let crypto.randomByte cause an error.

Upvotes: 2

Views: 645

Answers (1)

Julian
Julian

Reputation: 2822

There will be an error if you provide an invalid value. e.g.

crypto.randomBytes(-1)

Upvotes: 1

Related Questions