From 55d8fc68cd77cfbb919d6790bb4092a8358e0c8c Mon Sep 17 00:00:00 2001 From: cdetrio Date: Sun, 21 Jan 2018 22:14:02 +0100 Subject: [PATCH] fix async balance and test --- EVMimports.js | 4 ++-- tests/interface/balance.json | 2 +- tests/interface/balance.wasm | Bin 147 -> 149 bytes tests/interface/balance.wast | 9 ++++----- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/EVMimports.js b/EVMimports.js index 2e30a7b..3f26564 100644 --- a/EVMimports.js +++ b/EVMimports.js @@ -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) @@ -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()) }) } diff --git a/tests/interface/balance.json b/tests/interface/balance.json index e818b77..c03d78a 100644 --- a/tests/interface/balance.json +++ b/tests/interface/balance.json @@ -3,7 +3,7 @@ "callData": "0x00", "state": { "0x5d48c1018904a172886829bbbd9c6f4a2d06c47b": { - "balance": "0x056bc75e2d63100000", + "balance": "0xde0b6b3a7640000", "code": "0x00", "nonce": "0x00" } diff --git a/tests/interface/balance.wasm b/tests/interface/balance.wasm index 1f94431fbf52248fc2761a57cda0cf9943a00eb5..6d09822bacacf3263a20694d3e554b903fd30a3f 100644 GIT binary patch delta 44 zcmbQtIF)gNzmg^sH-jUC;{gUoMgazHX$B?-AX}4}!KtBP!tPzy)_&lfn6Cl=;Ux@q delta 42 pcmbQrIGJ&Rzk)gw7lR`RG72zoOEEAxI5KE5GdMLs0qev<6#%Ph3331c diff --git a/tests/interface/balance.wast b/tests/interface/balance.wast index 9a5e6b7..7f59a6a 100644 --- a/tests/interface/balance.wast +++ b/tests/interface/balance.wast @@ -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 ) @@ -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) ) ) ) -