Skip to content

Commit

Permalink
Merge pull request #169 from Gearbox-protocol/attach-test-degen-nft
Browse files Browse the repository at this point in the history
feat: add degen nft minting to live/attach tests
  • Loading branch information
Van0k authored Dec 26, 2023
2 parents 99d4ccd + 10ddfc1 commit 63bcadf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
14 changes: 13 additions & 1 deletion contracts/test/helpers/IntegrationTestHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@ contract IntegrationTestHelper is TestHelper, BalanceHelper, ConfigManager {
creditFacade = CreditFacadeV3(creditManager.creditFacade());
creditConfigurator = CreditConfiguratorV3(creditManager.creditConfigurator());

address degenNFT = creditFacade.degenNFT();

if (!_attachPool(creditManager.pool())) {
return false;
}
Expand All @@ -325,7 +327,7 @@ contract IntegrationTestHelper is TestHelper, BalanceHelper, ConfigManager {
return false;
}

if (!anyDegenNFT && whitelisted != (creditFacade.degenNFT() != address(0))) {
if (!anyDegenNFT && whitelisted != (degenNFT != address(0))) {
return false;
}
if (configAccountAmount == 0) {
Expand All @@ -334,6 +336,13 @@ contract IntegrationTestHelper is TestHelper, BalanceHelper, ConfigManager {
creditAccountAmount = configAccountAmount;
}

if (degenNFT != address(0)) {
address minter = DegenNFTV2(degenNFT).minter();

vm.prank(minter);
DegenNFTV2(degenNFT).mint(USER, 1000);
}

return true;
}

Expand Down Expand Up @@ -386,6 +395,9 @@ contract IntegrationTestHelper is TestHelper, BalanceHelper, ConfigManager {
vm.prank(CONFIGURATOR);
degenNFT.setMinter(CONFIGURATOR);

vm.prank(CONFIGURATOR);
degenNFT.mint(USER, 1000);

uint256 len = allCms.length;

for (uint256 i; i < len; ++i) {
Expand Down
6 changes: 4 additions & 2 deletions contracts/test/integration/credit/OpenCreditAccount.int.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,16 @@ contract OpenCreditAccountIntegrationTest is IntegrationTestHelper, ICreditFacad
function test_I_OCA_03_openCreditAccount_burns_token_in_whitelisted_mode() public withDegenNFT creditTest {
IDegenNFTV2 degenNFT = IDegenNFTV2(creditFacade.degenNFT());

uint256 startingBalance = degenNFT.balanceOf(USER);

vm.prank(CONFIGURATOR);
degenNFT.mint(USER, 2);

expectBalance(address(degenNFT), USER, 2);
expectBalance(address(degenNFT), USER, startingBalance + 2);

_openTestCreditAccount();

expectBalance(address(degenNFT), USER, 1);
expectBalance(address(degenNFT), USER, startingBalance + 1);
}

// // /// @dev I:[OCA-4]: openCreditAccount sets correct values
Expand Down

0 comments on commit 63bcadf

Please sign in to comment.