@@ -3,7 +3,6 @@ pragma solidity 0.8.26;
3
3
4
4
import { PILFlavors } from "@storyprotocol/core/lib/PILFlavors.sol " ;
5
5
import { Licensing } from "@storyprotocol/core/lib/Licensing.sol " ;
6
- import "@storyprotocol/core/lib/Errors.sol " ;
7
6
8
7
import { TotalLicenseTokenLimitHook } from "contracts/hooks/TotalLicenseTokenLimitHook.sol " ;
9
8
@@ -73,12 +72,22 @@ contract TotalLicenseTokenLimitHookTest is BaseTest {
73
72
licensingModule.mintLicenseTokens (ipId3, address (pilTemplate), socialRemixTermsId, 10 , u.alice, "" );
74
73
75
74
vm.expectRevert (
76
- abi.encodeWithSelector (TotalLicenseTokenLimitHook.TotalLicenseTokenLimitExceeded.selector , 10 , 5 , 10 )
75
+ abi.encodeWithSelector (
76
+ TotalLicenseTokenLimitHook.TotalLicenseTokenLimitHook_TotalLicenseTokenLimitExceeded.selector ,
77
+ 10 ,
78
+ 5 ,
79
+ 10
80
+ )
77
81
);
78
82
licensingModule.mintLicenseTokens (ipId1, address (pilTemplate), socialRemixTermsId, 5 , u.alice, "" );
79
83
80
84
vm.expectRevert (
81
- abi.encodeWithSelector (TotalLicenseTokenLimitHook.TotalLicenseTokenLimitExceeded.selector , 20 , 5 , 20 )
85
+ abi.encodeWithSelector (
86
+ TotalLicenseTokenLimitHook.TotalLicenseTokenLimitHook_TotalLicenseTokenLimitExceeded.selector ,
87
+ 20 ,
88
+ 5 ,
89
+ 20
90
+ )
82
91
);
83
92
licensingModule.mintLicenseTokens (ipId2, address (pilTemplate), socialRemixTermsId, 5 , u.alice, "" );
84
93
}
@@ -108,8 +117,50 @@ contract TotalLicenseTokenLimitHookTest is BaseTest {
108
117
vm.stopPrank ();
109
118
110
119
vm.startPrank (ipOwner2);
111
- vm.expectRevert (abi.encodeWithSelector (Errors.AccessController__PermissionDenied.selector , ipId1, ipOwner2, address (totalLimitHook), totalLimitHook.setTotalLicenseTokenLimit.selector ));
120
+ vm.expectRevert (
121
+ abi.encodeWithSelector (
122
+ Errors.AccessController__PermissionDenied.selector ,
123
+ ipId1,
124
+ ipOwner2,
125
+ address (totalLimitHook),
126
+ totalLimitHook.setTotalLicenseTokenLimit.selector
127
+ )
128
+ );
112
129
totalLimitHook.setTotalLicenseTokenLimit (ipId1, address (pilTemplate), socialRemixTermsId, 20 );
130
+ }
113
131
132
+ function test_TotalLicenseTokenLimitHook_revert_limitLowerThanTotalSupply_setLimit () public {
133
+ uint256 socialRemixTermsId = pilTemplate.registerLicenseTerms (PILFlavors.nonCommercialSocialRemixing ());
134
+ TotalLicenseTokenLimitHook totalLimitHook = new TotalLicenseTokenLimitHook (
135
+ address (licenseRegistry),
136
+ address (licenseToken),
137
+ address (accessController),
138
+ address (ipAssetRegistry)
139
+ );
140
+
141
+ vm.prank (u.admin);
142
+ moduleRegistry.registerModule ("TotalLicenseTokenLimitHook " , address (totalLimitHook));
143
+ Licensing.LicensingConfig memory licensingConfig = Licensing.LicensingConfig ({
144
+ isSet: true ,
145
+ mintingFee: 100 ,
146
+ licensingHook: address (totalLimitHook),
147
+ hookData: ""
148
+ });
149
+
150
+ vm.startPrank (ipOwner1);
151
+ licensingModule.setLicensingConfig (ipId1, address (pilTemplate), socialRemixTermsId, licensingConfig);
152
+ totalLimitHook.setTotalLicenseTokenLimit (ipId1, address (pilTemplate), socialRemixTermsId, 10 );
153
+ assertEq (totalLimitHook.getTotalLicenseTokenLimit (ipId1, address (pilTemplate), socialRemixTermsId), 10 );
154
+
155
+ licensingModule.mintLicenseTokens (ipId1, address (pilTemplate), socialRemixTermsId, 10 , u.alice, "" );
156
+
157
+ vm.expectRevert (
158
+ abi.encodeWithSelector (
159
+ TotalLicenseTokenLimitHook.TotalLicenseTokenLimitHook_LimitLowerThanTotalSupply.selector ,
160
+ 10 ,
161
+ 5
162
+ )
163
+ );
164
+ totalLimitHook.setTotalLicenseTokenLimit (ipId1, address (pilTemplate), socialRemixTermsId, 5 );
114
165
}
115
166
}
0 commit comments