diff --git a/client/rpc/block.go b/client/rpc/block.go index c3f80ae22e8a..d6b79c9fe6da 100644 --- a/client/rpc/block.go +++ b/client/rpc/block.go @@ -11,6 +11,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/types/rest" ) @@ -69,7 +70,7 @@ func getBlock(clientCtx client.Context, height *int64) ([]byte, error) { return nil, err } - return clientCtx.LegacyAmino.MarshalJSON(res) + return legacy.Cdc.MarshalJSON(res) } // get the current blockchain height diff --git a/client/rpc/rpc_test.go b/client/rpc/rpc_test.go index c1c233e73b6f..adb7dac82d21 100644 --- a/client/rpc/rpc_test.go +++ b/client/rpc/rpc_test.go @@ -5,10 +5,13 @@ import ( "testing" "github.com/stretchr/testify/suite" + ctypes "github.com/tendermint/tendermint/rpc/core/types" "github.com/cosmos/cosmos-sdk/client/rpc" + "github.com/cosmos/cosmos-sdk/codec/legacy" clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" "github.com/cosmos/cosmos-sdk/testutil/network" + "github.com/cosmos/cosmos-sdk/types/rest" ) type IntegrationTestSuite struct { @@ -42,6 +45,17 @@ func (s *IntegrationTestSuite) TestStatusCommand() { s.Require().Contains(out.String(), fmt.Sprintf("\"moniker\":\"%s\"", val0.Moniker)) } +func (s *IntegrationTestSuite) TestLatestBlocks() { + val0 := s.network.Validators[0] + + res, err := rest.GetRequest(fmt.Sprintf("%s/blocks/latest", val0.APIAddress)) + s.Require().NoError(err) + + var result ctypes.ResultBlock + err = legacy.Cdc.UnmarshalJSON(res, &result) + s.Require().NoError(err) +} + func TestIntegrationTestSuite(t *testing.T) { suite.Run(t, new(IntegrationTestSuite)) }