Skip to content
This repository has been archived by the owner on Apr 30, 2024. It is now read-only.

Commit

Permalink
adjust error.sol
Browse files Browse the repository at this point in the history
  • Loading branch information
Spablob committed Feb 4, 2024
1 parent 481ecae commit 5c067b2
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 15 deletions.
3 changes: 2 additions & 1 deletion contracts/lib/Errors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,9 @@ library Errors {
error RoyaltyModule__NotWhitelistedRoyaltyToken();
error RoyaltyModule__NoRoyaltyPolicySet();
error RoyaltyModule__IncompatibleRoyaltyPolicy();
error RoyaltyModule__NotRegistrationModule();
error RoyaltyModule__NotAllowedCaller();
error RoyaltyModule__ZeroLicensingModule();
error RoyaltyModule__ZeroLicenseRegistry();

error RoyaltyPolicyLS__ZeroRoyaltyModule();
error RoyaltyPolicyLS__ZeroLiquidSplitFactory();
Expand Down
2 changes: 1 addition & 1 deletion script/foundry/deployment/Main.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ contract Main is Script, BroadcastManager, JsonDeploymentHandler {

function _configInitialize() private {
accessController.initialize(address(ipAssetRegistry), address(moduleRegistry));
royaltyModule.initialize(address(registrationModule));
royaltyModule.initialize(address(registrationModule), address(licenseRegistry));
}

function _configureModuleRegistry() private {
Expand Down
2 changes: 1 addition & 1 deletion test/foundry/integration/BaseIntegration.sol
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ contract BaseIntegration is Test {
function _configDeployedContracts() internal {
vm.startPrank(u.admin);
accessController.initialize(address(ipAccountRegistry), address(moduleRegistry));
royaltyModule.initialize(address(registrationModule));
royaltyModule.initialize(address(registrationModule), address(licenseRegistry));

moduleRegistry.registerModule(REGISTRATION_MODULE_KEY, address(registrationModule));
moduleRegistry.registerModule(IP_RESOLVER_MODULE_KEY, address(ipResolver));
Expand Down
2 changes: 1 addition & 1 deletion test/foundry/modules/ModuleBase.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ abstract contract ModuleBaseTest is BaseTest {
);
baseModule = IModule(_deployModule());
accessController.initialize(address(ipAssetRegistry), address(moduleRegistry));
royaltyModule.initialize(address(registrationModule));
royaltyModule.initialize(address(registrationModule), address(licenseRegistry));
}

/// @notice Tests that the default resolver constructor runs successfully.
Expand Down
44 changes: 35 additions & 9 deletions test/foundry/modules/royalty/RoyaltyModule.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,27 @@ contract TestRoyaltyModule is TestHelper {
vm.stopPrank();
}

function test_RoyaltyModule_constructor_revert_ZeroRegistrationModule() public {
function test_RoyaltyModule_initialize_revert_ZeroRegistrationModule() public {
RoyaltyModule testRoyaltyModule = new RoyaltyModule(address(governance));
vm.expectRevert(Errors.RoyaltyModule__ZeroLicensingModule.selector);
vm.prank(u.admin);
testRoyaltyModule.initialize(address(0));
testRoyaltyModule.initialize(address(0), address(licenseRegistry));
}

function test_RoyaltyModule_constructor() public {
function test_RoyaltyModule_initialize_revert_ZeroLicenseRegistry() public {
RoyaltyModule testRoyaltyModule = new RoyaltyModule(address(governance));
vm.expectRevert(Errors.RoyaltyModule__ZeroLicenseRegistry.selector);
vm.prank(u.admin);
testRoyaltyModule.initialize(address(registrationModule));
testRoyaltyModule.initialize(address(registrationModule), address(0));
}

function test_RoyaltyModule_initialize() public {
vm.startPrank(u.admin);
RoyaltyModule testRoyaltyModule = new RoyaltyModule(address(governance));
testRoyaltyModule.initialize(address(registrationModule), address(licenseRegistry));

assertEq(testRoyaltyModule.REGISTRATION_MODULE(), address(registrationModule));
assertEq(testRoyaltyModule.governance(), address(governance));
assertEq(testRoyaltyModule.LICENSE_REGISTRY(), address(licenseRegistry));
}

function test_RoyaltyModule_whitelistRoyaltyPolicy_revert_ZeroRoyaltyToken() public {
Expand Down Expand Up @@ -83,16 +91,35 @@ contract TestRoyaltyModule is TestHelper {
assertEq(royaltyModule.isWhitelistedRoyaltyToken(address(1)), true);
}

function test_RoyaltyModule_setRoyaltyPolicy_revert_NotAllowedCaller() public {
address[] memory parentIpIds = new address[](0);
uint32 minRoyaltyIpAccount = 100; // 10%
bytes memory data = abi.encode(minRoyaltyIpAccount);

vm.expectRevert(Errors.RoyaltyModule__NotAllowedCaller.selector);
royaltyModule.setRoyaltyPolicy(ipAccount1, address(royaltyPolicyLS), parentIpIds, data);
}

function test_RoyaltyModule_setRoyaltyPolicy_revert_AlreadySetRoyaltyPolicy() public {
address[] memory parentIpIds1 = new address[](0);
uint32 minRoyaltyIpAccount1 = 100; // 10%
bytes memory data = abi.encode(minRoyaltyIpAccount1);
bytes memory data1 = abi.encode(minRoyaltyIpAccount1);

vm.startPrank(address(registrationModule));
royaltyModule.setRoyaltyPolicy(ipAccount1, address(royaltyPolicyLS), parentIpIds1, data);
royaltyModule.setRoyaltyPolicy(ipAccount1, address(royaltyPolicyLS), parentIpIds1, data1);

address[] memory parentIpIds2 = new address[](1);
parentIpIds2[0] = ipAccount1;
uint32 minRoyaltyIpAccount2 = 100; // 10%
bytes memory data2 = abi.encode(minRoyaltyIpAccount2);

royaltyModule.setRoyaltyPolicy(ipAccount1, address(royaltyPolicyLS), parentIpIds2, data2);

vm.expectRevert(Errors.RoyaltyModule__AlreadySetRoyaltyPolicy.selector);
royaltyModule.setRoyaltyPolicy(ipAccount1, address(royaltyPolicyLS), parentIpIds1, data);
royaltyModule.setRoyaltyPolicy(ipAccount1, address(royaltyPolicyLS), parentIpIds1, data1);

vm.expectRevert(Errors.RoyaltyModule__AlreadySetRoyaltyPolicy.selector);
royaltyModule.setRoyaltyPolicy(ipAccount1, address(royaltyPolicyLS), parentIpIds2, data2);
}

function test_RoyaltyModule_setRoyaltyPolicy_revert_NotWhitelistedRoyaltyPolicy() public {
Expand Down Expand Up @@ -187,7 +214,6 @@ contract TestRoyaltyModule is TestHelper {
vm.startPrank(address(registrationModule));
royaltyModule.setRoyaltyPolicy(ipAccount1, address(royaltyPolicyLS), parentIpIds1, data1);


address[] memory parentIpIds2 = new address[](0);
uint32 minRoyaltyIpAccount2 = 100; // 10%
bytes memory data2 = abi.encode(minRoyaltyIpAccount2);
Expand Down
2 changes: 1 addition & 1 deletion test/foundry/registries/metadata/IPAssetRenderer.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ contract IPAssetRendererTest is BaseTest {
);

accessController.initialize(address(ipAccountRegistry), address(moduleRegistry));
royaltyModule.initialize(address(registrationModule));
royaltyModule.initialize(address(registrationModule), address(licenseRegistry));

vm.prank(alice);
uint256 tokenId = erc721.mintId(alice, 99);
Expand Down
2 changes: 1 addition & 1 deletion test/utils/DeployHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ contract DeployHelper is Test {
function _configDeployedContracts() internal {
vm.startPrank(u.admin);
accessController.initialize(address(ipAccountRegistry), address(moduleRegistry));
royaltyModule.initialize(address(registrationModule));
royaltyModule.initialize(address(registrationModule), address(licenseRegistry));

moduleRegistry.registerModule(REGISTRATION_MODULE_KEY, address(registrationModule));
moduleRegistry.registerModule(IP_RESOLVER_MODULE_KEY, address(ipResolver));
Expand Down

0 comments on commit 5c067b2

Please sign in to comment.