CallReceiverMock.sol 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.0;
  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 mockFunctionWithArgs(uint256 a, uint256 b) public payable returns (string memory) {
  12. emit MockFunctionCalledWithArgs(a, b);
  13. return "0x1234";
  14. }
  15. function mockFunctionNonPayable() public returns (string memory) {
  16. emit MockFunctionCalled();
  17. return "0x1234";
  18. }
  19. function mockStaticFunction() public pure returns (string memory) {
  20. return "0x1234";
  21. }
  22. function mockFunctionRevertsNoReason() public payable {
  23. revert();
  24. }
  25. function mockFunctionRevertsReason() public payable {
  26. revert("CallReceiverMock: reverting");
  27. }
  28. function mockFunctionThrows() public payable {
  29. assert(false);
  30. }
  31. function mockFunctionOutOfGas() public payable {
  32. for (uint256 i = 0; ; ++i) {
  33. _array.push(i);
  34. }
  35. }
  36. function mockFunctionWritesStorage(bytes32 slot, bytes32 value) public returns (string memory) {
  37. assembly {
  38. sstore(slot, value)
  39. }
  40. return "0x1234";
  41. }
  42. }