From a17f22f0267525505ba62cd73107fdc1ebdd30d0 Mon Sep 17 00:00:00 2001 From: Artur Troian Date: Wed, 15 Nov 2023 07:21:59 -0800 Subject: [PATCH] feat: node client discovery refs akash-network/support#165 Signed-off-by: Artur Troian --- Makefile | 3 + go.mod | 8 +- go.sum | 6 +- go/manifest/v2beta2/group.go | 11 + go/node/client/akash.pb.go | 330 +++++ go/node/client/client.go | 76 ++ go/node/client/client_info.pb.go | 322 +++++ go/node/client/v1beta1/client.go | 189 +++ go/node/client/v1beta1/mocks/client.go | 165 +++ go/node/client/v1beta1/mocks/node.go | 92 ++ go/node/client/v1beta1/mocks/query.go | 1169 +++++++++++++++++ go/node/client/v1beta1/mocks/tx.go | 95 ++ go/node/client/v1beta2/client.go | 80 ++ go/node/client/v1beta2/errors.go | 11 + go/node/client/v1beta2/mocks/client.go | 165 +++ go/node/client/v1beta2/mocks/node.go | 92 ++ go/node/client/v1beta2/mocks/query.go | 1169 +++++++++++++++++ go/node/client/v1beta2/mocks/tx.go | 95 ++ go/node/client/v1beta2/node.go | 32 + go/node/client/v1beta2/options.go | 7 + go/node/client/v1beta2/query.go | 160 +++ go/node/client/v1beta2/tx.go | 413 ++++++ go/sdkutil/config.go | 2 +- make/codegen.mk | 5 +- make/setup-cache.mk | 9 + proto/node/akash/discovery/v1/akash.proto | 17 + .../node/akash/discovery/v1/client_info.proto | 16 + 27 files changed, 4733 insertions(+), 6 deletions(-) create mode 100644 go/node/client/akash.pb.go create mode 100644 go/node/client/client.go create mode 100644 go/node/client/client_info.pb.go create mode 100644 go/node/client/v1beta1/client.go create mode 100644 go/node/client/v1beta1/mocks/client.go create mode 100644 go/node/client/v1beta1/mocks/node.go create mode 100644 go/node/client/v1beta1/mocks/query.go create mode 100644 go/node/client/v1beta1/mocks/tx.go create mode 100644 go/node/client/v1beta2/client.go create mode 100644 go/node/client/v1beta2/errors.go create mode 100644 go/node/client/v1beta2/mocks/client.go create mode 100644 go/node/client/v1beta2/mocks/node.go create mode 100644 go/node/client/v1beta2/mocks/query.go create mode 100644 go/node/client/v1beta2/mocks/tx.go create mode 100644 go/node/client/v1beta2/node.go create mode 100644 go/node/client/v1beta2/options.go create mode 100644 go/node/client/v1beta2/query.go create mode 100644 go/node/client/v1beta2/tx.go create mode 100644 proto/node/akash/discovery/v1/akash.proto create mode 100644 proto/node/akash/discovery/v1/client_info.proto diff --git a/Makefile b/Makefile index e2f246d6..bdc27366 100644 --- a/Makefile +++ b/Makefile @@ -37,6 +37,7 @@ PROTOC_GEN_GO_VERSION ?= $(shell $(GO) list -mod=readonly -m -f '{{ .V PROTOC_GEN_GRPC_GATEWAY_VERSION := $(shell $(GO) list -mod=readonly -m -f '{{ .Version }}' github.com/grpc-ecosystem/grpc-gateway) PROTOC_GEN_SWAGGER_VERSION := $(PROTOC_GEN_GRPC_GATEWAY_VERSION) MODVENDOR_VERSION ?= v0.5.0 +MOCKERY_VERSION ?= 2.24.0 BUF_VERSION_FILE := $(AKASH_DEVCACHE_VERSIONS)/buf/$(BUF_VERSION) PROTOC_VERSION_FILE := $(AKASH_DEVCACHE_VERSIONS)/protoc/$(PROTOC_VERSION) @@ -48,6 +49,7 @@ PROTOC_GEN_GRPC_GATEWAY_VERSION_FILE := $(AKASH_DEVCACHE_VERSIONS)/protoc-gen-gr PROTOC_GEN_SWAGGER_VERSION_FILE := $(AKASH_DEVCACHE_VERSIONS)/protoc-gen-swagger/$(PROTOC_GEN_SWAGGER_VERSION) MODVENDOR_VERSION_FILE := $(AKASH_DEVCACHE_VERSIONS)/modvendor/$(MODVENDOR_VERSION) GIT_CHGLOG_VERSION_FILE := $(AKASH_DEVCACHE_VERSIONS)/git-chglog/$(GIT_CHGLOG_VERSION) +MOCKERY_VERSION_FILE := $(AKASH_DEVCACHE_VERSIONS)/mockery/v$(MOCKERY_VERSION) BUF := $(AKASH_DEVCACHE_BIN)/buf PROTOC := $(AKASH_DEVCACHE_BIN)/protoc @@ -60,6 +62,7 @@ PROTOC_GEN_SWAGGER := $(AKASH_DEVCACHE_BIN)/protoc-gen-swagger MODVENDOR := $(AKASH_DEVCACHE_BIN)/modvendor GIT_CHGLOG := $(AKASH_DEVCACHE_BIN)/git-chglog SWAGGER_COMBINE := $(AKASH_DEVCACHE_NODE_BIN)/swagger-combine +MOCKERY := $(AKASH_DEVCACHE_BIN)/mockery DOCKER_RUN := docker run --rm -v $(shell pwd):/workspace -w /workspace DOCKER_BUF := $(DOCKER_RUN) bufbuild/buf:$(BUF_VERSION) diff --git a/go.mod b/go.mod index ee847f0f..c9308140 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ go 1.21 require ( github.com/99designs/keyring v1.2.1 + github.com/boz/go-lifecycle v0.1.1 github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 github.com/cosmos/cosmos-sdk v0.45.16 github.com/gogo/protobuf v1.3.3 @@ -11,7 +12,8 @@ require ( github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/pkg/errors v0.9.1 github.com/regen-network/cosmos-proto v0.3.1 - github.com/stretchr/testify v1.8.1 + github.com/spf13/pflag v1.0.5 + github.com/stretchr/testify v1.8.4 github.com/tendermint/tendermint v0.34.27 google.golang.org/genproto v0.0.0-20230125152338-dcaf20b6aeaa google.golang.org/grpc v1.53.0 @@ -60,6 +62,7 @@ require ( github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect github.com/cockroachdb/pebble v0.0.0-20220817183557-09c6e030a677 // indirect github.com/cockroachdb/redact v1.1.3 // indirect + github.com/cometbft/cometbft-db v0.7.0 // indirect github.com/confio/ics23/go v0.9.0 // indirect github.com/cosmos/btcutil v1.0.4 // indirect github.com/cosmos/cosmos-db v0.0.0-20221226095112-f3c38ecb5e32 // indirect @@ -129,10 +132,11 @@ require ( github.com/spf13/cast v1.5.0 // indirect github.com/spf13/cobra v1.6.1 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect - github.com/spf13/pflag v1.0.5 // indirect github.com/spf13/viper v1.14.0 // indirect + github.com/stretchr/objx v0.5.0 // indirect github.com/subosito/gotenv v1.4.1 // indirect github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect + github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c // indirect github.com/tendermint/go-amino v0.16.0 // indirect github.com/tendermint/tm-db v0.6.7 // indirect github.com/tidwall/btree v1.5.0 // indirect diff --git a/go.sum b/go.sum index 1b1da38d..f93ed34d 100644 --- a/go.sum +++ b/go.sum @@ -92,6 +92,8 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 h1:41iFGWnSlI2gVpmOtVTJZNodLdLQLn/KsJqFvXwnd/s= github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/boz/go-lifecycle v0.1.1 h1:tG/wff7Zxbkf19g4D4I0G8Y4sq83iT5QjD4rzEf/zrI= +github.com/boz/go-lifecycle v0.1.1/go.mod h1:zdagAUMcC2C0OmQkBlJZFV77uF4GCVaGphAexGi7oho= github.com/btcsuite/btcd v0.20.1-beta h1:Ik4hyJqN8Jfyv3S4AGBOmyouMsYE3EdYODkMbQjwPGw= github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U= @@ -660,8 +662,8 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/subosito/gotenv v1.4.1 h1:jyEFiXpy21Wm81FBN71l9VoMMV8H8jG+qIK3GCpY6Qs= github.com/subosito/gotenv v1.4.1/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= diff --git a/go/manifest/v2beta2/group.go b/go/manifest/v2beta2/group.go index 22fdb49f..0c94d977 100644 --- a/go/manifest/v2beta2/group.go +++ b/go/manifest/v2beta2/group.go @@ -37,6 +37,17 @@ func (g Group) GetResourceUnits() dtypes.ResourceUnits { return units } +func (g Group) AllHostnames() []string { + allHostnames := make([]string, 0) + for _, service := range g.Services { + for _, expose := range service.Expose { + allHostnames = append(allHostnames, expose.Hosts...) + } + } + + return allHostnames +} + func (g *Group) Validate(helper *validateManifestGroupsHelper) error { if 0 == len(g.Services) { return fmt.Errorf("%w: group %q contains no services", ErrInvalidManifest, g.GetName()) diff --git a/go/node/client/akash.pb.go b/go/node/client/akash.pb.go new file mode 100644 index 00000000..503fbd7e --- /dev/null +++ b/go/node/client/akash.pb.go @@ -0,0 +1,330 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: akash/discovery/v1/akash.proto + +package client + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Akash akash specific RPC parameters +type Akash struct { + ClientInfo *ClientInfo `protobuf:"bytes,1,opt,name=client_info,json=clientInfo,proto3" json:"client_info" yaml:"client_info"` +} + +func (m *Akash) Reset() { *m = Akash{} } +func (m *Akash) String() string { return proto.CompactTextString(m) } +func (*Akash) ProtoMessage() {} +func (*Akash) Descriptor() ([]byte, []int) { + return fileDescriptor_bf31dd3d85bbd20d, []int{0} +} +func (m *Akash) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Akash) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Akash.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Akash) XXX_Merge(src proto.Message) { + xxx_messageInfo_Akash.Merge(m, src) +} +func (m *Akash) XXX_Size() int { + return m.Size() +} +func (m *Akash) XXX_DiscardUnknown() { + xxx_messageInfo_Akash.DiscardUnknown(m) +} + +var xxx_messageInfo_Akash proto.InternalMessageInfo + +func (m *Akash) GetClientInfo() *ClientInfo { + if m != nil { + return m.ClientInfo + } + return nil +} + +func init() { + proto.RegisterType((*Akash)(nil), "akash.discovery.v1.Akash") +} + +func init() { proto.RegisterFile("akash/discovery/v1/akash.proto", fileDescriptor_bf31dd3d85bbd20d) } + +var fileDescriptor_bf31dd3d85bbd20d = []byte{ + // 225 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4b, 0xcc, 0x4e, 0x2c, + 0xce, 0xd0, 0x4f, 0xc9, 0x2c, 0x4e, 0xce, 0x2f, 0x4b, 0x2d, 0xaa, 0xd4, 0x2f, 0x33, 0xd4, 0x07, + 0x0b, 0xe9, 0x15, 0x14, 0xe5, 0x97, 0xe4, 0x0b, 0x09, 0x41, 0x38, 0x70, 0x79, 0xbd, 0x32, 0x43, + 0x29, 0x15, 0x2c, 0x7a, 0x92, 0x73, 0x32, 0x53, 0xf3, 0x4a, 0xe2, 0x33, 0xf3, 0xd2, 0xf2, 0x21, + 0x3a, 0xa5, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x4c, 0x7d, 0x10, 0x0b, 0x22, 0xaa, 0x54, 0xcb, + 0xc5, 0xea, 0x08, 0xd2, 0x2d, 0x54, 0xc2, 0xc5, 0x8d, 0xa4, 0x47, 0x82, 0x51, 0x81, 0x51, 0x83, + 0xdb, 0x48, 0x4e, 0x0f, 0xd3, 0x3a, 0x3d, 0x67, 0xb0, 0x32, 0xcf, 0xbc, 0xb4, 0x7c, 0x27, 0xe3, + 0x47, 0xf7, 0xe4, 0xb9, 0x10, 0xfc, 0x57, 0xf7, 0xe4, 0x91, 0x0d, 0xf9, 0x74, 0x4f, 0x5e, 0xa8, + 0x32, 0x31, 0x37, 0xc7, 0x4a, 0x09, 0x49, 0x50, 0x29, 0x88, 0x2b, 0x19, 0x61, 0x80, 0xf7, 0x89, + 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, + 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x19, 0xa6, 0x67, 0x96, 0x64, 0x94, 0x26, + 0xe9, 0x25, 0xe7, 0xe7, 0x42, 0x02, 0x40, 0x37, 0x2f, 0xb5, 0xa4, 0x3c, 0xbf, 0x28, 0x1b, 0xca, + 0x4b, 0x2c, 0xc8, 0xd4, 0x4f, 0xcf, 0xd7, 0xcf, 0xcb, 0x4f, 0x49, 0x85, 0x7a, 0x36, 0x89, 0x0d, + 0xec, 0x25, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x54, 0xd8, 0x43, 0x8d, 0x44, 0x01, 0x00, + 0x00, +} + +func (m *Akash) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Akash) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Akash) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ClientInfo != nil { + { + size, err := m.ClientInfo.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintAkash(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintAkash(dAtA []byte, offset int, v uint64) int { + offset -= sovAkash(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Akash) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ClientInfo != nil { + l = m.ClientInfo.Size() + n += 1 + l + sovAkash(uint64(l)) + } + return n +} + +func sovAkash(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozAkash(x uint64) (n int) { + return sovAkash(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Akash) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAkash + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Akash: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Akash: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ClientInfo", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAkash + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAkash + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAkash + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ClientInfo == nil { + m.ClientInfo = &ClientInfo{} + } + if err := m.ClientInfo.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAkash(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAkash + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipAkash(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowAkash + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowAkash + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowAkash + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthAkash + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupAkash + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthAkash + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthAkash = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowAkash = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupAkash = fmt.Errorf("proto: unexpected end of group") +) diff --git a/go/node/client/client.go b/go/node/client/client.go new file mode 100644 index 00000000..1f776b38 --- /dev/null +++ b/go/node/client/client.go @@ -0,0 +1,76 @@ +package client + +import ( + "context" + "errors" + + sdkclient "github.com/cosmos/cosmos-sdk/client" + "github.com/spf13/pflag" + tmjclient "github.com/tendermint/tendermint/rpc/jsonrpc/client" + + "github.com/akash-network/akash-api/go/node/client/v1beta2" +) + +var ( + ErrUnknownClientVersion = errors.New("akash-api: unknown client version") +) + +func DiscoverClient(ctx context.Context, cctx sdkclient.Context, flags *pflag.FlagSet, setup func(interface{}) error) error { + rpc, err := tmjclient.New(cctx.NodeURI) + if err != nil { + return err + } + + result := new(Akash) + params := make(map[string]interface{}) + _, err = rpc.Call(ctx, "akash", params, result) + if err != nil { + return err + } + + var cl interface{} + + switch result.ClientInfo.ApiVersion { + case "v1beta2": + cl, err = v1beta2.NewClient(ctx, cctx, flags) + // case "": + default: + return ErrUnknownClientVersion + } + + if err = setup(cl); err != nil { + return err + } + + return nil +} + +func DiscoverQueryClient(ctx context.Context, cctx sdkclient.Context, setup func(interface{}) error) error { + rpc, err := tmjclient.New(cctx.NodeURI) + if err != nil { + return err + } + + result := new(Akash) + params := make(map[string]interface{}) + _, err = rpc.Call(ctx, "akash", params, result) + if err != nil { + return err + } + + var cl interface{} + + switch result.ClientInfo.ApiVersion { + case "v1beta2": + cl = v1beta2.NewQueryClient(cctx) + // case "": + default: + return ErrUnknownClientVersion + } + + if err = setup(cl); err != nil { + return err + } + + return nil +} diff --git a/go/node/client/client_info.pb.go b/go/node/client/client_info.pb.go new file mode 100644 index 00000000..8218fcf8 --- /dev/null +++ b/go/node/client/client_info.pb.go @@ -0,0 +1,322 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: akash/discovery/v1/client_info.proto + +package client + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// ClientInfo akash specific client info +type ClientInfo struct { + ApiVersion string `protobuf:"bytes,1,opt,name=api_version,json=apiVersion,proto3" json:"api_version" yaml:"api_version"` +} + +func (m *ClientInfo) Reset() { *m = ClientInfo{} } +func (m *ClientInfo) String() string { return proto.CompactTextString(m) } +func (*ClientInfo) ProtoMessage() {} +func (*ClientInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_d0e1ef320145891a, []int{0} +} +func (m *ClientInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ClientInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ClientInfo.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ClientInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_ClientInfo.Merge(m, src) +} +func (m *ClientInfo) XXX_Size() int { + return m.Size() +} +func (m *ClientInfo) XXX_DiscardUnknown() { + xxx_messageInfo_ClientInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_ClientInfo proto.InternalMessageInfo + +func (m *ClientInfo) GetApiVersion() string { + if m != nil { + return m.ApiVersion + } + return "" +} + +func init() { + proto.RegisterType((*ClientInfo)(nil), "akash.discovery.v1.ClientInfo") +} + +func init() { + proto.RegisterFile("akash/discovery/v1/client_info.proto", fileDescriptor_d0e1ef320145891a) +} + +var fileDescriptor_d0e1ef320145891a = []byte{ + // 223 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x49, 0xcc, 0x4e, 0x2c, + 0xce, 0xd0, 0x4f, 0xc9, 0x2c, 0x4e, 0xce, 0x2f, 0x4b, 0x2d, 0xaa, 0xd4, 0x2f, 0x33, 0xd4, 0x4f, + 0xce, 0xc9, 0x4c, 0xcd, 0x2b, 0x89, 0xcf, 0xcc, 0x4b, 0xcb, 0xd7, 0x2b, 0x28, 0xca, 0x2f, 0xc9, + 0x17, 0x12, 0x02, 0xab, 0xd2, 0x83, 0xab, 0xd2, 0x2b, 0x33, 0x94, 0x12, 0x49, 0xcf, 0x4f, 0xcf, + 0x07, 0x4b, 0xeb, 0x83, 0x58, 0x10, 0x95, 0x4a, 0x49, 0x5c, 0x5c, 0xce, 0x60, 0xed, 0x9e, 0x79, + 0x69, 0xf9, 0x42, 0x21, 0x5c, 0xdc, 0x89, 0x05, 0x99, 0xf1, 0x65, 0xa9, 0x45, 0xc5, 0x99, 0xf9, + 0x79, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x9c, 0x4e, 0xc6, 0x8f, 0xee, 0xc9, 0x73, 0x39, 0x16, 0x64, + 0x86, 0x41, 0x44, 0x5f, 0xdd, 0x93, 0x47, 0x56, 0xf4, 0xe9, 0x9e, 0xbc, 0x50, 0x65, 0x62, 0x6e, + 0x8e, 0x95, 0x12, 0x92, 0xa0, 0x52, 0x10, 0x57, 0x22, 0x5c, 0x83, 0x93, 0xf7, 0x89, 0x47, 0x72, + 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, + 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x19, 0xa6, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, + 0xe7, 0xe7, 0xea, 0x83, 0x9d, 0xac, 0x9b, 0x97, 0x5a, 0x52, 0x9e, 0x5f, 0x94, 0x0d, 0xe5, 0x25, + 0x16, 0x64, 0xea, 0xa7, 0xe7, 0xeb, 0xe7, 0xe5, 0xa7, 0xa4, 0x42, 0x7d, 0x99, 0xc4, 0x06, 0x76, + 0xb7, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xbb, 0x3d, 0x00, 0x57, 0x09, 0x01, 0x00, 0x00, +} + +func (m *ClientInfo) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ClientInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ClientInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ApiVersion) > 0 { + i -= len(m.ApiVersion) + copy(dAtA[i:], m.ApiVersion) + i = encodeVarintClientInfo(dAtA, i, uint64(len(m.ApiVersion))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintClientInfo(dAtA []byte, offset int, v uint64) int { + offset -= sovClientInfo(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ClientInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ApiVersion) + if l > 0 { + n += 1 + l + sovClientInfo(uint64(l)) + } + return n +} + +func sovClientInfo(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozClientInfo(x uint64) (n int) { + return sovClientInfo(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ClientInfo) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowClientInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ClientInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ClientInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ApiVersion", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowClientInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthClientInfo + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthClientInfo + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ApiVersion = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipClientInfo(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthClientInfo + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipClientInfo(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowClientInfo + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowClientInfo + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowClientInfo + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthClientInfo + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupClientInfo + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthClientInfo + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthClientInfo = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowClientInfo = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupClientInfo = fmt.Errorf("proto: unexpected end of group") +) diff --git a/go/node/client/v1beta1/client.go b/go/node/client/v1beta1/client.go new file mode 100644 index 00000000..10e23672 --- /dev/null +++ b/go/node/client/v1beta1/client.go @@ -0,0 +1,189 @@ +package v1beta1 + +import ( + "context" + + "github.com/pkg/errors" + "google.golang.org/grpc" + + tmrpc "github.com/tendermint/tendermint/rpc/core/types" + + sdk "github.com/cosmos/cosmos-sdk/types" + + atypes "github.com/akash-network/akash-api/go/node/audit/v1beta3" + ctypes "github.com/akash-network/akash-api/go/node/cert/v1beta3" + dtypes "github.com/akash-network/akash-api/go/node/deployment/v1beta3" + mtypes "github.com/akash-network/akash-api/go/node/market/v1beta3" + ptypes "github.com/akash-network/akash-api/go/node/provider/v1beta3" +) + +var ( + ErrClientNotFound = errors.New("client not found") +) + +//go:generate mockery --name Query --output ./mocks +type Query interface { + dtypes.QueryClient + mtypes.QueryClient + ptypes.QueryClient + atypes.QueryClient + ctypes.QueryClient +} + +//go:generate mockery --name Tx --output ./mocks +type Tx interface { + Broadcast(context.Context, ...sdk.Msg) error +} + +//go:generate mockery --name Node --output ./mocks +type Node interface { + SyncInfo(ctx context.Context) (*tmrpc.SyncInfo, error) +} + +//go:generate mockery --name Client --output ./mocks +type Client interface { + Query() Query + Tx() Tx + Node() Node +} + +type qclient struct { + dclient dtypes.QueryClient + mclient mtypes.QueryClient + pclient ptypes.QueryClient + aclient atypes.QueryClient + cclient ctypes.QueryClient +} + +// NewQueryClient creates new query client instance +func NewQueryClient( + dclient dtypes.QueryClient, + mclient mtypes.QueryClient, + pclient ptypes.QueryClient, + aclient atypes.QueryClient, + cclient ctypes.QueryClient, +) Query { + return &qclient{ + dclient: dclient, + mclient: mclient, + pclient: pclient, + aclient: aclient, + cclient: cclient, + } +} + +func (c *qclient) Deployments(ctx context.Context, in *dtypes.QueryDeploymentsRequest, opts ...grpc.CallOption) (*dtypes.QueryDeploymentsResponse, error) { + if c.dclient == nil { + return &dtypes.QueryDeploymentsResponse{}, ErrClientNotFound + } + return c.dclient.Deployments(ctx, in, opts...) +} + +func (c *qclient) Deployment(ctx context.Context, in *dtypes.QueryDeploymentRequest, opts ...grpc.CallOption) (*dtypes.QueryDeploymentResponse, error) { + if c.dclient == nil { + return &dtypes.QueryDeploymentResponse{}, ErrClientNotFound + } + return c.dclient.Deployment(ctx, in, opts...) +} + +func (c *qclient) Group(ctx context.Context, in *dtypes.QueryGroupRequest, opts ...grpc.CallOption) (*dtypes.QueryGroupResponse, error) { + if c.dclient == nil { + return &dtypes.QueryGroupResponse{}, ErrClientNotFound + } + return c.dclient.Group(ctx, in, opts...) +} + +func (c *qclient) Orders(ctx context.Context, in *mtypes.QueryOrdersRequest, opts ...grpc.CallOption) (*mtypes.QueryOrdersResponse, error) { + if c.mclient == nil { + return &mtypes.QueryOrdersResponse{}, ErrClientNotFound + } + return c.mclient.Orders(ctx, in, opts...) +} + +func (c *qclient) Order(ctx context.Context, in *mtypes.QueryOrderRequest, opts ...grpc.CallOption) (*mtypes.QueryOrderResponse, error) { + if c.mclient == nil { + return &mtypes.QueryOrderResponse{}, ErrClientNotFound + } + return c.mclient.Order(ctx, in, opts...) +} + +func (c *qclient) Bids(ctx context.Context, in *mtypes.QueryBidsRequest, opts ...grpc.CallOption) (*mtypes.QueryBidsResponse, error) { + if c.mclient == nil { + return &mtypes.QueryBidsResponse{}, ErrClientNotFound + } + return c.mclient.Bids(ctx, in, opts...) +} + +func (c *qclient) Bid(ctx context.Context, in *mtypes.QueryBidRequest, opts ...grpc.CallOption) (*mtypes.QueryBidResponse, error) { + if c.mclient == nil { + return &mtypes.QueryBidResponse{}, ErrClientNotFound + } + return c.mclient.Bid(ctx, in, opts...) +} + +func (c *qclient) Leases(ctx context.Context, in *mtypes.QueryLeasesRequest, opts ...grpc.CallOption) (*mtypes.QueryLeasesResponse, error) { + if c.mclient == nil { + return &mtypes.QueryLeasesResponse{}, ErrClientNotFound + } + return c.mclient.Leases(ctx, in, opts...) +} + +func (c *qclient) Lease(ctx context.Context, in *mtypes.QueryLeaseRequest, opts ...grpc.CallOption) (*mtypes.QueryLeaseResponse, error) { + if c.mclient == nil { + return &mtypes.QueryLeaseResponse{}, ErrClientNotFound + } + return c.mclient.Lease(ctx, in, opts...) +} + +func (c *qclient) Providers(ctx context.Context, in *ptypes.QueryProvidersRequest, opts ...grpc.CallOption) (*ptypes.QueryProvidersResponse, error) { + if c.pclient == nil { + return &ptypes.QueryProvidersResponse{}, ErrClientNotFound + } + return c.pclient.Providers(ctx, in, opts...) +} + +func (c *qclient) Provider(ctx context.Context, in *ptypes.QueryProviderRequest, opts ...grpc.CallOption) (*ptypes.QueryProviderResponse, error) { + if c.pclient == nil { + return &ptypes.QueryProviderResponse{}, ErrClientNotFound + } + return c.pclient.Provider(ctx, in, opts...) +} + +// AllProvidersAttributes queries all providers +func (c *qclient) AllProvidersAttributes(ctx context.Context, in *atypes.QueryAllProvidersAttributesRequest, opts ...grpc.CallOption) (*atypes.QueryProvidersResponse, error) { + if c.aclient == nil { + return &atypes.QueryProvidersResponse{}, ErrClientNotFound + } + return c.aclient.AllProvidersAttributes(ctx, in, opts...) +} + +// ProviderAttributes queries all provider signed attributes +func (c *qclient) ProviderAttributes(ctx context.Context, in *atypes.QueryProviderAttributesRequest, opts ...grpc.CallOption) (*atypes.QueryProvidersResponse, error) { + if c.aclient == nil { + return &atypes.QueryProvidersResponse{}, ErrClientNotFound + } + return c.aclient.ProviderAttributes(ctx, in, opts...) +} + +// ProviderAuditorAttributes queries provider signed attributes by specific validator +func (c *qclient) ProviderAuditorAttributes(ctx context.Context, in *atypes.QueryProviderAuditorRequest, opts ...grpc.CallOption) (*atypes.QueryProvidersResponse, error) { + if c.aclient == nil { + return &atypes.QueryProvidersResponse{}, ErrClientNotFound + } + return c.aclient.ProviderAuditorAttributes(ctx, in, opts...) +} + +// AuditorAttributes queries all providers signed by this validator +func (c *qclient) AuditorAttributes(ctx context.Context, in *atypes.QueryAuditorAttributesRequest, opts ...grpc.CallOption) (*atypes.QueryProvidersResponse, error) { + if c.aclient == nil { + return &atypes.QueryProvidersResponse{}, ErrClientNotFound + } + return c.aclient.AuditorAttributes(ctx, in, opts...) +} + +func (c *qclient) Certificates(ctx context.Context, in *ctypes.QueryCertificatesRequest, opts ...grpc.CallOption) (*ctypes.QueryCertificatesResponse, error) { + if c.cclient == nil { + return &ctypes.QueryCertificatesResponse{}, ErrClientNotFound + } + return c.cclient.Certificates(ctx, in, opts...) +} diff --git a/go/node/client/v1beta1/mocks/client.go b/go/node/client/v1beta1/mocks/client.go new file mode 100644 index 00000000..b921e97c --- /dev/null +++ b/go/node/client/v1beta1/mocks/client.go @@ -0,0 +1,165 @@ +// Code generated by mockery v2.24.0. DO NOT EDIT. + +package mocks + +import ( + v1beta1 "github.com/akash-network/akash-api/go/node/client/v1beta1" + mock "github.com/stretchr/testify/mock" +) + +// Client is an autogenerated mock type for the Client type +type Client struct { + mock.Mock +} + +type Client_Expecter struct { + mock *mock.Mock +} + +func (_m *Client) EXPECT() *Client_Expecter { + return &Client_Expecter{mock: &_m.Mock} +} + +// Node provides a mock function with given fields: +func (_m *Client) Node() v1beta1.Node { + ret := _m.Called() + + var r0 v1beta1.Node + if rf, ok := ret.Get(0).(func() v1beta1.Node); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(v1beta1.Node) + } + } + + return r0 +} + +// Client_Node_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Node' +type Client_Node_Call struct { + *mock.Call +} + +// Node is a helper method to define mock.On call +func (_e *Client_Expecter) Node() *Client_Node_Call { + return &Client_Node_Call{Call: _e.mock.On("Node")} +} + +func (_c *Client_Node_Call) Run(run func()) *Client_Node_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *Client_Node_Call) Return(_a0 v1beta1.Node) *Client_Node_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Client_Node_Call) RunAndReturn(run func() v1beta1.Node) *Client_Node_Call { + _c.Call.Return(run) + return _c +} + +// Query provides a mock function with given fields: +func (_m *Client) Query() v1beta1.Query { + ret := _m.Called() + + var r0 v1beta1.Query + if rf, ok := ret.Get(0).(func() v1beta1.Query); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(v1beta1.Query) + } + } + + return r0 +} + +// Client_Query_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Query' +type Client_Query_Call struct { + *mock.Call +} + +// Query is a helper method to define mock.On call +func (_e *Client_Expecter) Query() *Client_Query_Call { + return &Client_Query_Call{Call: _e.mock.On("Query")} +} + +func (_c *Client_Query_Call) Run(run func()) *Client_Query_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *Client_Query_Call) Return(_a0 v1beta1.Query) *Client_Query_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Client_Query_Call) RunAndReturn(run func() v1beta1.Query) *Client_Query_Call { + _c.Call.Return(run) + return _c +} + +// Tx provides a mock function with given fields: +func (_m *Client) Tx() v1beta1.Tx { + ret := _m.Called() + + var r0 v1beta1.Tx + if rf, ok := ret.Get(0).(func() v1beta1.Tx); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(v1beta1.Tx) + } + } + + return r0 +} + +// Client_Tx_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Tx' +type Client_Tx_Call struct { + *mock.Call +} + +// Tx is a helper method to define mock.On call +func (_e *Client_Expecter) Tx() *Client_Tx_Call { + return &Client_Tx_Call{Call: _e.mock.On("Tx")} +} + +func (_c *Client_Tx_Call) Run(run func()) *Client_Tx_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *Client_Tx_Call) Return(_a0 v1beta1.Tx) *Client_Tx_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Client_Tx_Call) RunAndReturn(run func() v1beta1.Tx) *Client_Tx_Call { + _c.Call.Return(run) + return _c +} + +type mockConstructorTestingTNewClient interface { + mock.TestingT + Cleanup(func()) +} + +// NewClient creates a new instance of Client. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewClient(t mockConstructorTestingTNewClient) *Client { + mock := &Client{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/go/node/client/v1beta1/mocks/node.go b/go/node/client/v1beta1/mocks/node.go new file mode 100644 index 00000000..222e0faa --- /dev/null +++ b/go/node/client/v1beta1/mocks/node.go @@ -0,0 +1,92 @@ +// Code generated by mockery v2.24.0. DO NOT EDIT. + +package mocks + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + coretypes "github.com/tendermint/tendermint/rpc/core/types" +) + +// Node is an autogenerated mock type for the Node type +type Node struct { + mock.Mock +} + +type Node_Expecter struct { + mock *mock.Mock +} + +func (_m *Node) EXPECT() *Node_Expecter { + return &Node_Expecter{mock: &_m.Mock} +} + +// SyncInfo provides a mock function with given fields: ctx +func (_m *Node) SyncInfo(ctx context.Context) (*coretypes.SyncInfo, error) { + ret := _m.Called(ctx) + + var r0 *coretypes.SyncInfo + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) (*coretypes.SyncInfo, error)); ok { + return rf(ctx) + } + if rf, ok := ret.Get(0).(func(context.Context) *coretypes.SyncInfo); ok { + r0 = rf(ctx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*coretypes.SyncInfo) + } + } + + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Node_SyncInfo_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SyncInfo' +type Node_SyncInfo_Call struct { + *mock.Call +} + +// SyncInfo is a helper method to define mock.On call +// - ctx context.Context +func (_e *Node_Expecter) SyncInfo(ctx interface{}) *Node_SyncInfo_Call { + return &Node_SyncInfo_Call{Call: _e.mock.On("SyncInfo", ctx)} +} + +func (_c *Node_SyncInfo_Call) Run(run func(ctx context.Context)) *Node_SyncInfo_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context)) + }) + return _c +} + +func (_c *Node_SyncInfo_Call) Return(_a0 *coretypes.SyncInfo, _a1 error) *Node_SyncInfo_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Node_SyncInfo_Call) RunAndReturn(run func(context.Context) (*coretypes.SyncInfo, error)) *Node_SyncInfo_Call { + _c.Call.Return(run) + return _c +} + +type mockConstructorTestingTNewNode interface { + mock.TestingT + Cleanup(func()) +} + +// NewNode creates a new instance of Node. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewNode(t mockConstructorTestingTNewNode) *Node { + mock := &Node{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/go/node/client/v1beta1/mocks/query.go b/go/node/client/v1beta1/mocks/query.go new file mode 100644 index 00000000..d8c8a347 --- /dev/null +++ b/go/node/client/v1beta1/mocks/query.go @@ -0,0 +1,1169 @@ +// Code generated by mockery v2.24.0. DO NOT EDIT. + +package mocks + +import ( + context "context" + + certv1beta3 "github.com/akash-network/akash-api/go/node/cert/v1beta3" + + deploymentv1beta3 "github.com/akash-network/akash-api/go/node/deployment/v1beta3" + + grpc "google.golang.org/grpc" + + marketv1beta3 "github.com/akash-network/akash-api/go/node/market/v1beta3" + + mock "github.com/stretchr/testify/mock" + + providerv1beta3 "github.com/akash-network/akash-api/go/node/provider/v1beta3" + + v1beta3 "github.com/akash-network/akash-api/go/node/audit/v1beta3" +) + +// Query is an autogenerated mock type for the Query type +type Query struct { + mock.Mock +} + +type Query_Expecter struct { + mock *mock.Mock +} + +func (_m *Query) EXPECT() *Query_Expecter { + return &Query_Expecter{mock: &_m.Mock} +} + +// AllProvidersAttributes provides a mock function with given fields: ctx, in, opts +func (_m *Query) AllProvidersAttributes(ctx context.Context, in *v1beta3.QueryAllProvidersAttributesRequest, opts ...grpc.CallOption) (*v1beta3.QueryProvidersResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *v1beta3.QueryProvidersResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *v1beta3.QueryAllProvidersAttributesRequest, ...grpc.CallOption) (*v1beta3.QueryProvidersResponse, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *v1beta3.QueryAllProvidersAttributesRequest, ...grpc.CallOption) *v1beta3.QueryProvidersResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*v1beta3.QueryProvidersResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *v1beta3.QueryAllProvidersAttributesRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Query_AllProvidersAttributes_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AllProvidersAttributes' +type Query_AllProvidersAttributes_Call struct { + *mock.Call +} + +// AllProvidersAttributes is a helper method to define mock.On call +// - ctx context.Context +// - in *v1beta3.QueryAllProvidersAttributesRequest +// - opts ...grpc.CallOption +func (_e *Query_Expecter) AllProvidersAttributes(ctx interface{}, in interface{}, opts ...interface{}) *Query_AllProvidersAttributes_Call { + return &Query_AllProvidersAttributes_Call{Call: _e.mock.On("AllProvidersAttributes", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *Query_AllProvidersAttributes_Call) Run(run func(ctx context.Context, in *v1beta3.QueryAllProvidersAttributesRequest, opts ...grpc.CallOption)) *Query_AllProvidersAttributes_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*v1beta3.QueryAllProvidersAttributesRequest), variadicArgs...) + }) + return _c +} + +func (_c *Query_AllProvidersAttributes_Call) Return(_a0 *v1beta3.QueryProvidersResponse, _a1 error) *Query_AllProvidersAttributes_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Query_AllProvidersAttributes_Call) RunAndReturn(run func(context.Context, *v1beta3.QueryAllProvidersAttributesRequest, ...grpc.CallOption) (*v1beta3.QueryProvidersResponse, error)) *Query_AllProvidersAttributes_Call { + _c.Call.Return(run) + return _c +} + +// AuditorAttributes provides a mock function with given fields: ctx, in, opts +func (_m *Query) AuditorAttributes(ctx context.Context, in *v1beta3.QueryAuditorAttributesRequest, opts ...grpc.CallOption) (*v1beta3.QueryProvidersResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *v1beta3.QueryProvidersResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *v1beta3.QueryAuditorAttributesRequest, ...grpc.CallOption) (*v1beta3.QueryProvidersResponse, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *v1beta3.QueryAuditorAttributesRequest, ...grpc.CallOption) *v1beta3.QueryProvidersResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*v1beta3.QueryProvidersResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *v1beta3.QueryAuditorAttributesRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Query_AuditorAttributes_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AuditorAttributes' +type Query_AuditorAttributes_Call struct { + *mock.Call +} + +// AuditorAttributes is a helper method to define mock.On call +// - ctx context.Context +// - in *v1beta3.QueryAuditorAttributesRequest +// - opts ...grpc.CallOption +func (_e *Query_Expecter) AuditorAttributes(ctx interface{}, in interface{}, opts ...interface{}) *Query_AuditorAttributes_Call { + return &Query_AuditorAttributes_Call{Call: _e.mock.On("AuditorAttributes", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *Query_AuditorAttributes_Call) Run(run func(ctx context.Context, in *v1beta3.QueryAuditorAttributesRequest, opts ...grpc.CallOption)) *Query_AuditorAttributes_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*v1beta3.QueryAuditorAttributesRequest), variadicArgs...) + }) + return _c +} + +func (_c *Query_AuditorAttributes_Call) Return(_a0 *v1beta3.QueryProvidersResponse, _a1 error) *Query_AuditorAttributes_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Query_AuditorAttributes_Call) RunAndReturn(run func(context.Context, *v1beta3.QueryAuditorAttributesRequest, ...grpc.CallOption) (*v1beta3.QueryProvidersResponse, error)) *Query_AuditorAttributes_Call { + _c.Call.Return(run) + return _c +} + +// Bid provides a mock function with given fields: ctx, in, opts +func (_m *Query) Bid(ctx context.Context, in *marketv1beta3.QueryBidRequest, opts ...grpc.CallOption) (*marketv1beta3.QueryBidResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *marketv1beta3.QueryBidResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *marketv1beta3.QueryBidRequest, ...grpc.CallOption) (*marketv1beta3.QueryBidResponse, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *marketv1beta3.QueryBidRequest, ...grpc.CallOption) *marketv1beta3.QueryBidResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*marketv1beta3.QueryBidResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *marketv1beta3.QueryBidRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Query_Bid_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Bid' +type Query_Bid_Call struct { + *mock.Call +} + +// Bid is a helper method to define mock.On call +// - ctx context.Context +// - in *marketv1beta3.QueryBidRequest +// - opts ...grpc.CallOption +func (_e *Query_Expecter) Bid(ctx interface{}, in interface{}, opts ...interface{}) *Query_Bid_Call { + return &Query_Bid_Call{Call: _e.mock.On("Bid", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *Query_Bid_Call) Run(run func(ctx context.Context, in *marketv1beta3.QueryBidRequest, opts ...grpc.CallOption)) *Query_Bid_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*marketv1beta3.QueryBidRequest), variadicArgs...) + }) + return _c +} + +func (_c *Query_Bid_Call) Return(_a0 *marketv1beta3.QueryBidResponse, _a1 error) *Query_Bid_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Query_Bid_Call) RunAndReturn(run func(context.Context, *marketv1beta3.QueryBidRequest, ...grpc.CallOption) (*marketv1beta3.QueryBidResponse, error)) *Query_Bid_Call { + _c.Call.Return(run) + return _c +} + +// Bids provides a mock function with given fields: ctx, in, opts +func (_m *Query) Bids(ctx context.Context, in *marketv1beta3.QueryBidsRequest, opts ...grpc.CallOption) (*marketv1beta3.QueryBidsResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *marketv1beta3.QueryBidsResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *marketv1beta3.QueryBidsRequest, ...grpc.CallOption) (*marketv1beta3.QueryBidsResponse, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *marketv1beta3.QueryBidsRequest, ...grpc.CallOption) *marketv1beta3.QueryBidsResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*marketv1beta3.QueryBidsResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *marketv1beta3.QueryBidsRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Query_Bids_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Bids' +type Query_Bids_Call struct { + *mock.Call +} + +// Bids is a helper method to define mock.On call +// - ctx context.Context +// - in *marketv1beta3.QueryBidsRequest +// - opts ...grpc.CallOption +func (_e *Query_Expecter) Bids(ctx interface{}, in interface{}, opts ...interface{}) *Query_Bids_Call { + return &Query_Bids_Call{Call: _e.mock.On("Bids", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *Query_Bids_Call) Run(run func(ctx context.Context, in *marketv1beta3.QueryBidsRequest, opts ...grpc.CallOption)) *Query_Bids_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*marketv1beta3.QueryBidsRequest), variadicArgs...) + }) + return _c +} + +func (_c *Query_Bids_Call) Return(_a0 *marketv1beta3.QueryBidsResponse, _a1 error) *Query_Bids_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Query_Bids_Call) RunAndReturn(run func(context.Context, *marketv1beta3.QueryBidsRequest, ...grpc.CallOption) (*marketv1beta3.QueryBidsResponse, error)) *Query_Bids_Call { + _c.Call.Return(run) + return _c +} + +// Certificates provides a mock function with given fields: ctx, in, opts +func (_m *Query) Certificates(ctx context.Context, in *certv1beta3.QueryCertificatesRequest, opts ...grpc.CallOption) (*certv1beta3.QueryCertificatesResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *certv1beta3.QueryCertificatesResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *certv1beta3.QueryCertificatesRequest, ...grpc.CallOption) (*certv1beta3.QueryCertificatesResponse, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *certv1beta3.QueryCertificatesRequest, ...grpc.CallOption) *certv1beta3.QueryCertificatesResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*certv1beta3.QueryCertificatesResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *certv1beta3.QueryCertificatesRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Query_Certificates_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Certificates' +type Query_Certificates_Call struct { + *mock.Call +} + +// Certificates is a helper method to define mock.On call +// - ctx context.Context +// - in *certv1beta3.QueryCertificatesRequest +// - opts ...grpc.CallOption +func (_e *Query_Expecter) Certificates(ctx interface{}, in interface{}, opts ...interface{}) *Query_Certificates_Call { + return &Query_Certificates_Call{Call: _e.mock.On("Certificates", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *Query_Certificates_Call) Run(run func(ctx context.Context, in *certv1beta3.QueryCertificatesRequest, opts ...grpc.CallOption)) *Query_Certificates_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*certv1beta3.QueryCertificatesRequest), variadicArgs...) + }) + return _c +} + +func (_c *Query_Certificates_Call) Return(_a0 *certv1beta3.QueryCertificatesResponse, _a1 error) *Query_Certificates_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Query_Certificates_Call) RunAndReturn(run func(context.Context, *certv1beta3.QueryCertificatesRequest, ...grpc.CallOption) (*certv1beta3.QueryCertificatesResponse, error)) *Query_Certificates_Call { + _c.Call.Return(run) + return _c +} + +// Deployment provides a mock function with given fields: ctx, in, opts +func (_m *Query) Deployment(ctx context.Context, in *deploymentv1beta3.QueryDeploymentRequest, opts ...grpc.CallOption) (*deploymentv1beta3.QueryDeploymentResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *deploymentv1beta3.QueryDeploymentResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *deploymentv1beta3.QueryDeploymentRequest, ...grpc.CallOption) (*deploymentv1beta3.QueryDeploymentResponse, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *deploymentv1beta3.QueryDeploymentRequest, ...grpc.CallOption) *deploymentv1beta3.QueryDeploymentResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*deploymentv1beta3.QueryDeploymentResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *deploymentv1beta3.QueryDeploymentRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Query_Deployment_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Deployment' +type Query_Deployment_Call struct { + *mock.Call +} + +// Deployment is a helper method to define mock.On call +// - ctx context.Context +// - in *deploymentv1beta3.QueryDeploymentRequest +// - opts ...grpc.CallOption +func (_e *Query_Expecter) Deployment(ctx interface{}, in interface{}, opts ...interface{}) *Query_Deployment_Call { + return &Query_Deployment_Call{Call: _e.mock.On("Deployment", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *Query_Deployment_Call) Run(run func(ctx context.Context, in *deploymentv1beta3.QueryDeploymentRequest, opts ...grpc.CallOption)) *Query_Deployment_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*deploymentv1beta3.QueryDeploymentRequest), variadicArgs...) + }) + return _c +} + +func (_c *Query_Deployment_Call) Return(_a0 *deploymentv1beta3.QueryDeploymentResponse, _a1 error) *Query_Deployment_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Query_Deployment_Call) RunAndReturn(run func(context.Context, *deploymentv1beta3.QueryDeploymentRequest, ...grpc.CallOption) (*deploymentv1beta3.QueryDeploymentResponse, error)) *Query_Deployment_Call { + _c.Call.Return(run) + return _c +} + +// Deployments provides a mock function with given fields: ctx, in, opts +func (_m *Query) Deployments(ctx context.Context, in *deploymentv1beta3.QueryDeploymentsRequest, opts ...grpc.CallOption) (*deploymentv1beta3.QueryDeploymentsResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *deploymentv1beta3.QueryDeploymentsResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *deploymentv1beta3.QueryDeploymentsRequest, ...grpc.CallOption) (*deploymentv1beta3.QueryDeploymentsResponse, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *deploymentv1beta3.QueryDeploymentsRequest, ...grpc.CallOption) *deploymentv1beta3.QueryDeploymentsResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*deploymentv1beta3.QueryDeploymentsResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *deploymentv1beta3.QueryDeploymentsRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Query_Deployments_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Deployments' +type Query_Deployments_Call struct { + *mock.Call +} + +// Deployments is a helper method to define mock.On call +// - ctx context.Context +// - in *deploymentv1beta3.QueryDeploymentsRequest +// - opts ...grpc.CallOption +func (_e *Query_Expecter) Deployments(ctx interface{}, in interface{}, opts ...interface{}) *Query_Deployments_Call { + return &Query_Deployments_Call{Call: _e.mock.On("Deployments", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *Query_Deployments_Call) Run(run func(ctx context.Context, in *deploymentv1beta3.QueryDeploymentsRequest, opts ...grpc.CallOption)) *Query_Deployments_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*deploymentv1beta3.QueryDeploymentsRequest), variadicArgs...) + }) + return _c +} + +func (_c *Query_Deployments_Call) Return(_a0 *deploymentv1beta3.QueryDeploymentsResponse, _a1 error) *Query_Deployments_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Query_Deployments_Call) RunAndReturn(run func(context.Context, *deploymentv1beta3.QueryDeploymentsRequest, ...grpc.CallOption) (*deploymentv1beta3.QueryDeploymentsResponse, error)) *Query_Deployments_Call { + _c.Call.Return(run) + return _c +} + +// Group provides a mock function with given fields: ctx, in, opts +func (_m *Query) Group(ctx context.Context, in *deploymentv1beta3.QueryGroupRequest, opts ...grpc.CallOption) (*deploymentv1beta3.QueryGroupResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *deploymentv1beta3.QueryGroupResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *deploymentv1beta3.QueryGroupRequest, ...grpc.CallOption) (*deploymentv1beta3.QueryGroupResponse, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *deploymentv1beta3.QueryGroupRequest, ...grpc.CallOption) *deploymentv1beta3.QueryGroupResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*deploymentv1beta3.QueryGroupResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *deploymentv1beta3.QueryGroupRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Query_Group_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Group' +type Query_Group_Call struct { + *mock.Call +} + +// Group is a helper method to define mock.On call +// - ctx context.Context +// - in *deploymentv1beta3.QueryGroupRequest +// - opts ...grpc.CallOption +func (_e *Query_Expecter) Group(ctx interface{}, in interface{}, opts ...interface{}) *Query_Group_Call { + return &Query_Group_Call{Call: _e.mock.On("Group", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *Query_Group_Call) Run(run func(ctx context.Context, in *deploymentv1beta3.QueryGroupRequest, opts ...grpc.CallOption)) *Query_Group_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*deploymentv1beta3.QueryGroupRequest), variadicArgs...) + }) + return _c +} + +func (_c *Query_Group_Call) Return(_a0 *deploymentv1beta3.QueryGroupResponse, _a1 error) *Query_Group_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Query_Group_Call) RunAndReturn(run func(context.Context, *deploymentv1beta3.QueryGroupRequest, ...grpc.CallOption) (*deploymentv1beta3.QueryGroupResponse, error)) *Query_Group_Call { + _c.Call.Return(run) + return _c +} + +// Lease provides a mock function with given fields: ctx, in, opts +func (_m *Query) Lease(ctx context.Context, in *marketv1beta3.QueryLeaseRequest, opts ...grpc.CallOption) (*marketv1beta3.QueryLeaseResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *marketv1beta3.QueryLeaseResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *marketv1beta3.QueryLeaseRequest, ...grpc.CallOption) (*marketv1beta3.QueryLeaseResponse, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *marketv1beta3.QueryLeaseRequest, ...grpc.CallOption) *marketv1beta3.QueryLeaseResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*marketv1beta3.QueryLeaseResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *marketv1beta3.QueryLeaseRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Query_Lease_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Lease' +type Query_Lease_Call struct { + *mock.Call +} + +// Lease is a helper method to define mock.On call +// - ctx context.Context +// - in *marketv1beta3.QueryLeaseRequest +// - opts ...grpc.CallOption +func (_e *Query_Expecter) Lease(ctx interface{}, in interface{}, opts ...interface{}) *Query_Lease_Call { + return &Query_Lease_Call{Call: _e.mock.On("Lease", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *Query_Lease_Call) Run(run func(ctx context.Context, in *marketv1beta3.QueryLeaseRequest, opts ...grpc.CallOption)) *Query_Lease_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*marketv1beta3.QueryLeaseRequest), variadicArgs...) + }) + return _c +} + +func (_c *Query_Lease_Call) Return(_a0 *marketv1beta3.QueryLeaseResponse, _a1 error) *Query_Lease_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Query_Lease_Call) RunAndReturn(run func(context.Context, *marketv1beta3.QueryLeaseRequest, ...grpc.CallOption) (*marketv1beta3.QueryLeaseResponse, error)) *Query_Lease_Call { + _c.Call.Return(run) + return _c +} + +// Leases provides a mock function with given fields: ctx, in, opts +func (_m *Query) Leases(ctx context.Context, in *marketv1beta3.QueryLeasesRequest, opts ...grpc.CallOption) (*marketv1beta3.QueryLeasesResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *marketv1beta3.QueryLeasesResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *marketv1beta3.QueryLeasesRequest, ...grpc.CallOption) (*marketv1beta3.QueryLeasesResponse, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *marketv1beta3.QueryLeasesRequest, ...grpc.CallOption) *marketv1beta3.QueryLeasesResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*marketv1beta3.QueryLeasesResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *marketv1beta3.QueryLeasesRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Query_Leases_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Leases' +type Query_Leases_Call struct { + *mock.Call +} + +// Leases is a helper method to define mock.On call +// - ctx context.Context +// - in *marketv1beta3.QueryLeasesRequest +// - opts ...grpc.CallOption +func (_e *Query_Expecter) Leases(ctx interface{}, in interface{}, opts ...interface{}) *Query_Leases_Call { + return &Query_Leases_Call{Call: _e.mock.On("Leases", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *Query_Leases_Call) Run(run func(ctx context.Context, in *marketv1beta3.QueryLeasesRequest, opts ...grpc.CallOption)) *Query_Leases_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*marketv1beta3.QueryLeasesRequest), variadicArgs...) + }) + return _c +} + +func (_c *Query_Leases_Call) Return(_a0 *marketv1beta3.QueryLeasesResponse, _a1 error) *Query_Leases_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Query_Leases_Call) RunAndReturn(run func(context.Context, *marketv1beta3.QueryLeasesRequest, ...grpc.CallOption) (*marketv1beta3.QueryLeasesResponse, error)) *Query_Leases_Call { + _c.Call.Return(run) + return _c +} + +// Order provides a mock function with given fields: ctx, in, opts +func (_m *Query) Order(ctx context.Context, in *marketv1beta3.QueryOrderRequest, opts ...grpc.CallOption) (*marketv1beta3.QueryOrderResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *marketv1beta3.QueryOrderResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *marketv1beta3.QueryOrderRequest, ...grpc.CallOption) (*marketv1beta3.QueryOrderResponse, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *marketv1beta3.QueryOrderRequest, ...grpc.CallOption) *marketv1beta3.QueryOrderResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*marketv1beta3.QueryOrderResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *marketv1beta3.QueryOrderRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Query_Order_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Order' +type Query_Order_Call struct { + *mock.Call +} + +// Order is a helper method to define mock.On call +// - ctx context.Context +// - in *marketv1beta3.QueryOrderRequest +// - opts ...grpc.CallOption +func (_e *Query_Expecter) Order(ctx interface{}, in interface{}, opts ...interface{}) *Query_Order_Call { + return &Query_Order_Call{Call: _e.mock.On("Order", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *Query_Order_Call) Run(run func(ctx context.Context, in *marketv1beta3.QueryOrderRequest, opts ...grpc.CallOption)) *Query_Order_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*marketv1beta3.QueryOrderRequest), variadicArgs...) + }) + return _c +} + +func (_c *Query_Order_Call) Return(_a0 *marketv1beta3.QueryOrderResponse, _a1 error) *Query_Order_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Query_Order_Call) RunAndReturn(run func(context.Context, *marketv1beta3.QueryOrderRequest, ...grpc.CallOption) (*marketv1beta3.QueryOrderResponse, error)) *Query_Order_Call { + _c.Call.Return(run) + return _c +} + +// Orders provides a mock function with given fields: ctx, in, opts +func (_m *Query) Orders(ctx context.Context, in *marketv1beta3.QueryOrdersRequest, opts ...grpc.CallOption) (*marketv1beta3.QueryOrdersResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *marketv1beta3.QueryOrdersResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *marketv1beta3.QueryOrdersRequest, ...grpc.CallOption) (*marketv1beta3.QueryOrdersResponse, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *marketv1beta3.QueryOrdersRequest, ...grpc.CallOption) *marketv1beta3.QueryOrdersResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*marketv1beta3.QueryOrdersResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *marketv1beta3.QueryOrdersRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Query_Orders_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Orders' +type Query_Orders_Call struct { + *mock.Call +} + +// Orders is a helper method to define mock.On call +// - ctx context.Context +// - in *marketv1beta3.QueryOrdersRequest +// - opts ...grpc.CallOption +func (_e *Query_Expecter) Orders(ctx interface{}, in interface{}, opts ...interface{}) *Query_Orders_Call { + return &Query_Orders_Call{Call: _e.mock.On("Orders", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *Query_Orders_Call) Run(run func(ctx context.Context, in *marketv1beta3.QueryOrdersRequest, opts ...grpc.CallOption)) *Query_Orders_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*marketv1beta3.QueryOrdersRequest), variadicArgs...) + }) + return _c +} + +func (_c *Query_Orders_Call) Return(_a0 *marketv1beta3.QueryOrdersResponse, _a1 error) *Query_Orders_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Query_Orders_Call) RunAndReturn(run func(context.Context, *marketv1beta3.QueryOrdersRequest, ...grpc.CallOption) (*marketv1beta3.QueryOrdersResponse, error)) *Query_Orders_Call { + _c.Call.Return(run) + return _c +} + +// Provider provides a mock function with given fields: ctx, in, opts +func (_m *Query) Provider(ctx context.Context, in *providerv1beta3.QueryProviderRequest, opts ...grpc.CallOption) (*providerv1beta3.QueryProviderResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *providerv1beta3.QueryProviderResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *providerv1beta3.QueryProviderRequest, ...grpc.CallOption) (*providerv1beta3.QueryProviderResponse, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *providerv1beta3.QueryProviderRequest, ...grpc.CallOption) *providerv1beta3.QueryProviderResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*providerv1beta3.QueryProviderResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *providerv1beta3.QueryProviderRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Query_Provider_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Provider' +type Query_Provider_Call struct { + *mock.Call +} + +// Provider is a helper method to define mock.On call +// - ctx context.Context +// - in *providerv1beta3.QueryProviderRequest +// - opts ...grpc.CallOption +func (_e *Query_Expecter) Provider(ctx interface{}, in interface{}, opts ...interface{}) *Query_Provider_Call { + return &Query_Provider_Call{Call: _e.mock.On("Provider", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *Query_Provider_Call) Run(run func(ctx context.Context, in *providerv1beta3.QueryProviderRequest, opts ...grpc.CallOption)) *Query_Provider_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*providerv1beta3.QueryProviderRequest), variadicArgs...) + }) + return _c +} + +func (_c *Query_Provider_Call) Return(_a0 *providerv1beta3.QueryProviderResponse, _a1 error) *Query_Provider_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Query_Provider_Call) RunAndReturn(run func(context.Context, *providerv1beta3.QueryProviderRequest, ...grpc.CallOption) (*providerv1beta3.QueryProviderResponse, error)) *Query_Provider_Call { + _c.Call.Return(run) + return _c +} + +// ProviderAttributes provides a mock function with given fields: ctx, in, opts +func (_m *Query) ProviderAttributes(ctx context.Context, in *v1beta3.QueryProviderAttributesRequest, opts ...grpc.CallOption) (*v1beta3.QueryProvidersResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *v1beta3.QueryProvidersResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *v1beta3.QueryProviderAttributesRequest, ...grpc.CallOption) (*v1beta3.QueryProvidersResponse, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *v1beta3.QueryProviderAttributesRequest, ...grpc.CallOption) *v1beta3.QueryProvidersResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*v1beta3.QueryProvidersResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *v1beta3.QueryProviderAttributesRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Query_ProviderAttributes_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ProviderAttributes' +type Query_ProviderAttributes_Call struct { + *mock.Call +} + +// ProviderAttributes is a helper method to define mock.On call +// - ctx context.Context +// - in *v1beta3.QueryProviderAttributesRequest +// - opts ...grpc.CallOption +func (_e *Query_Expecter) ProviderAttributes(ctx interface{}, in interface{}, opts ...interface{}) *Query_ProviderAttributes_Call { + return &Query_ProviderAttributes_Call{Call: _e.mock.On("ProviderAttributes", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *Query_ProviderAttributes_Call) Run(run func(ctx context.Context, in *v1beta3.QueryProviderAttributesRequest, opts ...grpc.CallOption)) *Query_ProviderAttributes_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*v1beta3.QueryProviderAttributesRequest), variadicArgs...) + }) + return _c +} + +func (_c *Query_ProviderAttributes_Call) Return(_a0 *v1beta3.QueryProvidersResponse, _a1 error) *Query_ProviderAttributes_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Query_ProviderAttributes_Call) RunAndReturn(run func(context.Context, *v1beta3.QueryProviderAttributesRequest, ...grpc.CallOption) (*v1beta3.QueryProvidersResponse, error)) *Query_ProviderAttributes_Call { + _c.Call.Return(run) + return _c +} + +// ProviderAuditorAttributes provides a mock function with given fields: ctx, in, opts +func (_m *Query) ProviderAuditorAttributes(ctx context.Context, in *v1beta3.QueryProviderAuditorRequest, opts ...grpc.CallOption) (*v1beta3.QueryProvidersResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *v1beta3.QueryProvidersResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *v1beta3.QueryProviderAuditorRequest, ...grpc.CallOption) (*v1beta3.QueryProvidersResponse, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *v1beta3.QueryProviderAuditorRequest, ...grpc.CallOption) *v1beta3.QueryProvidersResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*v1beta3.QueryProvidersResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *v1beta3.QueryProviderAuditorRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Query_ProviderAuditorAttributes_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ProviderAuditorAttributes' +type Query_ProviderAuditorAttributes_Call struct { + *mock.Call +} + +// ProviderAuditorAttributes is a helper method to define mock.On call +// - ctx context.Context +// - in *v1beta3.QueryProviderAuditorRequest +// - opts ...grpc.CallOption +func (_e *Query_Expecter) ProviderAuditorAttributes(ctx interface{}, in interface{}, opts ...interface{}) *Query_ProviderAuditorAttributes_Call { + return &Query_ProviderAuditorAttributes_Call{Call: _e.mock.On("ProviderAuditorAttributes", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *Query_ProviderAuditorAttributes_Call) Run(run func(ctx context.Context, in *v1beta3.QueryProviderAuditorRequest, opts ...grpc.CallOption)) *Query_ProviderAuditorAttributes_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*v1beta3.QueryProviderAuditorRequest), variadicArgs...) + }) + return _c +} + +func (_c *Query_ProviderAuditorAttributes_Call) Return(_a0 *v1beta3.QueryProvidersResponse, _a1 error) *Query_ProviderAuditorAttributes_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Query_ProviderAuditorAttributes_Call) RunAndReturn(run func(context.Context, *v1beta3.QueryProviderAuditorRequest, ...grpc.CallOption) (*v1beta3.QueryProvidersResponse, error)) *Query_ProviderAuditorAttributes_Call { + _c.Call.Return(run) + return _c +} + +// Providers provides a mock function with given fields: ctx, in, opts +func (_m *Query) Providers(ctx context.Context, in *providerv1beta3.QueryProvidersRequest, opts ...grpc.CallOption) (*providerv1beta3.QueryProvidersResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *providerv1beta3.QueryProvidersResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *providerv1beta3.QueryProvidersRequest, ...grpc.CallOption) (*providerv1beta3.QueryProvidersResponse, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *providerv1beta3.QueryProvidersRequest, ...grpc.CallOption) *providerv1beta3.QueryProvidersResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*providerv1beta3.QueryProvidersResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *providerv1beta3.QueryProvidersRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Query_Providers_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Providers' +type Query_Providers_Call struct { + *mock.Call +} + +// Providers is a helper method to define mock.On call +// - ctx context.Context +// - in *providerv1beta3.QueryProvidersRequest +// - opts ...grpc.CallOption +func (_e *Query_Expecter) Providers(ctx interface{}, in interface{}, opts ...interface{}) *Query_Providers_Call { + return &Query_Providers_Call{Call: _e.mock.On("Providers", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *Query_Providers_Call) Run(run func(ctx context.Context, in *providerv1beta3.QueryProvidersRequest, opts ...grpc.CallOption)) *Query_Providers_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*providerv1beta3.QueryProvidersRequest), variadicArgs...) + }) + return _c +} + +func (_c *Query_Providers_Call) Return(_a0 *providerv1beta3.QueryProvidersResponse, _a1 error) *Query_Providers_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Query_Providers_Call) RunAndReturn(run func(context.Context, *providerv1beta3.QueryProvidersRequest, ...grpc.CallOption) (*providerv1beta3.QueryProvidersResponse, error)) *Query_Providers_Call { + _c.Call.Return(run) + return _c +} + +type mockConstructorTestingTNewQuery interface { + mock.TestingT + Cleanup(func()) +} + +// NewQuery creates a new instance of Query. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewQuery(t mockConstructorTestingTNewQuery) *Query { + mock := &Query{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/go/node/client/v1beta1/mocks/tx.go b/go/node/client/v1beta1/mocks/tx.go new file mode 100644 index 00000000..cc28657d --- /dev/null +++ b/go/node/client/v1beta1/mocks/tx.go @@ -0,0 +1,95 @@ +// Code generated by mockery v2.24.0. DO NOT EDIT. + +package mocks + +import ( + context "context" + + types "github.com/cosmos/cosmos-sdk/types" + mock "github.com/stretchr/testify/mock" +) + +// Tx is an autogenerated mock type for the Tx type +type Tx struct { + mock.Mock +} + +type Tx_Expecter struct { + mock *mock.Mock +} + +func (_m *Tx) EXPECT() *Tx_Expecter { + return &Tx_Expecter{mock: &_m.Mock} +} + +// Broadcast provides a mock function with given fields: _a0, _a1 +func (_m *Tx) Broadcast(_a0 context.Context, _a1 ...types.Msg) error { + _va := make([]interface{}, len(_a1)) + for _i := range _a1 { + _va[_i] = _a1[_i] + } + var _ca []interface{} + _ca = append(_ca, _a0) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, ...types.Msg) error); ok { + r0 = rf(_a0, _a1...) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Tx_Broadcast_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Broadcast' +type Tx_Broadcast_Call struct { + *mock.Call +} + +// Broadcast is a helper method to define mock.On call +// - _a0 context.Context +// - _a1 ...types.Msg +func (_e *Tx_Expecter) Broadcast(_a0 interface{}, _a1 ...interface{}) *Tx_Broadcast_Call { + return &Tx_Broadcast_Call{Call: _e.mock.On("Broadcast", + append([]interface{}{_a0}, _a1...)...)} +} + +func (_c *Tx_Broadcast_Call) Run(run func(_a0 context.Context, _a1 ...types.Msg)) *Tx_Broadcast_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]types.Msg, len(args)-1) + for i, a := range args[1:] { + if a != nil { + variadicArgs[i] = a.(types.Msg) + } + } + run(args[0].(context.Context), variadicArgs...) + }) + return _c +} + +func (_c *Tx_Broadcast_Call) Return(_a0 error) *Tx_Broadcast_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Tx_Broadcast_Call) RunAndReturn(run func(context.Context, ...types.Msg) error) *Tx_Broadcast_Call { + _c.Call.Return(run) + return _c +} + +type mockConstructorTestingTNewTx interface { + mock.TestingT + Cleanup(func()) +} + +// NewTx creates a new instance of Tx. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewTx(t mockConstructorTestingTNewTx) *Tx { + mock := &Tx{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/go/node/client/v1beta2/client.go b/go/node/client/v1beta2/client.go new file mode 100644 index 00000000..fa3b3d1a --- /dev/null +++ b/go/node/client/v1beta2/client.go @@ -0,0 +1,80 @@ +package v1beta2 + +import ( + "context" + + "github.com/spf13/pflag" + + tmrpc "github.com/tendermint/tendermint/rpc/core/types" + + sdkclient "github.com/cosmos/cosmos-sdk/client" + sdk "github.com/cosmos/cosmos-sdk/types" + + atypes "github.com/akash-network/akash-api/go/node/audit/v1beta3" + ctypes "github.com/akash-network/akash-api/go/node/cert/v1beta3" + dtypes "github.com/akash-network/akash-api/go/node/deployment/v1beta3" + mtypes "github.com/akash-network/akash-api/go/node/market/v1beta4" + ptypes "github.com/akash-network/akash-api/go/node/provider/v1beta3" +) + +//go:generate mockery --name Query --output ./mocks +type Query interface { + dtypes.QueryClient + mtypes.QueryClient + ptypes.QueryClient + atypes.QueryClient + ctypes.QueryClient + ClientContext() sdkclient.Context +} + +//go:generate mockery --name Tx --output ./mocks +type Tx interface { + Broadcast(context.Context, ...sdk.Msg) error +} + +//go:generate mockery --name Node --output ./mocks +type Node interface { + SyncInfo(ctx context.Context) (*tmrpc.SyncInfo, error) +} + +//go:generate mockery --name Client --output ./mocks +type Client interface { + Query() Query + Tx() Tx + Node() Node +} + +type client struct { + qclient *QueryClient + tx Tx + node *node +} + +var _ Client = (*client)(nil) + +func NewClient(ctx context.Context, cctx sdkclient.Context, flags *pflag.FlagSet) (Client, error) { + cl := &client{ + qclient: newQueryClient(cctx), + node: newNode(cctx), + } + + var err error + cl.tx, err = newSerialTx(ctx, cctx, flags, BroadcastDefaultTimeout) + if err != nil { + return nil, err + } + + return cl, nil +} + +func (cl *client) Query() Query { + return cl.qclient +} + +func (cl *client) Tx() Tx { + return cl.tx +} + +func (cl *client) Node() Node { + return cl.node +} diff --git a/go/node/client/v1beta2/errors.go b/go/node/client/v1beta2/errors.go new file mode 100644 index 00000000..a5af3fcf --- /dev/null +++ b/go/node/client/v1beta2/errors.go @@ -0,0 +1,11 @@ +package v1beta2 + +import ( + "errors" +) + +var ( + // ErrClientNotFound is a new error with message "Client not found" + ErrClientNotFound = errors.New("client not found") + ErrNodeNotSynced = errors.New("rpc node is not catching up") +) diff --git a/go/node/client/v1beta2/mocks/client.go b/go/node/client/v1beta2/mocks/client.go new file mode 100644 index 00000000..10b6a7f8 --- /dev/null +++ b/go/node/client/v1beta2/mocks/client.go @@ -0,0 +1,165 @@ +// Code generated by mockery v2.24.0. DO NOT EDIT. + +package mocks + +import ( + v1beta2 "github.com/akash-network/akash-api/go/node/client/v1beta2" + mock "github.com/stretchr/testify/mock" +) + +// Client is an autogenerated mock type for the Client type +type Client struct { + mock.Mock +} + +type Client_Expecter struct { + mock *mock.Mock +} + +func (_m *Client) EXPECT() *Client_Expecter { + return &Client_Expecter{mock: &_m.Mock} +} + +// Node provides a mock function with given fields: +func (_m *Client) Node() v1beta2.Node { + ret := _m.Called() + + var r0 v1beta2.Node + if rf, ok := ret.Get(0).(func() v1beta2.Node); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(v1beta2.Node) + } + } + + return r0 +} + +// Client_Node_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Node' +type Client_Node_Call struct { + *mock.Call +} + +// Node is a helper method to define mock.On call +func (_e *Client_Expecter) Node() *Client_Node_Call { + return &Client_Node_Call{Call: _e.mock.On("Node")} +} + +func (_c *Client_Node_Call) Run(run func()) *Client_Node_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *Client_Node_Call) Return(_a0 v1beta2.Node) *Client_Node_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Client_Node_Call) RunAndReturn(run func() v1beta2.Node) *Client_Node_Call { + _c.Call.Return(run) + return _c +} + +// Query provides a mock function with given fields: +func (_m *Client) Query() v1beta2.Query { + ret := _m.Called() + + var r0 v1beta2.Query + if rf, ok := ret.Get(0).(func() v1beta2.Query); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(v1beta2.Query) + } + } + + return r0 +} + +// Client_Query_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Query' +type Client_Query_Call struct { + *mock.Call +} + +// Query is a helper method to define mock.On call +func (_e *Client_Expecter) Query() *Client_Query_Call { + return &Client_Query_Call{Call: _e.mock.On("Query")} +} + +func (_c *Client_Query_Call) Run(run func()) *Client_Query_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *Client_Query_Call) Return(_a0 v1beta2.Query) *Client_Query_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Client_Query_Call) RunAndReturn(run func() v1beta2.Query) *Client_Query_Call { + _c.Call.Return(run) + return _c +} + +// Tx provides a mock function with given fields: +func (_m *Client) Tx() v1beta2.Tx { + ret := _m.Called() + + var r0 v1beta2.Tx + if rf, ok := ret.Get(0).(func() v1beta2.Tx); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(v1beta2.Tx) + } + } + + return r0 +} + +// Client_Tx_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Tx' +type Client_Tx_Call struct { + *mock.Call +} + +// Tx is a helper method to define mock.On call +func (_e *Client_Expecter) Tx() *Client_Tx_Call { + return &Client_Tx_Call{Call: _e.mock.On("Tx")} +} + +func (_c *Client_Tx_Call) Run(run func()) *Client_Tx_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *Client_Tx_Call) Return(_a0 v1beta2.Tx) *Client_Tx_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Client_Tx_Call) RunAndReturn(run func() v1beta2.Tx) *Client_Tx_Call { + _c.Call.Return(run) + return _c +} + +type mockConstructorTestingTNewClient interface { + mock.TestingT + Cleanup(func()) +} + +// NewClient creates a new instance of Client. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewClient(t mockConstructorTestingTNewClient) *Client { + mock := &Client{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/go/node/client/v1beta2/mocks/node.go b/go/node/client/v1beta2/mocks/node.go new file mode 100644 index 00000000..222e0faa --- /dev/null +++ b/go/node/client/v1beta2/mocks/node.go @@ -0,0 +1,92 @@ +// Code generated by mockery v2.24.0. DO NOT EDIT. + +package mocks + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + coretypes "github.com/tendermint/tendermint/rpc/core/types" +) + +// Node is an autogenerated mock type for the Node type +type Node struct { + mock.Mock +} + +type Node_Expecter struct { + mock *mock.Mock +} + +func (_m *Node) EXPECT() *Node_Expecter { + return &Node_Expecter{mock: &_m.Mock} +} + +// SyncInfo provides a mock function with given fields: ctx +func (_m *Node) SyncInfo(ctx context.Context) (*coretypes.SyncInfo, error) { + ret := _m.Called(ctx) + + var r0 *coretypes.SyncInfo + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) (*coretypes.SyncInfo, error)); ok { + return rf(ctx) + } + if rf, ok := ret.Get(0).(func(context.Context) *coretypes.SyncInfo); ok { + r0 = rf(ctx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*coretypes.SyncInfo) + } + } + + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Node_SyncInfo_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SyncInfo' +type Node_SyncInfo_Call struct { + *mock.Call +} + +// SyncInfo is a helper method to define mock.On call +// - ctx context.Context +func (_e *Node_Expecter) SyncInfo(ctx interface{}) *Node_SyncInfo_Call { + return &Node_SyncInfo_Call{Call: _e.mock.On("SyncInfo", ctx)} +} + +func (_c *Node_SyncInfo_Call) Run(run func(ctx context.Context)) *Node_SyncInfo_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context)) + }) + return _c +} + +func (_c *Node_SyncInfo_Call) Return(_a0 *coretypes.SyncInfo, _a1 error) *Node_SyncInfo_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Node_SyncInfo_Call) RunAndReturn(run func(context.Context) (*coretypes.SyncInfo, error)) *Node_SyncInfo_Call { + _c.Call.Return(run) + return _c +} + +type mockConstructorTestingTNewNode interface { + mock.TestingT + Cleanup(func()) +} + +// NewNode creates a new instance of Node. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewNode(t mockConstructorTestingTNewNode) *Node { + mock := &Node{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/go/node/client/v1beta2/mocks/query.go b/go/node/client/v1beta2/mocks/query.go new file mode 100644 index 00000000..835e9b67 --- /dev/null +++ b/go/node/client/v1beta2/mocks/query.go @@ -0,0 +1,1169 @@ +// Code generated by mockery v2.24.0. DO NOT EDIT. + +package mocks + +import ( + context "context" + + certv1beta3 "github.com/akash-network/akash-api/go/node/cert/v1beta3" + + deploymentv1beta3 "github.com/akash-network/akash-api/go/node/deployment/v1beta3" + + grpc "google.golang.org/grpc" + + mock "github.com/stretchr/testify/mock" + + providerv1beta3 "github.com/akash-network/akash-api/go/node/provider/v1beta3" + + v1beta3 "github.com/akash-network/akash-api/go/node/audit/v1beta3" + + v1beta4 "github.com/akash-network/akash-api/go/node/market/v1beta4" +) + +// Query is an autogenerated mock type for the Query type +type Query struct { + mock.Mock +} + +type Query_Expecter struct { + mock *mock.Mock +} + +func (_m *Query) EXPECT() *Query_Expecter { + return &Query_Expecter{mock: &_m.Mock} +} + +// AllProvidersAttributes provides a mock function with given fields: ctx, in, opts +func (_m *Query) AllProvidersAttributes(ctx context.Context, in *v1beta3.QueryAllProvidersAttributesRequest, opts ...grpc.CallOption) (*v1beta3.QueryProvidersResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *v1beta3.QueryProvidersResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *v1beta3.QueryAllProvidersAttributesRequest, ...grpc.CallOption) (*v1beta3.QueryProvidersResponse, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *v1beta3.QueryAllProvidersAttributesRequest, ...grpc.CallOption) *v1beta3.QueryProvidersResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*v1beta3.QueryProvidersResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *v1beta3.QueryAllProvidersAttributesRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Query_AllProvidersAttributes_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AllProvidersAttributes' +type Query_AllProvidersAttributes_Call struct { + *mock.Call +} + +// AllProvidersAttributes is a helper method to define mock.On call +// - ctx context.Context +// - in *v1beta3.QueryAllProvidersAttributesRequest +// - opts ...grpc.CallOption +func (_e *Query_Expecter) AllProvidersAttributes(ctx interface{}, in interface{}, opts ...interface{}) *Query_AllProvidersAttributes_Call { + return &Query_AllProvidersAttributes_Call{Call: _e.mock.On("AllProvidersAttributes", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *Query_AllProvidersAttributes_Call) Run(run func(ctx context.Context, in *v1beta3.QueryAllProvidersAttributesRequest, opts ...grpc.CallOption)) *Query_AllProvidersAttributes_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*v1beta3.QueryAllProvidersAttributesRequest), variadicArgs...) + }) + return _c +} + +func (_c *Query_AllProvidersAttributes_Call) Return(_a0 *v1beta3.QueryProvidersResponse, _a1 error) *Query_AllProvidersAttributes_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Query_AllProvidersAttributes_Call) RunAndReturn(run func(context.Context, *v1beta3.QueryAllProvidersAttributesRequest, ...grpc.CallOption) (*v1beta3.QueryProvidersResponse, error)) *Query_AllProvidersAttributes_Call { + _c.Call.Return(run) + return _c +} + +// AuditorAttributes provides a mock function with given fields: ctx, in, opts +func (_m *Query) AuditorAttributes(ctx context.Context, in *v1beta3.QueryAuditorAttributesRequest, opts ...grpc.CallOption) (*v1beta3.QueryProvidersResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *v1beta3.QueryProvidersResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *v1beta3.QueryAuditorAttributesRequest, ...grpc.CallOption) (*v1beta3.QueryProvidersResponse, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *v1beta3.QueryAuditorAttributesRequest, ...grpc.CallOption) *v1beta3.QueryProvidersResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*v1beta3.QueryProvidersResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *v1beta3.QueryAuditorAttributesRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Query_AuditorAttributes_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AuditorAttributes' +type Query_AuditorAttributes_Call struct { + *mock.Call +} + +// AuditorAttributes is a helper method to define mock.On call +// - ctx context.Context +// - in *v1beta3.QueryAuditorAttributesRequest +// - opts ...grpc.CallOption +func (_e *Query_Expecter) AuditorAttributes(ctx interface{}, in interface{}, opts ...interface{}) *Query_AuditorAttributes_Call { + return &Query_AuditorAttributes_Call{Call: _e.mock.On("AuditorAttributes", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *Query_AuditorAttributes_Call) Run(run func(ctx context.Context, in *v1beta3.QueryAuditorAttributesRequest, opts ...grpc.CallOption)) *Query_AuditorAttributes_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*v1beta3.QueryAuditorAttributesRequest), variadicArgs...) + }) + return _c +} + +func (_c *Query_AuditorAttributes_Call) Return(_a0 *v1beta3.QueryProvidersResponse, _a1 error) *Query_AuditorAttributes_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Query_AuditorAttributes_Call) RunAndReturn(run func(context.Context, *v1beta3.QueryAuditorAttributesRequest, ...grpc.CallOption) (*v1beta3.QueryProvidersResponse, error)) *Query_AuditorAttributes_Call { + _c.Call.Return(run) + return _c +} + +// Bid provides a mock function with given fields: ctx, in, opts +func (_m *Query) Bid(ctx context.Context, in *v1beta4.QueryBidRequest, opts ...grpc.CallOption) (*v1beta4.QueryBidResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *v1beta4.QueryBidResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *v1beta4.QueryBidRequest, ...grpc.CallOption) (*v1beta4.QueryBidResponse, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *v1beta4.QueryBidRequest, ...grpc.CallOption) *v1beta4.QueryBidResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*v1beta4.QueryBidResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *v1beta4.QueryBidRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Query_Bid_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Bid' +type Query_Bid_Call struct { + *mock.Call +} + +// Bid is a helper method to define mock.On call +// - ctx context.Context +// - in *v1beta4.QueryBidRequest +// - opts ...grpc.CallOption +func (_e *Query_Expecter) Bid(ctx interface{}, in interface{}, opts ...interface{}) *Query_Bid_Call { + return &Query_Bid_Call{Call: _e.mock.On("Bid", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *Query_Bid_Call) Run(run func(ctx context.Context, in *v1beta4.QueryBidRequest, opts ...grpc.CallOption)) *Query_Bid_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*v1beta4.QueryBidRequest), variadicArgs...) + }) + return _c +} + +func (_c *Query_Bid_Call) Return(_a0 *v1beta4.QueryBidResponse, _a1 error) *Query_Bid_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Query_Bid_Call) RunAndReturn(run func(context.Context, *v1beta4.QueryBidRequest, ...grpc.CallOption) (*v1beta4.QueryBidResponse, error)) *Query_Bid_Call { + _c.Call.Return(run) + return _c +} + +// Bids provides a mock function with given fields: ctx, in, opts +func (_m *Query) Bids(ctx context.Context, in *v1beta4.QueryBidsRequest, opts ...grpc.CallOption) (*v1beta4.QueryBidsResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *v1beta4.QueryBidsResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *v1beta4.QueryBidsRequest, ...grpc.CallOption) (*v1beta4.QueryBidsResponse, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *v1beta4.QueryBidsRequest, ...grpc.CallOption) *v1beta4.QueryBidsResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*v1beta4.QueryBidsResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *v1beta4.QueryBidsRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Query_Bids_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Bids' +type Query_Bids_Call struct { + *mock.Call +} + +// Bids is a helper method to define mock.On call +// - ctx context.Context +// - in *v1beta4.QueryBidsRequest +// - opts ...grpc.CallOption +func (_e *Query_Expecter) Bids(ctx interface{}, in interface{}, opts ...interface{}) *Query_Bids_Call { + return &Query_Bids_Call{Call: _e.mock.On("Bids", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *Query_Bids_Call) Run(run func(ctx context.Context, in *v1beta4.QueryBidsRequest, opts ...grpc.CallOption)) *Query_Bids_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*v1beta4.QueryBidsRequest), variadicArgs...) + }) + return _c +} + +func (_c *Query_Bids_Call) Return(_a0 *v1beta4.QueryBidsResponse, _a1 error) *Query_Bids_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Query_Bids_Call) RunAndReturn(run func(context.Context, *v1beta4.QueryBidsRequest, ...grpc.CallOption) (*v1beta4.QueryBidsResponse, error)) *Query_Bids_Call { + _c.Call.Return(run) + return _c +} + +// Certificates provides a mock function with given fields: ctx, in, opts +func (_m *Query) Certificates(ctx context.Context, in *certv1beta3.QueryCertificatesRequest, opts ...grpc.CallOption) (*certv1beta3.QueryCertificatesResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *certv1beta3.QueryCertificatesResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *certv1beta3.QueryCertificatesRequest, ...grpc.CallOption) (*certv1beta3.QueryCertificatesResponse, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *certv1beta3.QueryCertificatesRequest, ...grpc.CallOption) *certv1beta3.QueryCertificatesResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*certv1beta3.QueryCertificatesResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *certv1beta3.QueryCertificatesRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Query_Certificates_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Certificates' +type Query_Certificates_Call struct { + *mock.Call +} + +// Certificates is a helper method to define mock.On call +// - ctx context.Context +// - in *certv1beta3.QueryCertificatesRequest +// - opts ...grpc.CallOption +func (_e *Query_Expecter) Certificates(ctx interface{}, in interface{}, opts ...interface{}) *Query_Certificates_Call { + return &Query_Certificates_Call{Call: _e.mock.On("Certificates", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *Query_Certificates_Call) Run(run func(ctx context.Context, in *certv1beta3.QueryCertificatesRequest, opts ...grpc.CallOption)) *Query_Certificates_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*certv1beta3.QueryCertificatesRequest), variadicArgs...) + }) + return _c +} + +func (_c *Query_Certificates_Call) Return(_a0 *certv1beta3.QueryCertificatesResponse, _a1 error) *Query_Certificates_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Query_Certificates_Call) RunAndReturn(run func(context.Context, *certv1beta3.QueryCertificatesRequest, ...grpc.CallOption) (*certv1beta3.QueryCertificatesResponse, error)) *Query_Certificates_Call { + _c.Call.Return(run) + return _c +} + +// Deployment provides a mock function with given fields: ctx, in, opts +func (_m *Query) Deployment(ctx context.Context, in *deploymentv1beta3.QueryDeploymentRequest, opts ...grpc.CallOption) (*deploymentv1beta3.QueryDeploymentResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *deploymentv1beta3.QueryDeploymentResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *deploymentv1beta3.QueryDeploymentRequest, ...grpc.CallOption) (*deploymentv1beta3.QueryDeploymentResponse, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *deploymentv1beta3.QueryDeploymentRequest, ...grpc.CallOption) *deploymentv1beta3.QueryDeploymentResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*deploymentv1beta3.QueryDeploymentResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *deploymentv1beta3.QueryDeploymentRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Query_Deployment_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Deployment' +type Query_Deployment_Call struct { + *mock.Call +} + +// Deployment is a helper method to define mock.On call +// - ctx context.Context +// - in *deploymentv1beta3.QueryDeploymentRequest +// - opts ...grpc.CallOption +func (_e *Query_Expecter) Deployment(ctx interface{}, in interface{}, opts ...interface{}) *Query_Deployment_Call { + return &Query_Deployment_Call{Call: _e.mock.On("Deployment", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *Query_Deployment_Call) Run(run func(ctx context.Context, in *deploymentv1beta3.QueryDeploymentRequest, opts ...grpc.CallOption)) *Query_Deployment_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*deploymentv1beta3.QueryDeploymentRequest), variadicArgs...) + }) + return _c +} + +func (_c *Query_Deployment_Call) Return(_a0 *deploymentv1beta3.QueryDeploymentResponse, _a1 error) *Query_Deployment_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Query_Deployment_Call) RunAndReturn(run func(context.Context, *deploymentv1beta3.QueryDeploymentRequest, ...grpc.CallOption) (*deploymentv1beta3.QueryDeploymentResponse, error)) *Query_Deployment_Call { + _c.Call.Return(run) + return _c +} + +// Deployments provides a mock function with given fields: ctx, in, opts +func (_m *Query) Deployments(ctx context.Context, in *deploymentv1beta3.QueryDeploymentsRequest, opts ...grpc.CallOption) (*deploymentv1beta3.QueryDeploymentsResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *deploymentv1beta3.QueryDeploymentsResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *deploymentv1beta3.QueryDeploymentsRequest, ...grpc.CallOption) (*deploymentv1beta3.QueryDeploymentsResponse, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *deploymentv1beta3.QueryDeploymentsRequest, ...grpc.CallOption) *deploymentv1beta3.QueryDeploymentsResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*deploymentv1beta3.QueryDeploymentsResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *deploymentv1beta3.QueryDeploymentsRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Query_Deployments_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Deployments' +type Query_Deployments_Call struct { + *mock.Call +} + +// Deployments is a helper method to define mock.On call +// - ctx context.Context +// - in *deploymentv1beta3.QueryDeploymentsRequest +// - opts ...grpc.CallOption +func (_e *Query_Expecter) Deployments(ctx interface{}, in interface{}, opts ...interface{}) *Query_Deployments_Call { + return &Query_Deployments_Call{Call: _e.mock.On("Deployments", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *Query_Deployments_Call) Run(run func(ctx context.Context, in *deploymentv1beta3.QueryDeploymentsRequest, opts ...grpc.CallOption)) *Query_Deployments_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*deploymentv1beta3.QueryDeploymentsRequest), variadicArgs...) + }) + return _c +} + +func (_c *Query_Deployments_Call) Return(_a0 *deploymentv1beta3.QueryDeploymentsResponse, _a1 error) *Query_Deployments_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Query_Deployments_Call) RunAndReturn(run func(context.Context, *deploymentv1beta3.QueryDeploymentsRequest, ...grpc.CallOption) (*deploymentv1beta3.QueryDeploymentsResponse, error)) *Query_Deployments_Call { + _c.Call.Return(run) + return _c +} + +// Group provides a mock function with given fields: ctx, in, opts +func (_m *Query) Group(ctx context.Context, in *deploymentv1beta3.QueryGroupRequest, opts ...grpc.CallOption) (*deploymentv1beta3.QueryGroupResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *deploymentv1beta3.QueryGroupResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *deploymentv1beta3.QueryGroupRequest, ...grpc.CallOption) (*deploymentv1beta3.QueryGroupResponse, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *deploymentv1beta3.QueryGroupRequest, ...grpc.CallOption) *deploymentv1beta3.QueryGroupResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*deploymentv1beta3.QueryGroupResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *deploymentv1beta3.QueryGroupRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Query_Group_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Group' +type Query_Group_Call struct { + *mock.Call +} + +// Group is a helper method to define mock.On call +// - ctx context.Context +// - in *deploymentv1beta3.QueryGroupRequest +// - opts ...grpc.CallOption +func (_e *Query_Expecter) Group(ctx interface{}, in interface{}, opts ...interface{}) *Query_Group_Call { + return &Query_Group_Call{Call: _e.mock.On("Group", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *Query_Group_Call) Run(run func(ctx context.Context, in *deploymentv1beta3.QueryGroupRequest, opts ...grpc.CallOption)) *Query_Group_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*deploymentv1beta3.QueryGroupRequest), variadicArgs...) + }) + return _c +} + +func (_c *Query_Group_Call) Return(_a0 *deploymentv1beta3.QueryGroupResponse, _a1 error) *Query_Group_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Query_Group_Call) RunAndReturn(run func(context.Context, *deploymentv1beta3.QueryGroupRequest, ...grpc.CallOption) (*deploymentv1beta3.QueryGroupResponse, error)) *Query_Group_Call { + _c.Call.Return(run) + return _c +} + +// Lease provides a mock function with given fields: ctx, in, opts +func (_m *Query) Lease(ctx context.Context, in *v1beta4.QueryLeaseRequest, opts ...grpc.CallOption) (*v1beta4.QueryLeaseResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *v1beta4.QueryLeaseResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *v1beta4.QueryLeaseRequest, ...grpc.CallOption) (*v1beta4.QueryLeaseResponse, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *v1beta4.QueryLeaseRequest, ...grpc.CallOption) *v1beta4.QueryLeaseResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*v1beta4.QueryLeaseResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *v1beta4.QueryLeaseRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Query_Lease_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Lease' +type Query_Lease_Call struct { + *mock.Call +} + +// Lease is a helper method to define mock.On call +// - ctx context.Context +// - in *v1beta4.QueryLeaseRequest +// - opts ...grpc.CallOption +func (_e *Query_Expecter) Lease(ctx interface{}, in interface{}, opts ...interface{}) *Query_Lease_Call { + return &Query_Lease_Call{Call: _e.mock.On("Lease", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *Query_Lease_Call) Run(run func(ctx context.Context, in *v1beta4.QueryLeaseRequest, opts ...grpc.CallOption)) *Query_Lease_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*v1beta4.QueryLeaseRequest), variadicArgs...) + }) + return _c +} + +func (_c *Query_Lease_Call) Return(_a0 *v1beta4.QueryLeaseResponse, _a1 error) *Query_Lease_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Query_Lease_Call) RunAndReturn(run func(context.Context, *v1beta4.QueryLeaseRequest, ...grpc.CallOption) (*v1beta4.QueryLeaseResponse, error)) *Query_Lease_Call { + _c.Call.Return(run) + return _c +} + +// Leases provides a mock function with given fields: ctx, in, opts +func (_m *Query) Leases(ctx context.Context, in *v1beta4.QueryLeasesRequest, opts ...grpc.CallOption) (*v1beta4.QueryLeasesResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *v1beta4.QueryLeasesResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *v1beta4.QueryLeasesRequest, ...grpc.CallOption) (*v1beta4.QueryLeasesResponse, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *v1beta4.QueryLeasesRequest, ...grpc.CallOption) *v1beta4.QueryLeasesResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*v1beta4.QueryLeasesResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *v1beta4.QueryLeasesRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Query_Leases_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Leases' +type Query_Leases_Call struct { + *mock.Call +} + +// Leases is a helper method to define mock.On call +// - ctx context.Context +// - in *v1beta4.QueryLeasesRequest +// - opts ...grpc.CallOption +func (_e *Query_Expecter) Leases(ctx interface{}, in interface{}, opts ...interface{}) *Query_Leases_Call { + return &Query_Leases_Call{Call: _e.mock.On("Leases", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *Query_Leases_Call) Run(run func(ctx context.Context, in *v1beta4.QueryLeasesRequest, opts ...grpc.CallOption)) *Query_Leases_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*v1beta4.QueryLeasesRequest), variadicArgs...) + }) + return _c +} + +func (_c *Query_Leases_Call) Return(_a0 *v1beta4.QueryLeasesResponse, _a1 error) *Query_Leases_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Query_Leases_Call) RunAndReturn(run func(context.Context, *v1beta4.QueryLeasesRequest, ...grpc.CallOption) (*v1beta4.QueryLeasesResponse, error)) *Query_Leases_Call { + _c.Call.Return(run) + return _c +} + +// Order provides a mock function with given fields: ctx, in, opts +func (_m *Query) Order(ctx context.Context, in *v1beta4.QueryOrderRequest, opts ...grpc.CallOption) (*v1beta4.QueryOrderResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *v1beta4.QueryOrderResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *v1beta4.QueryOrderRequest, ...grpc.CallOption) (*v1beta4.QueryOrderResponse, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *v1beta4.QueryOrderRequest, ...grpc.CallOption) *v1beta4.QueryOrderResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*v1beta4.QueryOrderResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *v1beta4.QueryOrderRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Query_Order_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Order' +type Query_Order_Call struct { + *mock.Call +} + +// Order is a helper method to define mock.On call +// - ctx context.Context +// - in *v1beta4.QueryOrderRequest +// - opts ...grpc.CallOption +func (_e *Query_Expecter) Order(ctx interface{}, in interface{}, opts ...interface{}) *Query_Order_Call { + return &Query_Order_Call{Call: _e.mock.On("Order", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *Query_Order_Call) Run(run func(ctx context.Context, in *v1beta4.QueryOrderRequest, opts ...grpc.CallOption)) *Query_Order_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*v1beta4.QueryOrderRequest), variadicArgs...) + }) + return _c +} + +func (_c *Query_Order_Call) Return(_a0 *v1beta4.QueryOrderResponse, _a1 error) *Query_Order_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Query_Order_Call) RunAndReturn(run func(context.Context, *v1beta4.QueryOrderRequest, ...grpc.CallOption) (*v1beta4.QueryOrderResponse, error)) *Query_Order_Call { + _c.Call.Return(run) + return _c +} + +// Orders provides a mock function with given fields: ctx, in, opts +func (_m *Query) Orders(ctx context.Context, in *v1beta4.QueryOrdersRequest, opts ...grpc.CallOption) (*v1beta4.QueryOrdersResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *v1beta4.QueryOrdersResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *v1beta4.QueryOrdersRequest, ...grpc.CallOption) (*v1beta4.QueryOrdersResponse, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *v1beta4.QueryOrdersRequest, ...grpc.CallOption) *v1beta4.QueryOrdersResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*v1beta4.QueryOrdersResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *v1beta4.QueryOrdersRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Query_Orders_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Orders' +type Query_Orders_Call struct { + *mock.Call +} + +// Orders is a helper method to define mock.On call +// - ctx context.Context +// - in *v1beta4.QueryOrdersRequest +// - opts ...grpc.CallOption +func (_e *Query_Expecter) Orders(ctx interface{}, in interface{}, opts ...interface{}) *Query_Orders_Call { + return &Query_Orders_Call{Call: _e.mock.On("Orders", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *Query_Orders_Call) Run(run func(ctx context.Context, in *v1beta4.QueryOrdersRequest, opts ...grpc.CallOption)) *Query_Orders_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*v1beta4.QueryOrdersRequest), variadicArgs...) + }) + return _c +} + +func (_c *Query_Orders_Call) Return(_a0 *v1beta4.QueryOrdersResponse, _a1 error) *Query_Orders_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Query_Orders_Call) RunAndReturn(run func(context.Context, *v1beta4.QueryOrdersRequest, ...grpc.CallOption) (*v1beta4.QueryOrdersResponse, error)) *Query_Orders_Call { + _c.Call.Return(run) + return _c +} + +// Provider provides a mock function with given fields: ctx, in, opts +func (_m *Query) Provider(ctx context.Context, in *providerv1beta3.QueryProviderRequest, opts ...grpc.CallOption) (*providerv1beta3.QueryProviderResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *providerv1beta3.QueryProviderResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *providerv1beta3.QueryProviderRequest, ...grpc.CallOption) (*providerv1beta3.QueryProviderResponse, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *providerv1beta3.QueryProviderRequest, ...grpc.CallOption) *providerv1beta3.QueryProviderResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*providerv1beta3.QueryProviderResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *providerv1beta3.QueryProviderRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Query_Provider_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Provider' +type Query_Provider_Call struct { + *mock.Call +} + +// Provider is a helper method to define mock.On call +// - ctx context.Context +// - in *providerv1beta3.QueryProviderRequest +// - opts ...grpc.CallOption +func (_e *Query_Expecter) Provider(ctx interface{}, in interface{}, opts ...interface{}) *Query_Provider_Call { + return &Query_Provider_Call{Call: _e.mock.On("Provider", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *Query_Provider_Call) Run(run func(ctx context.Context, in *providerv1beta3.QueryProviderRequest, opts ...grpc.CallOption)) *Query_Provider_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*providerv1beta3.QueryProviderRequest), variadicArgs...) + }) + return _c +} + +func (_c *Query_Provider_Call) Return(_a0 *providerv1beta3.QueryProviderResponse, _a1 error) *Query_Provider_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Query_Provider_Call) RunAndReturn(run func(context.Context, *providerv1beta3.QueryProviderRequest, ...grpc.CallOption) (*providerv1beta3.QueryProviderResponse, error)) *Query_Provider_Call { + _c.Call.Return(run) + return _c +} + +// ProviderAttributes provides a mock function with given fields: ctx, in, opts +func (_m *Query) ProviderAttributes(ctx context.Context, in *v1beta3.QueryProviderAttributesRequest, opts ...grpc.CallOption) (*v1beta3.QueryProvidersResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *v1beta3.QueryProvidersResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *v1beta3.QueryProviderAttributesRequest, ...grpc.CallOption) (*v1beta3.QueryProvidersResponse, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *v1beta3.QueryProviderAttributesRequest, ...grpc.CallOption) *v1beta3.QueryProvidersResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*v1beta3.QueryProvidersResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *v1beta3.QueryProviderAttributesRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Query_ProviderAttributes_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ProviderAttributes' +type Query_ProviderAttributes_Call struct { + *mock.Call +} + +// ProviderAttributes is a helper method to define mock.On call +// - ctx context.Context +// - in *v1beta3.QueryProviderAttributesRequest +// - opts ...grpc.CallOption +func (_e *Query_Expecter) ProviderAttributes(ctx interface{}, in interface{}, opts ...interface{}) *Query_ProviderAttributes_Call { + return &Query_ProviderAttributes_Call{Call: _e.mock.On("ProviderAttributes", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *Query_ProviderAttributes_Call) Run(run func(ctx context.Context, in *v1beta3.QueryProviderAttributesRequest, opts ...grpc.CallOption)) *Query_ProviderAttributes_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*v1beta3.QueryProviderAttributesRequest), variadicArgs...) + }) + return _c +} + +func (_c *Query_ProviderAttributes_Call) Return(_a0 *v1beta3.QueryProvidersResponse, _a1 error) *Query_ProviderAttributes_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Query_ProviderAttributes_Call) RunAndReturn(run func(context.Context, *v1beta3.QueryProviderAttributesRequest, ...grpc.CallOption) (*v1beta3.QueryProvidersResponse, error)) *Query_ProviderAttributes_Call { + _c.Call.Return(run) + return _c +} + +// ProviderAuditorAttributes provides a mock function with given fields: ctx, in, opts +func (_m *Query) ProviderAuditorAttributes(ctx context.Context, in *v1beta3.QueryProviderAuditorRequest, opts ...grpc.CallOption) (*v1beta3.QueryProvidersResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *v1beta3.QueryProvidersResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *v1beta3.QueryProviderAuditorRequest, ...grpc.CallOption) (*v1beta3.QueryProvidersResponse, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *v1beta3.QueryProviderAuditorRequest, ...grpc.CallOption) *v1beta3.QueryProvidersResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*v1beta3.QueryProvidersResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *v1beta3.QueryProviderAuditorRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Query_ProviderAuditorAttributes_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ProviderAuditorAttributes' +type Query_ProviderAuditorAttributes_Call struct { + *mock.Call +} + +// ProviderAuditorAttributes is a helper method to define mock.On call +// - ctx context.Context +// - in *v1beta3.QueryProviderAuditorRequest +// - opts ...grpc.CallOption +func (_e *Query_Expecter) ProviderAuditorAttributes(ctx interface{}, in interface{}, opts ...interface{}) *Query_ProviderAuditorAttributes_Call { + return &Query_ProviderAuditorAttributes_Call{Call: _e.mock.On("ProviderAuditorAttributes", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *Query_ProviderAuditorAttributes_Call) Run(run func(ctx context.Context, in *v1beta3.QueryProviderAuditorRequest, opts ...grpc.CallOption)) *Query_ProviderAuditorAttributes_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*v1beta3.QueryProviderAuditorRequest), variadicArgs...) + }) + return _c +} + +func (_c *Query_ProviderAuditorAttributes_Call) Return(_a0 *v1beta3.QueryProvidersResponse, _a1 error) *Query_ProviderAuditorAttributes_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Query_ProviderAuditorAttributes_Call) RunAndReturn(run func(context.Context, *v1beta3.QueryProviderAuditorRequest, ...grpc.CallOption) (*v1beta3.QueryProvidersResponse, error)) *Query_ProviderAuditorAttributes_Call { + _c.Call.Return(run) + return _c +} + +// Providers provides a mock function with given fields: ctx, in, opts +func (_m *Query) Providers(ctx context.Context, in *providerv1beta3.QueryProvidersRequest, opts ...grpc.CallOption) (*providerv1beta3.QueryProvidersResponse, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, in) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *providerv1beta3.QueryProvidersResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *providerv1beta3.QueryProvidersRequest, ...grpc.CallOption) (*providerv1beta3.QueryProvidersResponse, error)); ok { + return rf(ctx, in, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, *providerv1beta3.QueryProvidersRequest, ...grpc.CallOption) *providerv1beta3.QueryProvidersResponse); ok { + r0 = rf(ctx, in, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*providerv1beta3.QueryProvidersResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *providerv1beta3.QueryProvidersRequest, ...grpc.CallOption) error); ok { + r1 = rf(ctx, in, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Query_Providers_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Providers' +type Query_Providers_Call struct { + *mock.Call +} + +// Providers is a helper method to define mock.On call +// - ctx context.Context +// - in *providerv1beta3.QueryProvidersRequest +// - opts ...grpc.CallOption +func (_e *Query_Expecter) Providers(ctx interface{}, in interface{}, opts ...interface{}) *Query_Providers_Call { + return &Query_Providers_Call{Call: _e.mock.On("Providers", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *Query_Providers_Call) Run(run func(ctx context.Context, in *providerv1beta3.QueryProvidersRequest, opts ...grpc.CallOption)) *Query_Providers_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*providerv1beta3.QueryProvidersRequest), variadicArgs...) + }) + return _c +} + +func (_c *Query_Providers_Call) Return(_a0 *providerv1beta3.QueryProvidersResponse, _a1 error) *Query_Providers_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Query_Providers_Call) RunAndReturn(run func(context.Context, *providerv1beta3.QueryProvidersRequest, ...grpc.CallOption) (*providerv1beta3.QueryProvidersResponse, error)) *Query_Providers_Call { + _c.Call.Return(run) + return _c +} + +type mockConstructorTestingTNewQuery interface { + mock.TestingT + Cleanup(func()) +} + +// NewQuery creates a new instance of Query. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewQuery(t mockConstructorTestingTNewQuery) *Query { + mock := &Query{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/go/node/client/v1beta2/mocks/tx.go b/go/node/client/v1beta2/mocks/tx.go new file mode 100644 index 00000000..cc28657d --- /dev/null +++ b/go/node/client/v1beta2/mocks/tx.go @@ -0,0 +1,95 @@ +// Code generated by mockery v2.24.0. DO NOT EDIT. + +package mocks + +import ( + context "context" + + types "github.com/cosmos/cosmos-sdk/types" + mock "github.com/stretchr/testify/mock" +) + +// Tx is an autogenerated mock type for the Tx type +type Tx struct { + mock.Mock +} + +type Tx_Expecter struct { + mock *mock.Mock +} + +func (_m *Tx) EXPECT() *Tx_Expecter { + return &Tx_Expecter{mock: &_m.Mock} +} + +// Broadcast provides a mock function with given fields: _a0, _a1 +func (_m *Tx) Broadcast(_a0 context.Context, _a1 ...types.Msg) error { + _va := make([]interface{}, len(_a1)) + for _i := range _a1 { + _va[_i] = _a1[_i] + } + var _ca []interface{} + _ca = append(_ca, _a0) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, ...types.Msg) error); ok { + r0 = rf(_a0, _a1...) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Tx_Broadcast_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Broadcast' +type Tx_Broadcast_Call struct { + *mock.Call +} + +// Broadcast is a helper method to define mock.On call +// - _a0 context.Context +// - _a1 ...types.Msg +func (_e *Tx_Expecter) Broadcast(_a0 interface{}, _a1 ...interface{}) *Tx_Broadcast_Call { + return &Tx_Broadcast_Call{Call: _e.mock.On("Broadcast", + append([]interface{}{_a0}, _a1...)...)} +} + +func (_c *Tx_Broadcast_Call) Run(run func(_a0 context.Context, _a1 ...types.Msg)) *Tx_Broadcast_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]types.Msg, len(args)-1) + for i, a := range args[1:] { + if a != nil { + variadicArgs[i] = a.(types.Msg) + } + } + run(args[0].(context.Context), variadicArgs...) + }) + return _c +} + +func (_c *Tx_Broadcast_Call) Return(_a0 error) *Tx_Broadcast_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Tx_Broadcast_Call) RunAndReturn(run func(context.Context, ...types.Msg) error) *Tx_Broadcast_Call { + _c.Call.Return(run) + return _c +} + +type mockConstructorTestingTNewTx interface { + mock.TestingT + Cleanup(func()) +} + +// NewTx creates a new instance of Tx. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewTx(t mockConstructorTestingTNewTx) *Tx { + mock := &Tx{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/go/node/client/v1beta2/node.go b/go/node/client/v1beta2/node.go new file mode 100644 index 00000000..e2eaa648 --- /dev/null +++ b/go/node/client/v1beta2/node.go @@ -0,0 +1,32 @@ +package v1beta2 + +import ( + "context" + + sdkclient "github.com/cosmos/cosmos-sdk/client" + rpcclient "github.com/tendermint/tendermint/rpc/client" + tmrpc "github.com/tendermint/tendermint/rpc/core/types" +) + +type node struct { + rpc rpcclient.Client +} + +func newNode(cctx sdkclient.Context) *node { + nd := &node{ + rpc: cctx.Client, + } + + return nd +} + +func (nd *node) SyncInfo(ctx context.Context) (*tmrpc.SyncInfo, error) { + status, err := nd.rpc.Status(ctx) + if err != nil { + return nil, err + } + + info := status.SyncInfo + + return &info, nil +} diff --git a/go/node/client/v1beta2/options.go b/go/node/client/v1beta2/options.go new file mode 100644 index 00000000..19d4e42f --- /dev/null +++ b/go/node/client/v1beta2/options.go @@ -0,0 +1,7 @@ +package v1beta2 + +type ClientOptions struct { + tclient Tx +} + +type ClientOption func(*ClientOptions) *ClientOptions diff --git a/go/node/client/v1beta2/query.go b/go/node/client/v1beta2/query.go new file mode 100644 index 00000000..d3e2bb0e --- /dev/null +++ b/go/node/client/v1beta2/query.go @@ -0,0 +1,160 @@ +package v1beta2 + +import ( + "context" + + "google.golang.org/grpc" + + sdkclient "github.com/cosmos/cosmos-sdk/client" + + atypes "github.com/akash-network/akash-api/go/node/audit/v1beta3" + ctypes "github.com/akash-network/akash-api/go/node/cert/v1beta3" + dtypes "github.com/akash-network/akash-api/go/node/deployment/v1beta3" + mtypes "github.com/akash-network/akash-api/go/node/market/v1beta4" + ptypes "github.com/akash-network/akash-api/go/node/provider/v1beta3" +) + +type QueryClient struct { + dclient dtypes.QueryClient + mclient mtypes.QueryClient + pclient ptypes.QueryClient + aclient atypes.QueryClient + cclient ctypes.QueryClient + cctx sdkclient.Context +} + +// NewQueryClient creates new query client instance +func NewQueryClient(cctx sdkclient.Context) Query { + return newQueryClient(cctx) +} + +func newQueryClient(cctx sdkclient.Context) *QueryClient { + return &QueryClient{ + dclient: dtypes.NewQueryClient(cctx), + mclient: mtypes.NewQueryClient(cctx), + pclient: ptypes.NewQueryClient(cctx), + aclient: atypes.NewQueryClient(cctx), + cclient: ctypes.NewQueryClient(cctx), + cctx: cctx, + } +} + +func (c *QueryClient) ClientContext() sdkclient.Context { + return c.cctx +} + +func (c *QueryClient) Deployments(ctx context.Context, in *dtypes.QueryDeploymentsRequest, opts ...grpc.CallOption) (*dtypes.QueryDeploymentsResponse, error) { + if c.dclient == nil { + return &dtypes.QueryDeploymentsResponse{}, ErrClientNotFound + } + return c.dclient.Deployments(ctx, in, opts...) +} + +func (c *QueryClient) Deployment(ctx context.Context, in *dtypes.QueryDeploymentRequest, opts ...grpc.CallOption) (*dtypes.QueryDeploymentResponse, error) { + if c.dclient == nil { + return &dtypes.QueryDeploymentResponse{}, ErrClientNotFound + } + return c.dclient.Deployment(ctx, in, opts...) +} + +func (c *QueryClient) Group(ctx context.Context, in *dtypes.QueryGroupRequest, opts ...grpc.CallOption) (*dtypes.QueryGroupResponse, error) { + if c.dclient == nil { + return &dtypes.QueryGroupResponse{}, ErrClientNotFound + } + return c.dclient.Group(ctx, in, opts...) +} + +func (c *QueryClient) Orders(ctx context.Context, in *mtypes.QueryOrdersRequest, opts ...grpc.CallOption) (*mtypes.QueryOrdersResponse, error) { + if c.mclient == nil { + return &mtypes.QueryOrdersResponse{}, ErrClientNotFound + } + return c.mclient.Orders(ctx, in, opts...) +} + +func (c *QueryClient) Order(ctx context.Context, in *mtypes.QueryOrderRequest, opts ...grpc.CallOption) (*mtypes.QueryOrderResponse, error) { + if c.mclient == nil { + return &mtypes.QueryOrderResponse{}, ErrClientNotFound + } + return c.mclient.Order(ctx, in, opts...) +} + +func (c *QueryClient) Bids(ctx context.Context, in *mtypes.QueryBidsRequest, opts ...grpc.CallOption) (*mtypes.QueryBidsResponse, error) { + if c.mclient == nil { + return &mtypes.QueryBidsResponse{}, ErrClientNotFound + } + return c.mclient.Bids(ctx, in, opts...) +} + +func (c *QueryClient) Bid(ctx context.Context, in *mtypes.QueryBidRequest, opts ...grpc.CallOption) (*mtypes.QueryBidResponse, error) { + if c.mclient == nil { + return &mtypes.QueryBidResponse{}, ErrClientNotFound + } + return c.mclient.Bid(ctx, in, opts...) +} + +func (c *QueryClient) Leases(ctx context.Context, in *mtypes.QueryLeasesRequest, opts ...grpc.CallOption) (*mtypes.QueryLeasesResponse, error) { + if c.mclient == nil { + return &mtypes.QueryLeasesResponse{}, ErrClientNotFound + } + return c.mclient.Leases(ctx, in, opts...) +} + +func (c *QueryClient) Lease(ctx context.Context, in *mtypes.QueryLeaseRequest, opts ...grpc.CallOption) (*mtypes.QueryLeaseResponse, error) { + if c.mclient == nil { + return &mtypes.QueryLeaseResponse{}, ErrClientNotFound + } + return c.mclient.Lease(ctx, in, opts...) +} + +func (c *QueryClient) Providers(ctx context.Context, in *ptypes.QueryProvidersRequest, opts ...grpc.CallOption) (*ptypes.QueryProvidersResponse, error) { + if c.pclient == nil { + return &ptypes.QueryProvidersResponse{}, ErrClientNotFound + } + return c.pclient.Providers(ctx, in, opts...) +} + +func (c *QueryClient) Provider(ctx context.Context, in *ptypes.QueryProviderRequest, opts ...grpc.CallOption) (*ptypes.QueryProviderResponse, error) { + if c.pclient == nil { + return &ptypes.QueryProviderResponse{}, ErrClientNotFound + } + return c.pclient.Provider(ctx, in, opts...) +} + +// AllProvidersAttributes queries all providers +func (c *QueryClient) AllProvidersAttributes(ctx context.Context, in *atypes.QueryAllProvidersAttributesRequest, opts ...grpc.CallOption) (*atypes.QueryProvidersResponse, error) { + if c.pclient == nil { + return &atypes.QueryProvidersResponse{}, ErrClientNotFound + } + return c.aclient.AllProvidersAttributes(ctx, in, opts...) +} + +// ProviderAttributes queries all provider signed attributes +func (c *QueryClient) ProviderAttributes(ctx context.Context, in *atypes.QueryProviderAttributesRequest, opts ...grpc.CallOption) (*atypes.QueryProvidersResponse, error) { + if c.pclient == nil { + return &atypes.QueryProvidersResponse{}, ErrClientNotFound + } + return c.aclient.ProviderAttributes(ctx, in, opts...) +} + +// ProviderAuditorAttributes queries provider signed attributes by specific validator +func (c *QueryClient) ProviderAuditorAttributes(ctx context.Context, in *atypes.QueryProviderAuditorRequest, opts ...grpc.CallOption) (*atypes.QueryProvidersResponse, error) { + if c.pclient == nil { + return &atypes.QueryProvidersResponse{}, ErrClientNotFound + } + return c.aclient.ProviderAuditorAttributes(ctx, in, opts...) +} + +// AuditorAttributes queries all providers signed by this validator +func (c *QueryClient) AuditorAttributes(ctx context.Context, in *atypes.QueryAuditorAttributesRequest, opts ...grpc.CallOption) (*atypes.QueryProvidersResponse, error) { + if c.aclient == nil { + return &atypes.QueryProvidersResponse{}, ErrClientNotFound + } + return c.aclient.AuditorAttributes(ctx, in, opts...) +} + +func (c *QueryClient) Certificates(ctx context.Context, in *ctypes.QueryCertificatesRequest, opts ...grpc.CallOption) (*ctypes.QueryCertificatesResponse, error) { + if c.cclient == nil { + return &ctypes.QueryCertificatesResponse{}, ErrClientNotFound + } + return c.cclient.Certificates(ctx, in, opts...) +} diff --git a/go/node/client/v1beta2/tx.go b/go/node/client/v1beta2/tx.go new file mode 100644 index 00000000..63c14c23 --- /dev/null +++ b/go/node/client/v1beta2/tx.go @@ -0,0 +1,413 @@ +package v1beta2 + +import ( + "context" + "encoding/hex" + "errors" + "strings" + "time" + "unsafe" + + "github.com/boz/go-lifecycle" + "github.com/spf13/pflag" + + "github.com/cosmos/cosmos-sdk/crypto/keyring" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + ttypes "github.com/tendermint/tendermint/types" + + sdkclient "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/tx" + sdk "github.com/cosmos/cosmos-sdk/types" + authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" +) + +var ( + ErrNotRunning = errors.New("not running") + ErrSyncTimedOut = errors.New("serial broadcast: timed-out waiting for sequence sync") +) + +const ( + BroadcastDefaultTimeout = 30 * time.Second + BroadcastBlockRetryTimeout = 300 * time.Second + broadcastBlockRetryPeriod = time.Second + sequenceSyncTimeout = 30 * time.Second + + // sadface. + + // Only way to detect the timeout error. + // https://github.com/tendermint/tendermint/blob/46e06c97320bc61c4d98d3018f59d47ec69863c9/rpc/core/mempool.go#L124 + timeoutErrorMessage = "timed out waiting for tx to be included in a block" + + // Only way to check for tx not found error. + // https://github.com/tendermint/tendermint/blob/46e06c97320bc61c4d98d3018f59d47ec69863c9/rpc/core/tx.go#L31-L33 + notFoundErrorMessageSuffix = ") not found" +) + +type broadcastRequest struct { + id uintptr + responsech chan<- error + msgs []sdk.Msg +} + +type seqreq struct { + curr uint64 + ch chan<- uint64 +} + +type broadcast struct { + donech chan<- error + respch chan<- error + msgs []sdk.Msg +} + +type serialBroadcaster struct { + ctx context.Context + cctx sdkclient.Context + info keyring.Info + broadcastTimeout time.Duration + reqch chan broadcastRequest + broadcastch chan broadcast + seqreqch chan seqreq + lc lifecycle.Lifecycle + // log log.Logger +} + +func newSerialTx(ctx context.Context, cctx sdkclient.Context, flags *pflag.FlagSet, timeout time.Duration) (*serialBroadcaster, error) { + txf := tx.NewFactoryCLI(cctx, flags).WithTxConfig(cctx.TxConfig).WithAccountRetriever(cctx.AccountRetriever) + + keyname := cctx.GetFromName() + info, err := txf.Keybase().Key(keyname) + if err != nil { + return nil, err + } + + // populate account number, current sequence number + poptxf, err := PrepareFactory(cctx, txf) + if err != nil { + return nil, err + } + + poptxf = poptxf.WithSimulateAndExecute(true) + + client := &serialBroadcaster{ + ctx: ctx, + cctx: cctx, + info: info, + broadcastTimeout: timeout, + lc: lifecycle.New(), + reqch: make(chan broadcastRequest, 1), + broadcastch: make(chan broadcast, 1), + seqreqch: make(chan seqreq), + // log: log.With("cmp", "client/broadcaster"), + } + + go client.lc.WatchContext(ctx) + go client.run() + go client.broadcaster(poptxf) + + return client, nil +} + +func (c *serialBroadcaster) Broadcast(ctx context.Context, msgs ...sdk.Msg) error { + responsech := make(chan error, 1) + request := broadcastRequest{ + responsech: responsech, + msgs: msgs, + } + + request.id = uintptr(unsafe.Pointer(&request)) + + select { + case c.reqch <- request: + case <-ctx.Done(): + return ctx.Err() + case <-c.lc.ShuttingDown(): + return ErrNotRunning + } + + select { + case err := <-responsech: + return err + case <-ctx.Done(): + return ctx.Err() + case <-c.lc.ShuttingDown(): + return ErrNotRunning + } +} + +func (c *serialBroadcaster) run() { + defer c.lc.ShutdownCompleted() + + donech := make(chan struct{}) + + go func() { + defer close(donech) + c.sequenceSync() + }() + + defer func() { <-donech }() + + var pending []broadcastRequest + + broadcastDoneCh := make(chan error, 1) + signalCh := make(chan struct{}, 1) + signal := signalCh + + trySignal := func() { + if len(pending) == 0 { + return + } + + select { + case signal <- struct{}{}: + default: + } + } + +loop: + for { + select { + case err := <-c.lc.ShutdownRequest(): + c.lc.ShutdownInitiated(err) + break loop + case req := <-c.reqch: + pending = append(pending, req) + + trySignal() + case <-signal: + signal = nil + + var req broadcastRequest + + req, pending = pending[len(pending)-1], pending[:len(pending)-1] + + // broadcastDoneCh = make(chan error, 1) + c.broadcastch <- broadcast{ + donech: broadcastDoneCh, + respch: req.responsech, + msgs: req.msgs, + } + case err := <-broadcastDoneCh: + // broadcastDoneCh = nil + signal = signalCh + + if err != nil { + // c.log.Error("unable to broadcast messages", "error", err) + } + trySignal() + } + } +} + +func (c *serialBroadcaster) broadcaster(txf tx.Factory) { + checkSync := func(rErr error) bool { + if rErr != nil { + if sdkerrors.ErrWrongSequence.Is(rErr) { + // attempt to sync account sequence + if rSeq, err := c.syncAccountSequence(txf.Sequence()); err == nil { + txf = txf.WithSequence(rSeq + 1) + } else { + // c.log.Error("failed to sync account sequence number", "err", err) + } + + return true + } + } + + return false + } + + for { + select { + case <-c.lc.ShuttingDown(): + return + case req := <-c.broadcastch: + var err error + + txf, err = AdjustGas(c.cctx, txf, req.msgs...) + if err != nil { + req.respch <- err + req.donech <- err + } + + done: + for i := 0; i < 2; i++ { + txf, err = c.broadcastTxs(txf, req.msgs...) + if !checkSync(err) { + break done + } + } + + req.respch <- err + + if err != nil { + _ = checkSync(err) + } + + req.donech <- err + } + } +} + +func (c *serialBroadcaster) sequenceSync() { + for { + select { + case <-c.lc.ShuttingDown(): + return + case req := <-c.seqreqch: + // query sequence number + _, seq, err := c.cctx.AccountRetriever.GetAccountNumberSequence(c.cctx, c.info.GetAddress()) + + if err != nil { + // c.log.Error("error requesting account", "err", err) + seq = req.curr + } + + select { + case req.ch <- seq: + case <-c.lc.ShuttingDown(): + } + } + } +} + +func (c *serialBroadcaster) broadcastTxs(txf tx.Factory, msgs ...sdk.Msg) (tx.Factory, error) { + var err error + + response, err := c.doBroadcast(c.cctx, txf, c.broadcastTimeout, c.info.GetName(), msgs...) + if err != nil { + return txf, err + } + + if response.Code != 0 { + return txf, sdkerrors.ABCIError(response.Codespace, response.Code, response.RawLog) + } + + txf = txf.WithSequence(txf.Sequence() + 1) + return txf, nil +} + +func (c *serialBroadcaster) syncAccountSequence(lSeq uint64) (uint64, error) { + ch := make(chan uint64, 1) + + c.seqreqch <- seqreq{ + curr: lSeq, + ch: ch, + } + + ctx, cancel := context.WithTimeout(c.ctx, sequenceSyncTimeout) + defer cancel() + + select { + case rSeq := <-ch: + return rSeq, nil + case <-ctx.Done(): + return lSeq, ErrSyncTimedOut + case <-c.lc.ShuttingDown(): + return lSeq, ErrNotRunning + } +} + +func (c *serialBroadcaster) doBroadcast(cctx sdkclient.Context, txf tx.Factory, timeout time.Duration, keyName string, msgs ...sdk.Msg) (*sdk.TxResponse, error) { + txn, err := tx.BuildUnsignedTx(txf, msgs...) + if err != nil { + return nil, err + } + + txn.SetFeeGranter(cctx.GetFeeGranterAddress()) + err = tx.Sign(txf, keyName, txn, true) + if err != nil { + return nil, err + } + + bytes, err := cctx.TxConfig.TxEncoder()(txn.GetTx()) + if err != nil { + return nil, err + } + + txb := ttypes.Tx(bytes) + hash := hex.EncodeToString(txb.Hash()) + + // broadcast-mode=block + // submit with mode commit/block + cres, err := cctx.BroadcastTxCommit(txb) + if err == nil { + // good job + return cres, nil + } else if !strings.HasSuffix(err.Error(), timeoutErrorMessage) { + return cres, err + } + + // timeout error, continue on to retry + + // loop + lctx, cancel := context.WithTimeout(c.ctx, timeout) + defer cancel() + + for lctx.Err() == nil { + // wait up to one second + select { + case <-lctx.Done(): + return cres, err + case <-time.After(broadcastBlockRetryPeriod): + } + + // check transaction + // https://github.com/cosmos/cosmos-sdk/pull/8734 + res, err := authtx.QueryTx(cctx, hash) + if err == nil { + return res, nil + } + + // if it's not a "not found" error, return + if !strings.HasSuffix(err.Error(), notFoundErrorMessageSuffix) { + return res, err + } + } + + return cres, lctx.Err() +} + +// PrepareFactory has been copied from cosmos-sdk to make it public. +// Source: https://github.com/cosmos/cosmos-sdk/blob/v0.43.0-rc2/client/tx/tx.go#L311 +func PrepareFactory(cctx sdkclient.Context, txf tx.Factory) (tx.Factory, error) { + from := cctx.GetFromAddress() + + if err := txf.AccountRetriever().EnsureExists(cctx, from); err != nil { + return txf, err + } + + initNum := txf.AccountNumber() + initSeq := txf.Sequence() + + if initNum == 0 || initSeq == 0 { + num, seq, err := txf.AccountRetriever().GetAccountNumberSequence(cctx, from) + if err != nil { + return txf, err + } + + if initNum == 0 { + txf = txf.WithAccountNumber(num) + } + + if initSeq == 0 { + txf = txf.WithSequence(seq) + } + } + + return txf, nil +} + +func AdjustGas(ctx sdkclient.Context, txf tx.Factory, msgs ...sdk.Msg) (tx.Factory, error) { + if !ctx.Simulate && !txf.SimulateAndExecute() { + return txf, nil + } + _, adjusted, err := tx.CalculateGas(ctx, txf, msgs...) + if err != nil { + return txf, err + } + + txf = txf.WithGas(adjusted) + + return txf, nil +} diff --git a/go/sdkutil/config.go b/go/sdkutil/config.go index 1816cb73..d3be973e 100644 --- a/go/sdkutil/config.go +++ b/go/sdkutil/config.go @@ -5,7 +5,7 @@ import ( ) // init atm SDK configs is instantiated with const values, so it sealed within init below -// this helps for all tests as well as packages relying on this api to always have the same config +// it helps for all tests as well as packages relying on this api to always have the same config // as soon as sdkutil is imported func init() { config := sdk.GetConfig() diff --git a/make/codegen.mk b/make/codegen.mk index 8a821aa7..20bd8448 100644 --- a/make/codegen.mk +++ b/make/codegen.mk @@ -11,8 +11,11 @@ endif proto-gen-swagger: modvendor $(BUF) $(PROTOC_GEN_SWAGGER) $(SWAGGER_COMBINE) ./script/protoc-gen-swagger.sh +mocks: $(MOCKERY) + $(GO) generate ./... + .PHONY: codegen -codegen: proto-gen proto-gen-swagger +codegen: proto-gen proto-gen-swagger mocks .PHONY: changelog changelog: $(GIT_CHGLOG) diff --git a/make/setup-cache.mk b/make/setup-cache.mk index aac5e3d2..99a6129a 100644 --- a/make/setup-cache.mk +++ b/make/setup-cache.mk @@ -117,6 +117,15 @@ $(GIT_CHGLOG_VERSION_FILE): $(AKASH_DEVCACHE) touch $@ $(GIT_CHGLOG): $(GIT_CHGLOG_VERSION_FILE) +$(MOCKERY_VERSION_FILE): $(AKASH_DEVCACHE) + @echo "installing mockery $(MOCKERY_VERSION) ..." + rm -f $(MOCKERY) + GOBIN=$(AKASH_DEVCACHE_BIN) go install -ldflags '-s -w -X github.com/vektra/mockery/v2/pkg/config.SemVer=$(MOCKERY_VERSION)' github.com/vektra/mockery/v2@v$(MOCKERY_VERSION) + rm -rf "$(dir $@)" + mkdir -p "$(dir $@)" + touch $@ +$(MOCKERY): $(MOCKERY_VERSION_FILE) + $(NPM): ifeq (, $(shell which $(NPM) 2>/dev/null)) $(error "npm installation required") diff --git a/proto/node/akash/discovery/v1/akash.proto b/proto/node/akash/discovery/v1/akash.proto new file mode 100644 index 00000000..5bdf3630 --- /dev/null +++ b/proto/node/akash/discovery/v1/akash.proto @@ -0,0 +1,17 @@ +syntax = "proto3"; + +package akash.discovery.v1; + +import "akash/discovery/v1/client_info.proto"; +import "gogoproto/gogo.proto"; + +option go_package = "github.com/akash-network/akash-api/go/node/client"; + +// Akash akash specific RPC parameters +message Akash { + ClientInfo client_info = 1 [ + (gogoproto.customname) = "ClientInfo", + (gogoproto.jsontag) = "client_info", + (gogoproto.moretags) = "yaml:\"client_info\"" + ]; +} diff --git a/proto/node/akash/discovery/v1/client_info.proto b/proto/node/akash/discovery/v1/client_info.proto new file mode 100644 index 00000000..d01ad9e8 --- /dev/null +++ b/proto/node/akash/discovery/v1/client_info.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; + +package akash.discovery.v1; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/akash-network/akash-api/go/node/client"; + +// ClientInfo akash specific client info +message ClientInfo { + string api_version = 1 [ + (gogoproto.customname) = "ApiVersion", + (gogoproto.jsontag) = "api_version", + (gogoproto.moretags) = "yaml:\"api_version\"" + ]; +}