@@ -8,7 +8,6 @@ import { IERC721Receiver } from "openzeppelin/token/ERC721/IERC721Receiver.sol";
88import {
99 PWNLoan,
1010 LOANStatus,
11- PWNHubTags,
1211 Math,
1312 MultiToken,
1413 Terms,
@@ -42,7 +41,6 @@ abstract contract PWNLoanTest is Test {
4241 bytes32 internal constant LOAN_LOCK_SLOT = bytes32 (uint256 (4 )); // `loanLock` mapping position
4342
4443 PWNLoan loanContract;
45- address hub = makeAddr ("hub " );
4644 address loanToken = makeAddr ("loanToken " );
4745 address config = makeAddr ("config " );
4846 address categoryRegistry = makeAddr ("categoryRegistry " );
@@ -80,14 +78,13 @@ abstract contract PWNLoanTest is Test {
8078 event LOANLiquidated (uint256 indexed loanId , address indexed liquidator , uint256 liquidationAmount );
8179
8280 function setUp () virtual public {
83- vm.etch (hub, bytes ("data " ));
8481 vm.etch (loanToken, bytes ("data " ));
8582 vm.etch (config, bytes ("data " ));
8683
8784 (lender, lenderPK) = makeAddrAndKey ("lender " );
8885 (borrower, borrowerPK) = makeAddrAndKey ("borrower " );
8986
90- loanContract = new PWNLoan (hub, loanToken, config, categoryRegistry);
87+ loanContract = new PWNLoan (loanToken, config, categoryRegistry);
9188 fungibleAsset = new T20 ();
9289 nonFungibleAsset = new T721 ();
9390
@@ -173,12 +170,6 @@ abstract contract PWNLoanTest is Test {
173170 vm.mockCall (config, abi.encodeWithSignature ("fee() " ), abi.encode (0 ));
174171 vm.mockCall (config, abi.encodeWithSignature ("feeCollector() " ), abi.encode (feeCollector));
175172
176- vm.mockCall (hub, abi.encodeWithSignature ("hasTag(address,bytes32) " ), abi.encode (false ));
177- _mockHubTag (address (lenderCreateHook), PWNHubTags.HOOK);
178- _mockHubTag (address (lenderRepaymentHook), PWNHubTags.HOOK);
179- _mockHubTag (address (borrowerCreateHook), PWNHubTags.HOOK);
180- _mockHubTag (address (borrowerCollateralRepaymentHook), PWNHubTags.HOOK);
181-
182173 vm.mockCall (
183174 address (lenderCreateHook),
184175 abi.encodeWithSelector (IPWNLenderCreateHook.onLoanCreated.selector ),
@@ -269,14 +260,6 @@ abstract contract PWNLoanTest is Test {
269260 vm.mockCall (loanToken, abi.encodeWithSignature ("ownerOf(uint256) " , _loanId), abi.encode (_owner));
270261 }
271262
272- function _mockHubTag (address _contract , bytes32 _tag ) internal {
273- _mockHubTag (_contract, _tag, true );
274- }
275-
276- function _mockHubTag (address _contract , bytes32 _tag , bool _set ) internal {
277- vm.mockCall (hub, abi.encodeWithSignature ("hasTag(address,bytes32) " , _contract, _tag), abi.encode (_set));
278- }
279-
280263 function _mockIsDefaulted (uint256 _loanId , bool _defaulted ) internal {
281264 vm.mockCall (
282265 address (product),
@@ -573,19 +556,6 @@ contract PWNLoan_Create_Test is PWNLoanTest {
573556 loanContract.create (proposalSpec, lenderSpec, borrowerSpec, "" );
574557 }
575558
576- function test_shouldFail_whenLenderCreateHookNotTaggedInHub () external {
577- lenderSpec.createHook = IPWNLenderCreateHook (makeAddr ("not tagged lender create hook " ));
578-
579- terms.proposerSpecHash = loanContract.getLenderSpecHash (lenderSpec);
580- _mockLoanTerms (terms);
581-
582- vm.expectRevert (
583- abi.encodeWithSelector (PWNLoan.AddressMissingHubTag.selector , address (lenderSpec.createHook), PWNHubTags.HOOK)
584- );
585- vm.prank (borrower);
586- loanContract.create (proposalSpec, lenderSpec, borrowerSpec, "" );
587- }
588-
589559 function test_shouldFail_whenLenderCreateHookReturnsWrongValue () external {
590560 lenderSpec.createHook = lenderCreateHook;
591561
@@ -656,16 +626,6 @@ contract PWNLoan_Create_Test is PWNLoanTest {
656626 loanContract.create (proposalSpec, lenderSpec, borrowerSpec, "" );
657627 }
658628
659- function test_shouldFail_whenBorrowerCreateHookNotTaggedInHub () external {
660- borrowerSpec.createHook = IPWNBorrowerCreateHook (makeAddr ("not tagged lender create hook " ));
661-
662- vm.expectRevert (
663- abi.encodeWithSelector (PWNLoan.AddressMissingHubTag.selector , address (borrowerSpec.createHook), PWNHubTags.HOOK)
664- );
665- vm.prank (borrower);
666- loanContract.create (proposalSpec, lenderSpec, borrowerSpec, "" );
667- }
668-
669629 function test_shouldFail_whenBorrowerCreateHookReturnsWrongValue () external {
670630 borrowerSpec.createHook = borrowerCreateHook;
671631
@@ -968,30 +928,6 @@ contract PWNLoan_Repay_Test is PWNLoanTest {
968928 loanContract.repay (loanId, repayment);
969929 }
970930
971- function testFuzz_shouldTransferRepaymentToVault_whenLenderRepaymentHookSet_whenNotTaggedInHub (uint256 repayment ) external {
972- repayment = bound (repayment, 1 , loanContract.getLOANDebt (loanId));
973-
974- vm.prank (lender);
975- loanContract.updateLenderRepaymentHook (loanId, lenderRepaymentHook, "" );
976-
977- _mockHubTag (address (lenderRepaymentHook), PWNHubTags.HOOK, false );
978-
979- vm.expectCall (
980- loan.creditAddress,
981- abi.encodeWithSignature (
982- "transferFrom(address,address,uint256) " , borrower, address (loanContract), repayment
983- )
984- );
985-
986- uint256 vaultBalanceBefore = fungibleAsset.balanceOf (address (loanContract));
987-
988- vm.prank (borrower);
989- loanContract.repay (loanId, repayment);
990-
991- assertEq (fungibleAsset.balanceOf (address (loanContract)), vaultBalanceBefore + repayment);
992- assertEq (fungibleAsset.balanceOf (address (lenderRepaymentHook)), 0 );
993- }
994-
995931 function testFuzz_shouldTransferRepaymentToVault_whenLenderRepaymentHookSet_whenWrongReturnValue (uint256 repayment ) external {
996932 repayment = bound (repayment, 1 , loanContract.getLOANDebt (loanId));
997933
@@ -1117,16 +1053,6 @@ contract PWNLoan_RepayWithCollateral_Test is PWNLoanTest {
11171053 loanContract.repayWithCollateral (loanId, borrowerCollateralRepaymentHook, "hook data " );
11181054 }
11191055
1120- function test_shouldFail_whenBorrowerCollateralRepaymentHookNotTaggedInHub () external {
1121- IPWNBorrowerCollateralRepaymentHook hook = IPWNBorrowerCollateralRepaymentHook (makeAddr ("not tagged hook " ));
1122-
1123- vm.expectRevert (
1124- abi.encodeWithSelector (PWNLoan.AddressMissingHubTag.selector , address (hook), PWNHubTags.HOOK)
1125- );
1126- vm.prank (borrower);
1127- loanContract.repayWithCollateral (loanId, hook, "" );
1128- }
1129-
11301056 function test_shouldFail_whenBorrowerCollateralRepaymentHookReturnsWrongValue () external {
11311057 bytes32 wrongReturn = keccak256 ("wrong return " );
11321058 vm.mockCall (
@@ -1226,19 +1152,6 @@ contract PWNLoan_TryCallLenderRepaymentHook_Test is PWNLoanTest {
12261152 );
12271153 }
12281154
1229- function test_shouldFail_whenLenderRepaymentHookNotTaggedInHub () external {
1230- _mockHubTag (address (lenderRepaymentHook), PWNHubTags.HOOK, false );
1231-
1232- vm.expectRevert (
1233- abi.encodeWithSelector (PWNLoan.AddressMissingHubTag.selector , address (lenderRepaymentHook), PWNHubTags.HOOK)
1234- );
1235- vm.prank (address (loanContract));
1236- loanContract.tryCallLenderRepaymentHook (
1237- PWNLoan.LenderRepaymentHookData (lenderRepaymentHook, "" ),
1238- borrower, lender, loan.creditAddress, 1 ether
1239- );
1240- }
1241-
12421155 function test_shouldFail_whenLenderRepaymentHookReverts () external {
12431156 vm.mockCallRevert (
12441157 address (lenderRepaymentHook),
@@ -1801,17 +1714,7 @@ contract PWNLoan_GetBorrowerSpecHash_Test is PWNLoanTest {
18011714
18021715contract PWNLoan_UpdateLenderRepaymentHook_Test is PWNLoanTest {
18031716
1804- function test_shouldFail_whenNewHookIsNotTagged () external {
1805- _mockHubTag (address (lenderRepaymentHook), PWNHubTags.HOOK, false );
1806-
1807- vm.expectRevert (abi.encodeWithSelector (PWNLoan.AddressMissingHubTag.selector , lenderRepaymentHook, PWNHubTags.HOOK));
1808- vm.prank (lender);
1809- loanContract.updateLenderRepaymentHook (loanId, lenderRepaymentHook, "new repayment hook data " );
1810- }
1811-
18121717 function test_shouldUpdateLenderRepaymentHook () external {
1813- _mockHubTag (address (lenderRepaymentHook), PWNHubTags.HOOK);
1814-
18151718 vm.prank (lender);
18161719 loanContract.updateLenderRepaymentHook (loanId, lenderRepaymentHook, "new repayment hook data " );
18171720
@@ -1821,7 +1724,6 @@ contract PWNLoan_UpdateLenderRepaymentHook_Test is PWNLoanTest {
18211724
18221725 // Rewrite to new hook
18231726 IPWNLenderRepaymentHook newHook = IPWNLenderRepaymentHook (makeAddr ("newHook " ));
1824- _mockHubTag (address (newHook), PWNHubTags.HOOK);
18251727
18261728 vm.prank (lender);
18271729 loanContract.updateLenderRepaymentHook (loanId, newHook, "" );
0 commit comments