CallReceiverMock.sol 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.19;
  3. contract CallReceiverMock {
  4. event MockFunctionCalled();
  5. event MockFunctionCalledWithArgs(uint256 a, uint256 b);
  6. uint256[] private _array;
  7. function mockFunction() public payable returns (string memory) {
  8. emit MockFunctionCalled();
  9. return "0x1234";
  10. }
  11. function mockFunctionEmptyReturn() public payable {
  12. emit MockFunctionCalled();
  13. }
  14. function mockFunctionWithArgs(uint256 a, uint256 b) public payable returns (string memory) {
  15. emit MockFunctionCalledWithArgs(a, b);
  16. return "0x1234";
  17. }
  18. function mockFunctionNonPayable() public returns (string memory) {
  19. emit MockFunctionCalled();
  20. return "0x1234";
  21. }
  22. function mockStaticFunction() public pure returns (string memory) {
  23. return "0x1234";
  24. }
  25. function mockFunctionRevertsNoReason() public payable {
  26. revert();
  27. }
  28. function mockFunctionRevertsReason() public payable {
  29. revert("CallReceiverMock: reverting");
  30. }
  31. function mockFunctionThrows() public payable {
  32. assert(false);
  33. }
  34. function mockFunctionOutOfGas() public payable {
  35. for (uint256 i = 0; ; ++i) {
  36. _array.push(i);
  37. }
  38. }
  39. function mockFunctionWritesStorage(bytes32 slot, bytes32 value) public returns (string memory) {
  40. assembly {
  41. sstore(slot, value)
  42. }
  43. return "0x1234";
  44. }
  45. }