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

[isoltest] Add balance: statement #10426

Closed
axic opened this issue Nov 26, 2020 · 5 comments · Fixed by #10873
Closed

[isoltest] Add balance: statement #10426

axic opened this issue Nov 26, 2020 · 5 comments · Fixed by #10873
Assignees

Comments

@axic
Copy link
Member

axic commented Nov 26, 2020

Currently there is no simple way to query a contract balance in the semantic tests. Due to this lack of support, numerous tests were not moved from SolidityEndToEndTest.

(It is possible to add a helper in the contract, like function balance() external view returns (uint) { return address(this).balance; }, but that is a bit overkill.)

It would be nice to support a // balance: 12 wei or // balance -> 12 wei line to assert balance at that given point.

Could also consider checking the balance of any account, so perhaps the better syntax is:

// balance -> 12 wei   # for the current contract #
// balance 0x1234... -> 34 wei  # for address 0x1234... #
@chriseth
Copy link
Contributor

Should be similar to storage: empty / non-empty

@axic
Copy link
Member Author

axic commented Nov 30, 2020

Should be similar to storage: empty / non-empty

That was the inspiration, but the second syntax proposal is better if we want to support querying any account (which I think would be useful to test transfers, etc.)

@chriseth
Copy link
Contributor

chriseth commented Dec 2, 2020

the problem is that addresses are not fixed. If we want to query an external balance we could provide the contract name, but I think just supporting the balance of the "current" contract is already nice

@axic
Copy link
Member Author

axic commented Dec 2, 2020

the problem is that addresses are not fixed.

I think they are, but agree if there is no such big need yet to check other balances, that can done via wrapper functions and we can change this as the need arises.

@axic
Copy link
Member Author

axic commented Apr 28, 2021

The syntax implemented by #10873 is:

// balance -> 0
// balance: 0x0000000000000000000000000000000000000000 -> 0

The wei/ether suffix is not supported.

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

Successfully merging a pull request may close this issue.

3 participants