@@ -4,6 +4,7 @@ pragma solidity ^0.8.0;
4
4
import "forge-std/Test.sol " ;
5
5
import "src/ChainlinkOracle.sol " ;
6
6
import "src/libraries/ErrorsLib.sol " ;
7
+ import "./mock/ChainlinkAggregatorMock.sol " ;
7
8
8
9
AggregatorV3Interface constant feedZero = AggregatorV3Interface (address (0 ));
9
10
// 8 decimals of precision
@@ -21,22 +22,6 @@ AggregatorV3Interface constant usdcEthFeed = AggregatorV3Interface(0x986b5E1e175
21
22
// 8 decimals of precision
22
23
AggregatorV3Interface constant ethUsdFeed = AggregatorV3Interface (0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419 );
23
24
24
- contract FakeAggregator {
25
- int256 public answer;
26
-
27
- function setAnwser (int256 newAnswer ) external {
28
- answer = newAnswer;
29
- }
30
-
31
- function latestRoundData () external view returns (uint80 , int256 , uint256 , uint256 , uint80 ) {
32
- return (0 , answer, 0 , 0 , 0 );
33
- }
34
-
35
- function decimals () external pure returns (uint256 ) {
36
- return 8 ;
37
- }
38
- }
39
-
40
25
contract ChainlinkOracleTest is Test {
41
26
function setUp () public {
42
27
vm.createSelectFork (vm.envString ("ETH_RPC_URL " ));
@@ -107,7 +92,7 @@ contract ChainlinkOracleTest is Test {
107
92
108
93
function testNegativeAnswer (int256 price ) public {
109
94
price = bound (price, type (int256 ).min, - 1 );
110
- FakeAggregator aggregator = new FakeAggregator ();
95
+ ChainlinkAggregatorMock aggregator = new ChainlinkAggregatorMock ();
111
96
ChainlinkOracle oracle =
112
97
new ChainlinkOracle (AggregatorV3Interface (address (aggregator)), feedZero, feedZero, feedZero, 18 , 0 );
113
98
aggregator.setAnwser (price);
0 commit comments