Merge pull request #1211 from ethereum/improve_remix_sim2

implement more methods in remix-sim
pull/5370/head
yann300 5 years ago committed by GitHub
commit ca5de0c3ff
  1. 29
      remix-lib/src/execution/execution-context.js
  2. 49
      remix-lib/src/execution/txRunner.js
  3. 1
      remix-lib/src/web3Provider/web3VmProvider.js
  4. 29
      remix-simulator/README.md
  5. 27
      remix-simulator/src/genesis.js
  6. 109
      remix-simulator/src/methods/blocks.js
  7. 17
      remix-simulator/src/methods/misc.js
  8. 157
      remix-simulator/src/methods/transactions.js
  9. 4
      remix-simulator/src/provider.js
  10. 20
      remix-simulator/test/blocks.js
  11. 1
      remix-tests/src/testRunner.ts
  12. 6
      remix-tests/tests/testRunner.ts

@ -67,6 +67,7 @@ function createVm (hardfork) {
stateManager: stateManager,
hardfork: hardfork
})
vm.blockchain.validate = false
var web3vm = new Web3VMProvider()
web3vm.setVM(vm)
return { vm, web3vm, stateManager }
@ -91,6 +92,8 @@ function ExecutionContext () {
this.blockGasLimitDefault = 4300000
this.blockGasLimit = this.blockGasLimitDefault
this.customNetWorks = {}
this.blocks = {}
this.txs = {}
this.init = function (config) {
if (config.get('settings/always-use-vm')) {
@ -217,6 +220,20 @@ function ExecutionContext () {
}
}
this.checkpointAndCommit = function (cb, checkpointCount) {
// due to issue https://github.com/ethereumjs/ethereumjs-vm/issues/567
if (this.vm().stateManager._checkpointCount > (checkpointCount || 0)) {
return this.vm().stateManager.commit(() => {
cb()
})
}
this.vm().stateManager.checkpoint(() => {
this.vm().stateManager.commit(() => {
cb()
})
})
}
this.currentblockGasLimit = function () {
return this.blockGasLimit
}
@ -274,6 +291,18 @@ function ExecutionContext () {
return transactionDetailsLinks[network] + hash
}
}
this.addBlock = function (block) {
let blockNumber = '0x' + block.header.number.toString('hex')
blockNumber = web3.toHex(web3.toBigNumber(blockNumber))
self.blocks['0x' + block.hash().toString('hex')] = block
self.blocks[blockNumber] = block
}
this.trackTx = function (tx, block) {
self.txs[tx] = block
}
}
var transactionDetailsLinks = {

@ -13,12 +13,14 @@ class TxRunner {
this.blockNumber = 0
this.runAsync = true
if (executionContext.isVM()) {
this.blockNumber = 1150000 // The VM is running in Homestead mode, which started at this block.
// this.blockNumber = 1150000 // The VM is running in Homestead mode, which started at this block.
this.blockNumber = 2 // The VM is running in Homestead mode, which started at this block.
this.runAsync = false // We have to run like this cause the VM Event Manager does not support running multiple txs at the same time.
}
this.pendingTxs = {}
this.vmaccounts = vmaccounts
this.queusTxs = []
this.blocks = []
}
rawRun (args, confirmationCb, gasEstimationForceSend, promptCb, cb) {
@ -98,19 +100,20 @@ class TxRunner {
if (!account) {
return callback('Invalid account selected')
}
var tx = new EthJSTX({
timestamp: timestamp,
nonce: new BN(account.nonce++),
gasPrice: new BN(1),
gasLimit: new BN(gasLimit, 10),
gasLimit: gasLimit,
to: to,
value: new BN(value, 10),
data: Buffer.from(data.slice(2), 'hex')
})
tx.sign(account.privateKey)
const coinbases = [ '0x0e9281e9c6a0808672eaba6bd1220e144c9bb07a', '0x8945a1288dc78a6d8952a92c77aee6730b414778', '0x94d76e24f818426ae84aa404140e8d5f60e10e7e' ]
const difficulties = [ new BN('69762765929000', 10), new BN('70762765929000', 10), new BN('71762765929000', 10) ]
const coinbases = ['0x0e9281e9c6a0808672eaba6bd1220e144c9bb07a', '0x8945a1288dc78a6d8952a92c77aee6730b414778', '0x94d76e24f818426ae84aa404140e8d5f60e10e7e']
const difficulties = [new BN('69762765929000', 10), new BN('70762765929000', 10), new BN('71762765929000', 10)]
var block = new EthJSBlock({
header: {
timestamp: timestamp || (new Date().getTime() / 1000 | 0),
@ -119,28 +122,38 @@ class TxRunner {
difficulty: difficulties[self.blockNumber % difficulties.length],
gasLimit: new BN(gasLimit, 10).imuln(2)
},
transactions: [],
transactions: [tx],
uncleHeaders: []
})
if (!useCall) {
++self.blockNumber
} else {
executionContext.vm().stateManager.checkpoint(() => {})
executionContext.vm().stateManager.checkpoint(() => { })
}
executionContext.vm().runTx({block: block, tx: tx, skipBalance: true, skipNonce: true}, function (err, result) {
if (useCall) {
executionContext.vm().stateManager.revert(function () {})
}
err = err ? err.message : err
if (result) {
result.status = '0x' + result.vm.exception.toString(16)
}
callback(err, {
result: result,
transactionHash: ethJSUtil.bufferToHex(Buffer.from(tx.hash()))
executionContext.checkpointAndCommit(() => {
executionContext.vm().runBlock({ block: block, generate: true, skipBlockValidation: true, skipBalance: false }, function (err, results) {
err = err ? err.message : err
if (err) {
return callback(err)
}
let result = results.results[0]
if (useCall) {
executionContext.vm().stateManager.revert(function () { })
}
if (result) {
result.status = '0x' + result.vm.exception.toString(16)
}
executionContext.addBlock(block)
executionContext.trackTx('0x' + tx.hash().toString('hex'), block)
callback(err, {
result: result,
transactionHash: ethJSUtil.bufferToHex(Buffer.from(tx.hash()))
})
})
})
}, 1)
}
runInNode (from, to, data, value, gasLimit, useCall, confirmCb, gasEstimationForceSend, promptCb, callback) {

@ -40,6 +40,7 @@ function web3VmProvider () {
this.toWei = function () { return self.web3.toWei.apply(self.web3, arguments) }
this.toBigNumber = function () { return self.web3.toBigNumber.apply(self.web3, arguments) }
this.isAddress = function () { return self.web3.isAddress.apply(self.web3, arguments) }
this.utils = Web3.utils || []
}
web3VmProvider.prototype.setVM = function (vm) {

@ -17,29 +17,29 @@ Implemented:
* [X] eth_blockNumber
* [X] eth_getBalance
* [_] eth_getStorageAt
* [~] eth_getTransactionCount
* [_] eth_getBlockTransactionCountByHash
* [_] eth_getBlockTransactionCountByNumber
* [_] eth_getUncleCountByBlockHash
* [_] eth_getUncleCountByBlockNumber
* [X] eth_getTransactionCount
* [X] eth_getBlockTransactionCountByHash
* [X] eth_getBlockTransactionCountByNumber
* [~] eth_getUncleCountByBlockHash
* [~] eth_getUncleCountByBlockNumber
* [X] eth_getCode
* [~] eth_sign
* [X] eth_sendTransaction
* [_] eth_sendRawTransaction
* [X] eth_call
* [~] eth_estimateGas
* [~] eth_getBlockByHash
* [~] eth_getBlockByNumber
* [~] eth_getTransactionByHash
* [_] eth_getTransactionByBlockHashAndIndex
* [_] eth_getTransactionByBlockNumberAndIndex
* [~] eth_getTransactionReceipt
* [X] eth_getBlockByHash
* [X] eth_getBlockByNumber
* [X] eth_getTransactionByHash
* [X] eth_getTransactionByBlockHashAndIndex
* [X] eth_getTransactionByBlockNumberAndIndex
* [X] eth_getTransactionReceipt
* [_] eth_getUncleByBlockHashAndIndex
* [_] eth_getUncleByBlockNumberAndIndex
* [X] eth_getCompilers (DEPRECATED)
* [_] eth_compileSolidity (DEPRECATED)
* [_] eth_compileLLL (DEPRECATED)
* [_] eth_compileSerpent (DEPRECATED)
* [X] eth_compileSolidity (DEPRECATED)
* [X] eth_compileLLL (DEPRECATED)
* [X] eth_compileSerpent (DEPRECATED)
* [_] eth_newFilter
* [_] eth_newBlockFilter
* [_] eth_newPendingTransactionFilter
@ -81,4 +81,3 @@ Implemented:
* [_] rpc_modules
* [_] web3_clientVersion
* [_] web3_sha3

@ -0,0 +1,27 @@
var EthJSBlock = require('ethereumjs-block')
var RemixLib = require('remix-lib')
var executionContext = RemixLib.execution.executionContext
var ethJSUtil = require('ethereumjs-util')
var BN = ethJSUtil.BN
function generateBlock () {
var block = new EthJSBlock({
header: {
timestamp: (new Date().getTime() / 1000 | 0),
number: 1,
coinbase: '0x0e9281e9c6a0808672eaba6bd1220e144c9bb07a',
difficulty: (new BN('69762765929000', 10)),
gasLimit: new BN('8000000').imuln(1)
},
transactions: [],
uncleHeaders: []
})
executionContext.checkpointAndCommit(() => {
executionContext.vm().runBlock({ block: block, generate: true, skipBlockValidation: true, skipBalance: false }, function () {
executionContext.addBlock(block)
})
})
}
module.exports = generateBlock

@ -1,4 +1,5 @@
var Web3 = require('web3')
var RemixLib = require('remix-lib')
var executionContext = RemixLib.execution.executionContext
var Blocks = function (_options) {
const options = _options || {}
@ -12,59 +13,75 @@ Blocks.prototype.methods = function () {
eth_gasPrice: this.eth_gasPrice.bind(this),
eth_coinbase: this.eth_coinbase.bind(this),
eth_blockNumber: this.eth_blockNumber.bind(this),
eth_getBlockByHash: this.eth_getBlockByHash.bind(this)
eth_getBlockByHash: this.eth_getBlockByHash.bind(this),
eth_getBlockTransactionCountByHash: this.eth_getBlockTransactionCountByHash.bind(this),
eth_getBlockTransactionCountByNumber: this.eth_getBlockTransactionCountByNumber.bind(this),
eth_getUncleCountByBlockHash: this.eth_getUncleCountByBlockHash.bind(this),
eth_getUncleCountByBlockNumber: this.eth_getUncleCountByBlockNumber.bind(this)
}
}
Blocks.prototype.eth_getBlockByNumber = function (payload, cb) {
var block = executionContext.blocks[payload.params[0]]
if (!block) {
return cb(new Error('block not found'))
}
let b = {
'difficulty': '0x0',
'extraData': '0x',
'gasLimit': '0x7a1200',
'gasUsed': '0x0',
'hash': '0xdb731f3622ef37b4da8db36903de029220dba74c41185f8429f916058b86559f',
'logsBloom': '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
'miner': this.coinbase,
'mixHash': '0x0000000000000000000000000000000000000000000000000000000000000000',
'nonce': '0x0000000000000042',
'number': Web3.utils.toHex(this.blockNumber),
'parentHash': '0x0000000000000000000000000000000000000000000000000000000000000000',
'receiptsRoot': '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421',
'number': toHex(block.header.number),
'hash': toHex(block.hash()),
'parentHash': toHex(block.header.parentHash),
'nonce': toHex(block.header.nonce),
'sha3Uncles': '0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347',
'size': '0x1f8',
'stateRoot': '0xb7917653f92e62394d2207d0f39a1320ff1cb93d1cee80d3c492627e00b219ff',
'timestamp': '0x0',
'totalDifficulty': '0x0',
'transactions': [],
'logsBloom': '0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331',
'transactionsRoot': '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421',
'stateRoot': toHex(block.header.stateRoot),
'miner': this.coinbase,
'difficulty': toHex(block.header.difficulty),
'totalDifficulty': toHex(block.header.totalDifficulty),
'extraData': toHex(block.header.extraData),
'size': '0x027f07', // 163591
'gasLimit': toHex(block.header.gasLimit),
'gasUsed': toHex(block.header.gasUsed),
'timestamp': toHex(block.header.timestamp),
'transactions': block.transactions.map((t) => '0x' + t.hash().toString('hex')),
'uncles': []
}
cb(null, b)
}
function toHex (value) {
if (!value) return '0x0'
let v = value.toString('hex')
return ((v === '0x' || v === '') ? '0x0' : ('0x' + v))
}
Blocks.prototype.eth_getBlockByHash = function (payload, cb) {
var block = executionContext.blocks[payload.params[0]]
let b = {
'difficulty': '0x0',
'extraData': '0x',
'gasLimit': '0x7a1200',
'gasUsed': '0x0',
'hash': '0xdb731f3622ef37b4da8db36903de029220dba74c41185f8429f916058b86559f',
'logsBloom': '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
'miner': this.coinbase,
'mixHash': '0x0000000000000000000000000000000000000000000000000000000000000000',
'nonce': '0x0000000000000042',
'number': Web3.utils.toHex(this.blockNumber),
'parentHash': '0x0000000000000000000000000000000000000000000000000000000000000000',
'receiptsRoot': '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421',
'number': toHex(block.header.number),
'hash': toHex(block.hash()),
'parentHash': toHex(block.header.parentHash),
'nonce': toHex(block.header.nonce),
'sha3Uncles': '0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347',
'size': '0x1f8',
'stateRoot': '0xb7917653f92e62394d2207d0f39a1320ff1cb93d1cee80d3c492627e00b219ff',
'timestamp': '0x0',
'totalDifficulty': '0x0',
'transactions': [],
'logsBloom': '0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331',
'transactionsRoot': '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421',
'stateRoot': toHex(block.header.stateRoot),
'miner': this.coinbase,
'difficulty': toHex(block.header.difficulty),
'totalDifficulty': toHex(block.header.totalDifficulty),
'extraData': toHex(block.header.extraData),
'size': '0x027f07', // 163591
'gasLimit': toHex(block.header.gasLimit),
'gasUsed': toHex(block.header.gasUsed),
'timestamp': toHex(block.header.timestamp),
'transactions': block.transactions.map((t) => '0x' + t.hash().toString('hex')),
'uncles': []
}
cb(null, b)
}
@ -80,4 +97,24 @@ Blocks.prototype.eth_blockNumber = function (payload, cb) {
cb(null, this.blockNumber)
}
Blocks.prototype.eth_getBlockTransactionCountByHash = function (payload, cb) {
var block = executionContext.blocks[payload.params[0]]
cb(null, block.transactions.length)
}
Blocks.prototype.eth_getBlockTransactionCountByNumber = function (payload, cb) {
var block = executionContext.blocks[payload.params[0]]
cb(null, block.transactions.length)
}
Blocks.prototype.eth_getUncleCountByBlockHash = function (payload, cb) {
cb(null, 0)
}
Blocks.prototype.eth_getUncleCountByBlockNumber = function (payload, cb) {
cb(null, 0)
}
module.exports = Blocks

@ -12,7 +12,10 @@ Misc.prototype.methods = function () {
eth_mining: this.eth_mining.bind(this),
eth_hashrate: this.eth_hashrate.bind(this),
web3_sha3: this.web3_sha3.bind(this),
eth_getCompilers: this.eth_getCompilers.bind(this)
eth_getCompilers: this.eth_getCompilers.bind(this),
eth_compileSolidity: this.eth_compileSolidity.bind(this),
eth_compileLLL: this.eth_compileLLL.bind(this),
eth_compileSerpent: this.eth_compileSerpent.bind(this)
}
}
@ -46,4 +49,16 @@ Misc.prototype.eth_getCompilers = function (payload, cb) {
cb(null, [])
}
Misc.prototype.eth_compileSolidity = function (payload, cb) {
cb(null, 'unsupported')
}
Misc.prototype.eth_compileLLL = function (payload, cb) {
cb(null, 'unsupported')
}
Misc.prototype.eth_compileSerpent = function (payload, cb) {
cb(null, 'unsupported')
}
module.exports = Misc

@ -1,22 +1,10 @@
var Web3 = require('web3')
var RemixLib = require('remix-lib')
var executionContext = RemixLib.execution.executionContext
var ethJSUtil = require('ethereumjs-util')
var processTx = require('./txProcess.js')
var BN = ethJSUtil.BN
function hexConvert (ints) {
var ret = '0x'
for (var i = 0; i < ints.length; i++) {
var h = ints[i]
if (h) {
ret += (h <= 0xf ? '0' : '') + h.toString(16)
} else {
ret += '00'
}
}
return ret
}
var Transactions = function (accounts) {
this.accounts = accounts
}
@ -29,7 +17,9 @@ Transactions.prototype.methods = function () {
eth_call: this.eth_call.bind(this),
eth_estimateGas: this.eth_estimateGas.bind(this),
eth_getTransactionCount: this.eth_getTransactionCount.bind(this),
eth_getTransactionByHash: this.eth_getTransactionByHash.bind(this)
eth_getTransactionByHash: this.eth_getTransactionByHash.bind(this),
eth_getTransactionByBlockHashAndIndex: this.eth_getTransactionByBlockHashAndIndex.bind(this),
eth_getTransactionByBlockNumberAndIndex: this.eth_getTransactionByBlockNumberAndIndex.bind(this)
}
}
@ -43,13 +33,15 @@ Transactions.prototype.eth_getTransactionReceipt = function (payload, cb) {
return cb(error)
}
var txBlock = executionContext.txs[receipt.hash]
var r = {
'transactionHash': receipt.hash,
'transactionIndex': '0x00',
'blockHash': '0x766d18646a06cf74faeabf38597314f84a82c3851859d9da9d94fc8d037269e5',
'blockNumber': '0x06',
'gasUsed': '0x06345f',
'cumulativeGasUsed': '0x06345f',
'blockHash': '0x' + txBlock.hash().toString('hex'),
'blockNumber': '0x' + txBlock.header.number.toString('hex'),
'gasUsed': Web3.utils.toHex(receipt.gas),
'cumulativeGasUsed': Web3.utils.toHex(receipt.gas),
'contractAddress': receipt.contractAddress,
'logs': receipt.logs,
'status': receipt.status
@ -66,10 +58,12 @@ Transactions.prototype.eth_estimateGas = function (payload, cb) {
Transactions.prototype.eth_getCode = function (payload, cb) {
let address = payload.params[0]
const account = ethJSUtil.toBuffer(address)
executionContext.vm().stateManager.getContractCode(account, (error, result) => {
cb(error, hexConvert(result))
executionContext.web3().eth.getCode(address, (error, result) => {
if (error) {
console.dir('error getting code')
console.dir(error)
}
cb(error, result)
})
}
@ -97,23 +91,120 @@ Transactions.prototype.eth_getTransactionByHash = function (payload, cb) {
return cb(error)
}
// executionContext.web3().eth.getBlock(receipt.hash).then((block) => {
const r = {
var txBlock = executionContext.txs[receipt.transactionHash]
// TODO: params to add later
let r = {
'blockHash': '0x' + txBlock.hash().toString('hex'),
'blockNumber': '0x' + txBlock.header.number.toString('hex'),
'from': receipt.from,
'gas': Web3.utils.toHex(receipt.gas),
// 'gasPrice': '2000000000000', // 0x123
'gasPrice': '0x4a817c800', // 20000000000
'hash': receipt.transactionHash,
// "nonce": 2,
'blockHash': receipt.hash,
// 'blockNumber': block.number,
'input': receipt.input,
// "nonce": 2, // 0x15
// "transactionIndex": 0,
'value': receipt.value
// "value":"0xf3dbb76162000" // 4290000000000000
// "v": "0x25", // 37
// "r": "0x1b5e176d927f8e9ab405058b2d2457392da3e20f328b16ddabcebc33eaac5fea",
// "s": "0x4ba69724e8f69de52f0125ad8b3c5c2cef33019bac3249e2c0a2192766d1721c"
}
if (receipt.to) {
r.to = receipt.to
}
if (r.value === '0x') {
r.value = '0x0'
}
cb(null, r)
})
}
Transactions.prototype.eth_getTransactionByBlockHashAndIndex = function (payload, cb) {
const txIndex = payload.params[1]
var txBlock = executionContext.blocks[payload.params[0]]
const txHash = '0x' + txBlock.transactions[Web3.utils.toDecimal(txIndex)].hash().toString('hex')
executionContext.web3().eth.getTransactionReceipt(txHash, (error, receipt) => {
if (error) {
return cb(error)
}
// TODO: params to add later
let r = {
'blockHash': '0x' + txBlock.hash().toString('hex'),
'blockNumber': '0x' + txBlock.header.number.toString('hex'),
'from': receipt.from,
'to': receipt.to,
'value': receipt.value,
'gas': receipt.gas,
'gasPrice': '2000000000000',
'input': receipt.input
'gas': Web3.utils.toHex(receipt.gas),
// 'gasPrice': '2000000000000', // 0x123
'gasPrice': '0x4a817c800', // 20000000000
'hash': receipt.transactionHash,
'input': receipt.input,
// "nonce": 2, // 0x15
// "transactionIndex": 0,
'value': receipt.value
// "value":"0xf3dbb76162000" // 4290000000000000
// "v": "0x25", // 37
// "r": "0x1b5e176d927f8e9ab405058b2d2457392da3e20f328b16ddabcebc33eaac5fea",
// "s": "0x4ba69724e8f69de52f0125ad8b3c5c2cef33019bac3249e2c0a2192766d1721c"
}
if (receipt.to) {
r.to = receipt.to
}
if (r.value === '0x') {
r.value = '0x0'
}
cb(null, r)
})
}
Transactions.prototype.eth_getTransactionByBlockNumberAndIndex = function (payload, cb) {
const txIndex = payload.params[1]
var txBlock = executionContext.blocks[payload.params[0]]
const txHash = '0x' + txBlock.transactions[Web3.utils.toDecimal(txIndex)].hash().toString('hex')
executionContext.web3().eth.getTransactionReceipt(txHash, (error, receipt) => {
if (error) {
return cb(error)
}
// TODO: params to add later
let r = {
'blockHash': '0x' + txBlock.hash().toString('hex'),
'blockNumber': '0x' + txBlock.header.number.toString('hex'),
'from': receipt.from,
'gas': Web3.utils.toHex(receipt.gas),
// 'gasPrice': '2000000000000', // 0x123
'gasPrice': '0x4a817c800', // 20000000000
'hash': receipt.transactionHash,
'input': receipt.input,
// "nonce": 2, // 0x15
// "transactionIndex": 0,
'value': receipt.value
// "value":"0xf3dbb76162000" // 4290000000000000
// "v": "0x25", // 37
// "r": "0x1b5e176d927f8e9ab405058b2d2457392da3e20f328b16ddabcebc33eaac5fea",
// "s": "0x4ba69724e8f69de52f0125ad8b3c5c2cef33019bac3249e2c0a2192766d1721c"
}
if (receipt.to) {
r.to = receipt.to
}
if (r.value === '0x') {
r.value = '0x0'
}
cb(null, r)
// })
})
}

@ -8,6 +8,8 @@ const Net = require('./methods/net.js')
const Transactions = require('./methods/transactions.js')
const Whisper = require('./methods/whisper.js')
const generateBlock = require('./genesis.js')
var Provider = function (options) {
this.Accounts = new Accounts()
@ -18,6 +20,8 @@ var Provider = function (options) {
this.methods = merge(this.methods, (new Net()).methods())
this.methods = merge(this.methods, (new Transactions(this.Accounts.accounts)).methods())
this.methods = merge(this.methods, (new Whisper()).methods())
generateBlock()
}
Provider.prototype.sendAsync = function (payload, callback) {

@ -16,22 +16,20 @@ describe('blocks', function () {
let block = await web3.eth.getBlock(1)
let expectedBlock = {
difficulty: '0',
extraData: '0x',
difficulty: '69762765929000',
extraData: '0x0',
gasLimit: 8000000,
gasUsed: 0,
hash: '0xdb731f3622ef37b4da8db36903de029220dba74c41185f8429f916058b86559f',
logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
hash: block.hash.toString('hex'),
logsBloom: '0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331',
miner: '0x0000000000000000000000000000000000000001',
mixHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
nonce: '0x0000000000000042',
number: 0,
nonce: '0x0000000000000000',
number: 1,
parentHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
receiptsRoot: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421',
sha3Uncles: '0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347',
size: 504,
stateRoot: '0xb7917653f92e62394d2207d0f39a1320ff1cb93d1cee80d3c492627e00b219ff',
timestamp: 0,
size: 163591,
stateRoot: '0xa633ca0e8f0ae4e86d4d572b048ea93d84eb4b11e2c988b48cb3a5f6f10b3c68',
timestamp: block.timestamp,
totalDifficulty: '0',
transactions: [],
transactionsRoot: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421',

@ -76,6 +76,7 @@ export function runTest (testName, testObject: any, contractDetails: any, opts:
value: testName,
filename: testObject.filename
}
testCallback(undefined, resp)
async.eachOfLimit(runList, 1, function (func, index, next) {
let sender

@ -9,15 +9,18 @@ import { deployAll } from '../dist/deployer'
import { runTest } from '../dist/index'
import { ResultsInterface, TestCbInterface, ResultCbInterface } from '../dist/index'
var provider = new Provider()
function compileAndDeploy(filename: string, callback: Function) {
let web3: Web3 = new Web3()
web3.setProvider(new Provider())
web3.setProvider(provider)
let compilationData: object
let accounts: string[]
async.waterfall([
function getAccountList(next: Function): void {
web3.eth.getAccounts((_err: Error | null | undefined, _accounts: string[]) => {
accounts = _accounts
web3.eth.defaultAccount = accounts[0]
next(_err)
})
},
@ -93,6 +96,7 @@ describe('testRunner', () => {
results = _results
done()
}
runTest('MyTest', contracts.MyTest, compilationData[filename]['MyTest'], { accounts }, testCallback, resultsCallback)
})
})

Loading…
Cancel
Save