diff options
-rw-r--r-- | dev/vm.js | 7 | ||||
-rw-r--r-- | test/test-core.js | 11 |
2 files changed, 8 insertions, 10 deletions
@@ -150,6 +150,13 @@ class VM { constructor(context={}) { this._urlMap = new Map(); context.URL = createURLClass(this._urlMap); + context.crypto = { + getRandomValues: (array) => { + const buffer = crypto.randomBytes(array.byteLength); + buffer.copy(array); + return array; + } + }; this._context = vm.createContext(context); this._assert = { deepStrictEqual diff --git a/test/test-core.js b/test/test-core.js index cf9a5c35..22392359 100644 --- a/test/test-core.js +++ b/test/test-core.js @@ -16,19 +16,10 @@ */ const assert = require('assert'); -const crypto = require('crypto'); const {testMain} = require('../dev/util'); const {VM} = require('../dev/vm'); -const vm = new VM({ - crypto: { - getRandomValues: (array) => { - const buffer = crypto.randomBytes(array.byteLength); - buffer.copy(array); - return array; - } - } -}); +const vm = new VM(); vm.execute([ 'js/core.js' ]); |