Skip to content

Commit

Permalink
feat(billboard): add tests for mintBoard
Browse files Browse the repository at this point in the history
  • Loading branch information
robertu7 committed Nov 15, 2023
1 parent d282702 commit 32f96d5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/Billboard/Billboard.sol
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ contract Billboard is IBillboard {

/// @inheritdoc IBillboard
function mintBoard(address to_) external {
if (!isOpened && whitelist[msg.sender] != true) {
if (isOpened || whitelist[msg.sender] == true) {
registry.mintBoard(to_);
} else {
revert Unauthorized("whitelist");
}

registry.mintBoard(to_);
}

/// @inheritdoc IBillboard
Expand Down
23 changes: 16 additions & 7 deletions src/test/Billboard/BillboardTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ contract BillboardTest is BillboardTestBase {

// mint
operator.mintBoard(ADMIN);
assertEq(1, registry.balanceOf(ADMIN));
assertEq(registry.balanceOf(ADMIN), 1);

// get board & check data
IBillboardRegistry.Board memory board = operator.getBoard(1);
Expand All @@ -104,17 +104,26 @@ contract BillboardTest is BillboardTestBase {

// mint again for checking id generator
operator.mintBoard(ADMIN);
assertEq(2, registry.balanceOf(ADMIN));
assertEq(registry.balanceOf(ADMIN), 2);
board = operator.getBoard(2);
assertEq(board.creator, ADMIN);
}

// function testMintBoardByAttacker() public {
// vm.startPrank(ATTACKER);
function testMintBoardIfOpened() public {
vm.startPrank(ADMIN);
operator.setIsOpened(true);

// vm.expectRevert(abi.encodeWithSignature("Unauthorized(string)", "creator"));
// operator.mintBoard(ATTACKER);
// }
vm.startPrank(USER_A);
operator.mintBoard(USER_A);
assertEq(registry.balanceOf(USER_A), 1);
}

function testMintBoardByAttacker() public {
vm.startPrank(ATTACKER);

vm.expectRevert(abi.encodeWithSignature("Unauthorized(string)", "whitelist"));
operator.mintBoard(ATTACKER);
}

// function testSetBoardProperties() public {
// _mintBoard();
Expand Down

0 comments on commit 32f96d5

Please sign in to comment.