Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 7fbbc76
Merge: e772dfb 095a076
Author: Marius Poke <[email protected]>
Date:   Fri Nov 25 12:04:15 2022 +0100

    Merge branch 'main' into marius/key-assignment

commit e772dfb
Author: mpoke <[email protected]>
Date:   Fri Nov 25 11:47:25 2022 +0100

    fix address conversion

commit 095a076
Author: Shawn Marshall-Spitzbart <[email protected]>
Date:   Wed Nov 23 11:12:48 2022 -0800

    Multi-consumer capable e2e tests (#475)

    * changes

    * mas

    * Update README.md

    * Update README.md

    * sorry for the friday night emails

    * Update instance_test.go

    * wip

    * wip

    * wip

    * wip

    * wip

    * wip

    * wip

    * wip

    * works

    * Update generic_setup.go

    * Update setup.go

    * smol

    * small

    * path to ccv chan setup

    * todos

    * Update setup.go

    * Create debug_test.go

    * democ

    * Update debug_test.go

    * setup all ccv channels

    * bump to main

    * another bump, missed one

    * fix after merge main

    * fixes

    * Update slashing.go

    * expired client tests

    * checks

    * fixed the stuff

    * smol

    * changes

    * updates

    * cleans

    * clean

    * todo

    * fixes

    * cleans

    * Update slashing.go

    * Update slashing.go

    Co-authored-by: Jehan <[email protected]>
  • Loading branch information
Daniel committed Nov 25, 2022
1 parent 438cc31 commit 73a1ad2
Show file tree
Hide file tree
Showing 11 changed files with 276 additions and 187 deletions.
2 changes: 1 addition & 1 deletion tests/e2e/channel_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (suite *CCVTestSuite) TestConsumerGenesis() {
_, ok = suite.consumerApp.GetIBCKeeper().ClientKeeper.GetClientState(ctx, clientId)
suite.Require().True(ok)

suite.SetupCCVChannel()
suite.SetupCCVChannel(suite.path)

origTime := suite.consumerChain.GetContext().BlockTime()

Expand Down
39 changes: 25 additions & 14 deletions tests/e2e/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,18 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/cosmos/interchain-security/testutil/e2e"
providertypes "github.com/cosmos/interchain-security/x/ccv/provider/types"
ccv "github.com/cosmos/interchain-security/x/ccv/types"
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"

clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types"
channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types"
commitmenttypes "github.com/cosmos/ibc-go/v3/modules/core/23-commitment/types"
"github.com/cosmos/ibc-go/v3/modules/core/exported"
ibctm "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types"
ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types"
ibctesting "github.com/cosmos/ibc-go/v3/testing"
"github.com/cosmos/interchain-security/testutil/e2e"
icstestingutils "github.com/cosmos/interchain-security/testutil/ibc_testing"
providertypes "github.com/cosmos/interchain-security/x/ccv/provider/types"
ccv "github.com/cosmos/interchain-security/x/ccv/types"
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
)

// ChainType defines the type of chain (either provider or consumer)
Expand All @@ -29,10 +28,16 @@ const (
Consumer
)

// firstConsumerBundle returns the bundle of the first consumer chain
func (s *CCVTestSuite) getFirstBundle() icstestingutils.ConsumerBundle {
return *s.consumerBundles[icstestingutils.FirstConsumerChainID]
}

func (s *CCVTestSuite) providerCtx() sdk.Context {
return s.providerChain.GetContext()
}

// consumerCtx returns the context of only the FIRST consumer chain
func (s *CCVTestSuite) consumerCtx() sdk.Context {
return s.consumerChain.GetContext()
}
Expand Down Expand Up @@ -199,6 +204,7 @@ func relayAllCommittedPackets(
// - get packets
packet, found := srcChain.GetSentPacket(commitment.Sequence, srcChannelID)
s.Require().True(found, "did not find sent packet")

// - relay the packet
err := path.RelayPacket(packet)
s.Require().NoError(err)
Expand Down Expand Up @@ -425,7 +431,7 @@ func (suite *CCVTestSuite) CreateCustomClient(endpoint *ibctesting.Endpoint, unb

height := endpoint.Counterparty.Chain.LastHeader.GetHeight().(clienttypes.Height)
UpgradePath := []string{"upgrade", "upgradedIBCState"}
clientState := ibctmtypes.NewClientState(
clientState := ibctm.NewClientState(
endpoint.Counterparty.Chain.ChainID, tmConfig.TrustLevel, tmConfig.TrustingPeriod, tmConfig.UnbondingPeriod, tmConfig.MaxClockDrift,
height, commitmenttypes.GetSDKSpecs(), UpgradePath, tmConfig.AllowUpdateAfterExpiry, tmConfig.AllowUpdateAfterMisbehaviour,
)
Expand All @@ -443,17 +449,22 @@ func (suite *CCVTestSuite) CreateCustomClient(endpoint *ibctesting.Endpoint, unb
require.NoError(endpoint.Chain.T, err)
}

func (suite *CCVTestSuite) GetConsumerEndpointClientAndConsState() (exported.ClientState, exported.ConsensusState) {
// GetConsumerEndpointClientAndConsState returns the client and consensus state
// for a particular consumer endpoint, as specified by the consumer's bundle.
func (suite *CCVTestSuite) GetConsumerEndpointClientAndConsState(
consumerBundle icstestingutils.ConsumerBundle) (exported.ClientState, exported.ConsensusState) {

ctx := consumerBundle.GetCtx()
consumerKeeper := consumerBundle.GetKeeper()

clientID, found := suite.consumerApp.GetConsumerKeeper().GetProviderClientID(suite.consumerCtx())
clientID, found := consumerKeeper.GetProviderClientID(ctx)
suite.Require().True(found)

clientState, found := suite.consumerApp.GetIBCKeeper().ClientKeeper.GetClientState(
suite.consumerCtx(), clientID)
clientState, found := consumerBundle.App.GetIBCKeeper().ClientKeeper.GetClientState(ctx, clientID)
suite.Require().True(found)

consState, found := suite.consumerApp.GetIBCKeeper().ClientKeeper.GetClientConsensusState(
suite.consumerCtx(), clientID, clientState.GetLatestHeight())
consState, found := consumerBundle.App.GetIBCKeeper().ClientKeeper.GetClientConsensusState(
ctx, clientID, clientState.GetLatestHeight())
suite.Require().True(found)

return clientState, consState
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/distribution.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
func (s *CCVTestSuite) TestRewardsDistribution() {

//set up channel and delegate some tokens in order for validator set update to be sent to the consumer chain
s.SetupCCVChannel()
s.SetupCCVChannel(s.path)
s.SetupTransferChannel()
bondAmt := sdk.NewInt(10000000)
delAddr := s.providerChain.SenderAccount.GetAddress()
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/expired_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
func (s *CCVTestSuite) TestVSCPacketSendExpiredClient() {
providerKeeper := s.providerApp.GetProviderKeeper()

s.SetupCCVChannel()
s.SetupCCVChannel(s.path)

expireClient(s, Consumer)

Expand Down Expand Up @@ -85,7 +85,7 @@ func (s *CCVTestSuite) TestConsumerPacketSendExpiredClient() {
providerKeeper := s.providerApp.GetProviderKeeper()
consumerKeeper := s.consumerApp.GetConsumerKeeper()

s.SetupCCVChannel()
s.SetupCCVChannel(s.path)

// bond some tokens on provider to change validator powers
bondAmt := sdk.NewInt(1000000)
Expand Down
Loading

0 comments on commit 73a1ad2

Please sign in to comment.