Skip to content

Commit

Permalink
chore: move example implementations to mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
0xgregthedev committed Feb 2, 2024
1 parent 852edf8 commit 076d9c6
Show file tree
Hide file tree
Showing 25 changed files with 333 additions and 56 deletions.
2 changes: 1 addition & 1 deletion src/enforcers/BorrowerEnforcer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ contract BorrowerEnforcer is CaveatEnforcer {
/**
* @dev Enforces that the loan terms are identical except for the issuer
* The issuer is allowed to be any address
* No additional transfers are permitted
* No additional transfers are permitted from the borrower
* @param additionalTransfers The additional transfers to be made
* @param loan The loan terms
* @param caveatData The borrowers encoded details
Expand Down
29 changes: 14 additions & 15 deletions test/StarportTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "forge-std/Test.sol";
import {Vm} from "forge-std/Vm.sol";
import {Starport, Stargate} from "starport-core/Starport.sol";
import {Pricing} from "starport-core/pricing/Pricing.sol";
import {StrategistOriginator} from "starport-core/originators/StrategistOriginator.sol";
import {StrategistOriginator} from "starport-test/mocks/originators/StrategistOriginator.sol";
import {
ItemType,
ReceivedItem,
Expand All @@ -29,39 +29,38 @@ import {Consideration} from "seaport-core/src/lib/Consideration.sol";
//import {
// ReferenceConsideration as Consideration
//} from "seaport/reference/ReferenceConsideration.sol";
import {StrategistOriginator} from "starport-core/originators/StrategistOriginator.sol";

import {SimpleInterestPricing} from "starport-core/pricing/SimpleInterestPricing.sol";

import {BasePricing} from "starport-core/pricing/BasePricing.sol";

import {FixedTermStatus} from "starport-core/status/FixedTermStatus.sol";
import {FixedTermDutchAuctionSettlement} from "starport-core/settlement/FixedTermDutchAuctionSettlement.sol";
import {DutchAuctionSettlement} from "starport-core/settlement/DutchAuctionSettlement.sol";

import {Custodian} from "starport-core/Custodian.sol";
import {Starport} from "starport-core/Starport.sol";

import {Actions} from "starport-core/lib/StarportLib.sol";
import {BaseOrderTest} from "seaport/test/foundry/utils/BaseOrderTest.sol";
import {TestERC721} from "seaport/contracts/test/TestERC721.sol";
import {TestERC1155} from "seaport/contracts/test/TestERC1155.sol";
import {TestERC20} from "seaport/contracts/test/TestERC20.sol";
import {ConsiderationItemLib} from "seaport/lib/seaport-sol/src/lib/ConsiderationItemLib.sol";
import {Custodian} from "starport-core/Custodian.sol";
import "seaport/lib/seaport-sol/src/lib/AdvancedOrderLib.sol";
import {Status} from "starport-core/status/Status.sol";
import {Settlement} from "starport-core/settlement/Settlement.sol";
import {TestERC721} from "seaport/contracts/test/TestERC721.sol";
import {TestERC1155} from "seaport/contracts/test/TestERC1155.sol";
import {TestERC20} from "seaport/contracts/test/TestERC20.sol";
import {TokenReceiverInterface} from "starport-core/interfaces/TokenReceiverInterface.sol";
import {Pricing} from "starport-core/pricing/Pricing.sol";

import {BorrowerEnforcerBNPL} from "starport-test/mocks/enforcers/BorrowerEnforcerBNPL.sol";
import {Cast} from "starport-test/utils/Cast.sol";
import {DutchAuctionSettlement} from "starport-test/mocks/settlement/DutchAuctionSettlement.sol";
import {FixedTermStatus} from "starport-test/mocks/status/FixedTermStatus.sol";
import {FixedTermDutchAuctionSettlement} from "starport-test/mocks/settlement/FixedTermDutchAuctionSettlement.sol";
import {SimpleInterestPricing} from "starport-test/mocks/pricing/SimpleInterestPricing.sol";

import {ERC20} from "solady/src/tokens/ERC20.sol";
import {ERC721} from "solady/src/tokens/ERC721.sol";
import {ERC1155} from "solady/src/tokens/ERC1155.sol";
import {ContractOffererInterface} from "seaport-types/src/interfaces/ContractOffererInterface.sol";
import {TokenReceiverInterface} from "starport-core/interfaces/TokenReceiverInterface.sol";
import {Actions} from "starport-core/lib/StarportLib.sol";

import {CaveatEnforcer} from "starport-core/enforcers/CaveatEnforcer.sol";
import {BorrowerEnforcer} from "starport-core/enforcers/BorrowerEnforcer.sol";
import {BorrowerEnforcerBNPL} from "starport-core/enforcers/BorrowerEnforcerBNPL.sol";

import {LenderEnforcer} from "starport-core/enforcers/LenderEnforcer.sol";
import {FixedPointMathLib} from "solady/src/utils/FixedPointMathLib.sol";
Expand Down
4 changes: 2 additions & 2 deletions test/integration-testing/TestNewLoan.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ pragma solidity ^0.8.17;

import "starport-test/StarportTest.sol";
import {StarportLib, Actions} from "starport-core/lib/StarportLib.sol";
import {BNPLHelper, IFlashLoanRecipient} from "starport-core/BNPLHelper.sol";
import {Originator} from "starport-core/originators/Originator.sol";
import {BNPLHelper, IFlashLoanRecipient} from "starport-test/mocks/BNPLHelper.sol";
import {Originator} from "starport-test/mocks/originators/Originator.sol";
import {SignatureCheckerLib} from "solady/src/utils/SignatureCheckerLib.sol";

contract FlashLoan {
Expand Down
2 changes: 1 addition & 1 deletion test/integration-testing/TestRepayLoan.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pragma solidity ^0.8.17;

import "starport-test/StarportTest.sol";
import {SimpleInterestPricing} from "starport-core/pricing/SimpleInterestPricing.sol";
import {SimpleInterestPricing} from "starport-test/mocks/pricing/SimpleInterestPricing.sol";
import {BasePricing} from "starport-core/pricing/BasePricing.sol";
import {FixedPointMathLib} from "solady/src/utils/FixedPointMathLib.sol";
import {ZoneInteractionErrors} from "seaport-types/src/interfaces/ZoneInteractionErrors.sol";
Expand Down
6 changes: 3 additions & 3 deletions src/BNPLHelper.sol → test/mocks/BNPLHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@

pragma solidity ^0.8.17;

import {Starport} from "./Starport.sol";
import {CaveatEnforcer} from "./enforcers/CaveatEnforcer.sol";
import {AdditionalTransfer} from "./lib/StarportLib.sol";
import {Starport} from "starport-core/Starport.sol";
import {CaveatEnforcer} from "starport-core/enforcers/CaveatEnforcer.sol";
import {AdditionalTransfer} from "starport-core/lib/StarportLib.sol";
import {Ownable} from "solady/src/auth/Ownable.sol";
import {Seaport} from "seaport/contracts/Seaport.sol";
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@

pragma solidity ^0.8.17;

import {Starport} from "../Starport.sol";
import {CaveatEnforcer} from "../enforcers/CaveatEnforcer.sol";
import {AdditionalTransfer} from "../lib/StarportLib.sol";
import {Starport} from "starport-core/Starport.sol";
import {CaveatEnforcer} from "starport-core/enforcers/CaveatEnforcer.sol";
import {AdditionalTransfer} from "starport-core/lib/StarportLib.sol";

import {ConsiderationInterface} from "seaport-types/src/interfaces/ConsiderationInterface.sol";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

pragma solidity ^0.8.17;

import {Starport} from "../Starport.sol";
import {CaveatEnforcer} from "../enforcers/CaveatEnforcer.sol";
import {Starport} from "starport-core/Starport.sol";
import {CaveatEnforcer} from "starport-core/enforcers/CaveatEnforcer.sol";

import {SpentItem} from "seaport-types/src/lib/ConsiderationStructs.sol";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@

pragma solidity ^0.8.17;

import {Starport} from "../Starport.sol";
import {CaveatEnforcer} from "../enforcers/CaveatEnforcer.sol";
import {Originator} from "../originators/Originator.sol";
import {AdditionalTransfer, StarportLib} from "../lib/StarportLib.sol";
import {Starport} from "starport-core/Starport.sol";
import {CaveatEnforcer} from "starport-core/enforcers/CaveatEnforcer.sol";
import {Originator} from "starport-test/mocks/originators/Originator.sol";
import {AdditionalTransfer, StarportLib} from "starport-core/lib/StarportLib.sol";

import {ConduitControllerInterface} from "seaport-types/src/interfaces/ConduitControllerInterface.sol";
import {ConduitInterface} from "seaport-types/src/interfaces/ConduitInterface.sol";
import {ItemType, ReceivedItem, SpentItem} from "seaport-types/src/lib/ConsiderationStructs.sol";
import {ECDSA} from "solady/src/utils/ECDSA.sol";
import {Ownable} from "solady/src/auth/Ownable.sol";
import {SignatureCheckerLib} from "solady/src/utils/SignatureCheckerLib.sol";
import {TokenReceiverInterface} from "../interfaces/TokenReceiverInterface.sol";
import {TokenReceiverInterface} from "starport-core/interfaces/TokenReceiverInterface.sol";

// Validator abstract contract that lays out the necessary structure and functions for the validator
contract StrategistOriginator is Ownable, Originator, TokenReceiverInterface {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@

pragma solidity ^0.8.17;

import {Starport} from "../Starport.sol";
import {ReceivedItem, BasePricing} from "../pricing/BasePricing.sol";
import {Pricing} from "../pricing/Pricing.sol";
import {Validation} from "../lib/Validation.sol";
import {StarportLib, AdditionalTransfer} from "../lib/StarportLib.sol";
import {Starport} from "starport-core/Starport.sol";
import {ReceivedItem, BasePricing} from "starport-core/pricing/BasePricing.sol";
import {Pricing} from "starport-core/pricing/Pricing.sol";
import {Validation} from "starport-core/lib/Validation.sol";
import {StarportLib, AdditionalTransfer} from "starport-core/lib/StarportLib.sol";

import {SpentItem, ReceivedItem} from "seaport-types/src/lib/ConsiderationStructs.sol";
import {FixedPointMathLib} from "solady/src/utils/FixedPointMathLib.sol";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ import {
OrderParameters
} from "seaport-types/src/lib/ConsiderationStructs.sol";

import {Pricing} from "../pricing/Pricing.sol";
import {Pricing} from "starport-core/pricing/Pricing.sol";
import {AmountDeriver} from "seaport-core/src/lib/AmountDeriver.sol";
import {FixedPointMathLib} from "solady/src/utils/FixedPointMathLib.sol";
import {Starport, Settlement} from "../settlement/Settlement.sol";
import {Starport, Settlement} from "starport-core/settlement/Settlement.sol";

import {BasePricing} from "../pricing/BasePricing.sol";
import {Validation} from "../lib/Validation.sol";
import {BasePricing} from "starport-core/pricing/BasePricing.sol";
import {Validation} from "starport-core/lib/Validation.sol";

// DutchAuctionSettlement is not full compatible with all debt assets supported by Starport
// DutchAuctionSettlement makes the assumption that the loan.debt consists on an array size 1 containing only ERC-20s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@

pragma solidity ^0.8.17;

import {Starport} from "../Starport.sol";
import {DutchAuctionSettlement} from "../settlement/DutchAuctionSettlement.sol";
import {FixedTermStatus} from "../status/FixedTermStatus.sol";
import {Settlement} from "../settlement/Settlement.sol";
import {StarportLib} from "../lib/StarportLib.sol";
import {Starport} from "starport-core/Starport.sol";
import {DutchAuctionSettlement} from "starport-test/mocks/settlement/DutchAuctionSettlement.sol";
import {FixedTermStatus} from "starport-test/mocks/status/FixedTermStatus.sol";
import {Settlement} from "starport-core/settlement/Settlement.sol";
import {StarportLib} from "starport-core/lib/StarportLib.sol";

import {FixedPointMathLib} from "solady/src/utils/FixedPointMathLib.sol";
import {SpentItem} from "seaport-types/src/lib/ConsiderationStructs.sol";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@

pragma solidity ^0.8.17;

import {Starport} from "../Starport.sol";
import {Status} from "../status/Status.sol";
import {Validation} from "../lib/Validation.sol";
import {Starport} from "starport-core/Starport.sol";
import {Status} from "starport-core/status/Status.sol";
import {Validation} from "starport-core/lib/Validation.sol";

contract FixedTermStatus is Status {
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
Expand Down
4 changes: 2 additions & 2 deletions test/unit-testing/ModuleTesting.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {LibString} from "solady/src/utils/LibString.sol";
import {Validation} from "starport-core/lib/Validation.sol";
import "forge-std/console.sol";
import "../utils/DeepEq.sol";
import {DutchAuctionSettlement} from "starport-core/settlement/DutchAuctionSettlement.sol";
import {FixedTermStatus} from "starport-core/status/FixedTermStatus.sol";
import {DutchAuctionSettlement} from "starport-test/mocks/settlement/DutchAuctionSettlement.sol";
import {FixedTermStatus} from "starport-test/mocks/status/FixedTermStatus.sol";
import {BasePricing} from "starport-core/pricing/BasePricing.sol";

contract MockBasePricing is BasePricing {
Expand Down
29 changes: 29 additions & 0 deletions test/unit-testing/TestBorrowerEnforcer.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
// SPDX-License-Identifier: BUSL-1.1
//
// ↑↑↑↑ ↑↑
// ↑↑↑↑ ↑↑↑↑↑
// ↑↑↑↑ ↑ ↑
// ↑↑↑↑ ↑↑↑↑↑
// ↑ ↑↑↑↑ ↑ ↑
// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑
// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑↑
// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑
// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑↑↑ ↑↑↑↑↑↑↑↑↑ ↑↑ ↑↑↑ ↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑↑↑↑
// ↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑ ↑↑↑
// ↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑
// ↑↑↑↑ ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑↑↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑
// ↑↑↑↑ ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑
// ↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑ ↑↑ ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑
// ↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑↑↑↑ ↑↑↑↑↑↑ ↑↑↑ ↑↑↑
// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑
// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑ ↑↑↑ Starport: Lending Kernel
// ↑ ↑↑↑↑ ↑↑↑↑↑
// ↑↑↑↑ ↑↑↑↑↑ Designed with love by Astaria Labs, Inc
// ↑↑↑↑ ↑
// ↑↑↑↑
// ↑↑↑↑
// ↑↑↑↑
// ↑↑↑↑

pragma solidity ^0.8.17;

import "starport-test/StarportTest.sol";
import {BorrowerEnforcer} from "starport-core/enforcers/BorrowerEnforcer.sol";
import {AdditionalTransfer, ItemType} from "starport-core/lib/StarportLib.sol";
Expand Down
27 changes: 27 additions & 0 deletions test/unit-testing/TestCustodian.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
// SPDX-License-Identifier: BUSL-1.1
//
// ↑↑↑↑ ↑↑
// ↑↑↑↑ ↑↑↑↑↑
// ↑↑↑↑ ↑ ↑
// ↑↑↑↑ ↑↑↑↑↑
// ↑ ↑↑↑↑ ↑ ↑
// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑
// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑↑
// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑
// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑↑↑ ↑↑↑↑↑↑↑↑↑ ↑↑ ↑↑↑ ↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑↑↑↑
// ↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑ ↑↑↑
// ↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑
// ↑↑↑↑ ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑↑↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑
// ↑↑↑↑ ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑
// ↑↑↑↑↑↑↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑↑ ↑↑ ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑ ↑↑↑ ↑↑↑ ↑↑↑
// ↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑ ↑↑ ↑↑↑ ↑↑↑↑↑↑ ↑↑↑↑↑↑ ↑↑↑ ↑↑↑
// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑↑ ↑↑↑
// ↑↑↑↑↑ ↑↑↑↑ ↑↑↑↑ ↑↑↑ Starport: Lending Kernel
// ↑ ↑↑↑↑ ↑↑↑↑↑
// ↑↑↑↑ ↑↑↑↑↑ Designed with love by Astaria Labs, Inc
// ↑↑↑↑ ↑
// ↑↑↑↑
// ↑↑↑↑
// ↑↑↑↑
// ↑↑↑↑

pragma solidity ^0.8.17;

import "starport-test/StarportTest.sol";
Expand Down
4 changes: 2 additions & 2 deletions test/unit-testing/TestPricing.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import {StarportLib} from "starport-core/lib/StarportLib.sol";
import {DeepEq} from "starport-test/utils/DeepEq.sol";
import {FixedPointMathLib} from "solady/src/utils/FixedPointMathLib.sol";
import {SpentItemLib} from "seaport-sol/src/lib/SpentItemLib.sol";
import {Originator} from "starport-core/originators/Originator.sol";
import {Originator} from "starport-test/mocks/originators/Originator.sol";
import {Starport} from "starport-core/Starport.sol";
import {ReceivedItem} from "seaport-types/src/lib/ConsiderationStructs.sol";

import {BasePricing} from "starport-core/pricing/BasePricing.sol";
import {SimpleInterestPricing} from "starport-core/pricing/SimpleInterestPricing.sol";
import {SimpleInterestPricing} from "starport-test/mocks/pricing/SimpleInterestPricing.sol";

contract TestSimpleInterestPricing is StarportTest, DeepEq {
using Cast for *;
Expand Down
Loading

0 comments on commit 076d9c6

Please sign in to comment.