diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index 7762ac8a9..1bd28d3e4 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -47648,7 +47648,7 @@ paths: - Query /pocket/supplier/proof: get: - operationId: PocketSupplierProofAll + operationId: PocketSupplierAllProofs responses: '200': description: A successful response. @@ -47780,7 +47780,11 @@ paths: - Query /pocket/supplier/proof/{index}: get: - summary: Queries a list of Proof items. + summary: >- + TODO_UPNEXT(@Olshansk): Update these endpoints after implementing proof + persistence + + Queries a list of Proof items. operationId: PocketSupplierProof responses: '200': @@ -78289,7 +78293,7 @@ definitions: repeated Bar results = 1; PageResponse page = 2; } - pocket.supplier.QueryAllProofResponse: + pocket.supplier.QueryAllProofsResponse: type: object properties: proof: diff --git a/proto/pocket/supplier/query.proto b/proto/pocket/supplier/query.proto index 1cc1d3a37..6e663607c 100644 --- a/proto/pocket/supplier/query.proto +++ b/proto/pocket/supplier/query.proto @@ -14,41 +14,42 @@ option go_package = "github.com/pokt-network/poktroll/x/supplier/types"; // Query defines the gRPC querier service. service Query { - + // Parameters queries the parameters of the module. rpc Params (QueryParamsRequest) returns (QueryParamsResponse) { option (google.api.http).get = "/pocket/supplier/params"; - + } - + // Queries a list of Supplier items. rpc Supplier (QueryGetSupplierRequest) returns (QueryGetSupplierResponse) { option (google.api.http).get = "/pocket/supplier/supplier/{address}"; - + } rpc SupplierAll (QueryAllSupplierRequest) returns (QueryAllSupplierResponse) { option (google.api.http).get = "/pocket/supplier/supplier"; - + } - + // Queries a list of Claim items. rpc Claim (QueryGetClaimRequest ) returns (QueryGetClaimResponse ) { option (google.api.http).get = "/pocket/supplier/claim/{index}"; - + } rpc AllClaims (QueryAllClaimsRequest) returns (QueryAllClaimsResponse) { option (google.api.http).get = "/pocket/supplier/claim"; - + } - + + // TODO_UPNEXT(@Olshansk): Update these endpoints after implementing proof persistence // Queries a list of Proof items. rpc Proof (QueryGetProofRequest) returns (QueryGetProofResponse) { option (google.api.http).get = "/pocket/supplier/proof/{index}"; - + } - rpc ProofAll (QueryAllProofRequest) returns (QueryAllProofResponse) { + rpc AllProofs (QueryAllProofsRequest) returns (QueryAllProofsResponse) { option (google.api.http).get = "/pocket/supplier/proof"; - + } } // QueryParamsRequest is request type for the Query/Params RPC method. @@ -56,7 +57,7 @@ message QueryParamsRequest {} // QueryParamsResponse is response type for the Query/Params RPC method. message QueryParamsResponse { - + // params holds all the parameters of this module. Params params = 1 [(gogoproto.nullable) = false]; } @@ -103,11 +104,11 @@ message QueryGetProofResponse { Proof proof = 1 [(gogoproto.nullable) = false]; } -message QueryAllProofRequest { +message QueryAllProofsRequest { cosmos.base.query.v1beta1.PageRequest pagination = 1; } -message QueryAllProofResponse { +message QueryAllProofsResponse { repeated Proof proof = 1 [(gogoproto.nullable) = false]; cosmos.base.query.v1beta1.PageResponse pagination = 2; } diff --git a/testutil/keeper/session.go b/testutil/keeper/session.go index 8b57ec0c4..2e70e666e 100644 --- a/testutil/keeper/session.go +++ b/testutil/keeper/session.go @@ -14,14 +14,13 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" typesparams "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/golang/mock/gomock" - "github.com/stretchr/testify/require" - "github.com/pokt-network/poktroll/testutil/sample" "github.com/pokt-network/poktroll/testutil/session/mocks" apptypes "github.com/pokt-network/poktroll/x/application/types" "github.com/pokt-network/poktroll/x/session/keeper" "github.com/pokt-network/poktroll/x/session/types" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" + "github.com/stretchr/testify/require" ) type option[V any] func(k *keeper.Keeper) diff --git a/x/pocket/types/codec.go b/x/pocket/types/codec.go index 72399f81e..39e7482ab 100644 --- a/x/pocket/types/codec.go +++ b/x/pocket/types/codec.go @@ -1,10 +1,11 @@ package types import ( + // this line is used by starport scaffolding # 1 + "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/types/msgservice" - // this line is used by starport scaffolding # 1 ) func RegisterCodec(cdc *codec.LegacyAmino) { diff --git a/x/service/types/codec.go b/x/service/types/codec.go index 72399f81e..39e7482ab 100644 --- a/x/service/types/codec.go +++ b/x/service/types/codec.go @@ -1,10 +1,11 @@ package types import ( + // this line is used by starport scaffolding # 1 + "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/types/msgservice" - // this line is used by starport scaffolding # 1 ) func RegisterCodec(cdc *codec.LegacyAmino) { diff --git a/x/session/types/codec.go b/x/session/types/codec.go index 72399f81e..39e7482ab 100644 --- a/x/session/types/codec.go +++ b/x/session/types/codec.go @@ -1,10 +1,11 @@ package types import ( + // this line is used by starport scaffolding # 1 + "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/types/msgservice" - // this line is used by starport scaffolding # 1 ) func RegisterCodec(cdc *codec.LegacyAmino) { diff --git a/x/supplier/client/cli/query_proof.go b/x/supplier/client/cli/query_proof.go index 2c7dfea7a..bc4d34092 100644 --- a/x/supplier/client/cli/query_proof.go +++ b/x/supplier/client/cli/query_proof.go @@ -1,17 +1,16 @@ package cli import ( - "github.com/pokt-network/poktroll/x/supplier/types" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/pokt-network/poktroll/x/supplier/types" "github.com/spf13/cobra" ) func CmdListProof() *cobra.Command { cmd := &cobra.Command{ - Use: "list-proof", - Short: "list all proof", + Use: "list-proofs", + Short: "list all proofs", RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { @@ -25,11 +24,11 @@ func CmdListProof() *cobra.Command { queryClient := types.NewQueryClient(clientCtx) - params := &types.QueryAllProofRequest{ + params := &types.QueryAllProofsRequest{ Pagination: pageReq, } - res, err := queryClient.ProofAll(cmd.Context(), params) + res, err := queryClient.AllProofs(cmd.Context(), params) if err != nil { return err } diff --git a/x/supplier/client/cli/query_proof_test.go b/x/supplier/client/cli/query_proof_test.go index b87f4e24f..1301b236f 100644 --- a/x/supplier/client/cli/query_proof_test.go +++ b/x/supplier/client/cli/query_proof_test.go @@ -103,7 +103,7 @@ package cli_test // args := request(nil, uint64(i), uint64(step), false) // out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListProof(), args) // require.NoError(t, err) -// var resp types.QueryAllProofResponse +// var resp types.QueryAllProofsResponse // require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) // require.LessOrEqual(t, len(resp.Proof), step) // require.Subset(t, @@ -119,7 +119,7 @@ package cli_test // args := request(next, 0, uint64(step), false) // out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListProof(), args) // require.NoError(t, err) -// var resp types.QueryAllProofResponse +// var resp types.QueryAllProofsResponse // require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) // require.LessOrEqual(t, len(resp.Proof), step) // require.Subset(t, @@ -133,7 +133,7 @@ package cli_test // args := request(nil, 0, uint64(len(objs)), true) // out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListProof(), args) // require.NoError(t, err) -// var resp types.QueryAllProofResponse +// var resp types.QueryAllProofsResponse // require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) // require.NoError(t, err) // require.Equal(t, len(objs), int(resp.Pagination.Total)) diff --git a/x/supplier/keeper/msg_server_test.go b/x/supplier/keeper/msg_server_test.go index 39fc0075f..3a5927aec 100644 --- a/x/supplier/keeper/msg_server_test.go +++ b/x/supplier/keeper/msg_server_test.go @@ -5,10 +5,10 @@ import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" + keepertest "github.com/pokt-network/poktroll/testutil/keeper" + "github.com/pokt-network/poktroll/x/supplier/keeper" + "github.com/pokt-network/poktroll/x/supplier/types" "github.com/stretchr/testify/require" - "github.com/pokt-network/poktroll/x/supplier/types" - "github.com/pokt-network/poktroll/x/supplier/keeper" - keepertest "github.com/pokt-network/poktroll/testutil/keeper" ) func setupMsgServer(t testing.TB) (types.MsgServer, context.Context) { diff --git a/x/supplier/keeper/proof_test.go b/x/supplier/keeper/proof_test.go index 6c9208792..6f8c60a56 100644 --- a/x/supplier/keeper/proof_test.go +++ b/x/supplier/keeper/proof_test.go @@ -4,10 +4,9 @@ import ( "strconv" "testing" - keepertest "pocket/testutil/keeper" - "pocket/testutil/nullify" - sdk "github.com/cosmos/cosmos-sdk/types" + keepertest "github.com/pokt-network/poktroll/testutil/keeper" + "github.com/pokt-network/poktroll/testutil/nullify" "github.com/pokt-network/poktroll/x/supplier/keeper" "github.com/pokt-network/poktroll/x/supplier/types" "github.com/stretchr/testify/require" diff --git a/x/supplier/keeper/query_proof.go b/x/supplier/keeper/query_proof.go index 6a754c8d7..594eff71c 100644 --- a/x/supplier/keeper/query_proof.go +++ b/x/supplier/keeper/query_proof.go @@ -11,7 +11,7 @@ import ( "google.golang.org/grpc/status" ) -func (k Keeper) ProofAll(goCtx context.Context, req *types.QueryAllProofRequest) (*types.QueryAllProofResponse, error) { +func (k Keeper) AllProofs(goCtx context.Context, req *types.QueryAllProofsRequest) (*types.QueryAllProofsResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") } @@ -36,7 +36,7 @@ func (k Keeper) ProofAll(goCtx context.Context, req *types.QueryAllProofRequest) return nil, status.Error(codes.Internal, err.Error()) } - return &types.QueryAllProofResponse{Proof: proofs, Pagination: pageRes}, nil + return &types.QueryAllProofsResponse{Proof: proofs, Pagination: pageRes}, nil } func (k Keeper) Proof(goCtx context.Context, req *types.QueryGetProofRequest) (*types.QueryGetProofResponse, error) { diff --git a/x/supplier/keeper/query_proof_test.go b/x/supplier/keeper/query_proof_test.go index 84b31416b..386565e78 100644 --- a/x/supplier/keeper/query_proof_test.go +++ b/x/supplier/keeper/query_proof_test.go @@ -1,19 +1,17 @@ package keeper_test import ( + keepertest "pocket/testutil/keeper" + "pocket/testutil/nullify" "strconv" "testing" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" + "github.com/pokt-network/poktroll/x/supplier/types" "github.com/stretchr/testify/require" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - - keepertest "pocket/testutil/keeper" - "pocket/testutil/nullify" - - "github.com/pokt-network/poktroll/x/supplier/types" ) // Prevent strconv unused error @@ -76,8 +74,8 @@ func TestProofQueryPaginated(t *testing.T) { wctx := sdk.WrapSDKContext(ctx) msgs := createNProof(keeper, ctx, 5) - request := func(next []byte, offset, limit uint64, total bool) *types.QueryAllProofRequest { - return &types.QueryAllProofRequest{ + request := func(next []byte, offset, limit uint64, total bool) *types.QueryAllProofsRequest { + return &types.QueryAllProofsRequest{ Pagination: &query.PageRequest{ Key: next, Offset: offset, @@ -89,7 +87,7 @@ func TestProofQueryPaginated(t *testing.T) { t.Run("ByOffset", func(t *testing.T) { step := 2 for i := 0; i < len(msgs); i += step { - resp, err := keeper.ProofAll(wctx, request(nil, uint64(i), uint64(step), false)) + resp, err := keeper.AllProofs(wctx, request(nil, uint64(i), uint64(step), false)) require.NoError(t, err) require.LessOrEqual(t, len(resp.Proof), step) require.Subset(t, @@ -102,7 +100,7 @@ func TestProofQueryPaginated(t *testing.T) { step := 2 var next []byte for i := 0; i < len(msgs); i += step { - resp, err := keeper.ProofAll(wctx, request(next, 0, uint64(step), false)) + resp, err := keeper.AllProofs(wctx, request(next, 0, uint64(step), false)) require.NoError(t, err) require.LessOrEqual(t, len(resp.Proof), step) require.Subset(t, @@ -113,7 +111,7 @@ func TestProofQueryPaginated(t *testing.T) { } }) t.Run("Total", func(t *testing.T) { - resp, err := keeper.ProofAll(wctx, request(nil, 0, 0, true)) + resp, err := keeper.AllProofs(wctx, request(nil, 0, 0, true)) require.NoError(t, err) require.Equal(t, len(msgs), int(resp.Pagination.Total)) require.ElementsMatch(t, @@ -122,7 +120,7 @@ func TestProofQueryPaginated(t *testing.T) { ) }) t.Run("InvalidRequest", func(t *testing.T) { - _, err := keeper.ProofAll(wctx, nil) + _, err := keeper.AllProofs(wctx, nil) require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) }) } diff --git a/x/supplier/types/codec.go b/x/supplier/types/codec.go index 02d5e43a5..41d74aa3f 100644 --- a/x/supplier/types/codec.go +++ b/x/supplier/types/codec.go @@ -1,7 +1,6 @@ package types import ( -"github.com/cosmos/cosmos-sdk/types/msgservice" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -29,7 +28,7 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { ) // this line is used by starport scaffolding # 3 -msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/supplier/types/genesis_test.go b/x/supplier/types/genesis_test.go index abfebdde7..dd8f536fb 100644 --- a/x/supplier/types/genesis_test.go +++ b/x/supplier/types/genesis_test.go @@ -319,11 +319,6 @@ func TestGenesisState_Validate(t *testing.T) { }, valid: false, }, - { - desc: "duplicated proof", - genState: &types.GenesisState{}, - valid: false, - }, // this line is used by starport scaffolding # types/genesis/testcase } for _, tc := range tests { diff --git a/x/supplier/types/key_proof.go b/x/supplier/types/key_proof.go index 5a2f19a4c..d3d6d791e 100644 --- a/x/supplier/types/key_proof.go +++ b/x/supplier/types/key_proof.go @@ -5,19 +5,19 @@ import "encoding/binary" var _ binary.ByteOrder const ( - // ProofKeyPrefix is the prefix to retrieve all Proof + // ProofKeyPrefix is the prefix to retrieve all Proof ProofKeyPrefix = "Proof/value/" ) // ProofKey returns the store key to retrieve a Proof from the index fields func ProofKey( -index string, + index string, ) []byte { var key []byte - - indexBytes := []byte(index) - key = append(key, indexBytes...) - key = append(key, []byte("/")...) - + + indexBytes := []byte(index) + key = append(key, indexBytes...) + key = append(key, []byte("/")...) + return key -} \ No newline at end of file +}