Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-consumer capable e2e tests #475

Merged
merged 59 commits into from
Nov 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
0475032
changes
shaspitz Nov 11, 2022
3af89d1
Merge branch 'main' into testutil-refactor
shaspitz Nov 11, 2022
8a55b0a
mas
shaspitz Nov 11, 2022
b83d8cb
Update README.md
shaspitz Nov 11, 2022
3c5c817
Update README.md
shaspitz Nov 12, 2022
69596b6
sorry for the friday night emails
shaspitz Nov 12, 2022
e7cde9e
Update instance_test.go
shaspitz Nov 12, 2022
71bf63b
wip
shaspitz Nov 12, 2022
0b924ac
wip
shaspitz Nov 15, 2022
226aa95
wip
shaspitz Nov 15, 2022
5f6952e
wip
shaspitz Nov 15, 2022
b64fece
wip
shaspitz Nov 15, 2022
bc577e0
wip
shaspitz Nov 15, 2022
48a8772
wip
shaspitz Nov 15, 2022
a4b755b
wip
shaspitz Nov 15, 2022
9f45d14
works
shaspitz Nov 15, 2022
b51510d
Update generic_setup.go
shaspitz Nov 15, 2022
8dca707
Merge branch 'main' into e2e-multiple-consumers
shaspitz Nov 15, 2022
7dcce36
Update setup.go
shaspitz Nov 15, 2022
ec469f1
smol
shaspitz Nov 15, 2022
dd8983d
small
shaspitz Nov 15, 2022
714be77
path to ccv chan setup
shaspitz Nov 15, 2022
49b45f2
todos
shaspitz Nov 15, 2022
df45b72
Update setup.go
shaspitz Nov 15, 2022
5db64cb
Merge branch 'main' into e2e-multiple-consumers
shaspitz Nov 16, 2022
d4c8df1
Create debug_test.go
shaspitz Nov 16, 2022
e89d605
democ
shaspitz Nov 17, 2022
bcc911b
Update debug_test.go
shaspitz Nov 17, 2022
8b85c90
Merge branch 'main' into debug-file
shaspitz Nov 17, 2022
02933c6
Merge branch 'debug-file' into e2e-multiple-consumers
shaspitz Nov 17, 2022
6d078c9
Merge branch 'main' into debug-file
shaspitz Nov 17, 2022
0c1e582
setup all ccv channels
shaspitz Nov 18, 2022
e771e00
Merge branch 'main' into debug-file
shaspitz Nov 18, 2022
3feffc3
bump to main
shaspitz Nov 18, 2022
5820981
another bump, missed one
shaspitz Nov 18, 2022
869a0fa
Merge branch 'main' into debug-file
jtremback Nov 18, 2022
fb6f948
Merge branch 'main' into debug-file
shaspitz Nov 18, 2022
d78b599
fix after merge main
shaspitz Nov 18, 2022
19669d4
Merge branch 'debug-file' into e2e-multiple-consumers
shaspitz Nov 18, 2022
91d5203
fixes
shaspitz Nov 18, 2022
631fbf9
Update slashing.go
shaspitz Nov 18, 2022
97eb82e
expired client tests
shaspitz Nov 18, 2022
741f387
Merge branch 'debug-file' into e2e-multiple-consumers
shaspitz Nov 18, 2022
3a384fd
checks
shaspitz Nov 18, 2022
04cee6a
fixed the stuff
shaspitz Nov 19, 2022
a55fd94
smol
shaspitz Nov 19, 2022
36b78fb
changes
shaspitz Nov 21, 2022
c476872
Merge branch 'mapped-sent-packets-fix' into e2e-multiple-consumers
shaspitz Nov 21, 2022
aba6ccc
updates
shaspitz Nov 21, 2022
1598b5b
cleans
shaspitz Nov 21, 2022
7d2e39a
clean
shaspitz Nov 21, 2022
71463e0
todo
shaspitz Nov 21, 2022
c1a9926
fixes
shaspitz Nov 21, 2022
9587b4c
cleans
shaspitz Nov 21, 2022
3b81eb2
Update slashing.go
shaspitz Nov 21, 2022
7c85833
Update slashing.go
shaspitz Nov 21, 2022
68cfe9f
Merge branch 'main' into e2e-multiple-consumers
shaspitz Nov 22, 2022
9f2236f
Merge branch 'main' into e2e-multiple-consumers
shaspitz Nov 22, 2022
1010813
Merge branch 'main' into e2e-multiple-consumers
shaspitz Nov 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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