Skip to content

Commit

Permalink
feat(distribution): add tests for setAdmin
Browse files Browse the repository at this point in the history
  • Loading branch information
robertu7 committed Dec 20, 2023
1 parent 7ba7ba5 commit a56cf95
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ CurationTest:testCannotCurateNativeTokenZeroAddress() (gas: 16488)
CurationTest:testERC20Curation() (gas: 59908)
CurationTest:testNativeTokenCuration() (gas: 60085)
CurationTest:testNativeTokenCurationToContractAcceptor() (gas: 37466)
DistributionTest:testCannotSetAdminByAdmin() (gas: 19969)
DistributionTest:testCannotSetAdminByAttacker() (gas: 11000)
DistributionTest:testDrop() (gas: 164)
DistributionTest:testSetAdmin() (gas: 18154)
LogbookNFTSVGTest:testTokenURI(uint8,uint8,uint16) (runs: 256, μ: 2019505, ~: 1310779)
LogbookTest:testClaim() (gas: 135608)
LogbookTest:testDonate(uint96) (runs: 256, μ: 155485, ~: 156936)
Expand Down
22 changes: 22 additions & 0 deletions src/test/Billboard/DistributionTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,27 @@ import "./DistributionTestBase.t.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";

contract DistributionTest is DistributionTestBase {
function testSetAdmin() public {
vm.prank(OWNER);
distribution.setAdmin(ADMIN);
assertEq(distribution.admin(), ADMIN);
}

function testCannotSetAdminByAdmin() public {
vm.prank(OWNER);
distribution.setAdmin(ADMIN);
assertEq(distribution.admin(), ADMIN);

vm.prank(ADMIN);
vm.expectRevert("Ownable: caller is not the owner");
distribution.setAdmin(USER);
}

function testCannotSetAdminByAttacker() public {
vm.prank(ATTACKER);
vm.expectRevert("Ownable: caller is not the owner");
distribution.setAdmin(USER);
}

function testDrop() public {}
}
11 changes: 5 additions & 6 deletions src/test/Billboard/DistributionTestBase.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,17 @@ contract DistributionTestBase is Test {
address constant FAKE_CONTRACT = address(1);

/// Deployer and admin could be the same one
address constant ADMIN = address(100);
address constant USER_A = address(101);
address constant USER_B = address(102);
address constant USER_C = address(103);
address constant OWNER = address(100);
address constant ADMIN = address(101);
address constant USER = address(102);
address constant ATTACKER = address(200);

function setUp() public {
vm.startPrank(ADMIN);
vm.startPrank(OWNER);

// deploy
distribution = new Distribution();
assertEq(distribution.admin(), ADMIN);
assertEq(distribution.admin(), OWNER);

vm.stopPrank();
}
Expand Down

0 comments on commit a56cf95

Please sign in to comment.