Skip to content

Commit

Permalink
fix: fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sendra committed Dec 10, 2024
1 parent 12c47ad commit 7e34160
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 26 deletions.
5 changes: 3 additions & 2 deletions tests/BaseCrossChainController.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {ChainIds} from 'solidity-utils/contracts/utils/ChainHelpers.sol';
import {Errors} from '../src/contracts/libs/Errors.sol';
import {IBaseAdapter} from '../src/contracts/adapters/IBaseAdapter.sol';
import {ProxyAdmin} from 'solidity-utils/contracts/transparent-proxy/ProxyAdmin.sol';
import {IRescuable} from 'solidity-utils/contracts/utils/interfaces/IRescuable.sol';

abstract contract BaseCrossChainControllerTest is Test {
address public constant OWNER = address(65536 + 123);
Expand Down Expand Up @@ -192,7 +193,7 @@ abstract contract BaseCrossChainControllerTest is Test {

address recipient = address(1230123519);

vm.expectRevert((bytes('ONLY_RESCUE_GUARDIAN')));
vm.expectRevert(abi.encodeWithSelector(IRescuable.OnlyRescueGuardian.selector));
crossChainController.emergencyEtherTransfer(recipient, 5 ether);
}

Expand Down Expand Up @@ -225,7 +226,7 @@ abstract contract BaseCrossChainControllerTest is Test {

address recipient = address(1230123519);

vm.expectRevert((bytes('ONLY_RESCUE_GUARDIAN')));
vm.expectRevert(abi.encodeWithSelector(IRescuable.OnlyRescueGuardian.selector));
crossChainController.emergencyTokenTransfer(address(testToken), recipient, 3 ether);
}
}
44 changes: 20 additions & 24 deletions tests/access_control/GranularGuardianAccessControl.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {TestUtils} from '../utils/TestUtils.sol';
import '../../src/contracts/access_control/GranularGuardianAccessControl.sol';
import {OwnableWithGuardian, IWithGuardian} from 'solidity-utils/contracts/access-control/OwnableWithGuardian.sol';
import '../BaseTest.sol';
import {IAccessControl} from 'openzeppelin-contracts/contracts/access/IAccessControl.sol';

contract GranularGuardianAccessControlTest is BaseTest {
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
Expand Down Expand Up @@ -105,13 +106,12 @@ contract GranularGuardianAccessControlTest is BaseTest {
) public setUpGranularGuardians(defaultAdmin, retryGuardian, solveEmergencyGuardian, ccc) {
vm.assume(retryCaller != retryGuardian);
hoax(retryCaller);

vm.expectRevert(
bytes(
string.concat(
'AccessControl: account 0x',
TestUtils.toAsciiString(retryCaller),
' is missing role 0xc448b9502bbdf9850cc39823b6ea40cfe96d3ac63008e89edd2b8e98c6cc0af3'
)
abi.encodeWithSelector(
IAccessControl.AccessControlUnauthorizedAccount.selector,
retryCaller,
0xc448b9502bbdf9850cc39823b6ea40cfe96d3ac63008e89edd2b8e98c6cc0af3
)
);
_retryTx(ccc);
Expand Down Expand Up @@ -141,13 +141,12 @@ contract GranularGuardianAccessControlTest is BaseTest {
) public setUpGranularGuardians(defaultAdmin, retryGuardian, solveEmergencyGuardian, ccc) {
vm.assume(retryCaller != retryGuardian);
hoax(retryCaller);

vm.expectRevert(
bytes(
string.concat(
'AccessControl: account 0x',
TestUtils.toAsciiString(retryCaller),
' is missing role 0xc448b9502bbdf9850cc39823b6ea40cfe96d3ac63008e89edd2b8e98c6cc0af3'
)
abi.encodeWithSelector(
IAccessControl.AccessControlUnauthorizedAccount.selector,
retryCaller,
0xc448b9502bbdf9850cc39823b6ea40cfe96d3ac63008e89edd2b8e98c6cc0af3
)
);
_retryEnvelope(ccc, mockEnvId);
Expand All @@ -174,12 +173,10 @@ contract GranularGuardianAccessControlTest is BaseTest {
vm.assume(solveCaller != solveEmergencyGuardian);
hoax(solveCaller);
vm.expectRevert(
bytes(
string.concat(
'AccessControl: account 0x',
TestUtils.toAsciiString(solveCaller),
' is missing role 0xf4cdc679c22cbf47d6de8e836ce79ffdae51f38408dcde3f0645de7634fa607d'
)
abi.encodeWithSelector(
IAccessControl.AccessControlUnauthorizedAccount.selector,
solveCaller,
0xf4cdc679c22cbf47d6de8e836ce79ffdae51f38408dcde3f0645de7634fa607d
)
);
_solveEmergency(ccc);
Expand Down Expand Up @@ -213,13 +210,12 @@ contract GranularGuardianAccessControlTest is BaseTest {
) public setUpGranularGuardians(defaultAdmin, retryGuardian, solveEmergencyGuardian, ccc) {
vm.assume(guardianCaller != defaultAdmin);
hoax(guardianCaller);

vm.expectRevert(
bytes(
string.concat(
'AccessControl: account 0x',
TestUtils.toAsciiString(guardianCaller),
' is missing role 0x0000000000000000000000000000000000000000000000000000000000000000'
)
abi.encodeWithSelector(
IAccessControl.AccessControlUnauthorizedAccount.selector,
guardianCaller,
0x0000000000000000000000000000000000000000000000000000000000000000
)
);
control.updateGuardian(newGuardian);
Expand Down

0 comments on commit 7e34160

Please sign in to comment.