Skip to content

Commit

Permalink
Add --dist test option to run tests against dist folder build, switch…
Browse files Browse the repository at this point in the history
… package.json script cmds to use --dist option
  • Loading branch information
holgerd77 committed Mar 1, 2018
1 parent 8c186f4 commit 348f0f1
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@ Running the Blockchain tests:

`node ./tests/tester -b`

State tests and Blockchain tests can also be run against the ``dist`` folder (default: ``lib``):

`node ./tests/tester -b --dist`

State tests run significantly faster than Blockchain tests, so it is often a good choice to start fixing State tests.

#### Running Specific Tests
Expand Down
16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@
"dist"
],
"scripts": {
"coverage": "istanbul cover ./tests/tester.js -- -s",
"coverage": "npm run build:dist && istanbul cover ./tests/tester.js -- -s --dist",
"coveralls": "npm run coverage && coveralls <coverage/lcov.info",
"testVM": "node ./tests/tester -v",
"testState": "node ./tests/tester -s",
"testBlockchain": "node --stack-size=1500 ./tests/tester -b --excludeDir='GeneralStateTests'",
"testBlockchainGeneralStateTests": "node --stack-size=1500 ./tests/tester -b --dir='GeneralStateTests'",
"testBlockchainBlockGasLimit": "node --stack-size=1500 ./tests/tester -b --dir='bcBlockGasLimitTest'",
"testBlockchainValid": "node --stack-size=1500 ./tests/tester -b --dir='bcValidBlockTest'",
"testBlockchainTotalDifficulty": "node --stack-size=1500 ./tests/tester -b --dir='bcTotalDifficultyTest'",
"testState": "npm run build:dist && node ./tests/tester -s --dist",
"testBuildIntegrity": "node ./tests/tester -s --dist --test='stackOverflow'",
"testBlockchain": "npm run build:dist && node --stack-size=1500 ./tests/tester -b --dist --excludeDir='GeneralStateTests'",
"testBlockchainGeneralStateTests": "npm run build:dist && node --stack-size=1500 ./tests/tester -b --dist --dir='GeneralStateTests'",
"testBlockchainBlockGasLimit": "npm run build:dist && node --stack-size=1500 ./tests/tester -b --dist --dir='bcBlockGasLimitTest'",
"testBlockchainValid": "npm run build:dist && node --stack-size=1500 ./tests/tester -b --dist --dir='bcValidBlockTest'",
"testBlockchainTotalDifficulty": "npm run build:dist && node --stack-size=1500 ./tests/tester -b --dist --dir='bcTotalDifficultyTest'",
"test": "node ./tests/tester -a",
"lint": "standard",
"prepublishOnly": "npm run lint && npm run build:dist && npm run testBuildIntegrity",
"build:dist": "babel lib/ -d dist/"
},
"repository": {
Expand Down
7 changes: 6 additions & 1 deletion tests/BlockchainTestsRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const Trie = require('merkle-patricia-tree/secure')
const Block = require('ethereumjs-block')
const Blockchain = require('ethereumjs-blockchain')
const BlockHeader = require('ethereumjs-block/header.js')
const VM = require('../')
const Level = require('levelup')

var cacheDB = new Level('./.cachedb')
Expand All @@ -16,6 +15,12 @@ module.exports = function runBlockchainTest (options, testData, t, cb) {
var state = new Trie()
var blockchain = new Blockchain(blockchainDB)
blockchain.ethash.cacheDB = cacheDB
var VM
if (options.dist) {
VM = require('../dist/index.js')
} else {
VM = require('../lib/index.js')
}
var vm = new VM({
state: state,
blockchain: blockchain
Expand Down
7 changes: 6 additions & 1 deletion tests/GeneralStateTestsRunner.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const async = require('async')
const VM = require('../index.js')
const testUtil = require('./util')
const Trie = require('merkle-patricia-tree/secure')
const ethUtil = require('ethereumjs-util')
Expand Down Expand Up @@ -45,6 +44,12 @@ function runTestCase (options, testData, t, cb) {

async.series([
function (done) {
var VM
if (options.dist) {
VM = require('../dist/index.js')
} else {
VM = require('../lib/index.js')
}
vm = new VM({
state: state
})
Expand Down

0 comments on commit 348f0f1

Please sign in to comment.