Skip to content

Commit

Permalink
chore: add more unittest and add setting to skip converted file from …
Browse files Browse the repository at this point in the history
…proto in codecov.yml
  • Loading branch information
zemyblue committed Aug 21, 2023
1 parent d7f2be1 commit e436174
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
22 changes: 21 additions & 1 deletion client/grpc/ocservice/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,29 @@ func (s IntegrationTestSuite) TestQueryBlockByHash() {
s.Require().Equal(val.ClientCtx.ChainID, block.Header.ChainID)
}

func (s IntegrationTestSuite) TestGetLatestBlock() {
val := s.network.Validators[0]
latestHeight, err := s.network.LatestHeight()
s.Require().NoError(err)

blockRes, err := s.queryClient.GetLatestBlock(context.Background(), &ocservice.GetLatestBlockRequest{})
s.Require().NoError(err)
s.Require().NotNil(blockRes)
s.Require().Equal(latestHeight, blockRes.Block.Header.Height)

restRes, err := rest.GetRequest(fmt.Sprintf("%s/lbm/base/ostracon/v1/blocks/latest", val.APIAddress))
s.Require().NoError(err)
var blockInfoRes ocservice.GetLatestBlockResponse
s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(restRes, &blockInfoRes))
s.Require().Equal(blockRes.Block.Header.Height, blockInfoRes.Block.Header.Height)
}

func (s IntegrationTestSuite) TestQueryBlockByHeight() {
val := s.network.Validators[0]
_, err := s.queryClient.GetBlockByHeight(context.Background(), &ocservice.GetBlockByHeightRequest{Height: 1})
_, err := s.queryClient.GetBlockByHeight(context.Background(), &ocservice.GetBlockByHeightRequest{})
s.Require().Error(err)

_, err = s.queryClient.GetBlockByHeight(context.Background(), &ocservice.GetBlockByHeightRequest{Height: 1})
s.Require().NoError(err)

restRes, err := rest.GetRequest(fmt.Sprintf("%s/lbm/base/ostracon/v1/blocks/%d", val.APIAddress, 1))
Expand Down
4 changes: 2 additions & 2 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ ignore:
- "*.png"
- "*_test.go"
- "**/*_easyjson.go"
- "x/**/*.pb.go"
- "x/**/*.pb.gw.go"
- "**/*.pb.go"
- "**/*.pb.gw.go"
- "scripts/"
- "x/**/test_common.go"
- "*_cmd.go"
Expand Down

0 comments on commit e436174

Please sign in to comment.