diff --git a/package.json b/package.json index 0a10158400..92fde19f9a 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "ethereumjs-util": "^6.0.0", "fake-merkle-patricia-tree": "^1.0.1", "functional-red-black-tree": "^1.0.1", - "merkle-patricia-tree": "^2.1.2", + "merkle-patricia-tree": "^2.3.2", "rustbn.js": "~0.2.0", "safe-buffer": "^5.1.1" }, diff --git a/tests/api/index.js b/tests/api/index.js index 1f569f234a..aa9a01e096 100644 --- a/tests/api/index.js +++ b/tests/api/index.js @@ -2,13 +2,14 @@ const { promisify } = require('util') const tape = require('tape') const util = require('ethereumjs-util') const Block = require('ethereumjs-block') +const Trie = require('merkle-patricia-tree/secure') const VM = require('../../lib/index') const { setupVM } = require('./utils') const { setupPreConditions } = require('../util') const testData = require('./testdata.json') tape('VM with fake blockchain', (t) => { - t.test('should insantiate without params', (st) => { + t.test('should instantiate without params', (st) => { const vm = new VM() st.ok(vm.stateManager) st.deepEqual(vm.stateManager._trie.root, util.KECCAK256_RLP, 'it has default trie') @@ -22,6 +23,15 @@ tape('VM with fake blockchain', (t) => { st.end() }) + t.test('should work with trie (state) provided', (st) => { + let trie = new Trie() + trie.isTestTrie = true + let vm = new VM({ state: trie, activatePrecompiles: true }) + st.notEqual(vm.stateManager._trie.root, util.KECCAK256_RLP, 'it has different root') + st.ok(vm.stateManager._trie.isTestTrie, 'it works on trie provided') + st.end() + }) + t.test('should only accept valid chain and fork', (st) => { let vm = new VM({ chain: 'ropsten', hardfork: 'byzantium' }) st.equal(vm.stateManager._common.param('gasPrices', 'ecAdd'), 500)