Commit 51b309693ae24e58fef5c9a30f63e30aca8a24aa
theses chages make tests in evm2wasm pass again
wanderer authored on 8/25/2016, 2:04:10 AMAlex Beregszaszi committed on 8/25/2016, 2:35:34 AM
Parent: ba8942733776fbc730e385e2758b1c9424000c4a
Files changed
environment.js | changed |
interface.js | changed |
environment.js | ||
---|---|---|
@@ -41,13 +41,23 @@ | ||
41 | 41 | this.state.set(address.toString(), account) |
42 | 42 | } |
43 | 43 | |
44 | 44 | getBalance (address) { |
45 | - return this.state.get(address.toString())['balance'] | |
45 | + const account = this.state.get(address.toString()) | |
46 | + if (account) { | |
47 | + return account['balance'] | |
48 | + } else { | |
49 | + return new U256() | |
50 | + } | |
46 | 51 | } |
47 | 52 | |
48 | 53 | getCode (address) { |
49 | - return this.state.get(address.toString())['code'] | |
54 | + const account = this.state.get(address.toString()) | |
55 | + if (account) { | |
56 | + return account['code'] | |
57 | + } else { | |
58 | + return Uint8Array.from(new Buffer([])) | |
59 | + } | |
50 | 60 | } |
51 | 61 | |
52 | 62 | getBlockHash (height) { |
53 | 63 | return this.blockchain.getBlock(height).hash() |
interface.js | ||
---|---|---|
@@ -157,9 +157,9 @@ | ||
157 | 157 | * @param {integer} dataOffset the offset in the input data |
158 | 158 | * @param {integer} length the length of data to copy |
159 | 159 | */ |
160 | 160 | callDataCopy (offset, dataOffset, length) { |
161 | - this.takeGas(3 + ((length / 32) * 3)) | |
161 | + this.takeGas(3 + Math.ceil(length / 32) * 3) | |
162 | 162 | |
163 | 163 | const callData = this.environment.callData.slice(dataOffset, dataOffset + length) |
164 | 164 | this.setMemory(offset, length, callData) |
165 | 165 | } |
@@ -192,9 +192,9 @@ | ||
192 | 192 | * @param {integer} codeOffset the code offset |
193 | 193 | * @param {integer} length the length of code to copy |
194 | 194 | */ |
195 | 195 | codeCopy (resultOffset, codeOffset, length) { |
196 | - this.takeGas(3 + ((length / 32) * 3)) | |
196 | + this.takeGas(3 + Math.ceil(length / 32) * 3) | |
197 | 197 | |
198 | 198 | const code = new Uint8Array(this.environment.code, codeOffset, length) |
199 | 199 | this.setMemory(resultOffset, length, code) |
200 | 200 | } |
@@ -219,9 +219,9 @@ | ||
219 | 219 | * @param {integer} codeOffset the code offset |
220 | 220 | * @param {integer} length the length of code to copy |
221 | 221 | */ |
222 | 222 | externalCodeCopy (addressOffset, resultOffset, codeOffset, length) { |
223 | - this.takeGas(20 + ((length / 32) * 3)) | |
223 | + this.takeGas(20 + Math.ceil(length / 32) * 3) | |
224 | 224 | |
225 | 225 | const address = Address.fromMemory(this.getMemory(addressOffset, constants.ADDRESS_SIZE_BYTES)) |
226 | 226 | let code = this.environment.getCode(address) |
227 | 227 | code = new Uint8Array(code, codeOffset, length) |
Built with git-ssb-web