Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix getExternalBalance #5

Open
loredanacirstea opened this issue May 15, 2020 · 0 comments
Open

Fix getExternalBalance #5

loredanacirstea opened this issue May 15, 2020 · 0 comments

Comments

@loredanacirstea
Copy link
Owner

Fix

it('test c6 getExternalBalance', async function () {
const ewmodule = ewasmjsvm.initialize(contracts.c6.bin, c6Abi);
const runtime = await ewmodule.main(DEFAULT_TX_INFO);
deployments.c6 = runtime;
const answ = await runtime.main(accounts[0].address, DEFAULT_TX_INFO);
// expect(answ.balance).toBe(accounts[0].balance);
});

getExternalBalance correctly stores the balance in memory:

ewasm-jsvm/src/index.js

Lines 205 to 208 in 3b9ca9d

balance.set(tightValue, size - tightValue.length);
storeMemory(balance, resultOffset_i32ptr, size);
console.log('getExternalBalance', logu8a(loadMemory(resultOffset_i32ptr, size)));

However, it never gets written to the proper return pointer. So it is always 0 when returned:

// getExternalBalance i32
let account := mload(_calldata)
mstore(_data, balance(account))
return (_data, 32)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant