Skip to content

Commit

Permalink
added test coverage for update / approve implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
0xPilou committed Dec 12, 2023
1 parent a1e3c42 commit 3299f4b
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions test/factory/AnotherCloneFactory.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,60 @@ contract AnotherCloneFactoryTest is Test, AnotherCloneFactoryTestData {
anotherCloneFactory.createCollection1155(SALT);
}

function test_approveERC721Implementation_admin(address _dummyImplementation) public {
uint256 currentImplId = 0;

uint256 newImplId = anotherCloneFactory.approveERC721Implementation(_dummyImplementation);

address impl = anotherCloneFactory.erc721ImplAddresses(currentImplId);

assertEq(currentImplId, newImplId);
assertEq(impl, _dummyImplementation);
}

function test_approveERC721Implementation_nonAdmin(address _nonAdmin, address _dummyImplementation) public {
vm.assume(_nonAdmin != address(this));
vm.assume(_nonAdmin != address(proxyAdmin));

vm.prank(_nonAdmin);

vm.expectRevert();
anotherCloneFactory.approveERC721Implementation(_dummyImplementation);
}

function test_updateERC721Implementation_admin(address _dummyImplementation, address _dummyImplementation2)
public
{
uint256 implId = anotherCloneFactory.approveERC721Implementation(_dummyImplementation);

address impl = anotherCloneFactory.erc721ImplAddresses(implId);
assertEq(impl, _dummyImplementation);

anotherCloneFactory.updateERC721Implementation(implId, _dummyImplementation2);

impl = anotherCloneFactory.erc721ImplAddresses(implId);
assertEq(impl, _dummyImplementation2);
}

function test_updateERC721Implementation_nonAdmin(
address _nonAdmin,
address _dummyImplementation,
address _dummyImplementation2
) public {
vm.assume(_nonAdmin != address(this));
vm.assume(_nonAdmin != address(proxyAdmin));

uint256 implId = anotherCloneFactory.approveERC721Implementation(_dummyImplementation);

address impl = anotherCloneFactory.erc721ImplAddresses(implId);
assertEq(impl, _dummyImplementation);

vm.prank(_nonAdmin);

vm.expectRevert();
anotherCloneFactory.updateERC721Implementation(implId, _dummyImplementation2);
}

function test_setERC721Implementation_admin() public {
ERC721ABLE newErc721Implementation = new ERC721ABLE();

Expand Down

0 comments on commit 3299f4b

Please sign in to comment.