Skip to content

Commit

Permalink
test: fix expected errors
Browse files Browse the repository at this point in the history
  • Loading branch information
xenide committed Nov 28, 2024
1 parent 8f1099a commit dd85cc6
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 48 deletions.
18 changes: 0 additions & 18 deletions src/libraries/Uint31Lib.sol

This file was deleted.

4 changes: 3 additions & 1 deletion test/unit/AssetManagedPair.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ pragma solidity ^0.8.0;

import "test/__fixtures/BaseTest.sol";

import { SafeCast } from "@openzeppelin/utils/math/SafeCast.sol";
import { MathUtils } from "src/libraries/MathUtils.sol";
import { ReservoirPair, IERC20 } from "src/ReservoirPair.sol";
import { AssetManager } from "test/__mocks/AssetManager.sol";
import {SafeCast} from "../../lib/openzeppelin-contracts/contracts/utils/math/SafeCast.sol";

contract AssetManagedPairTest is BaseTest {
AssetManager private _manager = new AssetManager();
Expand Down Expand Up @@ -102,7 +104,7 @@ contract AssetManagedPairTest is BaseTest {
_pair.setManager(AssetManager(address(this)));

// act & assert
vm.expectRevert("SafeCast: value doesn't fit in 104 bits");
vm.expectPartialRevert(SafeCast.SafeCastOverflowedUintDowncast.selector);
_pair.adjustManagement(0, int256(uint256(type(uint104).max)) + 1);
}

Expand Down
11 changes: 5 additions & 6 deletions test/unit/ConstantProductPair.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { stdStorage } from "forge-std/Test.sol";
import { MintableERC20 } from "test/__fixtures/MintableERC20.sol";
import { AssetManager } from "test/__mocks/AssetManager.sol";

import { Uint31Lib } from "src/libraries/Uint31Lib.sol";
import { LogCompression } from "src/libraries/LogCompression.sol";
import { Observation } from "src/ReservoirPair.sol";
import { IERC20 } from "src/GenericFactory.sol";
Expand Down Expand Up @@ -324,14 +323,14 @@ contract ConstantProductPairTest is BaseTest, IReservoirCallee {

assertApproxEqRel(
LogCompression.fromLowResLog(
(lObs1.logAccRawPrice - lObs0.logAccRawPrice) / int32(Uint31Lib.sub(lObs1.timestamp, lObs0.timestamp))
(lObs1.logAccRawPrice - lObs0.logAccRawPrice) / int32(lObs1.timestamp - lObs0.timestamp)
),
lPrice1,
0.0001e18
);
assertApproxEqRel(
LogCompression.fromLowResLog(
(lObs2.logAccRawPrice - lObs0.logAccRawPrice) / int32(Uint31Lib.sub(lObs2.timestamp, lObs0.timestamp))
(lObs2.logAccRawPrice - lObs0.logAccRawPrice) / int32(lObs2.timestamp - lObs0.timestamp)
),
Math.sqrt(lPrice1 * lPrice2),
0.0001e18
Expand Down Expand Up @@ -411,23 +410,23 @@ contract ConstantProductPairTest is BaseTest, IReservoirCallee {
// Price for observation window 0-1
assertApproxEqRel(
LogCompression.fromLowResLog(
(lObs1.logAccRawPrice - lObs0.logAccRawPrice) / int32(Uint31Lib.sub(lObs1.timestamp, lObs0.timestamp))
(lObs1.logAccRawPrice - lObs0.logAccRawPrice) / int32(lObs1.timestamp - lObs0.timestamp)
),
4e18,
0.0001e18
);
// Price for observation window 1-2
assertApproxEqRel(
LogCompression.fromLowResLog(
(lObs2.logAccRawPrice - lObs1.logAccRawPrice) / int32(Uint31Lib.sub(lObs2.timestamp, lObs1.timestamp))
(lObs2.logAccRawPrice - lObs1.logAccRawPrice) / int32(lObs2.timestamp - lObs1.timestamp)
),
16e18,
0.0001e18
);
// Price for observation window 0-2
assertApproxEqRel(
LogCompression.fromLowResLog(
(lObs2.logAccRawPrice - lObs0.logAccRawPrice) / int32(Uint31Lib.sub(lObs2.timestamp, lObs0.timestamp))
(lObs2.logAccRawPrice - lObs0.logAccRawPrice) / int32(lObs2.timestamp - lObs0.timestamp)
),
8e18,
0.0001e18
Expand Down
11 changes: 5 additions & 6 deletions test/unit/StablePair.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { Math } from "test/__fixtures/Math.sol";
import { MathUtils } from "src/libraries/MathUtils.sol";
import { LogCompression } from "src/libraries/LogCompression.sol";
import { StableOracleMath } from "src/libraries/StableOracleMath.sol";
import { Uint31Lib } from "src/libraries/Uint31Lib.sol";
import { StableMath } from "src/libraries/StableMath.sol";
import { Observation } from "src/ReservoirPair.sol";
import { StablePair } from "src/curve/stable/StablePair.sol";
Expand Down Expand Up @@ -1454,14 +1453,14 @@ contract StablePairTest is BaseTest {

assertApproxEqRel(
LogCompression.fromLowResLog(
(lObs1.logAccRawPrice - lObs0.logAccRawPrice) / int32(Uint31Lib.sub(lObs1.timestamp, lObs0.timestamp))
(lObs1.logAccRawPrice - lObs0.logAccRawPrice) / int32(lObs1.timestamp - lObs0.timestamp)
),
lPrice1,
0.0001e18
);
assertApproxEqRel(
LogCompression.fromLowResLog(
(lObs2.logAccRawPrice - lObs0.logAccRawPrice) / int32(Uint31Lib.sub(lObs2.timestamp, lObs0.timestamp))
(lObs2.logAccRawPrice - lObs0.logAccRawPrice) / int32(lObs2.timestamp - lObs0.timestamp)
),
Math.sqrt(lPrice1 * lPrice2),
0.0001e18
Expand Down Expand Up @@ -1533,23 +1532,23 @@ contract StablePairTest is BaseTest {
// Price for observation window 0-1
assertApproxEqRel(
LogCompression.fromLowResLog(
(lObs1.logAccRawPrice - lObs0.logAccRawPrice) / int32(Uint31Lib.sub(lObs1.timestamp, lObs0.timestamp))
(lObs1.logAccRawPrice - lObs0.logAccRawPrice) / int32(lObs1.timestamp - lObs0.timestamp)
),
lSpotPrice1,
0.0001e18
);
// Price for observation window 1-2
assertApproxEqRel(
LogCompression.fromLowResLog(
(lObs2.logAccRawPrice - lObs1.logAccRawPrice) / int32(Uint31Lib.sub(lObs2.timestamp, lObs1.timestamp))
(lObs2.logAccRawPrice - lObs1.logAccRawPrice) / int32(lObs2.timestamp - lObs1.timestamp)
),
lSpotPrice2,
0.0001e18
);
// Price for observation window 0-2
assertApproxEqRel(
LogCompression.fromLowResLog(
(lObs2.logAccRawPrice - lObs0.logAccRawPrice) / int32(Uint31Lib.sub(lObs2.timestamp, lObs0.timestamp))
(lObs2.logAccRawPrice - lObs0.logAccRawPrice) / int32(lObs2.timestamp - lObs0.timestamp)
),
Math.sqrt(lSpotPrice1 * lSpotPrice2),
0.0001e18
Expand Down
17 changes: 0 additions & 17 deletions test/unit/libraries/Uint31Lib.t.sol

This file was deleted.

0 comments on commit dd85cc6

Please sign in to comment.