Skip to content

Commit

Permalink
Further simplification of AccessControl tests
Browse files Browse the repository at this point in the history
  • Loading branch information
scnale committed Nov 21, 2024
1 parent 704ffa3 commit 2d9c215
Showing 1 changed file with 17 additions and 34 deletions.
51 changes: 17 additions & 34 deletions test/components/dispatcher/AccessControl.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,13 @@ contract AcessControlTest is DispatcherTestBase {
);

commandCount = 2;
bytes memory getRes = invokeStaticDispatcher(
abi.encodePacked(
ACCESS_CONTROL_QUERIES_ID,
commandCount,
OWNER_ID,
PENDING_OWNER_ID
)
);
bytes memory queries = abi.encodePacked(
ACCESS_CONTROL_QUERIES_ID,
commandCount,
OWNER_ID,
PENDING_OWNER_ID
)
bytes memory getRes = invokeStaticDispatcher(queries);
(address owner_, ) = getRes.asAddressUnchecked(0);
(address pendingOwner_, ) = getRes.asAddressUnchecked(20);

Expand All @@ -58,15 +57,7 @@ contract AcessControlTest is DispatcherTestBase {
)
);

getRes = invokeStaticDispatcher(
abi.encodePacked(

ACCESS_CONTROL_QUERIES_ID,
commandCount,
OWNER_ID,
PENDING_OWNER_ID
)
);
getRes = invokeStaticDispatcher(queries);
(owner_, ) = getRes.asAddressUnchecked(0);
(pendingOwner_, ) = getRes.asAddressUnchecked(20);

Expand Down Expand Up @@ -155,7 +146,6 @@ contract AcessControlTest is DispatcherTestBase {

bytes memory getRes = invokeStaticDispatcher(
abi.encodePacked(

ACCESS_CONTROL_QUERIES_ID,
commandCount,
OWNER_ID,
Expand Down Expand Up @@ -308,26 +298,19 @@ contract AcessControlTest is DispatcherTestBase {
address newAdmin = makeAddr("newAdmin");
uint8 commandCount = 1;

vm.expectRevert(NotAuthorized.selector);
invokeDispatcher(
abi.encodePacked(
ACCESS_CONTROL_ID,
commandCount,
ADD_ADMIN_ID,
newAdmin
)
bytes memory = addAdminCommand = abi.encodePacked(
ACCESS_CONTROL_ID,
commandCount,
ADD_ADMIN_ID,
newAdmin
);

vm.expectRevert(NotAuthorized.selector);
invokeDispatcher(addAdminCommand);

vm.expectRevert(NotAuthorized.selector);
vm.prank(admin);
invokeDispatcher(
abi.encodePacked(
ACCESS_CONTROL_ID,
commandCount,
ADD_ADMIN_ID,
newAdmin
)
);
invokeDispatcher(addAdminCommand);
}

function testAddAdmin(address newAdmin) public {
Expand Down

0 comments on commit 2d9c215

Please sign in to comment.