Skip to content

Commit

Permalink
test: fix ShouldSetAdminRoleForGivenRole and add test for revert
Browse files Browse the repository at this point in the history
  • Loading branch information
gitcoindev committed Jan 19, 2024
1 parent 3185ffd commit 3e96286
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions packages/contracts/test/diamond/facets/AccessControlFacet.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -136,18 +136,24 @@ contract AccessControlFacetTest is DiamondTestSetup {
assertEq(adminRole, DEFAULT_ADMIN_ROLE);
}

// test setRoleAdmin function should set correct admin role
function testSetRoleAdmin_ShouldRevertWhenNotAdmin() public {
vm.prank(mock_sender);

vm.expectRevert("Manager: Caller is not admin");
accessControlFacet.setRoleAdmin(
DOLLAR_TOKEN_BURNER_ROLE,
DEFAULT_ADMIN_ROLE
);
}

function testSetRoleAdmin_ShouldSetAdminRoleForGivenRole() public {
bytes32 adminRole = accessControlFacet.getRoleAdmin(
DOLLAR_TOKEN_MINTER_ROLE
);
assertEq(adminRole, DOLLAR_TOKEN_MINTER_ROLE);
assertEq(adminRole, DEFAULT_ADMIN_ROLE);
vm.prank(admin);
accessControlFacet.setRoleAdmin(
DOLLAR_TOKEN_MINTER_ROLE,
DOLLAR_TOKEN_BURNER_ROLE
);
accessControlFacet.setRoleAdmin(DOLLAR_TOKEN_MINTER_ROLE, PAUSER_ROLE);
adminRole = accessControlFacet.getRoleAdmin(DOLLAR_TOKEN_MINTER_ROLE);
assertEq(adminRole, DOLLAR_TOKEN_BURNER_ROLE);
assertEq(adminRole, PAUSER_ROLE);
}
}

0 comments on commit 3e96286

Please sign in to comment.