Skip to content

Commit

Permalink
PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
skosito committed Jun 3, 2024
1 parent be0f3ed commit 32388f0
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 8 deletions.
1 change: 0 additions & 1 deletion app/ante/vesting_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ func TestVesting_AnteHandle(t *testing.T) {
_, err = decorator.AnteHandle(ctx, tx, false, mmd.AnteHandle)

if tt.wantHasErr {
require.Error(t, err)
require.ErrorContains(t, err, tt.wantErr)
} else {
require.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/crypto/pubkey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ func TestGetEVMAddress(t *testing.T) {
t.Run("should error if non bech32", func(t *testing.T) {
pk := PubKey("invalid")
e, err := pk.GetEVMAddress()
require.Error(t, err)
require.ErrorContains(t, err, "decoding bech32 failed")
require.Equal(t, chains.NoAddress, e)
})
}
17 changes: 14 additions & 3 deletions x/crosschain/keeper/initiate_outbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package keeper
import (
"fmt"

cosmoserrors "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/zeta-chain/zetacore/pkg/chains"
Expand All @@ -11,17 +12,27 @@ import (

// InitiateOutbound initiates the outbound for the CCTX depending on the CCTX gateway.
// It does a conditional dispatch to correct CCTX gateway based on the receiver chain
// which handle the state changes and error handling.
// which handles the state changes and error handling.
func (k Keeper) InitiateOutbound(ctx sdk.Context, cctx *types.CrossChainTx) (types.CctxStatus, error) {
receiverChainID := cctx.GetCurrentOutboundParam().ReceiverChainId
chainInfo := chains.GetChainFromChainID(receiverChainID)
if chainInfo == nil {
return cctx.CctxStatus.Status, fmt.Errorf("chain info not found for %d", receiverChainID)
return cctx.CctxStatus.Status, cosmoserrors.Wrap(
types.ErrInitiatitingOutbound,
fmt.Sprintf(
"chain info not found for %d", receiverChainID,
),
)
}

cctxGateway, ok := k.cctxGateways[chainInfo.CctxGateway]
if !ok {
return cctx.CctxStatus.Status, fmt.Errorf("CCTXGateway not defined for receiver chain %d", receiverChainID)
return cctx.CctxStatus.Status, cosmoserrors.Wrap(
types.ErrInitiatitingOutbound,
fmt.Sprintf(
"CCTXGateway not defined for receiver chain %d", receiverChainID,
),
)
}

return cctxGateway.InitiateOutbound(ctx, cctx), nil
Expand Down
4 changes: 2 additions & 2 deletions x/crosschain/keeper/msg_server_vote_inbound_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ func (k msgServer) VoteInbound(
if err != nil {
return nil, err
}
// Inititiate outbound, the process function manages the state commit and cctx status change.
// If the process fails, the changes to the evm state are rolled back.
// Initiate outbound, the process function manages the state commit and cctx status change.
// If the process fails, the changes to the evm state are rolled back.
_, err = k.InitiateOutbound(ctx, &cctx)
if err != nil {
return nil, err
Expand Down
1 change: 1 addition & 0 deletions x/crosschain/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,5 @@ var (
ErrUnableToDecodeMessageString = errorsmod.Register(ModuleName, 1151, "unable to decode message string")
ErrInvalidRateLimiterFlags = errorsmod.Register(ModuleName, 1152, "invalid rate limiter flags")
ErrMaxTxOutTrackerHashesReached = errorsmod.Register(ModuleName, 1153, "max tx out tracker hashes reached")
ErrInitiatitingOutbound = errorsmod.Register(ModuleName, 1154, "cannot initiate outbound")
)
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ func TestMsgServer_DeploySystemContracts(t *testing.T) {
mockFailedContractDeployment(ctx, t, k)

_, err := msgServer.DeploySystemContracts(ctx, types.NewMsgDeploySystemContracts(admin))
require.Error(t, err)
require.ErrorContains(t, err, "failed to deploy")
})

Expand Down

0 comments on commit 32388f0

Please sign in to comment.