From e5c687e4a6ebdcb3cc5e2e3b3bb5df6c53c29346 Mon Sep 17 00:00:00 2001 From: green Date: Wed, 18 Sep 2024 15:59:30 +0200 Subject: [PATCH] test: add an invariant profile to the foundry configuration --- packages/contracts/foundry.toml | 3 +++ .../diamond/facets/PoolFacetHandler.sol | 16 ++++++++++------ .../facets/UbiquityPoolFacet.invariant.t.sol | 2 +- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/packages/contracts/foundry.toml b/packages/contracts/foundry.toml index 8b516b440..c1c0e91ca 100644 --- a/packages/contracts/foundry.toml +++ b/packages/contracts/foundry.toml @@ -43,3 +43,6 @@ src = 'src/dollar' [profile.intense.fuzz] runs = 100000 max_test_rejects = 900000 + +[profile.intense.invariant] +runs = 50000 # ~1 hour \ No newline at end of file diff --git a/packages/contracts/test/invariant/diamond/facets/PoolFacetHandler.sol b/packages/contracts/test/invariant/diamond/facets/PoolFacetHandler.sol index 651b46e5c..1617d5c0b 100644 --- a/packages/contracts/test/invariant/diamond/facets/PoolFacetHandler.sol +++ b/packages/contracts/test/invariant/diamond/facets/PoolFacetHandler.sol @@ -73,14 +73,18 @@ contract PoolFacetHandler is Test { } /** - * @notice Manipulates the Ubiquity Dollar price to a value above a set threshold. + * @notice Simulates setting the Ubiquity Dollar price to a value of the minting threshold. + * @dev This function updates the mocked Curve pool parameters to simulate a Ubiquity Dollar price of $1.01. + * The threshold of $1.01 is significant because it represents the upper bound at which new Ubiquity Dollars can be minted. */ function setDollarPriceAboveThreshold() public { curveDollarPlainPool.updateMockParams(1.01e18); } /** - * @notice Manipulates the Ubiquity Dollar price to a value below a set threshold. + * @notice Simulates setting the Ubiquity Dollar price to a value of the redemption threshold. + * @dev This function updates the mocked Curve pool parameters to simulate a Ubiquity Dollar price of $0.99. + * The threshold of $0.99 is significant because it represents the lower bound at which Ubiquity Dollars can be redeemed. */ function setDollarPriceBelowThreshold() public { curveDollarPlainPool.updateMockParams(0.99e18); @@ -139,9 +143,9 @@ contract PoolFacetHandler is Test { } /** - * @notice Manipulates the stable USD price and updates the corresponding collateral ratio. + * @notice Manipulates the stable USD price. * @dev This function adjusts the price of the stable USD token using a mock ChainLink price feed. - * It assumes the new price is within the specified range and updates the collateral ratio in the UbiquityPoolFacet. + * It assumes the new price is within the specified range. * @param _newPrice The new price of the stable USD token, scaled by 1e8 (e.g., a price of $1 is represented as 1e8). */ function setStableUsdPrice(uint256 _newPrice) public { @@ -158,9 +162,9 @@ contract PoolFacetHandler is Test { } /** - * @notice Manipulates the collateral price and updates the corresponding collateral ratio. + * @notice Manipulates the collateral price. * @dev This function adjusts the price of the collateral token using a mock ChainLink price feed. - * It assumes the new price is within the allowed range and updates the collateral ratio in the UbiquityPoolFacet. + * It assumes the new price is within the allowed range. * @param _newPrice The new price of the collateral, scaled by 1e8 (e.g., a price of $1 is represented as 1e8). */ function setCollateralPrice(int256 _newPrice) public { diff --git a/packages/contracts/test/invariant/diamond/facets/UbiquityPoolFacet.invariant.t.sol b/packages/contracts/test/invariant/diamond/facets/UbiquityPoolFacet.invariant.t.sol index 87b9ab74d..114d646a1 100644 --- a/packages/contracts/test/invariant/diamond/facets/UbiquityPoolFacet.invariant.t.sol +++ b/packages/contracts/test/invariant/diamond/facets/UbiquityPoolFacet.invariant.t.sol @@ -207,7 +207,7 @@ contract UbiquityPoolFacetInvariantTest is DiamondTestSetup { /** * @notice Helper function to get the USD value of total Dollar supply and the collateral USD balance. * @dev This function returns the current total supply of Ubiquity Dollars in USD and the USD value of the collateral. - * @return totalDollarSupplyInUsd The total supply of Ubiquity Dollars in USD (6 decimals). + * @return totalDollarSupplyInUsd The total supply of Ubiquity Dollars in USD (18 decimals). * @return collateralUsdBalance The total USD value of collateral backing the Ubiquity Dollars (18 decimals). */ function getDollarSupplyAndCollateralBalance()