Skip to content

Commit

Permalink
renaming revert messages
Browse files Browse the repository at this point in the history
  • Loading branch information
kelemeno committed Apr 3, 2024
1 parent ddf2223 commit 6cf29ea
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,44 +13,44 @@ contract ZkSyncHyperchainBase is ReentrancyGuard {

/// @notice Checks that the message sender is an active admin
modifier onlyAdmin() {
require(msg.sender == s.admin, "StateTransition Chain: not admin");
require(msg.sender == s.admin, "Hyperchain: not admin");
_;
}

/// @notice Checks if validator is active
modifier onlyValidator() {
require(s.validators[msg.sender], "StateTransition Chain: not validator");
require(s.validators[msg.sender], "Hyperchain: not validator");
_;
}

modifier onlyStateTransitionManager() {
require(msg.sender == s.stateTransitionManager, "StateTransition Chain: not state transition manager");
require(msg.sender == s.stateTransitionManager, "Hyperchain: not state transition manager");
_;
}

modifier onlyBridgehub() {
require(msg.sender == s.bridgehub, "StateTransition Chain: not bridgehub");
require(msg.sender == s.bridgehub, "Hyperchain: not bridgehub");
_;
}

modifier onlyAdminOrStateTransitionManager() {
require(
msg.sender == s.admin || msg.sender == s.stateTransitionManager,
"StateTransition Chain: Only by admin or state transition manager"
"Hyperchain: Only by admin or state transition manager"
);
_;
}

modifier onlyValidatorOrStateTransitionManager() {
require(
s.validators[msg.sender] || msg.sender == s.stateTransitionManager,
"StateTransition Chain: Only by validator or state transition manager"
"Hyperchain: Only by validator or state transition manager"
);
_;
}

modifier onlyBaseTokenBridge() {
require(msg.sender == s.baseTokenBridge, "Only shared bridge can call this function");
require(msg.sender == s.baseTokenBridge, "Hyperchain: Only shared bridge can call this function");
_;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ contract UpgradeLogicTest is DiamondCutTest {
function test_RevertWhen_EmergencyFreezeWhenUnauthorizedGovernor() public {
vm.startPrank(randomSigner);

vm.expectRevert(abi.encodePacked("StateTransition Chain: Only by admin or state transition manager"));
vm.expectRevert(abi.encodePacked("Hyperchain: Only by admin or state transition manager"));
proxyAsAdmin.freezeDiamond();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ contract AuthorizationTest is ExecutorTest {

vm.prank(randomSigner);

vm.expectRevert(bytes.concat("StateTransition Chain: not validator"));
vm.expectRevert(bytes.concat("Hyperchain: not validator"));
executor.commitBatches(storedBatchInfo, commitBatchInfoArray);
}

Expand All @@ -53,7 +53,7 @@ contract AuthorizationTest is ExecutorTest {

vm.prank(owner);

vm.expectRevert(bytes.concat("StateTransition Chain: not validator"));
vm.expectRevert(bytes.concat("Hyperchain: not validator"));
executor.proveBatches(storedBatchInfo, storedBatchInfoArray, proofInput);
}

Expand All @@ -63,7 +63,7 @@ contract AuthorizationTest is ExecutorTest {

vm.prank(randomSigner);

vm.expectRevert(bytes.concat("StateTransition Chain: not validator"));
vm.expectRevert(bytes.concat("Hyperchain: not validator"));
executor.executeBatches(storedBatchInfoArray);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ contract TestBaseFacet is ZkSyncHyperchainBase {
function test() internal virtual {}
}

bytes constant ERROR_ONLY_ADMIN = "StateTransition Chain: not admin";
bytes constant ERROR_ONLY_VALIDATOR = "StateTransition Chain: not validator";
bytes constant ERROR_ONLY_STATE_TRANSITION_MANAGER = "StateTransition Chain: not state transition manager";
bytes constant ERROR_ONLY_BRIDGEHUB = "StateTransition Chain: not bridgehub";
bytes constant ERROR_ONLY_ADMIN_OR_STATE_TRANSITION_MANAGER = "StateTransition Chain: Only by admin or state transition manager";
bytes constant ERROR_ONLY_VALIDATOR_OR_STATE_TRANSITION_MANAGER = "StateTransition Chain: Only by validator or state transition manager";
bytes constant ERROR_ONLY_ADMIN = "Hyperchain: not admin";
bytes constant ERROR_ONLY_VALIDATOR = "Hyperchain: not validator";
bytes constant ERROR_ONLY_STATE_TRANSITION_MANAGER = "Hyperchain: not state transition manager";
bytes constant ERROR_ONLY_BRIDGEHUB = "Hyperchain: not bridgehub";
bytes constant ERROR_ONLY_ADMIN_OR_STATE_TRANSITION_MANAGER = "Hyperchain: Only by admin or state transition manager";
bytes constant ERROR_ONLY_VALIDATOR_OR_STATE_TRANSITION_MANAGER = "Hyperchain: Only by validator or state transition manager";

contract ZkSyncHyperchainBaseTest is Test {
TestBaseFacet internal testBaseFacet;
Expand Down
6 changes: 3 additions & 3 deletions l1-contracts/test/unit_tests/governance_test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe("Admin facet tests", function () {
const revertReason = await getCallRevertReason(
adminFacetTest.connect(randomSigner).setValidator(validatorAddress, true)
);
expect(revertReason).equal("StateTransition Chain: not state transition manager");
expect(revertReason).equal("Hyperchain: not state transition manager");
});

it("StateTransitionManager successfully set porter availability", async () => {
Expand All @@ -48,7 +48,7 @@ describe("Admin facet tests", function () {

it("random account fails to set porter availability", async () => {
const revertReason = await getCallRevertReason(adminFacetTest.connect(randomSigner).setPorterAvailability(false));
expect(revertReason).equal("StateTransition Chain: not state transition manager");
expect(revertReason).equal("Hyperchain: not state transition manager");
});

it("StateTransitionManager successfully set priority transaction max gas limit", async () => {
Expand All @@ -64,7 +64,7 @@ describe("Admin facet tests", function () {
const revertReason = await getCallRevertReason(
adminFacetTest.connect(randomSigner).setPriorityTxMaxGasLimit(gasLimit)
);
expect(revertReason).equal("StateTransition Chain: not state transition manager");
expect(revertReason).equal("Hyperchain: not state transition manager");
});

describe("change admin", function () {
Expand Down

0 comments on commit 6cf29ea

Please sign in to comment.