Files: 52733a7622044cda7ec1de6a666ed8c8747162c6 / testEnvironment.js
1203 bytesRaw
1 | const Environment = require('./environment.js') |
2 | const U256 = require('./u256.js') |
3 | const Address = require('./address.js') |
4 | const BN = require('bn.js') |
5 | |
6 | module.exports = class TestEnvironment extends Environment { |
7 | constructor (data) { |
8 | super() |
9 | |
10 | if (typeof data === 'string') { |
11 | data = JSON.parse(data) |
12 | } |
13 | |
14 | let self = this |
15 | |
16 | if (data.accounts) { |
17 | data.accounts.forEach((account) => { |
18 | let tmp = account[1] |
19 | self.state.set(new Address(account[0]).toString(), { |
20 | balance: new U256(tmp.balance) |
21 | }) |
22 | }) |
23 | } |
24 | |
25 | if (data.address) { |
26 | self.address = new Address(data.address) |
27 | } |
28 | |
29 | if (data.origin) { |
30 | self.origin = new Address(data.origin) |
31 | } |
32 | |
33 | if (data.caller) { |
34 | self.caller = new Address(data.caller) |
35 | } |
36 | |
37 | if (data.coinbase) { |
38 | self.coinbase = new Address(data.coinbase) |
39 | } |
40 | |
41 | if (data.callValue) { |
42 | self.callValue = new U256(data.callValue) |
43 | } |
44 | |
45 | if (data.callData) { |
46 | self.callData = Uint8Array.from(new Buffer(data.callData, 'hex')) |
47 | } |
48 | |
49 | if (data.gasPrice) { |
50 | self.gasPrice = data.gasPrice |
51 | } |
52 | |
53 | if (data.gasLimit) { |
54 | self.gasLimit = data.gasLimit |
55 | } |
56 | } |
57 | } |
58 |
Built with git-ssb-web