From 2fd566e2a9031eb83271826996b912614bcf3aeb Mon Sep 17 00:00:00 2001 From: Marko Baricevic Date: Thu, 12 Dec 2019 11:55:21 +0100 Subject: [PATCH 1/2] Add tests for proto files - imported gogo/protobuf for remotedb to generate tests and update the .pb.go file Signed-off-by: Marko Baricevic --- go.mod | 4 +- go.sum | 5 + makefile | 11 + mem_db_test.go | 14 +- remotedb/proto/defs.pb.go | 987 +++++++++++++++++++++++++++++----- remotedb/proto/defs.proto | 7 + remotedb/proto/defspb_test.go | 639 ++++++++++++++++++++++ 7 files changed, 1518 insertions(+), 149 deletions(-) create mode 100644 remotedb/proto/defspb_test.go diff --git a/go.mod b/go.mod index a6bdcf350..2c732aa4a 100644 --- a/go.mod +++ b/go.mod @@ -8,13 +8,13 @@ require ( github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51 // indirect github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 // indirect github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870 // indirect - github.com/golang/protobuf v1.3.2 + github.com/gogo/protobuf v1.3.1 github.com/jmhodges/levigo v1.0.0 github.com/pkg/errors v0.8.1 github.com/stretchr/testify v1.4.0 github.com/syndtr/goleveldb v1.0.1-0.20190923125748-758128399b1d github.com/tecbot/gorocksdb v0.0.0-20191017175515-d217d93fd4c5 go.etcd.io/bbolt v1.3.3 // indirect - golang.org/x/net v0.0.0-20190628185345-da137c7871d7 + golang.org/x/net v0.0.0-20190628185345-da137c7871d7 // indirect google.golang.org/grpc v1.25.1 ) diff --git a/go.sum b/go.sum index 01ed41016..946d59642 100644 --- a/go.sum +++ b/go.sum @@ -18,6 +18,8 @@ github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870 h1:E2s37DuLxFhQD github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870/go.mod h1:5tD+neXqOorC30/tWg0LCSkrqj/AR6gu8yY8/fpw1q0= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls= +github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= @@ -31,6 +33,8 @@ github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/jmhodges/levigo v1.0.0 h1:q5EC36kV79HWeTBWsod3mG11EgStG3qArTKcvlksN1U= github.com/jmhodges/levigo v1.0.0/go.mod h1:Q6Qx+uH3RAqyK4rFQroq9RL7mdkABMcfhEI+nNuzMJQ= +github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -73,6 +77,7 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= diff --git a/makefile b/makefile index 90fd2baf3..c007d4aa3 100644 --- a/makefile +++ b/makefile @@ -1,5 +1,6 @@ GOTOOLS = github.com/golangci/golangci-lint/cmd/golangci-lint PACKAGES=$(shell go list ./...) +INCLUDE = -I=${GOPATH}/src/github.com/tendermint/tm-db -I=${GOPATH}/src -I=${GOPATH}/src/github.com/gogo/protobuf/protobuf export GO111MODULE = on @@ -30,4 +31,14 @@ gen_certs: clean_certs clean_certs: rm -f db/remotedb/test.crt rm -f db/remotedb/test.key + +%.pb.go: %.proto + ## If you get the following error, + ## "error while loading shared libraries: libprotobuf.so.14: cannot open shared object file: No such file or directory" + ## See https://stackoverflow.com/a/25518702 + ## Note the $< here is substituted for the %.proto + ## Note the $@ here is substituted for the %.pb.go + protoc $(INCLUDE) $< --gogo_out=Mgoogle/protobuf/timestamp.proto=github.com/golang/protobuf/ptypes/timestamp,plugins=grpc:../../.. + +protoc_remotedb: remotedb/proto/defs.pb.go \ No newline at end of file diff --git a/mem_db_test.go b/mem_db_test.go index 387e52d0e..55998cf2b 100644 --- a/mem_db_test.go +++ b/mem_db_test.go @@ -11,18 +11,24 @@ func TestMemDB_Iterator(t *testing.T) { defer db.Close() // if db is empty, iterator is invalid - itr := db.Iterator(nil, nil) + itr, err := db.Iterator(nil, nil) + assert.NoError(t, err) defer itr.Close() assert.False(t, itr.Valid()) db.Set([]byte("foo"), []byte("bar")) // single iteration - itr = db.Iterator(nil, nil) + itr, err = db.Iterator(nil, nil) + assert.NoError(t, err) defer itr.Close() + key, err := itr.Key() + assert.NoError(t, err) assert.True(t, itr.Valid()) - assert.Equal(t, []byte("foo"), itr.Key()) - assert.Equal(t, []byte("bar"), itr.Value()) + assert.Equal(t, []byte("foo"), key) + value, err := itr.Value() + assert.NoError(t, err) + assert.Equal(t, []byte("bar"), value) itr.Next() assert.False(t, itr.Valid()) } diff --git a/remotedb/proto/defs.pb.go b/remotedb/proto/defs.pb.go index 4d9f0b272..f3b9858b1 100644 --- a/remotedb/proto/defs.pb.go +++ b/remotedb/proto/defs.pb.go @@ -1,31 +1,18 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: defs.proto - -/* -Package protodb is a generated protocol buffer package. - -It is generated from these files: - defs.proto - -It has these top-level messages: - Batch - Operation - Entity - Nothing - Domain - Iterator - Stats - Init -*/ -package protodb +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: remotedb/proto/defs.proto -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" +package protodb import ( - context "golang.org/x/net/context" + bytes "bytes" + context "context" + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + math "math" ) // Reference imports to suppress errors if they are not otherwise used. @@ -37,7 +24,7 @@ var _ = math.Inf // 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.ProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Operation_Type int32 @@ -50,6 +37,7 @@ var Operation_Type_name = map[int32]string{ 0: "SET", 1: "DELETE", } + var Operation_Type_value = map[string]int32{ "SET": 0, "DELETE": 1, @@ -58,16 +46,41 @@ var Operation_Type_value = map[string]int32{ func (x Operation_Type) String() string { return proto.EnumName(Operation_Type_name, int32(x)) } -func (Operation_Type) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{1, 0} } + +func (Operation_Type) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_ef1eada6618d0075, []int{1, 0} +} type Batch struct { - Ops []*Operation `protobuf:"bytes,1,rep,name=ops" json:"ops,omitempty"` + Ops []*Operation `protobuf:"bytes,1,rep,name=ops,proto3" json:"ops,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (m *Batch) Reset() { *m = Batch{} } -func (m *Batch) String() string { return proto.CompactTextString(m) } -func (*Batch) ProtoMessage() {} -func (*Batch) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } +func (m *Batch) Reset() { *m = Batch{} } +func (m *Batch) String() string { return proto.CompactTextString(m) } +func (*Batch) ProtoMessage() {} +func (*Batch) Descriptor() ([]byte, []int) { + return fileDescriptor_ef1eada6618d0075, []int{0} +} +func (m *Batch) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Batch.Unmarshal(m, b) +} +func (m *Batch) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Batch.Marshal(b, m, deterministic) +} +func (m *Batch) XXX_Merge(src proto.Message) { + xxx_messageInfo_Batch.Merge(m, src) +} +func (m *Batch) XXX_Size() int { + return xxx_messageInfo_Batch.Size(m) +} +func (m *Batch) XXX_DiscardUnknown() { + xxx_messageInfo_Batch.DiscardUnknown(m) +} + +var xxx_messageInfo_Batch proto.InternalMessageInfo func (m *Batch) GetOps() []*Operation { if m != nil { @@ -77,14 +90,36 @@ func (m *Batch) GetOps() []*Operation { } type Operation struct { - Entity *Entity `protobuf:"bytes,1,opt,name=entity" json:"entity,omitempty"` - Type Operation_Type `protobuf:"varint,2,opt,name=type,enum=protodb.Operation_Type" json:"type,omitempty"` + Entity *Entity `protobuf:"bytes,1,opt,name=entity,proto3" json:"entity,omitempty"` + Type Operation_Type `protobuf:"varint,2,opt,name=type,proto3,enum=protodb.Operation_Type" json:"type,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Operation) Reset() { *m = Operation{} } +func (m *Operation) String() string { return proto.CompactTextString(m) } +func (*Operation) ProtoMessage() {} +func (*Operation) Descriptor() ([]byte, []int) { + return fileDescriptor_ef1eada6618d0075, []int{1} +} +func (m *Operation) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Operation.Unmarshal(m, b) +} +func (m *Operation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Operation.Marshal(b, m, deterministic) +} +func (m *Operation) XXX_Merge(src proto.Message) { + xxx_messageInfo_Operation.Merge(m, src) +} +func (m *Operation) XXX_Size() int { + return xxx_messageInfo_Operation.Size(m) +} +func (m *Operation) XXX_DiscardUnknown() { + xxx_messageInfo_Operation.DiscardUnknown(m) } -func (m *Operation) Reset() { *m = Operation{} } -func (m *Operation) String() string { return proto.CompactTextString(m) } -func (*Operation) ProtoMessage() {} -func (*Operation) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } +var xxx_messageInfo_Operation proto.InternalMessageInfo func (m *Operation) GetEntity() *Entity { if m != nil { @@ -101,20 +136,42 @@ func (m *Operation) GetType() Operation_Type { } type Entity struct { - Id int32 `protobuf:"varint,1,opt,name=id" json:"id,omitempty"` - Key []byte `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` - Value []byte `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"` - Exists bool `protobuf:"varint,4,opt,name=exists" json:"exists,omitempty"` - Start []byte `protobuf:"bytes,5,opt,name=start,proto3" json:"start,omitempty"` - End []byte `protobuf:"bytes,6,opt,name=end,proto3" json:"end,omitempty"` - Err string `protobuf:"bytes,7,opt,name=err" json:"err,omitempty"` - CreatedAt int64 `protobuf:"varint,8,opt,name=created_at,json=createdAt" json:"created_at,omitempty"` + Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Key []byte `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` + Value []byte `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"` + Exists bool `protobuf:"varint,4,opt,name=exists,proto3" json:"exists,omitempty"` + Start []byte `protobuf:"bytes,5,opt,name=start,proto3" json:"start,omitempty"` + End []byte `protobuf:"bytes,6,opt,name=end,proto3" json:"end,omitempty"` + Err string `protobuf:"bytes,7,opt,name=err,proto3" json:"err,omitempty"` + CreatedAt int64 `protobuf:"varint,8,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (m *Entity) Reset() { *m = Entity{} } -func (m *Entity) String() string { return proto.CompactTextString(m) } -func (*Entity) ProtoMessage() {} -func (*Entity) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} } +func (m *Entity) Reset() { *m = Entity{} } +func (m *Entity) String() string { return proto.CompactTextString(m) } +func (*Entity) ProtoMessage() {} +func (*Entity) Descriptor() ([]byte, []int) { + return fileDescriptor_ef1eada6618d0075, []int{2} +} +func (m *Entity) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Entity.Unmarshal(m, b) +} +func (m *Entity) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Entity.Marshal(b, m, deterministic) +} +func (m *Entity) XXX_Merge(src proto.Message) { + xxx_messageInfo_Entity.Merge(m, src) +} +func (m *Entity) XXX_Size() int { + return xxx_messageInfo_Entity.Size(m) +} +func (m *Entity) XXX_DiscardUnknown() { + xxx_messageInfo_Entity.DiscardUnknown(m) +} + +var xxx_messageInfo_Entity proto.InternalMessageInfo func (m *Entity) GetId() int32 { if m != nil { @@ -173,22 +230,66 @@ func (m *Entity) GetCreatedAt() int64 { } type Nothing struct { + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Nothing) Reset() { *m = Nothing{} } +func (m *Nothing) String() string { return proto.CompactTextString(m) } +func (*Nothing) ProtoMessage() {} +func (*Nothing) Descriptor() ([]byte, []int) { + return fileDescriptor_ef1eada6618d0075, []int{3} +} +func (m *Nothing) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Nothing.Unmarshal(m, b) +} +func (m *Nothing) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Nothing.Marshal(b, m, deterministic) +} +func (m *Nothing) XXX_Merge(src proto.Message) { + xxx_messageInfo_Nothing.Merge(m, src) +} +func (m *Nothing) XXX_Size() int { + return xxx_messageInfo_Nothing.Size(m) +} +func (m *Nothing) XXX_DiscardUnknown() { + xxx_messageInfo_Nothing.DiscardUnknown(m) } -func (m *Nothing) Reset() { *m = Nothing{} } -func (m *Nothing) String() string { return proto.CompactTextString(m) } -func (*Nothing) ProtoMessage() {} -func (*Nothing) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} } +var xxx_messageInfo_Nothing proto.InternalMessageInfo type Domain struct { - Start []byte `protobuf:"bytes,1,opt,name=start,proto3" json:"start,omitempty"` - End []byte `protobuf:"bytes,2,opt,name=end,proto3" json:"end,omitempty"` + Start []byte `protobuf:"bytes,1,opt,name=start,proto3" json:"start,omitempty"` + End []byte `protobuf:"bytes,2,opt,name=end,proto3" json:"end,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Domain) Reset() { *m = Domain{} } +func (m *Domain) String() string { return proto.CompactTextString(m) } +func (*Domain) ProtoMessage() {} +func (*Domain) Descriptor() ([]byte, []int) { + return fileDescriptor_ef1eada6618d0075, []int{4} +} +func (m *Domain) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Domain.Unmarshal(m, b) +} +func (m *Domain) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Domain.Marshal(b, m, deterministic) +} +func (m *Domain) XXX_Merge(src proto.Message) { + xxx_messageInfo_Domain.Merge(m, src) +} +func (m *Domain) XXX_Size() int { + return xxx_messageInfo_Domain.Size(m) +} +func (m *Domain) XXX_DiscardUnknown() { + xxx_messageInfo_Domain.DiscardUnknown(m) } -func (m *Domain) Reset() { *m = Domain{} } -func (m *Domain) String() string { return proto.CompactTextString(m) } -func (*Domain) ProtoMessage() {} -func (*Domain) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} } +var xxx_messageInfo_Domain proto.InternalMessageInfo func (m *Domain) GetStart() []byte { if m != nil { @@ -205,16 +306,38 @@ func (m *Domain) GetEnd() []byte { } type Iterator struct { - Domain *Domain `protobuf:"bytes,1,opt,name=domain" json:"domain,omitempty"` - Valid bool `protobuf:"varint,2,opt,name=valid" json:"valid,omitempty"` - Key []byte `protobuf:"bytes,3,opt,name=key,proto3" json:"key,omitempty"` - Value []byte `protobuf:"bytes,4,opt,name=value,proto3" json:"value,omitempty"` + Domain *Domain `protobuf:"bytes,1,opt,name=domain,proto3" json:"domain,omitempty"` + Valid bool `protobuf:"varint,2,opt,name=valid,proto3" json:"valid,omitempty"` + Key []byte `protobuf:"bytes,3,opt,name=key,proto3" json:"key,omitempty"` + Value []byte `protobuf:"bytes,4,opt,name=value,proto3" json:"value,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (m *Iterator) Reset() { *m = Iterator{} } -func (m *Iterator) String() string { return proto.CompactTextString(m) } -func (*Iterator) ProtoMessage() {} -func (*Iterator) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} } +func (m *Iterator) Reset() { *m = Iterator{} } +func (m *Iterator) String() string { return proto.CompactTextString(m) } +func (*Iterator) ProtoMessage() {} +func (*Iterator) Descriptor() ([]byte, []int) { + return fileDescriptor_ef1eada6618d0075, []int{5} +} +func (m *Iterator) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Iterator.Unmarshal(m, b) +} +func (m *Iterator) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Iterator.Marshal(b, m, deterministic) +} +func (m *Iterator) XXX_Merge(src proto.Message) { + xxx_messageInfo_Iterator.Merge(m, src) +} +func (m *Iterator) XXX_Size() int { + return xxx_messageInfo_Iterator.Size(m) +} +func (m *Iterator) XXX_DiscardUnknown() { + xxx_messageInfo_Iterator.DiscardUnknown(m) +} + +var xxx_messageInfo_Iterator proto.InternalMessageInfo func (m *Iterator) GetDomain() *Domain { if m != nil { @@ -245,14 +368,36 @@ func (m *Iterator) GetValue() []byte { } type Stats struct { - Data map[string]string `protobuf:"bytes,1,rep,name=data" json:"data,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` - TimeAt int64 `protobuf:"varint,2,opt,name=time_at,json=timeAt" json:"time_at,omitempty"` + Data map[string]string `protobuf:"bytes,1,rep,name=data,proto3" json:"data,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + TimeAt int64 `protobuf:"varint,2,opt,name=time_at,json=timeAt,proto3" json:"time_at,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Stats) Reset() { *m = Stats{} } +func (m *Stats) String() string { return proto.CompactTextString(m) } +func (*Stats) ProtoMessage() {} +func (*Stats) Descriptor() ([]byte, []int) { + return fileDescriptor_ef1eada6618d0075, []int{6} +} +func (m *Stats) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Stats.Unmarshal(m, b) +} +func (m *Stats) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Stats.Marshal(b, m, deterministic) +} +func (m *Stats) XXX_Merge(src proto.Message) { + xxx_messageInfo_Stats.Merge(m, src) +} +func (m *Stats) XXX_Size() int { + return xxx_messageInfo_Stats.Size(m) +} +func (m *Stats) XXX_DiscardUnknown() { + xxx_messageInfo_Stats.DiscardUnknown(m) } -func (m *Stats) Reset() { *m = Stats{} } -func (m *Stats) String() string { return proto.CompactTextString(m) } -func (*Stats) ProtoMessage() {} -func (*Stats) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{6} } +var xxx_messageInfo_Stats proto.InternalMessageInfo func (m *Stats) GetData() map[string]string { if m != nil { @@ -269,15 +414,37 @@ func (m *Stats) GetTimeAt() int64 { } type Init struct { - Type string `protobuf:"bytes,1,opt,name=Type" json:"Type,omitempty"` - Name string `protobuf:"bytes,2,opt,name=Name" json:"Name,omitempty"` - Dir string `protobuf:"bytes,3,opt,name=Dir" json:"Dir,omitempty"` + Type string `protobuf:"bytes,1,opt,name=Type,proto3" json:"Type,omitempty"` + Name string `protobuf:"bytes,2,opt,name=Name,proto3" json:"Name,omitempty"` + Dir string `protobuf:"bytes,3,opt,name=Dir,proto3" json:"Dir,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Init) Reset() { *m = Init{} } +func (m *Init) String() string { return proto.CompactTextString(m) } +func (*Init) ProtoMessage() {} +func (*Init) Descriptor() ([]byte, []int) { + return fileDescriptor_ef1eada6618d0075, []int{7} +} +func (m *Init) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Init.Unmarshal(m, b) +} +func (m *Init) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Init.Marshal(b, m, deterministic) +} +func (m *Init) XXX_Merge(src proto.Message) { + xxx_messageInfo_Init.Merge(m, src) +} +func (m *Init) XXX_Size() int { + return xxx_messageInfo_Init.Size(m) +} +func (m *Init) XXX_DiscardUnknown() { + xxx_messageInfo_Init.DiscardUnknown(m) } -func (m *Init) Reset() { *m = Init{} } -func (m *Init) String() string { return proto.CompactTextString(m) } -func (*Init) ProtoMessage() {} -func (*Init) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{7} } +var xxx_messageInfo_Init proto.InternalMessageInfo func (m *Init) GetType() string { if m != nil { @@ -301,6 +468,7 @@ func (m *Init) GetDir() string { } func init() { + proto.RegisterEnum("protodb.Operation_Type", Operation_Type_name, Operation_Type_value) proto.RegisterType((*Batch)(nil), "protodb.Batch") proto.RegisterType((*Operation)(nil), "protodb.Operation") proto.RegisterType((*Entity)(nil), "protodb.Entity") @@ -308,8 +476,325 @@ func init() { proto.RegisterType((*Domain)(nil), "protodb.Domain") proto.RegisterType((*Iterator)(nil), "protodb.Iterator") proto.RegisterType((*Stats)(nil), "protodb.Stats") + proto.RegisterMapType((map[string]string)(nil), "protodb.Stats.DataEntry") proto.RegisterType((*Init)(nil), "protodb.Init") - proto.RegisterEnum("protodb.Operation_Type", Operation_Type_name, Operation_Type_value) +} + +func init() { proto.RegisterFile("remotedb/proto/defs.proto", fileDescriptor_ef1eada6618d0075) } + +var fileDescriptor_ef1eada6618d0075 = []byte{ + // 662 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0x4d, 0x6f, 0xd3, 0x4a, + 0x14, 0xcd, 0x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, 0xa8, 0x8b, 0xc5, 0xe2, 0xae, 0x10, 0xfe, 0x5e, 0xfe, 0x0f, + 0x05, 0x26, 0xa8, 0x74, 0x08, 0x7d, 0x01, 0x3b, 0x92, 0x5f, 0x73, 0x99, 0xf3, 0xd3, 0x3f, 0xa5, + 0xee, 0xeb, 0xef, 0x09, 0x73, 0xba, 0x72, 0x96, 0x56, 0xe3, 0xf6, 0xde, 0x06, 0x15, 0xda, 0x01, + 0x18, 0xaa, 0x47, 0xef, 0xad, 0x14, 0xc8, 0xe9, 0xb2, 0xaf, 0x5f, 0xc2, 0xb5, 0xb7, 0x79, 0x0a, + 0x8d, 0x25, 0x43, 0x9b, 0xb0, 0x01, 0xeb, 0x64, 0xfb, 0xc7, 0xf7, 0x3d, 0xf2, 0xe5, 0x66, 0x8f, + 0x7c, 0xbb, 0xd9, 0x23, 0x43, 0x57, 0x03, 0x8e, 0x7e, 0x05, 0x00, 0x00, 0xff, 0xff, 0xc5, 0x88, + 0xfd, 0x5e, 0xc6, 0x05, 0x00, 0x00, +} + +func (this *Batch) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Batch) + if !ok { + that2, ok := that.(Batch) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if len(this.Ops) != len(that1.Ops) { + return false + } + for i := range this.Ops { + if !this.Ops[i].Equal(that1.Ops[i]) { + return false + } + } + if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { + return false + } + return true +} +func (this *Operation) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Operation) + if !ok { + that2, ok := that.(Operation) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !this.Entity.Equal(that1.Entity) { + return false + } + if this.Type != that1.Type { + return false + } + if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { + return false + } + return true +} +func (this *Entity) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Entity) + if !ok { + that2, ok := that.(Entity) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Id != that1.Id { + return false + } + if !bytes.Equal(this.Key, that1.Key) { + return false + } + if !bytes.Equal(this.Value, that1.Value) { + return false + } + if this.Exists != that1.Exists { + return false + } + if !bytes.Equal(this.Start, that1.Start) { + return false + } + if !bytes.Equal(this.End, that1.End) { + return false + } + if this.Err != that1.Err { + return false + } + if this.CreatedAt != that1.CreatedAt { + return false + } + if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { + return false + } + return true +} +func (this *Nothing) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Nothing) + if !ok { + that2, ok := that.(Nothing) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { + return false + } + return true +} +func (this *Domain) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Domain) + if !ok { + that2, ok := that.(Domain) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !bytes.Equal(this.Start, that1.Start) { + return false + } + if !bytes.Equal(this.End, that1.End) { + return false + } + if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { + return false + } + return true +} +func (this *Iterator) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Iterator) + if !ok { + that2, ok := that.(Iterator) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !this.Domain.Equal(that1.Domain) { + return false + } + if this.Valid != that1.Valid { + return false + } + if !bytes.Equal(this.Key, that1.Key) { + return false + } + if !bytes.Equal(this.Value, that1.Value) { + return false + } + if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { + return false + } + return true +} +func (this *Stats) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Stats) + if !ok { + that2, ok := that.(Stats) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if len(this.Data) != len(that1.Data) { + return false + } + for i := range this.Data { + if this.Data[i] != that1.Data[i] { + return false + } + } + if this.TimeAt != that1.TimeAt { + return false + } + if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { + return false + } + return true +} +func (this *Init) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Init) + if !ok { + that2, ok := that.(Init) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Type != that1.Type { + return false + } + if this.Name != that1.Name { + return false + } + if this.Dir != that1.Dir { + return false + } + if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { + return false + } + return true } // Reference imports to suppress errors if they are not otherwise used. @@ -320,8 +805,9 @@ var _ grpc.ClientConn // is compatible with the grpc package it is being compiled against. const _ = grpc.SupportPackageIsVersion4 -// Client API for DB service - +// DBClient is the client API for DB service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type DBClient interface { Init(ctx context.Context, in *Init, opts ...grpc.CallOption) (*Entity, error) Get(ctx context.Context, in *Entity, opts ...grpc.CallOption) (*Entity, error) @@ -349,7 +835,7 @@ func NewDBClient(cc *grpc.ClientConn) DBClient { func (c *dBClient) Init(ctx context.Context, in *Init, opts ...grpc.CallOption) (*Entity, error) { out := new(Entity) - err := grpc.Invoke(ctx, "/protodb.DB/init", in, out, c.cc, opts...) + err := c.cc.Invoke(ctx, "/protodb.DB/init", in, out, opts...) if err != nil { return nil, err } @@ -358,7 +844,7 @@ func (c *dBClient) Init(ctx context.Context, in *Init, opts ...grpc.CallOption) func (c *dBClient) Get(ctx context.Context, in *Entity, opts ...grpc.CallOption) (*Entity, error) { out := new(Entity) - err := grpc.Invoke(ctx, "/protodb.DB/get", in, out, c.cc, opts...) + err := c.cc.Invoke(ctx, "/protodb.DB/get", in, out, opts...) if err != nil { return nil, err } @@ -366,7 +852,7 @@ func (c *dBClient) Get(ctx context.Context, in *Entity, opts ...grpc.CallOption) } func (c *dBClient) GetStream(ctx context.Context, opts ...grpc.CallOption) (DB_GetStreamClient, error) { - stream, err := grpc.NewClientStream(ctx, &_DB_serviceDesc.Streams[0], c.cc, "/protodb.DB/getStream", opts...) + stream, err := c.cc.NewStream(ctx, &_DB_serviceDesc.Streams[0], "/protodb.DB/getStream", opts...) if err != nil { return nil, err } @@ -398,7 +884,7 @@ func (x *dBGetStreamClient) Recv() (*Entity, error) { func (c *dBClient) Has(ctx context.Context, in *Entity, opts ...grpc.CallOption) (*Entity, error) { out := new(Entity) - err := grpc.Invoke(ctx, "/protodb.DB/has", in, out, c.cc, opts...) + err := c.cc.Invoke(ctx, "/protodb.DB/has", in, out, opts...) if err != nil { return nil, err } @@ -407,7 +893,7 @@ func (c *dBClient) Has(ctx context.Context, in *Entity, opts ...grpc.CallOption) func (c *dBClient) Set(ctx context.Context, in *Entity, opts ...grpc.CallOption) (*Nothing, error) { out := new(Nothing) - err := grpc.Invoke(ctx, "/protodb.DB/set", in, out, c.cc, opts...) + err := c.cc.Invoke(ctx, "/protodb.DB/set", in, out, opts...) if err != nil { return nil, err } @@ -416,7 +902,7 @@ func (c *dBClient) Set(ctx context.Context, in *Entity, opts ...grpc.CallOption) func (c *dBClient) SetSync(ctx context.Context, in *Entity, opts ...grpc.CallOption) (*Nothing, error) { out := new(Nothing) - err := grpc.Invoke(ctx, "/protodb.DB/setSync", in, out, c.cc, opts...) + err := c.cc.Invoke(ctx, "/protodb.DB/setSync", in, out, opts...) if err != nil { return nil, err } @@ -425,7 +911,7 @@ func (c *dBClient) SetSync(ctx context.Context, in *Entity, opts ...grpc.CallOpt func (c *dBClient) Delete(ctx context.Context, in *Entity, opts ...grpc.CallOption) (*Nothing, error) { out := new(Nothing) - err := grpc.Invoke(ctx, "/protodb.DB/delete", in, out, c.cc, opts...) + err := c.cc.Invoke(ctx, "/protodb.DB/delete", in, out, opts...) if err != nil { return nil, err } @@ -434,7 +920,7 @@ func (c *dBClient) Delete(ctx context.Context, in *Entity, opts ...grpc.CallOpti func (c *dBClient) DeleteSync(ctx context.Context, in *Entity, opts ...grpc.CallOption) (*Nothing, error) { out := new(Nothing) - err := grpc.Invoke(ctx, "/protodb.DB/deleteSync", in, out, c.cc, opts...) + err := c.cc.Invoke(ctx, "/protodb.DB/deleteSync", in, out, opts...) if err != nil { return nil, err } @@ -442,7 +928,7 @@ func (c *dBClient) DeleteSync(ctx context.Context, in *Entity, opts ...grpc.Call } func (c *dBClient) Iterator(ctx context.Context, in *Entity, opts ...grpc.CallOption) (DB_IteratorClient, error) { - stream, err := grpc.NewClientStream(ctx, &_DB_serviceDesc.Streams[1], c.cc, "/protodb.DB/iterator", opts...) + stream, err := c.cc.NewStream(ctx, &_DB_serviceDesc.Streams[1], "/protodb.DB/iterator", opts...) if err != nil { return nil, err } @@ -474,7 +960,7 @@ func (x *dBIteratorClient) Recv() (*Iterator, error) { } func (c *dBClient) ReverseIterator(ctx context.Context, in *Entity, opts ...grpc.CallOption) (DB_ReverseIteratorClient, error) { - stream, err := grpc.NewClientStream(ctx, &_DB_serviceDesc.Streams[2], c.cc, "/protodb.DB/reverseIterator", opts...) + stream, err := c.cc.NewStream(ctx, &_DB_serviceDesc.Streams[2], "/protodb.DB/reverseIterator", opts...) if err != nil { return nil, err } @@ -507,7 +993,7 @@ func (x *dBReverseIteratorClient) Recv() (*Iterator, error) { func (c *dBClient) Stats(ctx context.Context, in *Nothing, opts ...grpc.CallOption) (*Stats, error) { out := new(Stats) - err := grpc.Invoke(ctx, "/protodb.DB/stats", in, out, c.cc, opts...) + err := c.cc.Invoke(ctx, "/protodb.DB/stats", in, out, opts...) if err != nil { return nil, err } @@ -516,7 +1002,7 @@ func (c *dBClient) Stats(ctx context.Context, in *Nothing, opts ...grpc.CallOpti func (c *dBClient) BatchWrite(ctx context.Context, in *Batch, opts ...grpc.CallOption) (*Nothing, error) { out := new(Nothing) - err := grpc.Invoke(ctx, "/protodb.DB/batchWrite", in, out, c.cc, opts...) + err := c.cc.Invoke(ctx, "/protodb.DB/batchWrite", in, out, opts...) if err != nil { return nil, err } @@ -525,15 +1011,14 @@ func (c *dBClient) BatchWrite(ctx context.Context, in *Batch, opts ...grpc.CallO func (c *dBClient) BatchWriteSync(ctx context.Context, in *Batch, opts ...grpc.CallOption) (*Nothing, error) { out := new(Nothing) - err := grpc.Invoke(ctx, "/protodb.DB/batchWriteSync", in, out, c.cc, opts...) + err := c.cc.Invoke(ctx, "/protodb.DB/batchWriteSync", in, out, opts...) if err != nil { return nil, err } return out, nil } -// Server API for DB service - +// DBServer is the server API for DB service. type DBServer interface { Init(context.Context, *Init) (*Entity, error) Get(context.Context, *Entity) (*Entity, error) @@ -551,6 +1036,50 @@ type DBServer interface { BatchWriteSync(context.Context, *Batch) (*Nothing, error) } +// UnimplementedDBServer can be embedded to have forward compatible implementations. +type UnimplementedDBServer struct { +} + +func (*UnimplementedDBServer) Init(ctx context.Context, req *Init) (*Entity, error) { + return nil, status.Errorf(codes.Unimplemented, "method Init not implemented") +} +func (*UnimplementedDBServer) Get(ctx context.Context, req *Entity) (*Entity, error) { + return nil, status.Errorf(codes.Unimplemented, "method Get not implemented") +} +func (*UnimplementedDBServer) GetStream(srv DB_GetStreamServer) error { + return status.Errorf(codes.Unimplemented, "method GetStream not implemented") +} +func (*UnimplementedDBServer) Has(ctx context.Context, req *Entity) (*Entity, error) { + return nil, status.Errorf(codes.Unimplemented, "method Has not implemented") +} +func (*UnimplementedDBServer) Set(ctx context.Context, req *Entity) (*Nothing, error) { + return nil, status.Errorf(codes.Unimplemented, "method Set not implemented") +} +func (*UnimplementedDBServer) SetSync(ctx context.Context, req *Entity) (*Nothing, error) { + return nil, status.Errorf(codes.Unimplemented, "method SetSync not implemented") +} +func (*UnimplementedDBServer) Delete(ctx context.Context, req *Entity) (*Nothing, error) { + return nil, status.Errorf(codes.Unimplemented, "method Delete not implemented") +} +func (*UnimplementedDBServer) DeleteSync(ctx context.Context, req *Entity) (*Nothing, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeleteSync not implemented") +} +func (*UnimplementedDBServer) Iterator(req *Entity, srv DB_IteratorServer) error { + return status.Errorf(codes.Unimplemented, "method Iterator not implemented") +} +func (*UnimplementedDBServer) ReverseIterator(req *Entity, srv DB_ReverseIteratorServer) error { + return status.Errorf(codes.Unimplemented, "method ReverseIterator not implemented") +} +func (*UnimplementedDBServer) Stats(ctx context.Context, req *Nothing) (*Stats, error) { + return nil, status.Errorf(codes.Unimplemented, "method Stats not implemented") +} +func (*UnimplementedDBServer) BatchWrite(ctx context.Context, req *Batch) (*Nothing, error) { + return nil, status.Errorf(codes.Unimplemented, "method BatchWrite not implemented") +} +func (*UnimplementedDBServer) BatchWriteSync(ctx context.Context, req *Batch) (*Nothing, error) { + return nil, status.Errorf(codes.Unimplemented, "method BatchWriteSync not implemented") +} + func RegisterDBServer(s *grpc.Server, srv DBServer) { s.RegisterService(&_DB_serviceDesc, srv) } @@ -866,49 +1395,221 @@ var _DB_serviceDesc = grpc.ServiceDesc{ ServerStreams: true, }, }, - Metadata: "defs.proto", -} - -func init() { proto.RegisterFile("defs.proto", fileDescriptor0) } - -var fileDescriptor0 = []byte{ - // 606 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0x4f, 0x6f, 0xd3, 0x4e, - 0x10, 0xcd, 0xda, 0x8e, 0x13, 0x4f, 0x7f, 0xbf, 0x34, 0x8c, 0x10, 0xb5, 0x8a, 0x90, 0x22, 0x0b, - 0x09, 0x43, 0x69, 0x14, 0x52, 0x24, 0xfe, 0x9c, 0x68, 0x95, 0x1c, 0x2a, 0xa1, 0x22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xf4, 0x27, 0x00, 0x00, 0xff, 0xff, 0x95, 0xf4, 0xe3, 0x82, 0x7a, 0x05, 0x00, 0x00, + Metadata: "remotedb/proto/defs.proto", +} + +func NewPopulatedBatch(r randyDefs, easy bool) *Batch { + this := &Batch{} + if r.Intn(5) != 0 { + v1 := r.Intn(5) + this.Ops = make([]*Operation, v1) + for i := 0; i < v1; i++ { + this.Ops[i] = NewPopulatedOperation(r, easy) + } + } + if !easy && r.Intn(10) != 0 { + this.XXX_unrecognized = randUnrecognizedDefs(r, 2) + } + return this +} + +func NewPopulatedOperation(r randyDefs, easy bool) *Operation { + this := &Operation{} + if r.Intn(5) != 0 { + this.Entity = NewPopulatedEntity(r, easy) + } + this.Type = Operation_Type([]int32{0, 1}[r.Intn(2)]) + if !easy && r.Intn(10) != 0 { + this.XXX_unrecognized = randUnrecognizedDefs(r, 3) + } + return this +} + +func NewPopulatedEntity(r randyDefs, easy bool) *Entity { + this := &Entity{} + this.Id = int32(r.Int31()) + if r.Intn(2) == 0 { + this.Id *= -1 + } + v2 := r.Intn(100) + this.Key = make([]byte, v2) + for i := 0; i < v2; i++ { + this.Key[i] = byte(r.Intn(256)) + } + v3 := r.Intn(100) + this.Value = make([]byte, v3) + for i := 0; i < v3; i++ { + this.Value[i] = byte(r.Intn(256)) + } + this.Exists = bool(bool(r.Intn(2) == 0)) + v4 := r.Intn(100) + this.Start = make([]byte, v4) + for i := 0; i < v4; i++ { + this.Start[i] = byte(r.Intn(256)) + } + v5 := r.Intn(100) + this.End = make([]byte, v5) + for i := 0; i < v5; i++ { + this.End[i] = byte(r.Intn(256)) + } + this.Err = string(randStringDefs(r)) + this.CreatedAt = int64(r.Int63()) + if r.Intn(2) == 0 { + this.CreatedAt *= -1 + } + if !easy && r.Intn(10) != 0 { + this.XXX_unrecognized = randUnrecognizedDefs(r, 9) + } + return this +} + +func NewPopulatedNothing(r randyDefs, easy bool) *Nothing { + this := &Nothing{} + if !easy && r.Intn(10) != 0 { + this.XXX_unrecognized = randUnrecognizedDefs(r, 1) + } + return this +} + +func NewPopulatedDomain(r randyDefs, easy bool) *Domain { + this := &Domain{} + v6 := r.Intn(100) + this.Start = make([]byte, v6) + for i := 0; i < v6; i++ { + this.Start[i] = byte(r.Intn(256)) + } + v7 := r.Intn(100) + this.End = make([]byte, v7) + for i := 0; i < v7; i++ { + this.End[i] = byte(r.Intn(256)) + } + if !easy && r.Intn(10) != 0 { + this.XXX_unrecognized = randUnrecognizedDefs(r, 3) + } + return this +} + +func NewPopulatedIterator(r randyDefs, easy bool) *Iterator { + this := &Iterator{} + if r.Intn(5) != 0 { + this.Domain = NewPopulatedDomain(r, easy) + } + this.Valid = bool(bool(r.Intn(2) == 0)) + v8 := r.Intn(100) + this.Key = make([]byte, v8) + for i := 0; i < v8; i++ { + this.Key[i] = byte(r.Intn(256)) + } + v9 := r.Intn(100) + this.Value = make([]byte, v9) + for i := 0; i < v9; i++ { + this.Value[i] = byte(r.Intn(256)) + } + if !easy && r.Intn(10) != 0 { + this.XXX_unrecognized = randUnrecognizedDefs(r, 5) + } + return this +} + +func NewPopulatedStats(r randyDefs, easy bool) *Stats { + this := &Stats{} + if r.Intn(5) != 0 { + v10 := r.Intn(10) + this.Data = make(map[string]string) + for i := 0; i < v10; i++ { + this.Data[randStringDefs(r)] = randStringDefs(r) + } + } + this.TimeAt = int64(r.Int63()) + if r.Intn(2) == 0 { + this.TimeAt *= -1 + } + if !easy && r.Intn(10) != 0 { + this.XXX_unrecognized = randUnrecognizedDefs(r, 3) + } + return this +} + +func NewPopulatedInit(r randyDefs, easy bool) *Init { + this := &Init{} + this.Type = string(randStringDefs(r)) + this.Name = string(randStringDefs(r)) + this.Dir = string(randStringDefs(r)) + if !easy && r.Intn(10) != 0 { + this.XXX_unrecognized = randUnrecognizedDefs(r, 4) + } + return this +} + +type randyDefs interface { + Float32() float32 + Float64() float64 + Int63() int64 + Int31() int32 + Uint32() uint32 + Intn(n int) int +} + +func randUTF8RuneDefs(r randyDefs) rune { + ru := r.Intn(62) + if ru < 10 { + return rune(ru + 48) + } else if ru < 36 { + return rune(ru + 55) + } + return rune(ru + 61) +} +func randStringDefs(r randyDefs) string { + v11 := r.Intn(100) + tmps := make([]rune, v11) + for i := 0; i < v11; i++ { + tmps[i] = randUTF8RuneDefs(r) + } + return string(tmps) +} +func randUnrecognizedDefs(r randyDefs, maxFieldNumber int) (dAtA []byte) { + l := r.Intn(5) + for i := 0; i < l; i++ { + wire := r.Intn(4) + if wire == 3 { + wire = 5 + } + fieldNumber := maxFieldNumber + r.Intn(100) + dAtA = randFieldDefs(dAtA, r, fieldNumber, wire) + } + return dAtA +} +func randFieldDefs(dAtA []byte, r randyDefs, fieldNumber int, wire int) []byte { + key := uint32(fieldNumber)<<3 | uint32(wire) + switch wire { + case 0: + dAtA = encodeVarintPopulateDefs(dAtA, uint64(key)) + v12 := r.Int63() + if r.Intn(2) == 0 { + v12 *= -1 + } + dAtA = encodeVarintPopulateDefs(dAtA, uint64(v12)) + case 1: + dAtA = encodeVarintPopulateDefs(dAtA, uint64(key)) + dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256))) + case 2: + dAtA = encodeVarintPopulateDefs(dAtA, uint64(key)) + ll := r.Intn(100) + dAtA = encodeVarintPopulateDefs(dAtA, uint64(ll)) + for j := 0; j < ll; j++ { + dAtA = append(dAtA, byte(r.Intn(256))) + } + default: + dAtA = encodeVarintPopulateDefs(dAtA, uint64(key)) + dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256))) + } + return dAtA +} +func encodeVarintPopulateDefs(dAtA []byte, v uint64) []byte { + for v >= 1<<7 { + dAtA = append(dAtA, uint8(uint64(v)&0x7f|0x80)) + v >>= 7 + } + dAtA = append(dAtA, uint8(v)) + return dAtA } diff --git a/remotedb/proto/defs.proto b/remotedb/proto/defs.proto index 70471f234..136e75f52 100644 --- a/remotedb/proto/defs.proto +++ b/remotedb/proto/defs.proto @@ -2,6 +2,13 @@ syntax = "proto3"; package protodb; +import "github.com/gogo/protobuf/gogoproto/gogo.proto"; + +// Generate tests +option (gogoproto.populate_all) = true; +option (gogoproto.equal_all) = true; +option (gogoproto.testgen_all) = true; + message Batch { repeated Operation ops = 1; } diff --git a/remotedb/proto/defspb_test.go b/remotedb/proto/defspb_test.go new file mode 100644 index 000000000..fd97a7b52 --- /dev/null +++ b/remotedb/proto/defspb_test.go @@ -0,0 +1,639 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: remotedb/proto/defs.proto + +package protodb + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + github_com_gogo_protobuf_jsonpb "github.com/gogo/protobuf/jsonpb" + github_com_gogo_protobuf_proto "github.com/gogo/protobuf/proto" + proto "github.com/gogo/protobuf/proto" + math "math" + math_rand "math/rand" + testing "testing" + time "time" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +func TestBatchProto(t *testing.T) { + seed := time.Now().UnixNano() + popr := math_rand.New(math_rand.NewSource(seed)) + p := NewPopulatedBatch(popr, false) + dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) + if err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + msg := &Batch{} + if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + littlefuzz := make([]byte, len(dAtA)) + copy(littlefuzz, dAtA) + for i := range dAtA { + dAtA[i] = byte(popr.Intn(256)) + } + if !p.Equal(msg) { + t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) + } + if len(littlefuzz) > 0 { + fuzzamount := 100 + for i := 0; i < fuzzamount; i++ { + littlefuzz[popr.Intn(len(littlefuzz))] = byte(popr.Intn(256)) + littlefuzz = append(littlefuzz, byte(popr.Intn(256))) + } + // shouldn't panic + _ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg) + } +} + +func TestOperationProto(t *testing.T) { + seed := time.Now().UnixNano() + popr := math_rand.New(math_rand.NewSource(seed)) + p := NewPopulatedOperation(popr, false) + dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) + if err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + msg := &Operation{} + if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + littlefuzz := make([]byte, len(dAtA)) + copy(littlefuzz, dAtA) + for i := range dAtA { + dAtA[i] = byte(popr.Intn(256)) + } + if !p.Equal(msg) { + t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) + } + if len(littlefuzz) > 0 { + fuzzamount := 100 + for i := 0; i < fuzzamount; i++ { + littlefuzz[popr.Intn(len(littlefuzz))] = byte(popr.Intn(256)) + littlefuzz = append(littlefuzz, byte(popr.Intn(256))) + } + // shouldn't panic + _ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg) + } +} + +func TestEntityProto(t *testing.T) { + seed := time.Now().UnixNano() + popr := math_rand.New(math_rand.NewSource(seed)) + p := NewPopulatedEntity(popr, false) + dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) + if err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + msg := &Entity{} + if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + littlefuzz := make([]byte, len(dAtA)) + copy(littlefuzz, dAtA) + for i := range dAtA { + dAtA[i] = byte(popr.Intn(256)) + } + if !p.Equal(msg) { + t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) + } + if len(littlefuzz) > 0 { + fuzzamount := 100 + for i := 0; i < fuzzamount; i++ { + littlefuzz[popr.Intn(len(littlefuzz))] = byte(popr.Intn(256)) + littlefuzz = append(littlefuzz, byte(popr.Intn(256))) + } + // shouldn't panic + _ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg) + } +} + +func TestNothingProto(t *testing.T) { + seed := time.Now().UnixNano() + popr := math_rand.New(math_rand.NewSource(seed)) + p := NewPopulatedNothing(popr, false) + dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) + if err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + msg := &Nothing{} + if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + littlefuzz := make([]byte, len(dAtA)) + copy(littlefuzz, dAtA) + for i := range dAtA { + dAtA[i] = byte(popr.Intn(256)) + } + if !p.Equal(msg) { + t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) + } + if len(littlefuzz) > 0 { + fuzzamount := 100 + for i := 0; i < fuzzamount; i++ { + littlefuzz[popr.Intn(len(littlefuzz))] = byte(popr.Intn(256)) + littlefuzz = append(littlefuzz, byte(popr.Intn(256))) + } + // shouldn't panic + _ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg) + } +} + +func TestDomainProto(t *testing.T) { + seed := time.Now().UnixNano() + popr := math_rand.New(math_rand.NewSource(seed)) + p := NewPopulatedDomain(popr, false) + dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) + if err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + msg := &Domain{} + if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + littlefuzz := make([]byte, len(dAtA)) + copy(littlefuzz, dAtA) + for i := range dAtA { + dAtA[i] = byte(popr.Intn(256)) + } + if !p.Equal(msg) { + t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) + } + if len(littlefuzz) > 0 { + fuzzamount := 100 + for i := 0; i < fuzzamount; i++ { + littlefuzz[popr.Intn(len(littlefuzz))] = byte(popr.Intn(256)) + littlefuzz = append(littlefuzz, byte(popr.Intn(256))) + } + // shouldn't panic + _ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg) + } +} + +func TestIteratorProto(t *testing.T) { + seed := time.Now().UnixNano() + popr := math_rand.New(math_rand.NewSource(seed)) + p := NewPopulatedIterator(popr, false) + dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) + if err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + msg := &Iterator{} + if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + littlefuzz := make([]byte, len(dAtA)) + copy(littlefuzz, dAtA) + for i := range dAtA { + dAtA[i] = byte(popr.Intn(256)) + } + if !p.Equal(msg) { + t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) + } + if len(littlefuzz) > 0 { + fuzzamount := 100 + for i := 0; i < fuzzamount; i++ { + littlefuzz[popr.Intn(len(littlefuzz))] = byte(popr.Intn(256)) + littlefuzz = append(littlefuzz, byte(popr.Intn(256))) + } + // shouldn't panic + _ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg) + } +} + +func TestStatsProto(t *testing.T) { + seed := time.Now().UnixNano() + popr := math_rand.New(math_rand.NewSource(seed)) + p := NewPopulatedStats(popr, false) + dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) + if err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + msg := &Stats{} + if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + littlefuzz := make([]byte, len(dAtA)) + copy(littlefuzz, dAtA) + for i := range dAtA { + dAtA[i] = byte(popr.Intn(256)) + } + if !p.Equal(msg) { + t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) + } + if len(littlefuzz) > 0 { + fuzzamount := 100 + for i := 0; i < fuzzamount; i++ { + littlefuzz[popr.Intn(len(littlefuzz))] = byte(popr.Intn(256)) + littlefuzz = append(littlefuzz, byte(popr.Intn(256))) + } + // shouldn't panic + _ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg) + } +} + +func TestInitProto(t *testing.T) { + seed := time.Now().UnixNano() + popr := math_rand.New(math_rand.NewSource(seed)) + p := NewPopulatedInit(popr, false) + dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) + if err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + msg := &Init{} + if err := github_com_gogo_protobuf_proto.Unmarshal(dAtA, msg); err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + littlefuzz := make([]byte, len(dAtA)) + copy(littlefuzz, dAtA) + for i := range dAtA { + dAtA[i] = byte(popr.Intn(256)) + } + if !p.Equal(msg) { + t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) + } + if len(littlefuzz) > 0 { + fuzzamount := 100 + for i := 0; i < fuzzamount; i++ { + littlefuzz[popr.Intn(len(littlefuzz))] = byte(popr.Intn(256)) + littlefuzz = append(littlefuzz, byte(popr.Intn(256))) + } + // shouldn't panic + _ = github_com_gogo_protobuf_proto.Unmarshal(littlefuzz, msg) + } +} + +func TestBatchJSON(t *testing.T) { + seed := time.Now().UnixNano() + popr := math_rand.New(math_rand.NewSource(seed)) + p := NewPopulatedBatch(popr, true) + marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{} + jsondata, err := marshaler.MarshalToString(p) + if err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + msg := &Batch{} + err = github_com_gogo_protobuf_jsonpb.UnmarshalString(jsondata, msg) + if err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + if !p.Equal(msg) { + t.Fatalf("seed = %d, %#v !Json Equal %#v", seed, msg, p) + } +} +func TestOperationJSON(t *testing.T) { + seed := time.Now().UnixNano() + popr := math_rand.New(math_rand.NewSource(seed)) + p := NewPopulatedOperation(popr, true) + marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{} + jsondata, err := marshaler.MarshalToString(p) + if err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + msg := &Operation{} + err = github_com_gogo_protobuf_jsonpb.UnmarshalString(jsondata, msg) + if err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + if !p.Equal(msg) { + t.Fatalf("seed = %d, %#v !Json Equal %#v", seed, msg, p) + } +} +func TestEntityJSON(t *testing.T) { + seed := time.Now().UnixNano() + popr := math_rand.New(math_rand.NewSource(seed)) + p := NewPopulatedEntity(popr, true) + marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{} + jsondata, err := marshaler.MarshalToString(p) + if err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + msg := &Entity{} + err = github_com_gogo_protobuf_jsonpb.UnmarshalString(jsondata, msg) + if err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + if !p.Equal(msg) { + t.Fatalf("seed = %d, %#v !Json Equal %#v", seed, msg, p) + } +} +func TestNothingJSON(t *testing.T) { + seed := time.Now().UnixNano() + popr := math_rand.New(math_rand.NewSource(seed)) + p := NewPopulatedNothing(popr, true) + marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{} + jsondata, err := marshaler.MarshalToString(p) + if err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + msg := &Nothing{} + err = github_com_gogo_protobuf_jsonpb.UnmarshalString(jsondata, msg) + if err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + if !p.Equal(msg) { + t.Fatalf("seed = %d, %#v !Json Equal %#v", seed, msg, p) + } +} +func TestDomainJSON(t *testing.T) { + seed := time.Now().UnixNano() + popr := math_rand.New(math_rand.NewSource(seed)) + p := NewPopulatedDomain(popr, true) + marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{} + jsondata, err := marshaler.MarshalToString(p) + if err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + msg := &Domain{} + err = github_com_gogo_protobuf_jsonpb.UnmarshalString(jsondata, msg) + if err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + if !p.Equal(msg) { + t.Fatalf("seed = %d, %#v !Json Equal %#v", seed, msg, p) + } +} +func TestIteratorJSON(t *testing.T) { + seed := time.Now().UnixNano() + popr := math_rand.New(math_rand.NewSource(seed)) + p := NewPopulatedIterator(popr, true) + marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{} + jsondata, err := marshaler.MarshalToString(p) + if err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + msg := &Iterator{} + err = github_com_gogo_protobuf_jsonpb.UnmarshalString(jsondata, msg) + if err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + if !p.Equal(msg) { + t.Fatalf("seed = %d, %#v !Json Equal %#v", seed, msg, p) + } +} +func TestStatsJSON(t *testing.T) { + seed := time.Now().UnixNano() + popr := math_rand.New(math_rand.NewSource(seed)) + p := NewPopulatedStats(popr, true) + marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{} + jsondata, err := marshaler.MarshalToString(p) + if err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + msg := &Stats{} + err = github_com_gogo_protobuf_jsonpb.UnmarshalString(jsondata, msg) + if err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + if !p.Equal(msg) { + t.Fatalf("seed = %d, %#v !Json Equal %#v", seed, msg, p) + } +} +func TestInitJSON(t *testing.T) { + seed := time.Now().UnixNano() + popr := math_rand.New(math_rand.NewSource(seed)) + p := NewPopulatedInit(popr, true) + marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{} + jsondata, err := marshaler.MarshalToString(p) + if err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + msg := &Init{} + err = github_com_gogo_protobuf_jsonpb.UnmarshalString(jsondata, msg) + if err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + if !p.Equal(msg) { + t.Fatalf("seed = %d, %#v !Json Equal %#v", seed, msg, p) + } +} +func TestBatchProtoText(t *testing.T) { + seed := time.Now().UnixNano() + popr := math_rand.New(math_rand.NewSource(seed)) + p := NewPopulatedBatch(popr, true) + dAtA := github_com_gogo_protobuf_proto.MarshalTextString(p) + msg := &Batch{} + if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + if !p.Equal(msg) { + t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) + } +} + +func TestBatchProtoCompactText(t *testing.T) { + seed := time.Now().UnixNano() + popr := math_rand.New(math_rand.NewSource(seed)) + p := NewPopulatedBatch(popr, true) + dAtA := github_com_gogo_protobuf_proto.CompactTextString(p) + msg := &Batch{} + if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + if !p.Equal(msg) { + t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) + } +} + +func TestOperationProtoText(t *testing.T) { + seed := time.Now().UnixNano() + popr := math_rand.New(math_rand.NewSource(seed)) + p := NewPopulatedOperation(popr, true) + dAtA := github_com_gogo_protobuf_proto.MarshalTextString(p) + msg := &Operation{} + if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + if !p.Equal(msg) { + t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) + } +} + +func TestOperationProtoCompactText(t *testing.T) { + seed := time.Now().UnixNano() + popr := math_rand.New(math_rand.NewSource(seed)) + p := NewPopulatedOperation(popr, true) + dAtA := github_com_gogo_protobuf_proto.CompactTextString(p) + msg := &Operation{} + if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + if !p.Equal(msg) { + t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) + } +} + +func TestEntityProtoText(t *testing.T) { + seed := time.Now().UnixNano() + popr := math_rand.New(math_rand.NewSource(seed)) + p := NewPopulatedEntity(popr, true) + dAtA := github_com_gogo_protobuf_proto.MarshalTextString(p) + msg := &Entity{} + if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + if !p.Equal(msg) { + t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) + } +} + +func TestEntityProtoCompactText(t *testing.T) { + seed := time.Now().UnixNano() + popr := math_rand.New(math_rand.NewSource(seed)) + p := NewPopulatedEntity(popr, true) + dAtA := github_com_gogo_protobuf_proto.CompactTextString(p) + msg := &Entity{} + if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + if !p.Equal(msg) { + t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) + } +} + +func TestNothingProtoText(t *testing.T) { + seed := time.Now().UnixNano() + popr := math_rand.New(math_rand.NewSource(seed)) + p := NewPopulatedNothing(popr, true) + dAtA := github_com_gogo_protobuf_proto.MarshalTextString(p) + msg := &Nothing{} + if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + if !p.Equal(msg) { + t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) + } +} + +func TestNothingProtoCompactText(t *testing.T) { + seed := time.Now().UnixNano() + popr := math_rand.New(math_rand.NewSource(seed)) + p := NewPopulatedNothing(popr, true) + dAtA := github_com_gogo_protobuf_proto.CompactTextString(p) + msg := &Nothing{} + if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + if !p.Equal(msg) { + t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) + } +} + +func TestDomainProtoText(t *testing.T) { + seed := time.Now().UnixNano() + popr := math_rand.New(math_rand.NewSource(seed)) + p := NewPopulatedDomain(popr, true) + dAtA := github_com_gogo_protobuf_proto.MarshalTextString(p) + msg := &Domain{} + if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + if !p.Equal(msg) { + t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) + } +} + +func TestDomainProtoCompactText(t *testing.T) { + seed := time.Now().UnixNano() + popr := math_rand.New(math_rand.NewSource(seed)) + p := NewPopulatedDomain(popr, true) + dAtA := github_com_gogo_protobuf_proto.CompactTextString(p) + msg := &Domain{} + if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + if !p.Equal(msg) { + t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) + } +} + +func TestIteratorProtoText(t *testing.T) { + seed := time.Now().UnixNano() + popr := math_rand.New(math_rand.NewSource(seed)) + p := NewPopulatedIterator(popr, true) + dAtA := github_com_gogo_protobuf_proto.MarshalTextString(p) + msg := &Iterator{} + if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + if !p.Equal(msg) { + t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) + } +} + +func TestIteratorProtoCompactText(t *testing.T) { + seed := time.Now().UnixNano() + popr := math_rand.New(math_rand.NewSource(seed)) + p := NewPopulatedIterator(popr, true) + dAtA := github_com_gogo_protobuf_proto.CompactTextString(p) + msg := &Iterator{} + if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + if !p.Equal(msg) { + t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) + } +} + +func TestStatsProtoText(t *testing.T) { + seed := time.Now().UnixNano() + popr := math_rand.New(math_rand.NewSource(seed)) + p := NewPopulatedStats(popr, true) + dAtA := github_com_gogo_protobuf_proto.MarshalTextString(p) + msg := &Stats{} + if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + if !p.Equal(msg) { + t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) + } +} + +func TestStatsProtoCompactText(t *testing.T) { + seed := time.Now().UnixNano() + popr := math_rand.New(math_rand.NewSource(seed)) + p := NewPopulatedStats(popr, true) + dAtA := github_com_gogo_protobuf_proto.CompactTextString(p) + msg := &Stats{} + if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + if !p.Equal(msg) { + t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) + } +} + +func TestInitProtoText(t *testing.T) { + seed := time.Now().UnixNano() + popr := math_rand.New(math_rand.NewSource(seed)) + p := NewPopulatedInit(popr, true) + dAtA := github_com_gogo_protobuf_proto.MarshalTextString(p) + msg := &Init{} + if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + if !p.Equal(msg) { + t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) + } +} + +func TestInitProtoCompactText(t *testing.T) { + seed := time.Now().UnixNano() + popr := math_rand.New(math_rand.NewSource(seed)) + p := NewPopulatedInit(popr, true) + dAtA := github_com_gogo_protobuf_proto.CompactTextString(p) + msg := &Init{} + if err := github_com_gogo_protobuf_proto.UnmarshalText(dAtA, msg); err != nil { + t.Fatalf("seed = %d, err = %v", seed, err) + } + if !p.Equal(msg) { + t.Fatalf("seed = %d, %#v !Proto %#v", seed, msg, p) + } +} + +//These tests are generated by github.com/gogo/protobuf/plugin/testgen From 015b217ed45b9d80bd0d5ee27015cad0b42061c2 Mon Sep 17 00:00:00 2001 From: Marko Baricevic Date: Thu, 12 Dec 2019 14:32:04 +0100 Subject: [PATCH 2/2] add changelog entry --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ffd054de..f3fe8034e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,8 @@ ### IMPROVEMENTS +- [remotedb] [\#34](https://github.com/tendermint/tm-db/pull/34) Add proto file tests and regenerate remotedb.pb.go + ## 0.3 **2019-11-18**