@@ -11,6 +11,7 @@ import {
11
11
OracleAverageQuery,
12
12
ReservoirPriceOracle,
13
13
IERC20 ,
14
+ IERC4626 ,
14
15
IPriceOracle,
15
16
RoutesLib
16
17
} from "src/ReservoirPriceOracle.sol " ;
@@ -19,6 +20,7 @@ import { EnumerableSetLib } from "lib/solady/src/utils/EnumerableSetLib.sol";
19
20
import { Constants } from "src/libraries/Constants.sol " ;
20
21
import { MockFallbackOracle } from "test/mock/MockFallbackOracle.sol " ;
21
22
import { StubERC4626 } from "test/mock/StubERC4626.sol " ;
23
+ import {Errors} from "../../lib/amm-core/test/integration/AaveErrors.sol " ;
22
24
23
25
contract ReservoirPriceOracleTest is BaseTest {
24
26
using Utils for * ;
@@ -95,6 +97,11 @@ contract ReservoirPriceOracleTest is BaseTest {
95
97
_oracle.setRoute (address (_tokenA), address (_tokenB), lRoute, lRewardThreshold);
96
98
}
97
99
100
+ function testName () external {
101
+ // act & assert
102
+ assertEq (_oracle.name (), "RESERVOIR PRICE ORACLE " );
103
+ }
104
+
98
105
function testWritePriceCache (uint256 aPrice ) external {
99
106
// arrange
100
107
uint256 lPrice = bound (aPrice, 1 , 1e36 );
@@ -976,6 +983,11 @@ contract ReservoirPriceOracleTest is BaseTest {
976
983
_oracle.updatePrice (address (_tokenB), address (_tokenC), address (0 ));
977
984
}
978
985
986
+ function testUpdatePrice_NoPath () external {
987
+ vm.expectRevert (OracleErrors.NoPath.selector );
988
+ _oracle.updatePrice (address (_tokenD), address (_tokenC), address (0 ));
989
+ }
990
+
979
991
function testSetRoute_SameToken () external {
980
992
// arrange
981
993
address lToken0 = address (0x1 );
@@ -1108,4 +1120,28 @@ contract ReservoirPriceOracleTest is BaseTest {
1108
1120
vm.expectRevert (OracleErrors.AmountInTooLarge.selector );
1109
1121
_oracle.getQuote (lAmtIn, address (_tokenA), address (_tokenB));
1110
1122
}
1123
+
1124
+ function testGetQuote_ERC4626AssetFails () external {
1125
+ // arrange
1126
+ address lTargetContract = address (_tokenA); // just any address that doesn't impl the `asset()` function
1127
+
1128
+ // act & assert - the target should be called but should not fail despite not having the function. It should only fail when attempting to query the fallback
1129
+ vm.expectCall (lTargetContract, abi.encodeCall (IERC4626 .asset, ()));
1130
+ vm.expectRevert (OracleErrors.NoPath.selector );
1131
+ _oracle.getQuote (123 , lTargetContract, address (_tokenD));
1132
+ }
1133
+
1134
+ function testValidatePair_NoDesignatedPair () external {
1135
+ // arrange
1136
+ skip (1 );
1137
+ _pair.sync ();
1138
+ skip (_oracle.twapPeriod ());
1139
+ _pair.sync ();
1140
+
1141
+ _oracle.undesignatePair (address (_tokenA), address (_tokenB));
1142
+
1143
+ // act & assert
1144
+ vm.expectRevert (OracleErrors.NoDesignatedPair.selector );
1145
+ _oracle.updatePrice (address (_tokenA), address (_tokenB), address (this ));
1146
+ }
1111
1147
}
0 commit comments