Skip to content

Commit

Permalink
Merge pull request #325 from ethereumjs/block-2-support
Browse files Browse the repository at this point in the history
Add support for ethereumjs-block 2.x and ethereumjs-blockchain 3.2.x
  • Loading branch information
holgerd77 authored Aug 29, 2018
2 parents 0dff06f + ae76a0b commit 3431a07
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"async": "^2.1.2",
"async-eventemitter": "^0.2.2",
"ethereumjs-account": "^2.0.3",
"ethereumjs-block": "~1.7.0",
"ethereumjs-block": "~2.0.1",
"ethereumjs-common": "~0.4.0",
"ethereumjs-util": "^5.2.0",
"fake-merkle-patricia-tree": "^1.0.1",
Expand All @@ -50,7 +50,7 @@
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.6.1",
"coveralls": "^3.0.0",
"ethereumjs-blockchain": "~2.1.0",
"ethereumjs-blockchain": "~3.2.1",
"ethereumjs-testing": "git+https://github.com/ethereumjs/ethereumjs-testing.git#v1.1.1",
"ethereumjs-tx": "1.3.3",
"level": "^1.4.0",
Expand Down
15 changes: 11 additions & 4 deletions tests/BlockchainTestsRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ module.exports = function runBlockchainTest (options, testData, t, cb) {
db: require('memdown')
})
var state = new Trie()
var blockchain = new Blockchain(blockchainDB)
var blockchain = new Blockchain({
db: blockchainDB,
hardfork: options.forkConfig.toLowerCase()
})
blockchain.ethash.cacheDB = cacheDB
var VM
if (options.dist) {
Expand All @@ -26,7 +29,7 @@ module.exports = function runBlockchainTest (options, testData, t, cb) {
blockchain: blockchain,
hardfork: options.forkConfig.toLowerCase()
})
var genesisBlock = new Block()
var genesisBlock = new Block({ hardfork: options.forkConfig.toLowerCase() })

testData.homestead = true
if (testData.homestead) {
Expand All @@ -48,7 +51,9 @@ module.exports = function runBlockchainTest (options, testData, t, cb) {
},
function (done) {
// create and add genesis block
genesisBlock.header = new BlockHeader(formatBlockHeader(testData.genesisBlockHeader))
genesisBlock.header = new BlockHeader(formatBlockHeader(testData.genesisBlockHeader), {
hardfork: options.forkConfig.toLowerCase()
})
t.equal(state.root.toString('hex'), genesisBlock.header.stateRoot.toString('hex'), 'correct pre stateRoot')
if (testData.genesisRLP) {
t.equal(genesisBlock.serialize().toString('hex'), testData.genesisRLP.slice(2), 'correct genesis RLP')
Expand All @@ -60,7 +65,9 @@ module.exports = function runBlockchainTest (options, testData, t, cb) {
function (done) {
async.eachSeries(testData.blocks, function (raw, cb) {
try {
var block = new Block(Buffer.from(raw.rlp.slice(2), 'hex'))
var block = new Block(Buffer.from(raw.rlp.slice(2), 'hex'), {
hardfork: options.forkConfig.toLowerCase()
})
// forces the block into thinking they are homestead
if (testData.homestead) {
block.header.isHomestead = function () {
Expand Down

0 comments on commit 3431a07

Please sign in to comment.