lotus/itests/contracts/DelegatecallStorage.sol
snissn 9060c474da
test: fevm: add in tests for deploying, destroying contracts, recursive calls, sending value (#10082)
adds the following tests to itests/fevm_test.go:
 - recursive tests
 - delegate call tests
 - delegate call recursive tests
 - revert tests
 - destruct tests
 - contract deploy address tests
 - send value to contracts
 - gas limit on value transfer tests
 - sending value to destroyed contracts
adds the test to itests/fevm_address_test.go:
 - deploy contract and confirm address is different second deploy
2023-01-31 19:13:13 -10:00

34 lines
1.2 KiB
Solidity

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract DelegatecallStorage {
uint public counter;
function getCounter() public view returns (uint){
return counter;
}
function setVars(address _contract, uint _counter) public payable returns (uint){
(bool success, ) = _contract.delegatecall(
abi.encodeWithSignature("setVars(uint256)", _counter)
);
require(success, 'Error message: Delegatecall failed');
return counter;
}
function setVarsSelf(address _contract, uint _counter) public payable returns (uint){
(bool success, ) = _contract.delegatecall(
abi.encodeWithSignature("setVarsSelf(address,uint256)", _contract, _counter)
);
require(success, 'Error message: Delegatecall failed');
return counter;
}
function setVarsRevert(address _contract, uint _counter) public payable returns (uint){
(bool success, ) = _contract.delegatecall(
abi.encodeWithSignature("setVars(uint256)", _counter)
);
require(false,"intentionally throwing error");
}
function revert() public{
require(false,"intentionally throwing error");
}
}