buyCollateral tests refactoring#369
Open
VladyslavPerederWoof wants to merge 2 commits intofeat/service-patchfrom
Open
buyCollateral tests refactoring#369VladyslavPerederWoof wants to merge 2 commits intofeat/service-patchfrom
VladyslavPerederWoof wants to merge 2 commits intofeat/service-patchfrom
Conversation
… cases - Updated the buyCollateral test suite to support 24 collateral assets and added detailed setup for asset configurations. - Implemented new revert cases for paused state and conditions where reserves equal or exceed target reserves. - Improved test structure for clarity and maintainability.
…al market - Introduced a new test suite for the buyCollateral function, specifically for the WBTC base (8 decimals) and tBTC collateral (18 decimals). - Implemented scenarios for standard buys and price fluctuations, ensuring accurate quoting and balance changes. - Enhanced test clarity with detailed comments and structured setup for asset configurations.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Rewrites the
buyCollateraltest suite to targetCometWithExtendedAssetList(24 collateral assets) and align with the project's test writing conventions.Key changes
makeProtocol()tomakeConfigurator()— the maindescribenow deploys a full configurator/proxy stack with 24 collateral assets (ASSET0..ASSET23), exercisingCometWithExtendedAssetList+CometExtAssetListthrough the proxy.wait(),portfolio(),event(), and harness state-manipulation helpers (setTotalsBasic,setTotalsCollateral,setCollateralBalance). All state is now established through real protocol interactions (supply,withdraw,absorb,buyCollateral).describestructure with atomicitblocks — eachitchecks exactly one value (a single balance, a single event, a single revert). Actions like time advances and contract calls are their ownitblocks, making failures immediately identifiable.takeSnapshot/snapshot.restore()isolation — independentdescribeblocks share a common starting state via snapshots instead of re-deploying the protocol.revertedWithCustomError— replaces string-basedrevertedWith("custom error '...()'")assertions with typed custom error assertions (e.g.,.to.be.revertedWithCustomError(comet, 'NotForSale')).New test coverage
describe('revert cases')):Paused— buying whenisBuyPausedis trueNotForSale— reserves equal targetReserves exactly, and reserves exceed targetReservesTooMuchSlippage—minAmountexceeds quoted collateralInsufficientReserves— single buy exceeds collateral reserves, and a second consecutive buy exceeds remaining reserves after a first successful buyBuyCollateral, baseTransfer, collateralTransfer), alice/comet token balances, protocol reserves, and collateral reservestargetReserves=0, creates bad debt viaabsorb(price drop + liquidation), then buys collateral with negative reservesAssetListslots, validatinggetAssetInfoByAddressinsidequoteCollateral/buyCollateralfor every slotbuyCollateralviaEvilTokenbase is blocked (ReentrantCallBlocked), and a state-comparison proof shows reentrantsupplyFromduringbuyCollateralis silently blocked (eviltotalSupplyBase = 0vs normaltotalSupplyBase = 1e6)