-
Notifications
You must be signed in to change notification settings - Fork 0
/
values_test.go
41 lines (32 loc) · 1.1 KB
/
values_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package collections
import (
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
"testing"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
"github.com/gogo/protobuf/types"
)
func TestProtoValueEncoder(t *testing.T) {
t.Run("bijectivity", func(t *testing.T) {
protoType := types.BytesValue{Value: []byte("testing")}
registry := testdata.NewTestInterfaceRegistry()
cdc := codec.NewProtoCodec(registry)
assertValueBijective[types.BytesValue](t, ProtoValueEncoder[types.BytesValue](cdc), protoType)
})
}
func TestDecValueEncoder(t *testing.T) {
t.Run("bijectivity", func(t *testing.T) {
assertValueBijective(t, DecValueEncoder, sdk.MustNewDecFromStr("-1000.5858"))
})
}
func TestAccAddressValueEncoder(t *testing.T) {
t.Run("bijectivity", func(t *testing.T) {
assertValueBijective(t, AccAddressValueEncoder, sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()))
})
}
func TestUint64ValueEncoder(t *testing.T) {
t.Run("bijectivity", func(t *testing.T) {
assertValueBijective(t, Uint64ValueEncoder, 1000)
})
}