Skip to content

Commit

Permalink
test: fails when using GRPC prior to upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
rootulp committed Apr 2, 2024
1 parent 24aefbf commit 82118d4
Showing 1 changed file with 16 additions and 22 deletions.
38 changes: 16 additions & 22 deletions app/test/ica_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
v2 "github.com/celestiaorg/celestia-app/pkg/appconsts/v2"
"github.com/celestiaorg/celestia-app/test/util"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/x/params/types/proposal"
icahosttypes "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/host/types"
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
Expand All @@ -31,42 +30,37 @@ func TestICA(t *testing.T) {
supportedVersions := []uint64{v1.Version, v2.Version}
require.Equal(t, supportedVersions, testApp.SupportedVersions())

ctx := testApp.NewContext(true, tmproto.Header{
Version: version.Consensus{
App: 1,
},
})
testApp.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{
Height: 2,
Version: version.Consensus{App: 1},
}})

// app version should not have changed yet
require.EqualValues(t, 1, testApp.AppVersion())

gotBefore, err := testApp.ParamsKeeper.Params(ctx, &proposal.QueryParamsRequest{
Subspace: icahosttypes.SubModuleName,
Key: string(icahosttypes.KeyHostEnabled),
})
require.Equal(t, "", gotBefore.Param.Value)
// Create the ICA host query client
conn, err := grpc.Dial(":9090", grpc.WithTransportCredentials(insecure.NewCredentials()))
require.NoError(t, err)
defer conn.Close()
icaClient := icahosttypes.NewQueryClient(conn)

// now the app version changes
// Query the ICA host params
goCtx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
paramsResp, err := icaClient.Params(goCtx, &icahosttypes.QueryParamsRequest{})
require.NoError(t, err)
require.Equal(t, true, paramsResp.Params.HostEnabled)
require.Len(t, paramsResp.Params.AllowMessages, 0)

// Upgrade from v1 -> v2
respEndBlock := testApp.EndBlock(abci.RequestEndBlock{Height: 2})
testApp.Commit()

require.NotNil(t, respEndBlock.ConsensusParamUpdates.Version)
require.EqualValues(t, 2, respEndBlock.ConsensusParamUpdates.Version.AppVersion)
require.EqualValues(t, 2, testApp.AppVersion())

conn, err := grpc.Dial(":9090", grpc.WithTransportCredentials(insecure.NewCredentials()))
require.NoError(t, err)
defer conn.Close()

icaClient := icahosttypes.NewQueryClient(conn)
goCtx, cancel := context.WithTimeout(context.Background(), time.Second)
// Query the ICA host params again
goCtx, cancel = context.WithTimeout(context.Background(), time.Second)
defer cancel()
paramsResp, err := icaClient.Params(goCtx, &icahosttypes.QueryParamsRequest{})
paramsResp, err = icaClient.Params(goCtx, &icahosttypes.QueryParamsRequest{})
require.NoError(t, err)
require.Equal(t, true, paramsResp.Params.HostEnabled)
require.Len(t, paramsResp.Params.AllowMessages, 12)
Expand Down

0 comments on commit 82118d4

Please sign in to comment.