Move test VM crypto definition (#1584)
This commit is contained in:
parent
8179846e38
commit
28fa3fa795
@ -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
|
||||
|
@ -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'
|
||||
]);
|
||||
|
Loading…
Reference in New Issue
Block a user