CallReceiverMock.sol 1.3 KB

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