Borrow Flow Testing
Smart Contract Suite for Borrow Flow
Contracts Covered
CreateClaimU
UpdateClaimU
AddBorrowToLoanU
MintLoanTokenU
SetFinancialTermsU
UpdateLoanInfoU
AddProtectionToLoanU
SetUpdateProtectionDataU
UpdateProtectionU
SwapExactETHForTokensU
SwapExactTokensForETHU
SwapExactTokensForTokensU
TransferTokenU
BatchMintPortfolioU
FactoryActionU
MintPortfolioU
SetApprovedCollateralToLenderU
UncoveredLoanBlueprintU
ConcreteBlueprintU
LTVProtectBlueprintU
ProtectionBlueprintU
AccessControlManangerU
ActionManagerU
BlueprintManagerU
ConcreteStorageU
ExecutorTest
GuardManagerU
ModuleManagerU
ProtcolU
CompoundInterestU
DsMathMU
LoanBrokerageModuelU
LoanManagmentModuleU
CreateClaimU.spec.sol (Create Claim Action)
Initial Set-up:
Deployment of contracts and initialization of test roles.
Creation of portfolios and loan tokens for testing.
Functionality Tests:
Creating Claims: Validates the ability to create claim records, verifying details like token type, claim date, amount, and claim ID.
Failure Cases: Checks for expected failures such as invalid addresses, byte storage errors, and incorrect claim amounts.
UpdateClaimU.spec.sol (Update Claim Action)
Initial Set-up:
Initialization of test environments and roles.
Creation of portfolios, loan tokens, and a claim for updating.
Functionality Tests:
Updating Claims: Examines the contract's capacity to update existing claims, including scenarios of partial and full payments.
Error Handling: Ensures that the contract correctly handles invalid inputs, such as incorrect addresses or loan IDs.
AddBorrowToLoanU.spec.sol (Add Borrow to Loan Action)
Initial Set-up:
Configuration of testing environment and roles.
Minting of portfolios and loan tokens.
Functionality Tests:
Adding Borrow to Loan: Tests the process of adding borrow details to a loan, confirming the correct update of loan balances and details.
Error Checks: Validates the contract's error handling for invalid debt token addresses, loan balances, and loan amounts.
MintLoanTokenU.spec.sol (Mint Loan Token Contract)
Initial Set-up:
Preparation of test environments and assignment of roles.
Set up necessary data for loan token minting.
Functionality Tests:
Minting Loan Tokens: Assesses the contract's ability to mint loan tokens and set initial loan information.
Interface Compliance: Verifies compliance with the IERC721 interface and checks against invalid interfaces.
Failure Scenarios: Tests for failure in scenarios like invalid token IDs or portfolio IDs.
SetFinancialTermsU.spec.sol (Set Financial Terms Contract)
Initial Set-up:
Role initialization and test environment configuration.
Functionality Tests:
Setting Financial Terms: Tests the contract's functionality to set financial terms for loans, including parameters like LTV, promised amount, and collateral address.
Failure Cases: Checks for failure in scenarios like invalid user addresses, LTV values, and collateral addresses.
UpdateLoanInfoU.spec.sol (Update Loan Information Contract)
Initial Set-up:
Setting up test roles and environment.
Minting of portfolios and loan tokens for testing.
Functionality Tests:
Updating Loan Information: Validates the contract's ability to update loan details, such as loan ID, portfolio ID, and collateral balance.
Error Handling: Ensures appropriate responses to invalid inputs like portfolio IDs, vault IDs, and collateral balances.
AddProtectionToLoanU.spec.sol (Add Protection to Loan Contract)
Initial Set-up:
Configuration of test environments, roles, and minting of portfolios and loan tokens.
Functionality Tests:
Incrementing Protection Counter: Validates the increment of the protection counter after adding protection to a loan.
Adding Protection to Loan: Ensures correct association of protection details with a loan.
Failure Scenarios: Checks for various failure scenarios including invalid cancellation fees, opening fees, and user addresses.
SetUpdateProtectionDataU.spec.sol (Set Update Protection Action)
Functionality Tests:
Setting Update Protection Data: Verifies the ability to set and update protection data for a loan.
UpdateProtectionU.spec.sol (Update Protection Action)
Initial Set-up:
Preparation of test environment, roles, and loan setup.
Functionality Tests:
Updating Protection: Tests updating protection details like end date, credit offered, and interest rate.
Updating Specific Fields: Examines the ability to update individual fields like end date, available credit, and interest rate.
SwapExactETHForTokensU.spec.sol (Swap Exact ETH for Tokens Action)
Functionality Tests:
Swap ETH for Tokens: Checks the contract's ability to swap ETH for tokens and validates the correctness of the transaction.
Error Handling: Ensures that the contract handles zero values and invalid addresses correctly.
SwapExactTokensForETHU.spec.sol (Swap Exact Tokens for ETH Contract)
Initial Set-up:
Configuration of the testing environment and token approvals.
Functionality Tests:
Swap Tokens for ETH: Validates the swap functionality from tokens to ETH and the update of balances.
Failure Scenarios: Tests for invalid input amounts, token addresses, and pool fees.
SwapExactTokensForTokensU.spec.sol (Swap Exact Tokens for Tokens Action)
Initial Set-up:
Token approvals.
Functionality Tests:
Token to Token Swap: Ensures the ability to swap one type of token for another and verifies balance changes.
Asset Price Retrieval: Checks the functionality of retrieving asset prices for swap calculations.
Failure Scenarios: Assesses various failure scenarios including zero amounts, invalid token addresses, and pool fees.
TransferTokenU.spec.sol (Transfer Token Action)
Initial Set-up:
Basic environment setup without complex prerequisites.
Functionality Tests:
Token Transfer: Validates the transfer of tokens between addresses.
Failure Scenarios: Checks for scenarios like zero transfer amounts, invalid addresses, and lack of approvals.
BatchMintPortfolioU.spec.sol (Batch Mint Portfolio Action)
Functionality Tests:
Batch Minting Portfolios: Tests the ability to mint multiple portfolios simultaneously and validates balance updates.
Failure Scenarios: Verifies correct handling of invalid inputs such as already minted addresses and zero addresses.
MintPortfolioU.spec.sol (Mint Portfolio Action)
Functionality Tests:
Minting Portfolios: Ensures the functionality of minting individual portfolios and checks for correct owner assignments.
ERC721 Compliance Checks: Validates compliance with ERC721 standards and interface support.
Failure Scenarios: Examines cases like minting to already owned addresses and zero addresses.
FactoryActionU.spec.sol (Factory Action Action)
Initial Set-up:
Preparing the test environment, roles, and necessary variables.
Functionality Tests:
Clone Contract: Assesses the cloning of contracts with various user blueprint preferences.
Failure Scenarios: Tests for invalid input scenarios like non-contract addresses and duplicate actions.
SetApprovedCollateralToLenderU.spec.sol (Set Approved Collateral to Lender Action)
Functionality Tests:
Setting Approved Collateral: Verifies the ability to set and remove approved collateral for lenders.
Failure Scenarios: Tests for invalid inputs such as zero addresses for collateral.
UncoveredLoanBlueprintU.spec.sol (Uncovered Loan Blueprint )
Initial Set-up:
Preparation of the test environment, roles, and minting of necessary tokens.
Functionality Tests:
Loan Token Minting and Borrowing: Tests the process of minting loan tokens, adding borrows, and updating loan information.
Action Management: Validates the addition, removal, and retrieval of various actions within the blueprint.
ConcreteBlueprintU.spec.sol (Concrete Blueprint)
Initial Set-up:
Comprehensive setup including module addition, action whitelisting, and vault creation.
Functionality Tests:
Token Transfers and Debt Requests: Validates the contract's functionality for initiating token transfers, requesting debt tokens, and updating protection and loan information.
Swap Execution and Collateral Withdrawal: Tests the execution of token swaps and the withdrawal of collateral.
Failure Scenarios: Includes various failure cases in the context of invalid inputs and transaction failures.
LTVProtectBlueprintU.spec.sol (LTV Protect Blueprint )
Initial Set-up:
Extensive setup involving module additions, action whitelisting, and token transfers.
Functionality Tests:
Claim Creation and Collateral Request: Assesses the ability to create claims and request collateral based on loan details.
Swap Execution for Tokens: Tests the execution of swaps for tokens and ETH.
Failure Scenarios: Includes various failure cases like invalid user inputs and non-existent loan IDs.
ProtectionBlueprintU.spec.sol (Protection Blueprint Contract)
Functionality Tests:
Adding Protection to Loan: Tests the addition of protection data to loans.
Validation of Protection Process: Verifies the correctness of the protection process through balance checks.
AccessControlManangerU.spec.sol (Access Control Manager Core)
Functionality Tests:
Role Assignment Tests: Verifies the assignment and revocation of various roles like borrower, holder, admin, and sudo admin.
Multiple Role Grants: Checks the functionality of granting a role to multiple addresses.
ActionManagerU.spec.sol (Action Manager Core)
Functionality Tests:
Action Enable/Disable: Assesses the enabling and disabling of actions.
Action Execution: Tests the execution of enabled actions.
Error Handling: Examines various error scenarios including invalid action names and addresses.
BlueprintManagerU.spec.sol (Blueprint Manager Core)
Functionality Tests:
Blueprint Management: Tests enabling, disabling, and execution of blueprints.
Failure Scenarios: Includes failure cases to check for invalid blueprint names and addresses.
ConcreteStorageU.spec.sol (Concrete Storage Core)
Functionality Tests:
Storage Operations: Tests various storage operations including setting, reading and deleting values of different types (Address, Uint, Int, Bool, Bytes, Bytes32, String).
Initialization Checks: Verifies correct initialization of storage and handling of invalid inputs.
ExecutorTest.spec.sol (Executor Core)
Functionality Tests:
Delegate Call and Call Operations: Validates delegate call and call operations within the contract.
Reentrancy Checks: Assesses the reentrancy checks for various transaction types.
GuardManagerU.spec.sol (Guard Manager Core)
Functionality Tests:
Guard Assignment and Removal: Tests setting and removing guards for contracts.
Error Handling: Includes various error scenarios such as invalid module names and addresses.
ModuleManagerU.spec.sol (Module Manager Core)
Functionality Tests:
Module Management: Verifies the enabling, disabling, and execution of modules.
ProtcolU.spec.sol (Protocol Core)
Functionality Tests:
Module Enabling and Execution: Tests the enabling of modules and execution of module transactions.
Module Removal: Verifies the removal of modules from the protocol.
Error Handling: Assesses handling of invalid inputs and module names.
CompoundInterestU.spec.sol (Compound Interest Library)
Functionality Tests:
Interest Calculation: Validates the calculation of compound interest over different periods and rates.
Rate Conversion: Tests the conversion of yearly rates to compound rates.
Overflow Handling: Includes tests for handling overflow scenarios in interest calculations.
DsMathMU.spec.sol (DsMath Library)
Functionality Tests:
Arithmetic Operations: Assesses basic and fixed-point arithmetic operations like addition, subtraction, multiplication, division, and exponentiation.
Min/Max Functions: Tests the min and max functions for various data types.
Edge Cases: Includes tests for edge cases in arithmetic operations.
LoanBrokerageModuelU.spec.sol (Loan Brokerage Module Contract)
Functionality Tests:
Minting Loan Token:
Configures the necessary actions in the uncovered loan blueprint.
Enables the blueprint in the loan brokerage module.
Performs loan token minting with relevant data.
Adding Borrow to Loan:
Builds upon the mint loan token test.
Adds borrow data to the loan.
Adding Protection to Loan:
Approves WETH token transfer.
Sets up necessary actions in the protection blueprint.
Creates a master vault using the vault creation blueprint.
Adds protection to the loan with relevant data.
Removing Blueprint:
Enables a blueprint in the loan brokerage module.
Verifies the blueprint's presence.
Removes the blueprint and verifies its absence.
Last updated