Skip to content

Commit

Permalink
Merge pull request #526 from ethereumjs/pass-common-statemanager-copy
Browse files Browse the repository at this point in the history
Pass the Common object when copying a StateManager
  • Loading branch information
alcuadrado authored May 28, 2019
2 parents 2e2e509 + 5c06175 commit 176058b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/state/stateManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default class StateManager {
* @method copy
*/
copy(): StateManager {
return new StateManager({ trie: this._trie.copy() })
return new StateManager({ trie: this._trie.copy(), common: this._common })
}

/**
Expand Down
16 changes: 16 additions & 0 deletions tests/api/state/stateManager.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const promisify = require('util.promisify')
const tape = require('tape')
const util = require('ethereumjs-util')
const Common = require('ethereumjs-common').default
const { StateManager } = require('../../../dist/state')
const { createAccount } = require('../utils')

Expand Down Expand Up @@ -160,4 +161,19 @@ tape('StateManager', (t) => {
st.end()
})
})

t.test('should pass Common object when copying the state manager', st => {
const stateManager = new StateManager({
common: new Common('goerli', 'byzantium')
})

st.equal(stateManager._common.chainName(), 'goerli')
st.equal(stateManager._common.hardfork(), 'byzantium')

const stateManagerCopy = stateManager.copy()
st.equal(stateManagerCopy._common.chainName(), 'goerli')
st.equal(stateManagerCopy._common.hardfork(), 'byzantium')

st.end()
})
})

0 comments on commit 176058b

Please sign in to comment.