From 5f9c5a963914ae34349ab04e683eb2f80805b4c6 Mon Sep 17 00:00:00 2001 From: sakulstra Date: Thu, 8 Aug 2024 15:55:07 +0200 Subject: [PATCH] fix: improve the test --- tests/periphery/static-a-token/StaticATokenLM.t.sol | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/periphery/static-a-token/StaticATokenLM.t.sol b/tests/periphery/static-a-token/StaticATokenLM.t.sol index 9686305c..a8a23c32 100644 --- a/tests/periphery/static-a-token/StaticATokenLM.t.sol +++ b/tests/periphery/static-a-token/StaticATokenLM.t.sol @@ -69,7 +69,12 @@ contract StaticATokenLMTest is BaseTest { ); uint256 stataPrice = uint256(staticATokenLM.latestAnswer()); uint256 underlyingPrice = contracts.aaveOracle.getAssetPrice(UNDERLYING); - assertEq(stataPrice, (underlyingPrice * liquidityIndex) / 1e27); + uint256 expectedStataPrice = (underlyingPrice * liquidityIndex) / 1e27; + assertEq(stataPrice, expectedStataPrice); + + // reverse the math to ensure precision loss is within bounds + uint256 reversedUnderlying = (stataPrice * 1e27) / liquidityIndex; + assertApproxEqAbs(underlyingPrice, reversedUnderlying, 1); } function test_convertersAndPreviews() public view {