forked from cosmos/ibc-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecoder_test.go
More file actions
64 lines (57 loc) · 1.61 KB
/
decoder_test.go
File metadata and controls
64 lines (57 loc) · 1.61 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package simulation_test
import (
"fmt"
"testing"
"github.com/cosmos/cosmos-sdk/types/kv"
"github.com/stretchr/testify/require"
"github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/simulation"
"github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/types"
ibctesting "github.com/cosmos/ibc-go/v6/testing"
)
func TestDecodeStore(t *testing.T) {
var (
owner = "owner"
channelID = ibctesting.FirstChannelID
)
dec := simulation.NewDecodeStore()
kvPairs := kv.Pairs{
Pairs: []kv.Pair{
{
Key: []byte(types.PortKeyPrefix),
Value: []byte(types.HostPortID),
},
{
Key: []byte(types.OwnerKeyPrefix),
Value: []byte("owner"),
},
{
Key: []byte(types.ActiveChannelKeyPrefix),
Value: []byte("channel-0"),
},
{
Key: []byte(types.IsMiddlewareEnabledPrefix),
Value: []byte("false"),
},
},
}
tests := []struct {
name string
expectedLog string
}{
{"PortID", fmt.Sprintf("Port A: %s\nPort B: %s", types.HostPortID, types.HostPortID)},
{"Owner", fmt.Sprintf("Owner A: %s\nOwner B: %s", owner, owner)},
{"ActiveChannel", fmt.Sprintf("ActiveChannel A: %s\nActiveChannel B: %s", channelID, channelID)},
{"IsMiddlewareEnabled", fmt.Sprintf("IsMiddlewareEnabled A: %s\nIsMiddlewareEnabled B: %s", "false", "false")},
{"other", ""},
}
for i, tt := range tests {
i, tt := i, tt
t.Run(tt.name, func(t *testing.T) {
if i == len(tests)-1 {
require.Panics(t, func() { dec(kvPairs.Pairs[i], kvPairs.Pairs[i]) }, tt.name)
} else {
require.Equal(t, tt.expectedLog, dec(kvPairs.Pairs[i], kvPairs.Pairs[i]), tt.name)
}
})
}
}