Skip to content

Commit c14dbff

Browse files
authored
Merge pull request ethereumjs#130 from cdetrio/homestead-testing-update
testing update for homestead
2 parents b994149 + 8e37c52 commit c14dbff

File tree

11 files changed

+212
-149
lines changed

11 files changed

+212
-149
lines changed

.travis.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ os:
44

55
language: node_js
66
node_js:
7-
- "5"
8-
- "6"
7+
- "7"
98
addons:
109
apt:
1110
sources:
@@ -23,12 +22,12 @@ matrix:
2322
fast_finish: true
2423
include:
2524
- os: linux
26-
node_js: "6"
25+
node_js: "7"
26+
env: CXX=g++-4.8 TEST_SUITE=lint
27+
- os: linux
28+
node_js: "7"
2729
env: CXX=g++-4.8 TEST_SUITE=testVM
2830
- os: linux
29-
node_js: "6"
31+
node_js: "7"
3032
env: CXX=g++-4.8 TEST_SUITE=testBlockchain
31-
- os: linux
32-
node_js: "6"
33-
env: CXX=g++-4.8 TEST_SUITE=lint
3433
script: npm run $TEST_SUITE

README.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# SYNOPSIS
1+
# SYNOPSIS
22

33
[![NPM Package](https://img.shields.io/npm/v/ethereumjs-vm.svg?style=flat-square)](https://www.npmjs.org/package/ethereumjs-vm)
44
[![Build Status](https://img.shields.io/travis/ethereumjs/ethereumjs-vm.svg?branch=master&style=flat-square)](https://travis-ci.org/ethereumjs/ethereumjs-vm)
55
[![Gitter](https://img.shields.io/gitter/room/ethereum/ethereumjs-lib.svg?style=flat-square)](https://gitter.im/ethereum/ethereumjs-lib) or #ethereumjs on freenode
66

7-
[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)
7+
[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)
88

99
Implements Ethereum's VM in JS
1010

@@ -23,7 +23,7 @@ code = new Buffer(code, 'hex')
2323

2424
vm.runCode({
2525
code: code,
26-
gasLimit: new Buffer('ffffffff', 'hex')
26+
gasLimit: new Buffer('ffffffff', 'hex')
2727
}, function(err, results){
2828
console.log('returned: ' + results.return.toString('hex'));
2929
})
@@ -101,7 +101,7 @@ Runs EVM code
101101
- `opts.caller` - The address that ran this code. The address should be a `Buffer` of 20bits. Defaults to `0`
102102
- `cb` - The callback. It is given two arguments, an `error` string containing an error that may have happened or `null` and a `results` object with the following properties
103103
- `gas` - the amount of gas left as a `bignum`
104-
- `gasUsed` - the amount of gas as a `bignum` the code used to run.
104+
- `gasUsed` - the amount of gas as a `bignum` the code used to run.
105105
- `gasRefund` - a `Bignum` containing the amount of gas to refund from deleting storage values
106106
- `suicides` - an `Object` with keys for accounts that have suicided and values for balance transfer recipient accounts.
107107
- `logs` - an `Array` of logs that the contract emitted.
@@ -136,18 +136,18 @@ vm.generateGenesis(genesisData, function(){
136136
### `events`
137137
All events are instances of [async-eventemmiter](https://www.npmjs.com/package/async-eventemitter). If an event handler has an arity of 2 the VM will pause until the callback is called
138138

139-
#### `step`
139+
#### `step`
140140
The `step` event is given an `Object` and callback. The `Object` has the following properties.
141141
- `pc` - a `Number` representing the program counter
142142
- `opcode` - the next opcode to be ran
143143
- `gas` - a `bignum` standing for the amount of gasLeft
144-
- `stack` - an `Array` of `Buffers` containing the stack.
144+
- `stack` - an `Array` of `Buffers` containing the stack.
145145
- `storageTrie` - the storage [trie](https://github.com/wanderer/merkle-patricia-tree) for the account
146146
- `account` - the [`Account`](https://github.com/ethereum/ethereumjs-account) which owns the code running.
147147
- `address` - the address of the `account`
148148
- `depth` - the current number of calls deep the contract is
149149
- `memory` - the memory of the VM as a `buffer`
150-
- `cache` - The account cache. Contains all the accounts loaded from the trie. It is an instance of [functional red black tree](https://www.npmjs.com/package/functional-red-black-tree)
150+
- `cache` - The account cache. Contains all the accounts loaded from the trie. It is an instance of [functional red black tree](https://www.npmjs.com/package/functional-red-black-tree)
151151

152152
#### `beforeBlock`
153153
Emits the block that is about to be processed.
@@ -164,11 +164,17 @@ Emits the result of the transaction.
164164
# TESTING
165165
`npm test`
166166
if you want to just run the Blockchain tests run
167-
`./test/tester -b`
167+
`node ./tests/tester -b`
168168
if you want to just run the VM tests run
169-
`./test/tester -v`
169+
`node ./tests/tester -v`
170170
if you want to just run the State tests run
171-
`./test/tester -s`
171+
`node ./tests/tester -s`
172+
173+
To run the all the tests in a file:
174+
`node ./tests/tester -b --file='randomStatetest303'`
175+
176+
or to run a specific test case:
177+
`node ./tests/tester -v --test='log0_nonEmptyMem_logMemSize1_logMemStart31'``
172178

173179
# Internal Structure
174180
The VM processes state changes at many levels.

circle.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
machine:
22
node:
3-
version: 6.3.1
3+
version: 7.1.0
44
dependencies:
55
pre:
66
- "npm rebuild"
77
test:
88
override:
9-
- case $CIRCLE_NODE_INDEX in 0) npm run testState ;; 1) npm run testVM ;; 2) npm run testBlockchain ;; 3) npm run lint ;; esac:
9+
- case $CIRCLE_NODE_INDEX in 0) npm run lint ;; 1) npm run testVM ;; 2) npm run testState ;; 3) npm run testBlockchain ;; esac:
1010
parallel: true

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@
3434
]
3535
},
3636
"scripts": {
37-
"testVM": "./tests/tester -v",
38-
"testState": "./tests/tester -s",
39-
"testBlockchain": "./tests/tester -b",
37+
"testVM": "node --harmony ./tests/tester -v",
38+
"testState": "node --harmony ./tests/tester -s",
39+
"testBlockchain": "node --harmony ./tests/tester -b",
4040
"lint": "standard",
41-
"test": "./tests/tester -a"
41+
"test": "node --harmony ./tests/tester -a"
4242
},
4343
"repository": {
4444
"type": "git",

tests/blockchainRunner.js renamed to tests/BlockchainTestsRunner.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ module.exports = function runBlockchainTest (options, testData, t, cb) {
1818
blockchain.ethash.cacheDB = cacheDB
1919
var vm = new VM({
2020
state: state,
21-
blockchain: blockchain
21+
blockchain: blockchain,
22+
enableHomestead: true
2223
})
2324
var genesisBlock = new Block()
2425

26+
testData.homestead = true
2527
if (testData.homestead) {
2628
vm.on('beforeTx', function (tx) {
2729
tx._homestead = true
@@ -82,9 +84,20 @@ module.exports = function runBlockchainTest (options, testData, t, cb) {
8284
},
8385
function getHead (done) {
8486
vm.blockchain.getHead(function (err, block) {
87+
if (testData.lastblockhash.substr(0,2) === '0x') {
88+
// fix for BlockchainTests/GeneralStateTests/stRandom/*
89+
testData.lastblockhash = testData.lastblockhash.substr(2)
90+
}
8591
t.equal(block.hash().toString('hex'), testData.lastblockhash, 'last block hash')
86-
// make sure the state is set beofore checking post conditions
87-
state.root = block.header.stateRoot
92+
// if the test fails, then block.header is the preState because
93+
// vm.runBlock has a check that prevents the actual postState from being
94+
// imported if it is not equal to the expected postState. it is useful
95+
// for debugging to skip this, so that verifyPostConditions will compare
96+
// testData.postState to the actual postState, rather than to the preState.
97+
if (!options.debugging) {
98+
// make sure the state is set before checking post conditions
99+
state.root = block.header.stateRoot
100+
}
88101
done(err)
89102
})
90103
},
File renamed without changes.
File renamed without changes.

tests/genesishashes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const genesisData = require('ethereumjs-testing').tests.basicTests.genesishashestest
1+
const genesisData = require('ethereumjs-testing').getSingleFile('BasicTests/genesishashestest.json')
22
const tape = require('tape')
33
const VM = require('../')
44

tests/tester

Lines changed: 0 additions & 96 deletions
This file was deleted.

0 commit comments

Comments
 (0)