Skip to content

Commit

Permalink
Adds a few event checks
Browse files Browse the repository at this point in the history
  • Loading branch information
scnale committed Nov 21, 2024
1 parent 4eb3500 commit 704ffa3
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions test/components/dispatcher/AccessControl.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pragma solidity ^0.8.4;

import {BytesParsing} from "wormhole-sdk/libraries/BytesParsing.sol";
import {NotAuthorized} from "wormhole-sdk/components/dispatcher/AccessControl.sol";
import {AdminsUpdated, NotAuthorized} from "wormhole-sdk/components/dispatcher/AccessControl.sol";
import {
ACCESS_CONTROL_ID,
ACCESS_CONTROL_QUERIES_ID,
Expand Down Expand Up @@ -334,6 +334,8 @@ contract AcessControlTest is DispatcherTestBase {
vm.assume(newAdmin != admin);
uint8 commandCount = 1;

vm.expectEmit();
emit AdminsUpdated(newAdmin, true, block.timestamp);
vm.prank(owner);
invokeDispatcher(
abi.encodePacked(
Expand Down Expand Up @@ -394,6 +396,10 @@ contract AcessControlTest is DispatcherTestBase {
);

commandCount = 1;

vm.expectEmit();
emit AdminsUpdated(newAdmin, false, block.timestamp);

vm.prank(admin);
invokeDispatcher(
abi.encodePacked(
Expand Down Expand Up @@ -425,6 +431,9 @@ contract AcessControlTest is DispatcherTestBase {
function testRelinquishAdministration() public {
uint8 commandCount = 1;

vm.expectEmit();
emit AdminsUpdated(admin, false, block.timestamp);

vm.prank(admin);
invokeDispatcher(
abi.encodePacked(
Expand All @@ -450,15 +459,19 @@ contract AcessControlTest is DispatcherTestBase {

function testRelinquishOwnership_NotAuthorized() public {
uint8 commandCount = 1;
bytes memory relinquishCommand = abi.encodePacked(
ACCESS_CONTROL_ID,
commandCount,
RELINQUISH_OWNERSHIP_ID
);

vm.expectRevert(NotAuthorized.selector);
invokeDispatcher(
abi.encodePacked(
ACCESS_CONTROL_ID,
commandCount,
RELINQUISH_OWNERSHIP_ID
)
);
invokeDispatcher(relinquishCommand);


vm.expectRevert(NotAuthorized.selector);
vm.prank(admin);
invokeDispatcher(relinquishCommand);
}

function testRelinquishOwnership_LengthMismatch() public {
Expand Down

0 comments on commit 704ffa3

Please sign in to comment.