Skip to content

Commit 0e44463

Browse files
authored
chore: prepare v1.4.12 (#116)
1 parent 07294c8 commit 0e44463

6 files changed

Lines changed: 131 additions & 77 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22

33
## Unreleased
44

5+
## [v1.4.12](https://github.com/cosmos/gogoproto/releases/tag/v1.4.12) - 2024-03-20
6+
7+
### Improvements
8+
59
- [#115](https://github.com/cosmos/gogoproto/pull/115) Move any type from `cosmos-sdk/codec/types` to `types/any`.
610

7-
## [v1.4.11](https://github.com/cosmos/gogoproto/releases/tag/v1.4.10) - 2023-05-11
11+
## [v1.4.11](https://github.com/cosmos/gogoproto/releases/tag/v1.4.11) - 2023-08-18
812

913
### Improvements
1014

go.mod

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ module github.com/cosmos/gogoproto
33
go 1.19
44

55
require (
6+
github.com/golang/protobuf v1.5.3
67
github.com/google/go-cmp v0.6.0
7-
github.com/stretchr/testify v1.8.4
88
github.com/tendermint/go-amino v0.16.0
99
golang.org/x/exp v0.0.0-20231006140011-7918f672742d
1010
google.golang.org/grpc v1.61.1
@@ -13,17 +13,12 @@ require (
1313

1414
require (
1515
github.com/davecgh/go-spew v1.1.1 // indirect
16-
github.com/golang/protobuf v1.5.3 // indirect
1716
github.com/google/gofuzz v1.2.0 // indirect
18-
github.com/kr/pretty v0.3.1 // indirect
19-
github.com/pmezard/go-difflib v1.0.0 // indirect
20-
github.com/rogpeppe/go-internal v1.11.0 // indirect
17+
github.com/stretchr/testify v1.8.4 // indirect
2118
golang.org/x/net v0.20.0 // indirect
2219
golang.org/x/sys v0.16.0 // indirect
2320
golang.org/x/text v0.14.0 // indirect
2421
google.golang.org/genproto/googleapis/rpc v0.0.0-20231212172506-995d672761c0 // indirect
25-
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
26-
gopkg.in/yaml.v3 v3.0.1 // indirect
2722
)
2823

2924
// API changed in an incompatible way

go.sum

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
21
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
32
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
43
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -12,19 +11,8 @@ github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN
1211
github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI=
1312
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
1413
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
15-
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
16-
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
17-
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
18-
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
19-
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
20-
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
21-
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
22-
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
2314
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
2415
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
25-
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
26-
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
27-
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
2816
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
2917
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
3018
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
@@ -52,8 +40,4 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0
5240
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
5341
google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
5442
google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
55-
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
56-
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
57-
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
5843
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
59-
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

types/any/any_with_cache.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
fmt "fmt"
66

77
"github.com/cosmos/gogoproto/proto"
8+
"github.com/cosmos/gogoproto/types/any/internal"
89
protov2 "google.golang.org/protobuf/proto"
910
)
1011

@@ -75,7 +76,7 @@ func NewAnyWithCacheWithValue(v proto.Message) (*Any, error) {
7576
}
7677

7778
return &Any{
78-
TypeUrl: MsgTypeURL(v),
79+
TypeUrl: internal.MsgTypeURL(v),
7980
Value: bz,
8081
cachedValue: v,
8182
}, nil
@@ -100,7 +101,7 @@ func UnsafePackAnyWithCache(x interface{}) *Any {
100101
// the packed value so that it can be retrieved from GetCachedValue without
101102
// unmarshalling
102103
func (any *Any) pack(x proto.Message) error {
103-
any.TypeUrl = MsgTypeURL(x)
104+
any.TypeUrl = internal.MsgTypeURL(x)
104105

105106
var (
106107
bz []byte
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package types
1+
package internal
22

33
import (
44
"github.com/cosmos/gogoproto/proto"

types/any/test/compat_test.go

Lines changed: 120 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package test
22

33
import (
4-
types "github.com/cosmos/gogoproto/types/any"
5-
4+
"bytes"
65
"testing"
76

8-
"github.com/stretchr/testify/suite"
7+
types "github.com/cosmos/gogoproto/types/any"
8+
"github.com/google/go-cmp/cmp"
99
amino "github.com/tendermint/go-amino"
1010
)
1111

@@ -14,118 +14,188 @@ type TypeWithInterface struct {
1414
X int64 `json:"x,omitempty"`
1515
}
1616

17-
type Suite struct {
18-
suite.Suite
17+
type testFixture struct {
1918
cdc *amino.Codec
2019
a TypeWithInterface
2120
b HasAnimal
2221
spot *Dog
2322
}
2423

25-
func (s *Suite) SetupTest() {
26-
s.cdc = amino.NewCodec()
27-
s.cdc.RegisterInterface((*Animal)(nil), nil)
28-
s.cdc.RegisterConcrete(&Dog{}, "test/Dog", nil)
24+
func newTestFixture(t *testing.T) *testFixture {
25+
t.Helper()
26+
27+
cdc := amino.NewCodec()
28+
cdc.RegisterInterface((*Animal)(nil), nil)
29+
cdc.RegisterConcrete(&Dog{}, "test/Dog", nil)
2930

30-
s.spot = &Dog{Size_: "small", Name: "Spot"}
31-
s.a = TypeWithInterface{Animal: s.spot}
31+
spot := &Dog{Size_: "small", Name: "Spot"}
32+
a := TypeWithInterface{Animal: spot}
3233

33-
any, err := types.NewAnyWithCacheWithValue(s.spot)
34-
s.Require().NoError(err)
35-
s.b = HasAnimal{Animal: any}
34+
any, err := types.NewAnyWithCacheWithValue(spot)
35+
if err != nil {
36+
t.Fatal(err)
37+
}
38+
39+
b := HasAnimal{Animal: any}
40+
41+
return &testFixture{
42+
cdc: cdc,
43+
a: a,
44+
b: b,
45+
spot: spot,
46+
}
3647
}
3748

38-
func (s *Suite) TestAminoBinary() {
49+
func TestAminoBinary(t *testing.T) {
50+
s := newTestFixture(t)
51+
3952
bz, err := s.cdc.MarshalBinaryBare(s.a)
40-
s.Require().NoError(err)
53+
if err != nil {
54+
t.Fatal(err)
55+
}
4156

4257
// expect plain amino marshal to fail
4358
_, err = s.cdc.MarshalBinaryBare(s.b)
44-
s.Require().Error(err)
59+
if err == nil {
60+
t.Fatal("expected error")
61+
}
4562

4663
// expect unpack interfaces before amino marshal to succeed
4764
err = types.UnpackInterfaces(s.b, types.AminoPacker{Cdc: s.cdc})
48-
s.Require().NoError(err)
65+
if err != nil {
66+
t.Fatal(err)
67+
}
4968
bz2, err := s.cdc.MarshalBinaryBare(s.b)
50-
s.Require().NoError(err)
51-
s.Require().Equal(bz, bz2)
69+
if err != nil {
70+
t.Fatal(err)
71+
}
72+
if !bytes.Equal(bz, bz2) {
73+
t.Fatalf("expected %X, got %X", bz, bz2)
74+
}
5275

5376
var c HasAnimal
5477
err = s.cdc.UnmarshalBinaryBare(bz, &c)
55-
s.Require().NoError(err)
78+
if err != nil {
79+
t.Fatal(err)
80+
}
5681
err = types.UnpackInterfaces(c, types.AminoUnpacker{Cdc: s.cdc})
57-
s.Require().NoError(err)
58-
s.Require().Equal(s.spot, c.Animal.GetCachedValue())
82+
if err != nil {
83+
t.Fatal(err)
84+
}
85+
86+
if result := cmp.Diff(s.spot, c.Animal.GetCachedValue()); result != "" {
87+
t.Fatalf("expected %v, got %v: %v", s.spot, c.Animal.GetCachedValue(), result)
88+
}
5989
}
6090

61-
func (s *Suite) TestAminoJSON() {
91+
func TestAminoJSON(t *testing.T) {
92+
s := newTestFixture(t)
93+
6294
bz, err := s.cdc.MarshalJSON(s.a)
63-
s.Require().NoError(err)
95+
if err != nil {
96+
t.Fatal(err)
97+
}
6498

6599
// expect plain amino marshal to fail
66100
_, err = s.cdc.MarshalJSON(s.b)
67-
s.Require().Error(err)
68-
101+
if err == nil {
102+
t.Fatal("expected error")
103+
}
69104
// expect unpack interfaces before amino marshal to succeed
70105
err = types.UnpackInterfaces(s.b, types.AminoJSONPacker{Cdc: s.cdc})
71-
s.Require().NoError(err)
106+
if err != nil {
107+
t.Fatal(err)
108+
}
72109
bz2, err := s.cdc.MarshalJSON(s.b)
73-
s.Require().NoError(err)
74-
s.Require().Equal(string(bz), string(bz2))
110+
if err != nil {
111+
t.Fatal(err)
112+
}
113+
if !bytes.Equal(bz, bz2) {
114+
t.Fatalf("expected %X, got %X", bz, bz2)
115+
}
75116

76117
var c HasAnimal
77118
err = s.cdc.UnmarshalJSON(bz, &c)
78-
s.Require().NoError(err)
119+
if err != nil {
120+
t.Fatal(err)
121+
}
79122
err = types.UnpackInterfaces(c, types.AminoJSONUnpacker{Cdc: s.cdc})
80-
s.Require().NoError(err)
81-
s.Require().Equal(s.spot, c.Animal.GetCachedValue())
123+
if err != nil {
124+
t.Fatal(err)
125+
}
126+
127+
if result := cmp.Diff(s.spot, c.Animal.GetCachedValue()); result != "" {
128+
t.Fatalf("expected %v, got %v: %v", s.spot, c.Animal.GetCachedValue(), result)
129+
}
82130
}
83131

84-
func (s *Suite) TestNested() {
132+
func TestNested(t *testing.T) {
133+
s := newTestFixture(t)
134+
85135
s.cdc.RegisterInterface((*HasAnimalI)(nil), nil)
86136
s.cdc.RegisterInterface((*HasHasAnimalI)(nil), nil)
87137
s.cdc.RegisterConcrete(&HasAnimal{}, "test/HasAnimal", nil)
88138
s.cdc.RegisterConcrete(&HasHasAnimal{}, "test/HasHasAnimal", nil)
89139
s.cdc.RegisterConcrete(&HasHasHasAnimal{}, "test/HasHasHasAnimal", nil)
90140

91141
any, err := types.NewAnyWithCacheWithValue(&s.b)
92-
s.Require().NoError(err)
142+
if err != nil {
143+
t.Fatal(err)
144+
}
93145
hha := HasHasAnimal{HasAnimal: any}
94146
any2, err := types.NewAnyWithCacheWithValue(&hha)
95-
s.Require().NoError(err)
147+
if err != nil {
148+
t.Fatal(err)
149+
}
96150
hhha := HasHasHasAnimal{HasHasAnimal: any2}
97151

98152
// marshal
99153
err = types.UnpackInterfaces(hhha, types.AminoPacker{Cdc: s.cdc})
100-
s.Require().NoError(err)
154+
if err != nil {
155+
t.Fatal(err)
156+
}
101157
bz, err := s.cdc.MarshalBinaryBare(hhha)
102-
s.Require().NoError(err)
158+
if err != nil {
159+
t.Fatal(err)
160+
}
103161

104162
// unmarshal
105163
var hhha2 HasHasHasAnimal
106164
err = s.cdc.UnmarshalBinaryBare(bz, &hhha2)
107-
s.Require().NoError(err)
165+
if err != nil {
166+
t.Fatal(err)
167+
}
108168
err = types.UnpackInterfaces(hhha2, types.AminoUnpacker{Cdc: s.cdc})
109-
s.Require().NoError(err)
169+
if err != nil {
170+
t.Fatal(err)
171+
}
110172

111-
s.Require().Equal(s.spot, hhha2.TheHasHasAnimal().TheHasAnimal().TheAnimal())
173+
if result := cmp.Diff(hhha2.TheHasHasAnimal().TheHasAnimal().TheAnimal(), s.spot); result != "" {
174+
t.Fatalf("expected %v, got %v: %v", s.spot, hhha2.TheHasHasAnimal().TheHasAnimal().TheAnimal(), result)
175+
}
112176

113177
// json marshal
114178
err = types.UnpackInterfaces(hhha, types.AminoJSONPacker{Cdc: s.cdc})
115-
s.Require().NoError(err)
179+
if err != nil {
180+
t.Fatal(err)
181+
}
116182
jsonBz, err := s.cdc.MarshalJSON(hhha)
117-
s.Require().NoError(err)
183+
if err != nil {
184+
t.Fatal(err)
185+
}
118186

119187
// json unmarshal
120188
var hhha3 HasHasHasAnimal
121189
err = s.cdc.UnmarshalJSON(jsonBz, &hhha3)
122-
s.Require().NoError(err)
190+
if err != nil {
191+
t.Fatal(err)
192+
}
123193
err = types.UnpackInterfaces(hhha3, types.AminoJSONUnpacker{Cdc: s.cdc})
124-
s.Require().NoError(err)
125-
126-
s.Require().Equal(s.spot, hhha3.TheHasHasAnimal().TheHasAnimal().TheAnimal())
127-
}
194+
if err != nil {
195+
t.Fatal(err)
196+
}
128197

129-
func TestSuite(t *testing.T) {
130-
suite.Run(t, &Suite{})
198+
if result := cmp.Diff(hhha3.TheHasHasAnimal().TheHasAnimal().TheAnimal(), s.spot); result != "" {
199+
t.Fatalf("expected %v, got %v: %v", s.spot, hhha3.TheHasHasAnimal().TheHasAnimal().TheAnimal(), result)
200+
}
131201
}

0 commit comments

Comments
 (0)