-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
49 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
pragma solidity ^0.8.0; | ||
|
||
import "forge-std/Test.sol"; | ||
|
||
import { IDSROracle } from "../src/interfaces/IDSROracle.sol"; | ||
import { DSRBalancerRateProviderAdapter } from "../src/adapters/DSRBalancerRateProviderAdapter.sol"; | ||
|
||
contract DSROracleMock { | ||
|
||
uint256 public conversionRate; | ||
|
||
constructor(uint256 _conversionRate) { | ||
conversionRate = _conversionRate; | ||
} | ||
|
||
function getConversionRateBinomialApprox() external view returns (uint256) { | ||
return conversionRate; | ||
} | ||
|
||
function setConversionRate(uint256 _conversionRate) external { | ||
conversionRate = _conversionRate; | ||
} | ||
|
||
} | ||
|
||
contract DSRBalancerRateProviderAdapterTest is Test { | ||
|
||
DSROracleMock oracle; | ||
|
||
DSRBalancerRateProviderAdapter adapter; | ||
|
||
function setUp() public { | ||
oracle = new DSROracleMock(1e27); | ||
adapter = new DSRBalancerRateProviderAdapter(IDSROracle(address(oracle))); | ||
} | ||
|
||
function test_constructor() public { | ||
adapter = new DSRBalancerRateProviderAdapter(IDSROracle(address(oracle))); | ||
assertEq(address(adapter.dsrOracle()), address(oracle)); | ||
} | ||
|
||
function test_getRate() public { | ||
assertEq(adapter.getRate(), 1e18); | ||
oracle.setConversionRate(1.2e27); | ||
assertEq(adapter.getRate(), 1.2e18); | ||
} | ||
|
||
} |