-
Notifications
You must be signed in to change notification settings - Fork 36
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
Add extra oracle tests #734
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don’t we need one for RETH? |
||
// Expensive SLOAD loop that hits the block gas limit before completing | ||
for (uint256 i = 0; i < 1000000; i++) { | ||
uint256 unusedVar = pointlessStorageVar + i; | ||
} | ||
return 11e17; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, so when the failure is catched by
vm.expecRevert
thenbool
return value is true?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, strange design choice in Foundry IMO. See the "Gotcha: low level calls" section here:
https://book.getfoundry.sh/cheatcodes/expect-revert