-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ef21e2e
commit 1285ea7
Showing
6 changed files
with
117 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
pragma solidity ^0.8.15; | ||
|
||
import "../../TestConfig.sol"; | ||
import "../../../contracts/SoundEdition/SoundEditionV1.sol"; | ||
import "../../../contracts/SoundCreator/SoundCreatorV1.sol"; | ||
import "../../../contracts/modules/Minters/FixedPricePublicSaleMinter.sol"; | ||
|
||
contract EditionMinterTests is TestConfig, EditionMinter { | ||
function createEditionMintController(address edition) external { | ||
_createEditionMintController(edition); | ||
} | ||
|
||
function deleteEditionMintController(address edition) external { | ||
_deleteEditionMintController(edition); | ||
} | ||
|
||
function test_createEditionMintControllerEmitsEvent(address edition) external { | ||
address controller = getRandomAccount(1); | ||
vm.expectEmit(false, false, false, true); | ||
emit MintControllerUpdated(address(edition), controller); | ||
vm.prank(controller); | ||
this.createEditionMintController(address(edition)); | ||
} | ||
|
||
function test_createEditionMintControllerChangesController(address edition) external { | ||
address controller = getRandomAccount(1); | ||
assertEq(this.editionMintController(edition), address(0)); | ||
vm.prank(controller); | ||
this.createEditionMintController(address(edition)); | ||
assertEq(this.editionMintController(edition), controller); | ||
} | ||
|
||
function test_createEditionMintControllerRevertsWhenAlreadyExists(address edition) external { | ||
address controller0 = getRandomAccount(0); | ||
address controller1 = getRandomAccount(1); | ||
vm.prank(controller0); | ||
this.createEditionMintController(address(edition)); | ||
vm.expectRevert(abi.encodeWithSelector(EditionMinter.MintControllerAlreadyExists.selector, controller0)); | ||
vm.prank(controller0); | ||
this.createEditionMintController(address(edition)); | ||
vm.prank(controller1); | ||
vm.expectRevert(abi.encodeWithSelector(EditionMinter.MintControllerAlreadyExists.selector, controller0)); | ||
this.createEditionMintController(address(edition)); | ||
} | ||
|
||
function test_setEditionMintControllerEmitsEvent(address edition) external { | ||
address controller0 = getRandomAccount(0); | ||
address controller1 = getRandomAccount(1); | ||
vm.prank(controller0); | ||
this.createEditionMintController(address(edition)); | ||
vm.expectEmit(false, false, false, true); | ||
emit MintControllerUpdated(address(edition), controller1); | ||
vm.prank(controller0); | ||
this.setEditionMintController(address(edition), controller1); | ||
} | ||
|
||
function test_setEditionMintControllerChangesController(address edition) external { | ||
address controller0 = getRandomAccount(0); | ||
address controller1 = getRandomAccount(1); | ||
vm.prank(controller0); | ||
this.createEditionMintController(address(edition)); | ||
vm.prank(controller0); | ||
this.setEditionMintController(address(edition), controller1); | ||
assertEq(this.editionMintController(edition), controller1); | ||
} | ||
|
||
function test_deleteEditionMintControllerEmitsEvent(address edition) external { | ||
address controller = getRandomAccount(0); | ||
vm.prank(controller); | ||
this.createEditionMintController(address(edition)); | ||
vm.expectEmit(false, false, false, true); | ||
emit MintControllerUpdated(address(edition), address(0)); | ||
vm.prank(controller); | ||
this.deleteEditionMintController(address(edition)); | ||
} | ||
|
||
function test_deleteEditionMintRevertsIfCallerUnauthorized(address edition) public { | ||
address controller0 = getRandomAccount(0); | ||
address controller1 = getRandomAccount(1); | ||
vm.prank(controller0); | ||
this.createEditionMintController(address(edition)); | ||
|
||
vm.prank(controller1); | ||
vm.expectRevert(EditionMinter.MintControllerUnauthorized.selector); | ||
this.deleteEditionMintController(address(edition)); | ||
} | ||
|
||
function test_deleteEditionMintRevertsIfMintEditionDoesNotExist(address edition0, address edition1) public { | ||
vm.assume(edition0 != edition1); | ||
|
||
address controller = getRandomAccount(0); | ||
vm.prank(controller); | ||
this.createEditionMintController(address(edition0)); | ||
|
||
vm.prank(controller); | ||
vm.expectRevert(EditionMinter.MintControllerNotFound.selector); | ||
this.deleteEditionMintController(address(edition1)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters