solidity/test/libsolidity/semanticTests/functionCall/gas_and_value_brace_syntax.sol

49 lines
1.1 KiB
Solidity
Raw Normal View History

contract helper {
bool flag;
function getBalance() payable public returns(uint256 myBalance) {
return address(this).balance;
}
function setFlag() public {
flag = true;
}
function getFlag() public returns(bool fl) {
return flag;
}
}
contract test {
helper h;
2020-06-23 12:14:24 +00:00
constructor() payable {
h = new helper();
}
function sendAmount(uint amount) public payable returns(uint256 bal) {
return h.getBalance{value: amount}();
}
function outOfGas() public returns(bool ret) {
h.setFlag {
gas: 2
}(); // should fail due to OOG
return true;
}
function checkState() public returns(bool flagAfter, uint myBal) {
flagAfter = h.getFlag();
myBal = address(this).balance;
}
}
// ====
// compileViaYul: also
// ----
// constructor(), 20 wei ->
2022-03-15 16:25:35 +00:00
// gas irOptimized: 270609
2021-11-15 15:19:33 +00:00
// gas legacy: 402654
// gas legacyOptimized: 274470
// sendAmount(uint256): 5 -> 5
// outOfGas() -> FAILURE # call to helper should not succeed but amount should be transferred anyway #
// checkState() -> false, 15