git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit f488805c0df12c74d2cb8ed0c5d0e439495676df

Merge pull request #31 from ewasm/better-test-environment

Better test environment
wanderer 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.jschanged
tests/interface/address.jsonchanged
tests/interface/balance.jsonchanged
tests/interface/callValue.jsonchanged
tests/interface/caller.jsonchanged
tests/interface/origin.jsonchanged
testEnvironment.jsView
@@ -15,36 +15,36 @@
1515
1616 if (data.accounts) {
1717 data.accounts.forEach((account) => {
1818 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)
2121 })
2222 })
2323 }
2424
2525 if (data.address) {
26- self.address = new Address(new Uint8Array(data.address))
26+ self.address = new Address(data.address)
2727 }
2828
2929 if (data.origin) {
30- self.origin = new Address(new Uint8Array(data.origin))
30+ self.origin = new Address(data.origin)
3131 }
3232
3333 if (data.caller) {
34- self.caller = new Address(new Uint8Array(data.caller))
34+ self.caller = new Address(data.caller)
3535 }
3636
3737 if (data.coinbase) {
38- self.coinbase = new Uint8Array(data.coinbase)
38+ self.coinbase = new Address(data.coinbase)
3939 }
4040
4141 if (data.callValue) {
4242 self.callValue = new U256(data.callValue)
4343 }
4444
4545 if (data.callData) {
46- self.callData = hexStr2arrayBuf(data.callData)
46+ self.callData = Uint8Array.from(new Buffer(data.callData, 'hex'))
4747 }
4848
4949 if (data.gasPrice) {
5050 self.gasPrice = data.gasPrice
@@ -54,18 +54,4 @@
5454 self.gasLimit = data.gasLimit
5555 }
5656 }
5757 }
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.jsonView
@@ -1,3 +1,3 @@
11 {
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"
33 }
tests/interface/balance.jsonView
@@ -1,9 +1,9 @@
11 {
22 "accounts": [
33 [
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"
66 }
77 ]
88 ]
99 }
tests/interface/callValue.jsonView
@@ -1,3 +1,3 @@
11 {
2- "callValue": [100]
2+ "callValue": "100"
33 }
tests/interface/caller.jsonView
@@ -1,3 +1,3 @@
11 {
2- "caller": [93,72,193,1,137,4,161,114,136,104,41,187,189,156,111,74,45,6,196,123]
2+ "caller": "0x5d48c1018904a172886829bbbd9c6f4a2d06c47b"
33 }
tests/interface/origin.jsonView
@@ -1,3 +1,3 @@
11 {
2- "origin": [93,72,193,1,137,4,161,114,136,104,41,187,189,156,111,74,45,6,196,123]
2+ "origin": "0x5d48c1018904a172886829bbbd9c6f4a2d06c47b"
33 }

Built with git-ssb-web