CallReceiverMockUpgradeable.sol 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.0;
  3. import "../proxy/utils/Initializable.sol";
  4. contract CallReceiverMockUpgradeable is Initializable {
  5. function __CallReceiverMock_init() internal onlyInitializing {
  6. }
  7. function __CallReceiverMock_init_unchained() internal onlyInitializing {
  8. }
  9. string public sharedAnswer;
  10. event MockFunctionCalled();
  11. event MockFunctionCalledWithArgs(uint256 a, uint256 b);
  12. uint256[] private _array;
  13. function mockFunction() public payable returns (string memory) {
  14. emit MockFunctionCalled();
  15. return "0x1234";
  16. }
  17. function mockFunctionWithArgs(uint256 a, uint256 b) public payable returns (string memory) {
  18. emit MockFunctionCalledWithArgs(a, b);
  19. return "0x1234";
  20. }
  21. function mockFunctionNonPayable() public returns (string memory) {
  22. emit MockFunctionCalled();
  23. return "0x1234";
  24. }
  25. function mockStaticFunction() public pure returns (string memory) {
  26. return "0x1234";
  27. }
  28. function mockFunctionRevertsNoReason() public payable {
  29. revert();
  30. }
  31. function mockFunctionRevertsReason() public payable {
  32. revert("CallReceiverMock: reverting");
  33. }
  34. function mockFunctionThrows() public payable {
  35. assert(false);
  36. }
  37. function mockFunctionOutOfGas() public payable {
  38. for (uint256 i = 0; ; ++i) {
  39. _array.push(i);
  40. }
  41. }
  42. function mockFunctionWritesStorage() public returns (string memory) {
  43. sharedAnswer = "42";
  44. return "0x1234";
  45. }
  46. /**
  47. * @dev This empty reserved space is put in place to allow future versions to add new
  48. * variables without shifting down storage in the inheritance chain.
  49. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
  50. */
  51. uint256[48] private __gap;
  52. }