Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
haiyizxx committed Apr 2, 2024
1 parent 7b41d29 commit efbe273
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 10 deletions.
5 changes: 1 addition & 4 deletions x/auxiliary/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/axelarnetwork/axelar-core/utils/events"
Expand All @@ -15,13 +14,11 @@ import (
var _ types.MsgServiceServer = msgServer{}

type msgServer struct {
cdc codec.Codec
router *baseapp.MsgServiceRouter
}

func NewMsgServer(cdc codec.Codec, msgServiceRouter *baseapp.MsgServiceRouter) types.MsgServiceServer {
func NewMsgServer(msgServiceRouter *baseapp.MsgServiceRouter) types.MsgServiceServer {
return msgServer{
cdc,
msgServiceRouter,
}
}
Expand Down
2 changes: 1 addition & 1 deletion x/auxiliary/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestBatching(t *testing.T) {
return votetypes.NewVoteRequest(sender, vote.PollID(rand.PosI64()), evmTypes.NewVoteEvents(nexus.ChainName(rand.NormalizedStr(3))))
}, int(rand2.I64Between(2, 10)))

msgServer = keeper.NewMsgServer(appParams.MakeEncodingConfig().Codec, msgServiceRouter)
msgServer = keeper.NewMsgServer(msgServiceRouter)
})

withBatchRequest := func() GivenStatement {
Expand Down
2 changes: 1 addition & 1 deletion x/auxiliary/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName))
}

types.RegisterMsgServiceServer(grpc.ServerWithSDKErrors{Server: cfg.MsgServer(), Err: types.ErrAuxiliary, Logger: logger}, keeper.NewMsgServer(am.cdc, am.router))
types.RegisterMsgServiceServer(grpc.ServerWithSDKErrors{Server: cfg.MsgServer(), Err: types.ErrAuxiliary, Logger: logger}, keeper.NewMsgServer(am.router))
}

// BeginBlock executes all state transitions this module requires at the beginning of each new block
Expand Down
4 changes: 0 additions & 4 deletions x/auxiliary/types/msg_batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ func (m BatchRequest) ValidateBasic() error {
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "message signer mismatch")
}

if !equalAccAddresses(msg.GetSigners(), m.GetSigners()) {
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "message signer mismatch")
}

if err := msg.ValidateBasic(); err != nil {
return err

Check warning on line 46 in x/auxiliary/types/msg_batch.go

View check run for this annotation

Codecov / codecov/patch

x/auxiliary/types/msg_batch.go#L45-L46

Added lines #L45 - L46 were not covered by tests
}
Expand Down
33 changes: 33 additions & 0 deletions x/auxiliary/types/msg_batch_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package types_test

import (
"testing"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/assert"

"github.com/axelarnetwork/axelar-core/testutils/rand"
"github.com/axelarnetwork/axelar-core/x/auxiliary/types"
evmtypes "github.com/axelarnetwork/axelar-core/x/evm/types"
)

func TestBatchRequest_ValidateBasic(t *testing.T) {
t.Run("should fail with nested batch", func(t *testing.T) {
sender := rand.AccAddr()

linkRequest := evmtypes.NewLinkRequest(sender, rand.NormalizedStr(5), rand.NormalizedStr(5), rand.NormalizedStr(5), rand.NormalizedStr(5))
batch := types.NewBatchRequest(sender, []sdk.Msg{linkRequest})
message := types.NewBatchRequest(sender, []sdk.Msg{linkRequest, batch})

assert.ErrorContains(t, message.ValidateBasic(), "nested batch")
})

t.Run("should fail with different signers", func(t *testing.T) {

message := types.NewBatchRequest(rand.AccAddr(), []sdk.Msg{
evmtypes.NewLinkRequest(rand.AccAddr(), rand.NormalizedStr(5), rand.NormalizedStr(5), rand.NormalizedStr(5), rand.NormalizedStr(5)),
})

assert.ErrorContains(t, message.ValidateBasic(), "message signer mismatch")
})
}

0 comments on commit efbe273

Please sign in to comment.