Commit f488805c0df12c74d2cb8ed0c5d0e439495676df
Merge pull request #31 from ewasm/better-test-environment
Better test environmentwanderer authored on 8/18/2016, 2:09:44 AM
GitHub committed on 8/18/2016, 2:09:44 AM
Parent: a4de660ae609d19d9547c07d2c507253598aa2bf
Parent: a4b17a05ea3da61030c0dc36eb69c2b6922359b6
Files changed
testEnvironment.js | changed |
tests/interface/address.json | changed |
tests/interface/balance.json | changed |
tests/interface/callValue.json | changed |
tests/interface/caller.json | changed |
tests/interface/origin.json | changed |
testEnvironment.js | ||
---|---|---|
@@ -15,36 +15,36 @@ | ||
15 | 15 | |
16 | 16 | if (data.accounts) { |
17 | 17 | data.accounts.forEach((account) => { |
18 | 18 | let tmp = account[1] |
19 | - self.state.set(new Address(new Uint8Array(account[0])).toString(), { | |
20 | - balance: new U256(new BN(tmp.balance, 16, 'le')) | |
19 | + self.state.set(new Address(account[0]).toString(), { | |
20 | + balance: new U256(tmp.balance) | |
21 | 21 | }) |
22 | 22 | }) |
23 | 23 | } |
24 | 24 | |
25 | 25 | if (data.address) { |
26 | - self.address = new Address(new Uint8Array(data.address)) | |
26 | + self.address = new Address(data.address) | |
27 | 27 | } |
28 | 28 | |
29 | 29 | if (data.origin) { |
30 | - self.origin = new Address(new Uint8Array(data.origin)) | |
30 | + self.origin = new Address(data.origin) | |
31 | 31 | } |
32 | 32 | |
33 | 33 | if (data.caller) { |
34 | - self.caller = new Address(new Uint8Array(data.caller)) | |
34 | + self.caller = new Address(data.caller) | |
35 | 35 | } |
36 | 36 | |
37 | 37 | if (data.coinbase) { |
38 | - self.coinbase = new Uint8Array(data.coinbase) | |
38 | + self.coinbase = new Address(data.coinbase) | |
39 | 39 | } |
40 | 40 | |
41 | 41 | if (data.callValue) { |
42 | 42 | self.callValue = new U256(data.callValue) |
43 | 43 | } |
44 | 44 | |
45 | 45 | if (data.callData) { |
46 | - self.callData = hexStr2arrayBuf(data.callData) | |
46 | + self.callData = Uint8Array.from(new Buffer(data.callData, 'hex')) | |
47 | 47 | } |
48 | 48 | |
49 | 49 | if (data.gasPrice) { |
50 | 50 | self.gasPrice = data.gasPrice |
@@ -54,18 +54,4 @@ | ||
54 | 54 | self.gasLimit = data.gasLimit |
55 | 55 | } |
56 | 56 | } |
57 | 57 | } |
58 | - | |
59 | -function hexStr2arrayBuf (string) { | |
60 | - const view = new Uint8Array(string.length / 2) | |
61 | - string = [...string] | |
62 | - let temp = '' | |
63 | - string.forEach((el, i) => { | |
64 | - temp += el | |
65 | - if (i % 2) { | |
66 | - view[(i + 1) / 2 - 1] = parseInt(temp, 16) | |
67 | - temp = '' | |
68 | - } | |
69 | - }) | |
70 | - return view | |
71 | -} |
tests/interface/address.json | ||
---|---|---|
@@ -1,3 +1,3 @@ | ||
1 | 1 | { |
2 | - "address": [93,72,193,1,137,4,161,114,136,104,41,187,189,156,111,74,45,6,196,123] | |
2 | + "address": "0x5d48c1018904a172886829bbbd9c6f4a2d06c47b" | |
3 | 3 | } |
tests/interface/balance.json | ||
---|---|---|
@@ -1,9 +1,9 @@ | ||
1 | 1 | { |
2 | 2 | "accounts": [ |
3 | 3 | [ |
4 | - [93, 72, 193, 1, 137, 4, 161, 114, 136, 104, 41, 187, 189, 156, 111, 74, 45, 6, 196, 123], { | |
5 | - "balance": [100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] | |
4 | + "0x5d48c1018904a172886829bbbd9c6f4a2d06c47b", { | |
5 | + "balance": "100" | |
6 | 6 | } |
7 | 7 | ] |
8 | 8 | ] |
9 | 9 | } |
Built with git-ssb-web