Skip to content

Commit

Permalink
Register GRPC query route for assets keeper (#188)
Browse files Browse the repository at this point in the history
* assets keeper register query

* fix tests
  • Loading branch information
jonfung-dydx authored Sep 6, 2023
1 parent f768aaf commit b2c6062
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions protocol/x/assets/module.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package assets

import (
"context"
"encoding/json"
"fmt"
"time"

// this line is used by starport scaffolding # 1

"github.com/gorilla/mux"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -80,7 +79,10 @@ func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Rout

// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module.
func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
// this line is used by starport scaffolding # 2
err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx))
if err != nil {
panic(err)
}
}

// GetTxCmd returns the assets module's root tx command.
Expand Down Expand Up @@ -123,6 +125,7 @@ func (am AppModule) Name() string {
// module-specific GRPC queries.
func (am AppModule) RegisterServices(cfg module.Configurator) {
types.RegisterQueryServer(cfg.QueryServer(), am.keeper)
types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper))
}

// RegisterInvariants registers the assets module's invariants.
Expand Down
4 changes: 2 additions & 2 deletions protocol/x/assets/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,9 @@ func TestAppModule_RegisterServices(t *testing.T) {
mockMsgServer := new(mocks.Server)

mockConfigurator.On("QueryServer").Return(mockQueryServer)
// Since there's no MsgServer for assets module, configurator does not call `MsgServer`.
mockConfigurator.On("MsgServer").Return(mockMsgServer)
mockQueryServer.On("RegisterService", mock.Anything, mock.Anything).Return()
// Since there's no MsgServer for assets module, MsgServer does not call `RegisterServer`.
mockMsgServer.On("RegisterService", mock.Anything, mock.Anything).Return()

am := createAppModule(t)
am.RegisterServices(mockConfigurator)
Expand Down

0 comments on commit b2c6062

Please # to comment.