Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove fakeBlockchain class and associated tests #466

Merged
merged 1 commit into from
Mar 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 0 additions & 33 deletions lib/fakeBlockChain.js

This file was deleted.

4 changes: 2 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ const Buffer = require('safe-buffer').Buffer
const ethUtil = require('ethereumjs-util')
const { StateManager } = require('./state')
const Common = require('ethereumjs-common').default
const Blockchain = require('ethereumjs-blockchain')
const Account = require('ethereumjs-account')
const AsyncEventEmitter = require('async-eventemitter')
const Trie = require('merkle-patricia-tree/secure.js')
const fakeBlockchain = require('./fakeBlockChain.js')
const BN = ethUtil.BN

// require the precompiled contracts
Expand Down Expand Up @@ -58,7 +58,7 @@ module.exports = class VM extends AsyncEventEmitter {
this.stateManager = new StateManager({ trie, common: this._common })
}

this.blockchain = opts.blockchain || fakeBlockchain
this.blockchain = opts.blockchain || new Blockchain({ common: this._common })

this.allowUnlimitedContractSize = opts.allowUnlimitedContractSize === undefined ? false : opts.allowUnlimitedContractSize
this.emitFreeLogs = opts.emitFreeLogs === undefined ? false : opts.emitFreeLogs
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"async-eventemitter": "^0.2.2",
"ethereumjs-account": "^2.0.3",
"ethereumjs-block": "~2.2.0",
"ethereumjs-blockchain": "^3.4.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this have been the reason for using fakeBlockchain? To avoid depending on ethereumjs-blockchain maybe?

Did you face any roadblocks when dropping the fake blockchain?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already wondered if browser compatibility would be the reason for this, maybe we should get some more of the Karma tests running before proceeding here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, better safe than sorry. Will work on the karma tests now.

"ethereumjs-common": "^1.1.0",
"ethereumjs-util": "^6.0.0",
"fake-merkle-patricia-tree": "^1.0.1",
Expand All @@ -53,7 +54,6 @@
"browserify": "^16.2.3",
"coveralls": "^3.0.0",
"documentation": "^8.1.2",
"ethereumjs-blockchain": "^3.4.0",
"ethereumjs-testing": "git+https://github.com/ethereumjs/ethereumjs-testing.git#v1.2.7",
"ethereumjs-tx": "1.3.7",
"karma": "^4.0.1",
Expand Down
36 changes: 0 additions & 36 deletions tests/api/fakeBlockChain.js

This file was deleted.

4 changes: 1 addition & 3 deletions tests/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ const { setupVM } = require('./utils')
const { setupPreConditions } = require('../util')
const testData = require('./testdata.json')

tape('VM with fake blockchain', (t) => {
tape('VM with default blockchain', (t) => {
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')
st.ok(vm.blockchain.fake, 'it has fake blockchain by default')
st.end()
})

Expand Down Expand Up @@ -58,7 +57,6 @@ tape('VM with blockchain', (t) => {
t.test('should instantiate', (st) => {
const vm = setupVM()
st.deepEqual(vm.stateManager._trie.root, util.KECCAK256_RLP, 'it has default trie')
st.notOk(vm.stateManager.fake, 'it doesn\'t have fake blockchain')
st.end()
})

Expand Down