Skip to content

Commit 801b8bd

Browse files
committed
test: improve test
1 parent b667bbe commit 801b8bd

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

test/WstEthOracle.sol

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,28 @@ contract ChainlinkOracleTest is Test {
4949
}
5050

5151
function testLastRoundData() public {
52-
(uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound) = oracle.latestRoundData();
52+
(uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound) =
53+
oracle.latestRoundData();
5354
assertEq(roundId, 0);
54-
assertEq(answer,int256(ST_ETH.getPooledEthByShares(10 ** 18)));
55+
assertEq(uint256(answer), ST_ETH.getPooledEthByShares(10 ** 18));
5556
assertEq(startedAt, 0);
5657
assertEq(updatedAt, 0);
5758
assertEq(answeredInRound, 0);
5859
}
5960

6061
function testGetLastRoundData() public {
61-
(uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound) = oracle.getRoundData(1);
62+
(uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound) =
63+
oracle.getRoundData(1);
6264
assertEq(roundId, 0);
63-
assertEq(answer, int256(ST_ETH.getPooledEthByShares(10 ** 18)));
65+
assertEq(uint256(answer), ST_ETH.getPooledEthByShares(10 ** 18));
6466
assertEq(startedAt, 0);
6567
assertEq(updatedAt, 0);
6668
assertEq(answeredInRound, 0);
6769
}
70+
71+
function testLastRoundDataBounds() public {
72+
(, int256 answer,,,) = oracle.latestRoundData();
73+
assertGe(uint256(answer), 1154690031824824994); // Exchange rate queried at block 19070943
74+
assertLe(uint256(answer), 1.5e18); // Max bounds of the exchange rate. Should work for a long enough time.
75+
}
6876
}

0 commit comments

Comments
 (0)