Skip to content

Commit

Permalink
fix async balance and test
Browse files Browse the repository at this point in the history
  • Loading branch information
cdetrio committed Jan 21, 2018
1 parent 2a1d2fc commit 55d8fc6
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions EVMimports.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ module.exports = class Interface {
* @param {integer} addressOffset the memory offset to laod the address
* @param {integer} resultOffset
*/
getBalance (addressOffset, offset, cbIndex) {
getBalance (addressOffset, resultOffset, cbIndex) {
log.debug('EVMImports.js getBalance')
this.takeGas(20)

Expand All @@ -137,7 +137,7 @@ module.exports = class Interface {
const opPromise = Promise.resolve(balanceU256)

this.kernel.pushOpsQueue(opPromise, cbIndex, balance => {
this.setMemory(offset, U128_SIZE_BYTES, balance.toMemory(U128_SIZE_BYTES))
this.setMemory(resultOffset, U128_SIZE_BYTES, balance.toMemory(U128_SIZE_BYTES).reverse())
})
}

Expand Down
2 changes: 1 addition & 1 deletion tests/interface/balance.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"callData": "0x00",
"state": {
"0x5d48c1018904a172886829bbbd9c6f4a2d06c47b": {
"balance": "0x056bc75e2d63100000",
"balance": "0xde0b6b3a7640000",
"code": "0x00",
"nonce": "0x00"
}
Expand Down
Binary file modified tests/interface/balance.wasm
Binary file not shown.
9 changes: 4 additions & 5 deletions tests/interface/balance.wast
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;; address of 5d48c1018904a172886829bbbd9c6f4a2d06c47b has a balance of 0x056bc75e2d63100000 (100 ETH)
;; address 5d48c1018904a172886829bbbd9c6f4a2d06c47b has a balance of 0xde0b6b3a7640000 (1 ETH)
(module
(import "ethereum" "getBalance" (func $balance (param i32 i32 i32)))
(memory 1 )
Expand All @@ -8,16 +8,15 @@
(export "1" (func $callback))

(func $main
(call $balance (i32.const 0) (i32.const 0) (i32.const 1))
(call $balance (i32.const 0) (i32.const 64) (i32.const 1))
)

(func $callback
(block
(if (i64.eq (i64.load (i32.const 0)) (i64.const 0x0500000000000000))
(if (i64.eq (i64.load (i32.const 64)) (i64.const 0xde0b6b3a7640000))
(return)
)
(unreachable)
)
)
)

0 comments on commit 55d8fc6

Please sign in to comment.