Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapted tests to work for Mainnet fork #42

Merged
merged 3 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions contracts/mock/MockFallbackCaller.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// SPDX-License-Identifier: MIT
// File: Interfaces/IFallbackCaller.sol

pragma solidity 0.8.17;

interface IFallbackCaller {
// --- Events ---
event FallbackTimeOutChanged(uint256 _oldTimeOut, uint256 _newTimeOut);

// --- Function External View ---

// NOTE: The fallback oracle must always return its answer scaled to 18 decimals where applicable
// The system will assume an 18 decimal response for efficiency.
function getFallbackResponse() external view returns (uint256, uint256, bool);

// NOTE: this returns the timeout window interval for the fallback oracle instead
// of storing in the `PriceFeed` contract is retrieve for the `FallbackCaller`
function fallbackTimeout() external view returns (uint256);

// --- Function External Setter ---

function setFallbackTimeout(uint256 newFallbackTimeout) external;
}
// File: contracts/MockFallbackCaller.sol

pragma solidity 0.8.17;

contract MockFallbackCaller is IFallbackCaller {
uint256 public _answer;
uint256 public _timestampRetrieved;
uint256 public _fallbackTimeout = 90000; // NOTE: MAYBE BEST TO CUSTOMIZE
bool public _success;
uint256 public _initAnswer;

bool public getFallbackResponseRevert;
bool public fallbackTimeoutRevert;

constructor(uint256 answer) {
_initAnswer = answer;
}

function setGetFallbackResponseRevert() external {
getFallbackResponseRevert = !getFallbackResponseRevert;
}

function setFallbackTimeoutRevert() external {
fallbackTimeoutRevert = !fallbackTimeoutRevert;
}

function setFallbackResponse(
uint256 answer,
uint256 timestampRetrieved,
bool success
) external {
_answer = answer;
_timestampRetrieved = timestampRetrieved;
_success = success;
}

function setFallbackTimeout(uint256 newFallbackTimeout) external {
uint256 oldTimeOut = _fallbackTimeout;
_fallbackTimeout = newFallbackTimeout;
emit FallbackTimeOutChanged(oldTimeOut, newFallbackTimeout);
}

function getFallbackResponse()
external
view
returns (uint256, uint256, bool)
{
if (getFallbackResponseRevert) {
require(1 == 0, "getFallbackResponse reverted");
}
return (_answer, _timestampRetrieved, _success);
}

function fallbackTimeout() external view returns (uint256) {
if (fallbackTimeoutRevert) {
require(1 == 0, "fallbackTimeout reverted");
}
return _fallbackTimeout;
}
}
Loading
Loading