Commit 59095b0502d442d94aafa6267d3d4e3cb01d7ba6
Tests: use two-level hierarchy for block level values
Alex Beregszaszi committed on 8/23/2016, 1:18:41 AMParent: 3a9b5f4c35935e1878a5aa201e5d3b00844c7aac
Files changed
testEnvironment.js | changed |
tests/interface/coinbase.json | changed |
testEnvironment.js | ||
---|---|---|
@@ -1,8 +1,9 @@ | ||
1 | 1 | const Environment = require('./environment.js') |
2 | 2 | const U256 = require('./u256.js') |
3 | 3 | const Address = require('./address.js') |
4 | 4 | const Block = require('./block.js') |
5 | +const ethUtil = require('ethereumjs-util') | |
5 | 6 | |
6 | 7 | module.exports = class TestEnvironment extends Environment { |
7 | 8 | constructor (data) { |
8 | 9 | super() |
@@ -49,31 +50,33 @@ | ||
49 | 50 | if (data.gasLeft) { |
50 | 51 | self.gasLeft = data.gasLeft |
51 | 52 | } |
52 | 53 | |
53 | - let block = {} | |
54 | + if (data.block) { | |
55 | + let block = {} | |
54 | 56 | |
55 | - if (data.blockNumber) { | |
56 | - block.number = data.blockNumber | |
57 | - } | |
57 | + if (data.block.blockNumber) { | |
58 | + block.number = ethUtil.toBuffer(data.block.blockNumber) | |
59 | + } | |
58 | 60 | |
59 | - if (data.gasLimit) { | |
60 | - block.gasLimit = data.gasLimit | |
61 | - } | |
61 | + if (data.block.gasLimit) { | |
62 | + block.gasLimit = ethUtil.toBuffer(data.block.gasLimit) | |
63 | + } | |
62 | 64 | |
63 | - if (data.difficulty) { | |
64 | - block.difficulty = adta.difficulty | |
65 | - } | |
65 | + if (data.block.difficulty) { | |
66 | + block.difficulty = ethUtil.toBuffer(data.block.difficulty) | |
67 | + } | |
66 | 68 | |
67 | - if (data.timestamp) { | |
68 | - block.timestamp = data.timestamp | |
69 | - } | |
69 | + if (data.block.timestamp) { | |
70 | + block.timestamp = ethUtil.toBuffer(data.block.timestam) | |
71 | + } | |
70 | 72 | |
71 | - if (data.coinbase) { | |
72 | - block.coinbase = data.coinbase | |
73 | - } | |
73 | + if (data.block.coinbase) { | |
74 | + block.coinbase = ethUtil.toBuffer(data.block.coinbase) | |
75 | + } | |
74 | 76 | |
75 | - if (Object.keys(block).length > 0) { | |
76 | - self.block = new Block({ header: block, transactions: [], uncleHeaders: [] }) | |
77 | + if (Object.keys(block).length > 0) { | |
78 | + self.block = new Block({ header: block, transactions: [], uncleHeaders: [] }) | |
79 | + } | |
77 | 80 | } |
78 | 81 | } |
79 | 82 | } |
Built with git-ssb-web