-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #734 from liquity/extra_oracle_tests
Add extra oracle tests
- Loading branch information
Showing
4 changed files
with
223 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
|
||
pragma solidity 0.8.24; | ||
|
||
import "src/Dependencies/AggregatorV3Interface.sol"; | ||
|
||
// Mock oracle that consumes all gas in the price getter. | ||
// this contract code is etched over mainnet oracle addresses in mainnet fork tests. | ||
contract GasGuzzlerOracle is AggregatorV3Interface { | ||
uint8 decimal; | ||
|
||
int256 price; | ||
|
||
uint256 lastUpdateTime; | ||
|
||
uint256 pointlessStorageVar = 42; | ||
|
||
// We use 8 decimals unless set to 18 | ||
function decimals() external view returns (uint8) { | ||
return decimal; | ||
} | ||
|
||
function latestRoundData() | ||
external | ||
view | ||
returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound) | ||
{ | ||
// Expensive SLOAD loop that hits the block gas limit before completing | ||
for (uint256 i = 0; i < 1000000; i++) { | ||
uint256 unusedVar = pointlessStorageVar + i; | ||
} | ||
|
||
return (0, price, 0, lastUpdateTime, 0); | ||
} | ||
|
||
function setDecimals(uint8 _decimals) external { | ||
decimal = _decimals; | ||
} | ||
|
||
function setPrice(int256 _price) external { | ||
price = _price; | ||
} | ||
|
||
function setUpdatedAt(uint256 _updatedAt) external { | ||
lastUpdateTime = _updatedAt; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
|
||
pragma solidity 0.8.24; | ||
|
||
// Mock token that uses all available gas on exchange rate calls. | ||
// This contract code is etched over LST token addresses in mainnet fork tests. | ||
// Has exchange rate functions for WSTETH and RETH. | ||
contract GasGuzzlerToken { | ||
uint256 pointlessStorageVar = 42; | ||
|
||
// RETH exchange rate getter | ||
function getExchangeRate() external view returns (uint256) { | ||
// Expensive SLOAD loop that hits the block gas limit before completing | ||
for (uint256 i = 0; i < 1000000; i++) { | ||
uint256 unusedVar = pointlessStorageVar + i; | ||
} | ||
return 11e17; | ||
} | ||
|
||
// WSTETH exchange rate getter | ||
function stEthPerToken() external view returns (uint256) { | ||
// Expensive SLOAD loop that hits the block gas limit before completing | ||
for (uint256 i = 0; i < 1000000; i++) { | ||
uint256 unusedVar = pointlessStorageVar + i; | ||
} | ||
return 11e17; | ||
} | ||
} |