Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ADR 031 BaseApp and codec infrastructure #7519

Merged
merged 59 commits into from
Oct 15, 2020
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
64c76d2
Refactor RegisterQueryServices -> RegisterServices
aaronc Oct 12, 2020
d9b8a1d
Cleaner proto files
amaury1093 Oct 12, 2020
889025b
Fix tests
aaronc Oct 12, 2020
b3c301d
Merge branch 'aaronc/7500-register-services' of ssh://github.com/cosm…
amaury1093 Oct 12, 2020
e1482f2
Add MsgServer
amaury1093 Oct 12, 2020
6c77f06
Fix lint
amaury1093 Oct 12, 2020
c746a2b
Remove MsgServer from configurator for now
amaury1093 Oct 12, 2020
ac713d2
Merge branch 'master' of ssh://github.com/cosmos/cosmos-sdk into am-7…
amaury1093 Oct 12, 2020
59ebc3b
Remove useless file
amaury1093 Oct 12, 2020
f18f4e3
Fix build
amaury1093 Oct 12, 2020
1ed29df
typo
amaury1093 Oct 12, 2020
0d9efc4
Add router
amaury1093 Oct 13, 2020
be1a26b
Fix test
amaury1093 Oct 13, 2020
b35ce5d
Merge branch 'master' of ssh://github.com/cosmos/cosmos-sdk into am-7…
amaury1093 Oct 13, 2020
fef78cf
WIP
amaury1093 Oct 13, 2020
ff05343
Add router
amaury1093 Oct 13, 2020
c323889
Merge branch 'master' of ssh://github.com/cosmos/cosmos-sdk into am-7…
amaury1093 Oct 13, 2020
13b8dbd
Remove test helper
amaury1093 Oct 13, 2020
ab00ebf
Add beginning of test
amaury1093 Oct 13, 2020
797ddd3
Move test to simapp?
amaury1093 Oct 13, 2020
a65ab55
ServiceMsg implement sdk.Msg
amaury1093 Oct 13, 2020
759b2a5
Add handler by MsgServiceRouter
amaury1093 Oct 13, 2020
931ca66
Correct signature
amaury1093 Oct 13, 2020
f21b332
Add full test
amaury1093 Oct 13, 2020
24fa6f0
use TxEncoder
amaury1093 Oct 13, 2020
12cbcec
Update baseapp/msg_service_router.go
amaury1093 Oct 13, 2020
b599b65
Push changes
amaury1093 Oct 13, 2020
0c5ce17
WIP on ServiceMsg unpacking
aaronc Oct 13, 2020
14619c4
Make TestMsgService test pass
aaronc Oct 13, 2020
687fc09
Fix tests
aaronc Oct 13, 2020
b6bec3a
Tidying up
aaronc Oct 13, 2020
d89f2f6
Tidying up
aaronc Oct 13, 2020
82e2521
Tidying up
aaronc Oct 13, 2020
42f59ff
Add JSON test
aaronc Oct 13, 2020
9a038a5
Add comments
aaronc Oct 13, 2020
8c56444
Tidying
aaronc Oct 13, 2020
a6a8132
Merge branch 'master' into am-7500-servicemsg
aaronc Oct 13, 2020
aa3192f
Lint
aaronc Oct 13, 2020
55577f6
Register MsgRequest interface
aaronc Oct 13, 2020
701f879
Rename
aaronc Oct 13, 2020
84033e4
Fix tests
aaronc Oct 13, 2020
3762e1d
Merge branch 'master' of ssh://github.com/cosmos/cosmos-sdk into am-7…
amaury1093 Oct 14, 2020
b30a5eb
RegisterCustomTypeURL
amaury1093 Oct 14, 2020
715d002
Add changelog entries
amaury1093 Oct 14, 2020
791097a
Put in features
amaury1093 Oct 14, 2020
62a887f
Update baseapp/msg_service_router.go
amaury1093 Oct 14, 2020
98fa5d2
Update baseapp/msg_service_router.go
amaury1093 Oct 14, 2020
c63105d
Update baseapp/msg_service_router.go
amaury1093 Oct 14, 2020
2be1a61
Update baseapp/msg_service_router.go
amaury1093 Oct 14, 2020
105b04a
Update baseapp/msg_service_router.go
amaury1093 Oct 14, 2020
c306dff
Update baseapp/msg_service_router.go
amaury1093 Oct 14, 2020
eaebd7e
Update baseapp/msg_service_router.go
amaury1093 Oct 14, 2020
7cbc9f9
Address review comments
amaury1093 Oct 14, 2020
dfb6cf6
Merge branch 'master' into am-7500-servicemsg
amaury1093 Oct 14, 2020
8624ad7
Address nit
amaury1093 Oct 14, 2020
880c7cb
Fix lint
amaury1093 Oct 14, 2020
304e937
Update codec/types/interface_registry.go
amaury1093 Oct 15, 2020
ca9258c
godoc
amaury1093 Oct 15, 2020
d6120af
Merge branch 'master' into am-7500-servicemsg
alexanderbez Oct 15, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions baseapp/baseapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1692,9 +1692,9 @@ func TestQuery(t *testing.T) {

func TestGRPCQuery(t *testing.T) {
grpcQueryOpt := func(bapp *BaseApp) {
testdata.RegisterTestServiceServer(
testdata.RegisterQueryServer(
bapp.GRPCQueryRouter(),
testdata.TestServiceImpl{},
testdata.QueryImpl{},
)
}

Expand All @@ -1711,7 +1711,7 @@ func TestGRPCQuery(t *testing.T) {

reqQuery := abci.RequestQuery{
Data: reqBz,
Path: "/testdata.TestService/SayHello",
Path: "/testdata.Query/SayHello",
}

resQuery := app.Query(reqQuery)
Expand Down
4 changes: 2 additions & 2 deletions baseapp/grpcrouter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ func TestGRPCRouter(t *testing.T) {
qr := NewGRPCQueryRouter()
interfaceRegistry := testdata.NewTestInterfaceRegistry()
qr.SetInterfaceRegistry(interfaceRegistry)
testdata.RegisterTestServiceServer(qr, testdata.TestServiceImpl{})
testdata.RegisterQueryServer(qr, testdata.QueryImpl{})
helper := &QueryServiceTestHelper{
GRPCQueryRouter: qr,
ctx: sdk.Context{}.WithContext(context.Background()),
}
client := testdata.NewTestServiceClient(helper)
client := testdata.NewQueryClient(helper)

res, err := client.Echo(context.Background(), &testdata.EchoRequest{Message: "hello"})
require.Nil(t, err)
Expand Down
8 changes: 8 additions & 0 deletions baseapp/msg_service.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package baseapp

type MsgServiceRouter struct{}

// NewMsgServiceRouter creates a new MsgServiceRouter.
func NewMsgServiceRouter() *MsgServiceRouter {
amaury1093 marked this conversation as resolved.
Show resolved Hide resolved
return &MsgServiceRouter{}
}
9 changes: 9 additions & 0 deletions baseapp/msg_service_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package baseapp

import (
"testing"
)

func TestMsgService(t *testing.T) {
// TODO
}
2 changes: 1 addition & 1 deletion client/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func TestCLIQueryConn(t *testing.T) {
n := network.New(t, cfg)
defer n.Cleanup()

testClient := testdata.NewTestServiceClient(n.Validators[0].ClientCtx)
testClient := testdata.NewQueryClient(n.Validators[0].ClientCtx)
res, err := testClient.Echo(context.Background(), &testdata.EchoRequest{Message: "hello"})
require.NoError(t, err)
require.Equal(t, "hello", res.Message)
Expand Down
2 changes: 1 addition & 1 deletion client/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (s *IntegrationTestSuite) TestGRPCQuery() {
val0 := s.network.Validators[0]

// gRPC query to test service should work
testClient := testdata.NewTestServiceClient(val0.ClientCtx)
testClient := testdata.NewQueryClient(val0.ClientCtx)
testRes, err := testClient.Echo(context.Background(), &testdata.EchoRequest{Message: "hello"})
s.Require().NoError(err)
s.Require().Equal("hello", testRes.Message)
Expand Down
2 changes: 1 addition & 1 deletion scripts/protocgen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ done

# generate codec/testdata proto code
protoc -I "proto" -I "third_party/proto" -I "testutil/testdata" --gocosmos_out=plugins=interfacetype+grpc,\
Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types:. ./testutil/testdata/proto.proto
Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types:. ./testutil/testdata/*.proto

# move proto files to the right places
cp -r github.com/cosmos/cosmos-sdk/* ./
Expand Down
2 changes: 1 addition & 1 deletion server/grpc/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (s *IntegrationTestSuite) TestGRPCServer() {
s.Require().NoError(err)

// gRPC query to test service should work
testClient := testdata.NewTestServiceClient(conn)
testClient := testdata.NewQueryClient(conn)
testRes, err := testClient.Echo(context.Background(), &testdata.EchoRequest{Message: "hello"})
s.Require().NoError(err)
s.Require().Equal("hello", testRes.Message)
Expand Down
2 changes: 1 addition & 1 deletion simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ func NewSimApp(
app.mm.RegisterServices(module.NewConfigurator(app.GRPCQueryRouter()))

// add test gRPC service for testing gRPC queries in isolation
testdata.RegisterTestServiceServer(app.GRPCQueryRouter(), testdata.TestServiceImpl{})
testdata.RegisterQueryServer(app.GRPCQueryRouter(), testdata.QueryImpl{})

// create the simulation manager and define the order of the modules for deterministic simulations
//
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ import (
"github.com/cosmos/cosmos-sdk/codec/types"
)

type TestServiceImpl struct{}
type QueryImpl struct{}

func (e TestServiceImpl) TestAny(_ context.Context, request *TestAnyRequest) (*TestAnyResponse, error) {
var _ QueryServer = QueryImpl{}

func (e QueryImpl) TestAny(_ context.Context, request *TestAnyRequest) (*TestAnyResponse, error) {
animal, ok := request.AnyAnimal.GetCachedValue().(Animal)
if !ok {
return nil, fmt.Errorf("expected Animal")
Expand All @@ -28,17 +30,15 @@ func (e TestServiceImpl) TestAny(_ context.Context, request *TestAnyRequest) (*T
}}, nil
}

func (e TestServiceImpl) Echo(_ context.Context, req *EchoRequest) (*EchoResponse, error) {
func (e QueryImpl) Echo(_ context.Context, req *EchoRequest) (*EchoResponse, error) {
return &EchoResponse{Message: req.Message}, nil
}

func (e TestServiceImpl) SayHello(_ context.Context, request *SayHelloRequest) (*SayHelloResponse, error) {
func (e QueryImpl) SayHello(_ context.Context, request *SayHelloRequest) (*SayHelloResponse, error) {
greeting := fmt.Sprintf("Hello %s!", request.Name)
return &SayHelloResponse{Greeting: greeting}, nil
}

var _ TestServiceServer = TestServiceImpl{}

var _ types.UnpackInterfacesMessage = &TestAnyRequest{}

func (m *TestAnyRequest) UnpackInterfaces(unpacker types.AnyUnpacker) error {
Expand Down
16 changes: 16 additions & 0 deletions testutil/testdata/msg_service.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package testdata

import (
"context"
)

type MsgImpl struct{}

var _ MsgServer = MsgImpl{}

// CreateDog implements the MsgServer interface.
func (m MsgImpl) CreateDog(_ context.Context, msg *MsgCreateDog) (*MsgCreateDogResponse, error) {
return &MsgCreateDogResponse{
Name: msg.Dog.Name,
}, nil
}
Loading