Skip to content

Commit

Permalink
test: add test for usdc (wbtc)
Browse files Browse the repository at this point in the history
  • Loading branch information
MathisGD committed Oct 2, 2023
1 parent 0124158 commit 6b76743
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ contract OracleTest is Test {

function testNegativeAnswer() public {
FakeAggregator aggregator = new FakeAggregator();
Oracle2 oracle = new Oracle2(AggregatorV3Interface(address(aggregator)), 18, AggregatorV3Interface(address(0)), 0);
Oracle2 oracle =
new Oracle2(AggregatorV3Interface(address(aggregator)), 18, AggregatorV3Interface(address(0)), 0);
aggregator.setAnwser(-1);
vm.expectRevert(bytes(ErrorsLib.NEGATIVE_ANSWER));
oracle.price();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ contract OracleTest is Test {
}

function testOracleWbtcUsdc() public {
Oracle4 oracle =
new Oracle4(wBtcBtcFeed, btcUsdFeed, usdcUsdFeed, AggregatorV3Interface(address(0)), 8, 6);
Oracle4 oracle = new Oracle4(wBtcBtcFeed, btcUsdFeed, usdcUsdFeed, AggregatorV3Interface(address(0)), 8, 6);
(, int256 firstBaseAnswer,,,) = wBtcBtcFeed.latestRoundData();
(, int256 secondBaseAnswer,,,) = btcUsdFeed.latestRoundData();
(, int256 quoteAnswer,,,) = usdcUsdFeed.latestRoundData();
Expand All @@ -32,6 +31,18 @@ contract OracleTest is Test {
);
}

function testOracleUsdcWbtc() public {
Oracle4 oracle = new Oracle4(usdcUsdFeed, AggregatorV3Interface(address(0)), wBtcBtcFeed, btcUsdFeed, 6, 8);
(, int256 baseAnswer,,,) = usdcUsdFeed.latestRoundData();
(, int256 firstQuoteAnswer,,,) = wBtcBtcFeed.latestRoundData();
(, int256 secondQuoteAnswer,,,) = btcUsdFeed.latestRoundData();
assertEq(
oracle.price(),
(uint256(baseAnswer) * 10 ** (36 + 8 + 8 + 6 - 8 - 8))
/ (uint256(firstQuoteAnswer) * uint256(secondQuoteAnswer))
);
}

function testOracleWbtcEth() public {
Oracle4 oracle =
new Oracle4(wBtcBtcFeed, btcEthFeed, AggregatorV3Interface(address(0)), AggregatorV3Interface(address(0)), 8, 0);
Expand Down

0 comments on commit 6b76743

Please sign in to comment.