@@ -232,18 +232,42 @@ contract ContractPublisherTest is BaseTest, IContractPublisherData {
232232 // );
233233 // }
234234
235- function test_unpublish () public {
235+ function test_unpublish_state () public {
236236 string memory contractId = "MyContract " ;
237237
238- vm.prank (publisher);
238+ vm.startPrank (publisher);
239239 byoc.publishContract (
240240 publisher,
241241 contractId,
242- publishMetadataUri ,
242+ " publish URI 1 " ,
243243 compilerMetadataUri,
244244 keccak256 (type (MockCustomContract).creationCode),
245245 address (0 )
246246 );
247+ byoc.publishContract (
248+ publisher,
249+ contractId,
250+ "publish URI 2 " ,
251+ compilerMetadataUri,
252+ keccak256 (type (MockCustomContract).creationCode),
253+ address (0 )
254+ );
255+ byoc.publishContract (
256+ publisher,
257+ contractId,
258+ "publish URI 3 " ,
259+ compilerMetadataUri,
260+ keccak256 (type (MockCustomContract).creationCode),
261+ address (0 )
262+ );
263+
264+ vm.stopPrank ();
265+
266+ IContractPublisher.CustomContractInstance[] memory allCustomContractsBefore = byoc.getPublishedContractVersions (
267+ publisher,
268+ contractId
269+ );
270+ assertEq (allCustomContractsBefore.length , 3 );
247271
248272 vm.prank (publisher);
249273 byoc.unpublishContract (publisher, contractId);
@@ -257,6 +281,36 @@ contract ContractPublisherTest is BaseTest, IContractPublisherData {
257281 assertEq (customContract.publishMetadataUri, "" );
258282 assertEq (customContract.bytecodeHash, bytes32 (0 ));
259283 assertEq (customContract.implementation, address (0 ));
284+
285+ IContractPublisher.CustomContractInstance[] memory allCustomContracts = byoc.getPublishedContractVersions (
286+ publisher,
287+ contractId
288+ );
289+
290+ assertEq (allCustomContracts.length , 0 );
291+
292+ vm.prank (publisher);
293+ byoc.publishContract (
294+ publisher,
295+ contractId,
296+ "publish URI 4 " ,
297+ compilerMetadataUri,
298+ keccak256 (type (MockCustomContract).creationCode),
299+ address (0 )
300+ );
301+
302+ IContractPublisher.CustomContractInstance memory customContractRepublish = byoc.getPublishedContract (
303+ publisher,
304+ contractId
305+ );
306+
307+ assertEq (customContractRepublish.contractId, contractId);
308+ assertEq (customContractRepublish.publishMetadataUri, "publish URI 4 " );
309+
310+ IContractPublisher.CustomContractInstance[] memory allCustomContractsRepublish = byoc
311+ .getPublishedContractVersions (publisher, contractId);
312+
313+ assertEq (allCustomContractsRepublish.length , 1 );
260314 }
261315
262316 // Deprecated
0 commit comments