Skip to content

Commit b6f34f3

Browse files
committed
add mainnet upgrade tests
1 parent 02dc0cf commit b6f34f3

1 file changed

Lines changed: 68 additions & 0 deletions

File tree

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package v16_0_0_test
2+
3+
import (
4+
"testing"
5+
6+
"cosmossdk.io/log"
7+
"github.com/CosmWasm/wasmd/x/wasm"
8+
dbm "github.com/cosmos/cosmos-db"
9+
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
10+
ibctransfertypes "github.com/cosmos/ibc-go/v10/modules/apps/transfer/types"
11+
channeltypes "github.com/cosmos/ibc-go/v10/modules/core/04-channel/types"
12+
"github.com/persistenceOne/persistenceCore/v16/app/constants"
13+
v1600 "github.com/persistenceOne/persistenceCore/v16/app/upgrades/v16.0.0"
14+
"github.com/stretchr/testify/require"
15+
16+
"github.com/persistenceOne/persistenceCore/v16/app"
17+
)
18+
19+
func TestResetIBCTransferVersions(t *testing.T) {
20+
constants.SetConfig()
21+
testApp := app.NewApplication(log.NewNopLogger(), dbm.NewMemDB(), nil, true, simtestutil.NewAppOptionsWithFlagHome(t.TempDir()), []wasm.Option{})
22+
ctx := testApp.NewContext(true)
23+
24+
type args struct {
25+
portID string
26+
channelID string
27+
version string
28+
}
29+
tests := []struct {
30+
name string
31+
args args
32+
}{
33+
{
34+
name: "correct case",
35+
args: args{ibctransfertypes.PortID, "channel-0", ibctransfertypes.V1},
36+
},
37+
{
38+
name: "fee version should be converted to v1",
39+
args: args{ibctransfertypes.PortID, "channel-1", "{\"fee_version\":\"ics29-1\",\"app_version\":\"ics20-1\"}"},
40+
},
41+
{
42+
name: "random port ids should not be affected",
43+
args: args{"ica-controller-xxx", "channel-2", ibctransfertypes.V1},
44+
},
45+
{
46+
name: "random port ids should not be affected 2",
47+
args: args{"ica-controller-xxxyyy", "channel-3", "ibcfee-0,controller-1"},
48+
},
49+
}
50+
for _, tt := range tests {
51+
t.Run(tt.name, func(t *testing.T) {
52+
testApp.IBCKeeper.ChannelKeeper.SetChannel(ctx, tt.args.portID, tt.args.channelID, channeltypes.Channel{
53+
Version: tt.args.version,
54+
})
55+
err := v1600.ResetIBCTransferVersions(ctx, testApp.AppKeepers)
56+
require.NoError(t, err)
57+
channel, ok := testApp.IBCKeeper.ChannelKeeper.GetChannel(ctx, tt.args.portID, tt.args.channelID)
58+
require.True(t, ok)
59+
if tt.args.portID == ibctransfertypes.PortID {
60+
require.Equal(t, ibctransfertypes.V1, channel.Version)
61+
} else {
62+
require.Equal(t, tt.args.version, channel.Version)
63+
64+
}
65+
66+
})
67+
}
68+
}

0 commit comments

Comments
 (0)