Skip to content

Commit 55f70f4

Browse files
committed
Make clearer distinction between VM and test suite fork config alias, consolidate error prone fork alias lowercase modifications
1 parent a528918 commit 55f70f4

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

tests/BlockchainTestsRunner.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module.exports = function runBlockchainTest (options, testData, t, cb) {
2020
}
2121
var blockchain = new Blockchain({
2222
db: blockchainDB,
23-
hardfork: options.forkConfig.toLowerCase(),
23+
hardfork: options.forkConfigVM,
2424
validate: validate
2525
})
2626
if (validate) {
@@ -35,9 +35,9 @@ module.exports = function runBlockchainTest (options, testData, t, cb) {
3535
var vm = new VM({
3636
state: state,
3737
blockchain: blockchain,
38-
hardfork: options.forkConfig.toLowerCase()
38+
hardfork: options.forkConfigVM
3939
})
40-
var genesisBlock = new Block({ hardfork: options.forkConfig.toLowerCase() })
40+
var genesisBlock = new Block({ hardfork: options.forkConfigVM })
4141

4242
testData.homestead = true
4343
if (testData.homestead) {
@@ -60,7 +60,7 @@ module.exports = function runBlockchainTest (options, testData, t, cb) {
6060
function (done) {
6161
// create and add genesis block
6262
genesisBlock.header = new BlockHeader(formatBlockHeader(testData.genesisBlockHeader), {
63-
hardfork: options.forkConfig.toLowerCase()
63+
hardfork: options.forkConfigVM
6464
})
6565
t.equal(state.root.toString('hex'), genesisBlock.header.stateRoot.toString('hex'), 'correct pre stateRoot')
6666
if (testData.genesisRLP) {
@@ -74,7 +74,7 @@ module.exports = function runBlockchainTest (options, testData, t, cb) {
7474
async.eachSeries(testData.blocks, function (raw, cb) {
7575
try {
7676
var block = new Block(Buffer.from(raw.rlp.slice(2), 'hex'), {
77-
hardfork: options.forkConfig.toLowerCase()
77+
hardfork: options.forkConfigVM
7878
})
7979
// forces the block into thinking they are homestead
8080
if (testData.homestead) {

tests/GeneralStateTestsRunner.js

+8-10
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ const Trie = require('merkle-patricia-tree/secure')
44
const ethUtil = require('ethereumjs-util')
55
const Account = require('ethereumjs-account').default
66
const BN = ethUtil.BN
7-
const { getRequiredForkConfigAlias } = require('./util')
87

9-
function parseTestCases (forkConfig, testData, data, gasLimit, value) {
8+
function parseTestCases (forkConfigTestSuite, testData, data, gasLimit, value) {
109
let testCases = []
11-
if (testData['post'][forkConfig]) {
12-
testCases = testData['post'][forkConfig].map(testCase => {
10+
if (testData['post'][forkConfigTestSuite]) {
11+
testCases = testData['post'][forkConfigTestSuite].map(testCase => {
1312
let testIndexes = testCase['indexes']
1413
let tx = { ...testData.transaction }
1514
if (data !== undefined && testIndexes['data'] !== data) {
@@ -57,12 +56,12 @@ function runTestCase (options, testData, t, cb) {
5756
}
5857
vm = new VM({
5958
state: state,
60-
hardfork: options.forkConfig.toLowerCase()
59+
hardfork: options.forkConfigVM
6160
})
6261
testUtil.setupPreConditions(state, testData, done)
6362
},
6463
function (done) {
65-
var tx = testUtil.makeTx(testData.transaction, options.forkConfig.toLowerCase())
64+
var tx = testUtil.makeTx(testData.transaction, options.forkConfigVM)
6665
block = testUtil.makeBlockFromEnv(testData.env)
6766
tx._homestead = true
6867
tx.enableHomestead = true
@@ -146,19 +145,18 @@ function runTestCase (options, testData, t, cb) {
146145
}
147146

148147
module.exports = function runStateTest (options, testData, t, cb) {
149-
const forkConfig = getRequiredForkConfigAlias(options.forkConfig)
150148
try {
151-
const testCases = parseTestCases(forkConfig, testData, options.data, options.gasLimit, options.value)
149+
const testCases = parseTestCases(options.forkConfigTestSuite, testData, options.data, options.gasLimit, options.value)
152150
if (testCases.length > 0) {
153151
async.eachSeries(testCases,
154152
(testCase, done) => runTestCase(options, testCase, t, done),
155153
cb)
156154
} else {
157-
t.comment(`No ${forkConfig} post state defined, skip test`)
155+
t.comment(`No ${options.forkConfigTestSuite} post state defined, skip test`)
158156
cb()
159157
}
160158
} catch (e) {
161-
t.fail('error running test case for fork: ' + forkConfig)
159+
t.fail('error running test case for fork: ' + options.forkConfigTestSuite)
162160
console.log('error:', e)
163161
cb()
164162
}

tests/tester.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
const argv = require('minimist')(process.argv.slice(2))
44
const tape = require('tape')
55
const testing = require('ethereumjs-testing')
6-
const FORK_CONFIG = argv.fork || 'Istanbul'
76
const { getRequiredForkConfigAlias } = require('./util')
7+
const FORK_CONFIG = (argv.fork || 'Istanbul')
8+
const FORK_CONFIG_TEST_SUITE = getRequiredForkConfigAlias(FORK_CONFIG)
9+
// Istanbul -> istanbul, MuirGlacier -> muirGlacier
10+
const FORK_CONFIG_VM = FORK_CONFIG.charAt(0).toLowerCase() + FORK_CONFIG.substring(1)
811
// tests which should be fixed
912
const skipBroken = [
1013
'dynamicAccountOverwriteEmpty', // temporary till fixed (2019-01-30), skipped along constantinopleFix work time constraints
@@ -138,7 +141,7 @@ function runTests(name, runnerArgs, cb) {
138141
testGetterArgs.skipTests = getSkipTests(argv.skip, argv.runSkipped ? 'NONE' : 'ALL')
139142
testGetterArgs.runSkipped = getSkipTests(argv.runSkipped, 'NONE')
140143
testGetterArgs.skipVM = skipVM
141-
testGetterArgs.forkConfig = getRequiredForkConfigAlias(FORK_CONFIG)
144+
testGetterArgs.forkConfig = FORK_CONFIG_TEST_SUITE
142145
testGetterArgs.file = argv.file
143146
testGetterArgs.test = argv.test
144147
testGetterArgs.dir = argv.dir
@@ -147,7 +150,8 @@ function runTests(name, runnerArgs, cb) {
147150

148151
testGetterArgs.customStateTest = argv.customStateTest
149152

150-
runnerArgs.forkConfig = FORK_CONFIG
153+
runnerArgs.forkConfigVM = FORK_CONFIG_VM
154+
runnerArgs.forkConfigTestSuite = FORK_CONFIG_TEST_SUITE
151155
runnerArgs.jsontrace = argv.jsontrace
152156
runnerArgs.debug = argv.debug // for BlockchainTests
153157

0 commit comments

Comments
 (0)