Skip to content

Commit

Permalink
fix: ExocoreGateway test updated
Browse files Browse the repository at this point in the history
  • Loading branch information
call-by committed Jul 22, 2024
1 parent c0ec4f2 commit 1516346
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 38 deletions.
2 changes: 1 addition & 1 deletion src/core/Bootstrap.sol
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ contract Bootstrap is
revert Errors.BootstrapSpawnTimeAlreadyPast();
}
if (offsetDuration_ == 0) {
revert Errors.ZeroAmount();
revert Errors.ZeroValue();
}
if (spawnTime_ <= offsetDuration_) {
revert Errors.BootstrapSpawnTimeLessThanDuration();
Expand Down
18 changes: 4 additions & 14 deletions src/core/ExocoreGateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -130,23 +130,13 @@ contract ExocoreGateway is
string calldata metaInfo,
string calldata signatureType
) public onlyOwner whenNotPaused {
if (clientChainId == uint32(0)) {
revert Errors.ZeroValue();
}
if (peer == bytes32(0)) {
revert Errors.ZeroValue();
}
if (addressLength == 0) {
revert Errors.ZeroValue();
}
if (bytes(name).length == 0) {
revert Errors.ZeroValue();
}
if (bytes(metaInfo).length == 0) {
if (
clientChainId == uint32(0) || peer == bytes32(0) || addressLength == 0 || bytes(name).length == 0
|| bytes(metaInfo).length == 0
) {
revert Errors.ZeroValue();
}
// signature type could be left as empty for current implementation

_registerClientChain(clientChainId, addressLength, name, metaInfo, signatureType);
super.setPeer(clientChainId, peer);

Expand Down
5 changes: 1 addition & 4 deletions src/core/Vault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ contract Vault is Initializable, VaultStorage, IVault {
}

function initialize(address underlyingToken_, address gateway_) external initializer {
if (underlyingToken_ == address(0)) {
revert Errors.ZeroAddress();
}
if (gateway_ == address(0)) {
if (underlyingToken_ == address(0) || gateway_ == address(0)) {
revert Errors.ZeroAddress();
}

Expand Down
13 changes: 0 additions & 13 deletions src/libraries/Events.sol

This file was deleted.

13 changes: 7 additions & 6 deletions test/foundry/unit/ExocoreGateway.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {NonShortCircuitEndpointV2Mock} from "../../mocks/NonShortCircuitEndpoint
import "src/interfaces/precompiles/IAssets.sol";
import "src/interfaces/precompiles/IClaimReward.sol";
import "src/interfaces/precompiles/IDelegation.sol";
import "src/libraries/Errors.sol";

import "@layerzero-v2/protocol/contracts/libs/AddressCast.sol";
import "@layerzerolabs/lz-evm-protocol-v2/contracts/libs/GUID.sol";
Expand Down Expand Up @@ -254,7 +255,7 @@ contract RegisterOrUpdateClientChain is SetUp {
_prepareClientChainData();
anotherClientChain = 0;

vm.expectRevert("ExocoreGateway: client chain id cannot be zero or empty");
vm.expectRevert(Errors.ZeroValue.selector);
vm.startPrank(exocoreValidatorSet.addr);
exocoreGateway.registerOrUpdateClientChain(
anotherClientChain, peer, addressLength, name, metaInfo, signatureType
Expand All @@ -265,7 +266,7 @@ contract RegisterOrUpdateClientChain is SetUp {
_prepareClientChainData();
peer = bytes32(0);

vm.expectRevert("ExocoreGateway: peer address cannot be zero or empty");
vm.expectRevert(Errors.ZeroValue.selector);
vm.startPrank(exocoreValidatorSet.addr);
exocoreGateway.registerOrUpdateClientChain(
anotherClientChain, peer, addressLength, name, metaInfo, signatureType
Expand All @@ -276,7 +277,7 @@ contract RegisterOrUpdateClientChain is SetUp {
_prepareClientChainData();
addressLength = 0;

vm.expectRevert("ExocoreGateway: address length cannot be zero or empty");
vm.expectRevert(Errors.ZeroValue.selector);
vm.startPrank(exocoreValidatorSet.addr);
exocoreGateway.registerOrUpdateClientChain(
anotherClientChain, peer, addressLength, name, metaInfo, signatureType
Expand All @@ -287,7 +288,7 @@ contract RegisterOrUpdateClientChain is SetUp {
_prepareClientChainData();
name = "";

vm.expectRevert("ExocoreGateway: name cannot be empty");
vm.expectRevert(Errors.ZeroValue.selector);
vm.startPrank(exocoreValidatorSet.addr);
exocoreGateway.registerOrUpdateClientChain(
anotherClientChain, peer, addressLength, name, metaInfo, signatureType
Expand All @@ -298,7 +299,7 @@ contract RegisterOrUpdateClientChain is SetUp {
_prepareClientChainData();
metaInfo = "";

vm.expectRevert("ExocoreGateway: meta data cannot be empty");
vm.expectRevert(Errors.ZeroValue.selector);
vm.startPrank(exocoreValidatorSet.addr);
exocoreGateway.registerOrUpdateClientChain(
anotherClientChain, peer, addressLength, name, metaInfo, signatureType
Expand Down Expand Up @@ -355,7 +356,7 @@ contract SetPeer is SetUp {

function test_RevertWhen_ClientChainNotRegistered() public {
vm.startPrank(exocoreValidatorSet.addr);
vm.expectRevert("ExocoreGateway: client chain should be registered before setting peer to change peer address");
vm.expectRevert(Errors.ExocoreGatewayNotRegisteredClientChainId.selector);
exocoreGateway.setPeer(anotherClientChain, newPeer);
}

Expand Down

0 comments on commit 1516346

Please sign in to comment.