Skip to content

Commit

Permalink
add test for registration with non-whitelisted token (#643)
Browse files Browse the repository at this point in the history
  • Loading branch information
doerfli committed Aug 27, 2024
1 parent 98fe508 commit ff354d4
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions test/component/product/ProductRegistration.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {RiskId, RiskIdLib, eqRiskId} from "../../../contracts/type/RiskId.sol";
import {ReferralLib} from "../../../contracts/type/Referral.sol";
import {SUBMITTED, ACTIVE, COLLATERALIZED, CONFIRMED, DECLINED, CLOSED} from "../../../contracts/type/StateId.sol";
import {StateId} from "../../../contracts/type/StateId.sol";
import {Usdc} from "../../mock/Usdc.sol";

contract TestProductRegistration is GifTest {

Expand All @@ -60,8 +61,7 @@ contract TestProductRegistration is GifTest {
}


// TODO fix + re-enable
function skip_test_productRegisterTwoProductsHappyCase() public {
function test_productRegisterTwoProductsHappyCase() public {
// GIVEN
SimpleProduct myProduct1 = _deployProductDefault("MyProduct1");
SimpleProduct myProduct2 = _deployProductDefault("MyProduct2");
Expand Down Expand Up @@ -199,6 +199,22 @@ contract TestProductRegistration is GifTest {
vm.stopPrank();
}

function test_productRegister_tokenNotWhitelisted() public {
// GIVEN
SimpleProduct myProduct = _deployProductDefault("MyProduct");
Usdc notWhitelistedToken = new Usdc();

vm.startPrank(instanceOwner);

// THEN
vm.expectRevert(abi.encodeWithSelector(
IComponentService.ErrorComponentServiceTokenInvalid.selector,
notWhitelistedToken));

// WHEN
instance.registerProduct(address(myProduct), address(notWhitelistedToken));
}

function _deployProductDefault(string memory name) internal returns(SimpleProduct) {
return _deployProduct(name, myProductOwner, false, 0);
}
Expand Down

0 comments on commit ff354d4

Please sign in to comment.