From 04750321105dac5d71406f8673ef9b0c28d2d6fb Mon Sep 17 00:00:00 2001 From: Shawn Marshall-Spitzbart <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Fri, 11 Nov 2022 09:50:06 -0800 Subject: [PATCH 1/7] changes --- .../proposals_whitelisting_test.go | 5 +- tests/difference/core/driver/setup.go | 11 ++- tests/e2e/instance_test.go | 19 +++-- testutil/ibc_testing/setup.go | 74 +++++++++++++++++ testutil/sample/sample.go | 13 --- testutil/simapp/simapp.go | 79 ------------------- 6 files changed, 96 insertions(+), 105 deletions(-) create mode 100644 testutil/ibc_testing/setup.go delete mode 100644 testutil/sample/sample.go delete mode 100644 testutil/simapp/simapp.go diff --git a/app/consumer-democracy/proposals_whitelisting_test.go b/app/consumer-democracy/proposals_whitelisting_test.go index a83fb686b5..45cd9496f7 100644 --- a/app/consumer-democracy/proposals_whitelisting_test.go +++ b/app/consumer-democracy/proposals_whitelisting_test.go @@ -5,12 +5,13 @@ import ( ibctesting "github.com/cosmos/ibc-go/v3/testing" appConsumer "github.com/cosmos/interchain-security/app/consumer-democracy" - simapp "github.com/cosmos/interchain-security/testutil/simapp" + ibctestingutils "github.com/cosmos/interchain-security/testutil/ibc_testing" "github.com/stretchr/testify/require" ) func TestDemocracyGovernanceWhitelistingKeys(t *testing.T) { - chain := ibctesting.NewTestChain(t, simapp.NewBasicCoordinator(t), simapp.SetupTestingAppConsumerDemocracy, "test") + chain := ibctesting.NewTestChain(t, ibctesting.NewCoordinator(t, 0), + ibctestingutils.DemocracyConsumerAppIniter, "test") paramKeeper := chain.App.(*appConsumer.App).ParamsKeeper for paramKey := range appConsumer.WhitelistedParams { ss, ok := paramKeeper.GetSubspace(paramKey.Subspace) diff --git a/tests/difference/core/driver/setup.go b/tests/difference/core/driver/setup.go index d3becc2912..3d7ed54102 100644 --- a/tests/difference/core/driver/setup.go +++ b/tests/difference/core/driver/setup.go @@ -10,7 +10,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - "github.com/cosmos/interchain-security/x/ccv/types" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" abci "github.com/tendermint/tendermint/abci/types" @@ -23,7 +22,6 @@ import ( cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - simapp "github.com/cosmos/interchain-security/testutil/simapp" cryptoEd25519 "crypto/ed25519" @@ -39,6 +37,7 @@ import ( stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" appConsumer "github.com/cosmos/interchain-security/app/consumer" appProvider "github.com/cosmos/interchain-security/app/provider" + ibctestingutils "github.com/cosmos/interchain-security/testutil/ibc_testing" simibc "github.com/cosmos/interchain-security/testutil/simibc" consumerkeeper "github.com/cosmos/interchain-security/x/ccv/consumer/keeper" consumertypes "github.com/cosmos/interchain-security/x/ccv/consumer/types" @@ -337,14 +336,14 @@ func (b *Builder) createValidators() (*tmtypes.ValidatorSet, map[string]tmtypes. func (b *Builder) createChains() { - coordinator := simapp.NewBasicCoordinator(b.suite.T()) + coordinator := ibctesting.NewCoordinator(b.suite.T(), 0) // Create validators validators, signers, addresses := b.createValidators() // Create provider - coordinator.Chains[ibctesting.GetChainID(0)] = b.newChain(coordinator, simapp.SetupTestingappProvider, ibctesting.GetChainID(0), validators, signers) + coordinator.Chains[ibctesting.GetChainID(0)] = b.newChain(coordinator, ibctestingutils.ProviderAppIniter, ibctesting.GetChainID(0), validators, signers) // Create consumer, using the same validators. - coordinator.Chains[ibctesting.GetChainID(1)] = b.newChain(coordinator, simapp.SetupTestingAppConsumer, ibctesting.GetChainID(1), validators, signers) + coordinator.Chains[ibctesting.GetChainID(1)] = b.newChain(coordinator, ibctestingutils.ConsumerAppIniter, ibctesting.GetChainID(1), validators, signers) b.coordinator = coordinator b.valAddresses = addresses @@ -539,7 +538,7 @@ func (b *Builder) sendEmptyVSCPacketToFinishHandshake() { timeout := uint64(b.chain(P).CurrentHeader.Time.Add(ccv.DefaultCCVTimeoutPeriod).UnixNano()) - pd := types.NewValidatorSetChangePacketData( + pd := ccv.NewValidatorSetChangePacketData( []abci.ValidatorUpdate{}, vscID, nil, diff --git a/tests/e2e/instance_test.go b/tests/e2e/instance_test.go index 4c6a47c39a..eb71a1ea3e 100644 --- a/tests/e2e/instance_test.go +++ b/tests/e2e/instance_test.go @@ -9,7 +9,7 @@ import ( appProvider "github.com/cosmos/interchain-security/app/provider" "github.com/cosmos/interchain-security/tests/e2e" e2etestutil "github.com/cosmos/interchain-security/testutil/e2e" - "github.com/cosmos/interchain-security/testutil/simapp" + ibctestingutils "github.com/cosmos/interchain-security/testutil/ibc_testing" "github.com/stretchr/testify/suite" ) @@ -30,10 +30,13 @@ func TestCCVTestSuite(t *testing.T) { e2etestutil.ProviderApp, e2etestutil.ConsumerApp, ) { + coordinator, provider := ibctestingutils.NewCoordinatorWithProvider(t) + consumers := ibctestingutils.AddConsumersToCoordinator(coordinator, t, 1, ibctestingutils.ConsumerAppIniter) + consumer := consumers[0] // Here we pass the concrete types that must implement the necessary interfaces // to be ran with e2e tests. - coord, prov, cons := simapp.NewProviderConsumerCoordinator(t) - return coord, prov, cons, prov.App.(*appProvider.App), cons.App.(*appConsumer.App) + // TODO: Allow e2e tests to accept multiple consumers + return coordinator, provider, consumers[0], provider.App.(*appProvider.App), consumer.App.(*appConsumer.App) }, ) suite.Run(t, ccvSuite) @@ -49,10 +52,16 @@ func TestConsumerDemocracyTestSuite(t *testing.T) { *ibctesting.TestChain, e2etestutil.DemocConsumerApp, ) { + coordinator := ibctesting.NewCoordinator(t, 0) + chainID := ibctesting.GetChainID(2) + + democracyConsumer := ibctesting.NewTestChain(t, coordinator, + ibctestingutils.DemocracyConsumerAppIniter, chainID) + + coordinator.Chains[chainID] = democracyConsumer // Here we pass the concrete types that must implement the necessary interfaces // to be ran with e2e tests. - coord, _, cons := simapp.NewProviderConsumerDemocracyCoordinator(t) - return coord, cons, cons.App.(*appConsumerDemocracy.App) + return coordinator, democracyConsumer, democracyConsumer.App.(*appConsumerDemocracy.App) }, ) suite.Run(t, democSuite) diff --git a/testutil/ibc_testing/setup.go b/testutil/ibc_testing/setup.go new file mode 100644 index 0000000000..ed9bcc8141 --- /dev/null +++ b/testutil/ibc_testing/setup.go @@ -0,0 +1,74 @@ +package ibc_testing + +// Contains util functions for using the IBC testing package with CCV. + +import ( + "encoding/json" + "testing" + + "github.com/cosmos/cosmos-sdk/simapp" + + ibctesting "github.com/cosmos/ibc-go/v3/testing" + + "github.com/tendermint/spm/cosmoscmd" + "github.com/tendermint/tendermint/libs/log" + tmdb "github.com/tendermint/tm-db" + + appConsumer "github.com/cosmos/interchain-security/app/consumer" + appConsumerDemocracy "github.com/cosmos/interchain-security/app/consumer-democracy" + appProvider "github.com/cosmos/interchain-security/app/provider" +) + +var ( + provChainID = ibctesting.GetChainID(1) +) + +// ProviderAppIniter implements ibctesting.AppIniter for a provider app +func ProviderAppIniter() (ibctesting.TestingApp, map[string]json.RawMessage) { + encoding := cosmoscmd.MakeEncodingConfig(appProvider.ModuleBasics) + testApp := appProvider.New(log.NewNopLogger(), tmdb.NewMemDB(), nil, true, map[int64]bool{}, + simapp.DefaultNodeHome, 5, encoding, simapp.EmptyAppOptions{}).(ibctesting.TestingApp) + return testApp, appProvider.NewDefaultGenesisState(encoding.Marshaler) +} + +// ConsumerAppIniter implements ibctesting.AppIniter for a consumer app +func ConsumerAppIniter() (ibctesting.TestingApp, map[string]json.RawMessage) { + encoding := cosmoscmd.MakeEncodingConfig(appConsumer.ModuleBasics) + testApp := appConsumer.New(log.NewNopLogger(), tmdb.NewMemDB(), nil, true, map[int64]bool{}, + simapp.DefaultNodeHome, 5, encoding, simapp.EmptyAppOptions{}).(ibctesting.TestingApp) + return testApp, appConsumer.NewDefaultGenesisState(encoding.Marshaler) +} + +// DemocracyConsumerAppIniter implements ibctesting.AppIniter for a democracy consumer app +func DemocracyConsumerAppIniter() (ibctesting.TestingApp, map[string]json.RawMessage) { + encoding := cosmoscmd.MakeEncodingConfig(appConsumerDemocracy.ModuleBasics) + testApp := appConsumerDemocracy.New(log.NewNopLogger(), tmdb.NewMemDB(), nil, true, map[int64]bool{}, + simapp.DefaultNodeHome, 5, encoding, simapp.EmptyAppOptions{}).(ibctesting.TestingApp) + return testApp, appConsumerDemocracy.NewDefaultGenesisState(encoding.Marshaler) +} + +// NewCoordinatorWithProvider initializes an IBC testing Coordinator with a properly setup provider +func NewCoordinatorWithProvider(t *testing.T) (*ibctesting.Coordinator, *ibctesting.TestChain) { + coordinator := ibctesting.NewCoordinator(t, 0) + provider := ibctesting.NewTestChain(t, coordinator, ProviderAppIniter, provChainID) + coordinator.Chains[provChainID] = provider + return coordinator, provider +} + +func AddConsumersToCoordinator(coordinator *ibctesting.Coordinator, + t *testing.T, numConsumers int, appIniter ibctesting.AppIniter) (consumers []*ibctesting.TestChain) { + + providerChain := coordinator.GetChain(provChainID) + + // Instantiate specified number of consumers, add them to the coordinator and returned slice + for i := 0; i < numConsumers; i++ { + chainID := ibctesting.GetChainID(i + 2) + testChain := ibctesting.NewTestChainWithValSet(t, coordinator, + appIniter, chainID, providerChain.Vals, providerChain.Signers) + + coordinator.Chains[chainID] = testChain + consumers = append(consumers, testChain) + } + + return consumers +} diff --git a/testutil/sample/sample.go b/testutil/sample/sample.go deleted file mode 100644 index 98f2153ed4..0000000000 --- a/testutil/sample/sample.go +++ /dev/null @@ -1,13 +0,0 @@ -package sample - -import ( - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// AccAddress returns a sample account address -func AccAddress() string { - pk := ed25519.GenPrivKey().PubKey() - addr := pk.Address() - return sdk.AccAddress(addr).String() -} diff --git a/testutil/simapp/simapp.go b/testutil/simapp/simapp.go deleted file mode 100644 index cd76500be6..0000000000 --- a/testutil/simapp/simapp.go +++ /dev/null @@ -1,79 +0,0 @@ -package simapp - -import ( - "encoding/json" - "testing" - - "github.com/cosmos/cosmos-sdk/simapp" - - ibctesting "github.com/cosmos/ibc-go/v3/testing" - - "github.com/tendermint/spm/cosmoscmd" - "github.com/tendermint/tendermint/libs/log" - tmdb "github.com/tendermint/tm-db" - - appConsumer "github.com/cosmos/interchain-security/app/consumer" - appConsumerDemocracy "github.com/cosmos/interchain-security/app/consumer-democracy" - appProvider "github.com/cosmos/interchain-security/app/provider" -) - -func SetupTestingappProvider() (ibctesting.TestingApp, map[string]json.RawMessage) { - db := tmdb.NewMemDB() - // encCdc := app.MakeTestEncodingConfig() - encoding := cosmoscmd.MakeEncodingConfig(appProvider.ModuleBasics) - testApp := appProvider.New(log.NewNopLogger(), db, nil, true, map[int64]bool{}, simapp.DefaultNodeHome, 5, encoding, simapp.EmptyAppOptions{}).(ibctesting.TestingApp) - return testApp, appProvider.NewDefaultGenesisState(encoding.Marshaler) -} - -func SetupTestingAppConsumerDemocracy() (ibctesting.TestingApp, map[string]json.RawMessage) { - db := tmdb.NewMemDB() - // encCdc := app.MakeTestEncodingConfig() - encoding := cosmoscmd.MakeEncodingConfig(appConsumerDemocracy.ModuleBasics) - testApp := appConsumerDemocracy.New(log.NewNopLogger(), db, nil, true, map[int64]bool{}, simapp.DefaultNodeHome, 5, encoding, simapp.EmptyAppOptions{}).(ibctesting.TestingApp) - return testApp, appConsumerDemocracy.NewDefaultGenesisState(encoding.Marshaler) -} - -func SetupTestingAppConsumer() (ibctesting.TestingApp, map[string]json.RawMessage) { - db := tmdb.NewMemDB() - // encCdc := app.MakeTestEncodingConfig() - encoding := cosmoscmd.MakeEncodingConfig(appConsumer.ModuleBasics) - testApp := appConsumer.New(log.NewNopLogger(), db, nil, true, map[int64]bool{}, simapp.DefaultNodeHome, 5, encoding, simapp.EmptyAppOptions{}).(ibctesting.TestingApp) - return testApp, appConsumer.NewDefaultGenesisState(encoding.Marshaler) -} - -// NewCoordinator initializes Coordinator with 0 TestChains -func NewBasicCoordinator(t *testing.T) *ibctesting.Coordinator { - chains := make(map[string]*ibctesting.TestChain) - coord := &ibctesting.Coordinator{ - T: t, - CurrentTime: ibctesting.GlobalStartTime, - } - coord.Chains = chains - return coord -} - -// NewCoordinator initializes Coordinator with 0 TestChains -func NewProviderConsumerCoordinator(t *testing.T) (*ibctesting.Coordinator, *ibctesting.TestChain, *ibctesting.TestChain) { - coordinator := NewBasicCoordinator(t) - chainID := ibctesting.GetChainID(1) - coordinator.Chains[chainID] = ibctesting.NewTestChain(t, coordinator, SetupTestingappProvider, chainID) - providerChain := coordinator.GetChain(chainID) - chainID = ibctesting.GetChainID(2) - coordinator.Chains[chainID] = ibctesting.NewTestChainWithValSet(t, coordinator, - SetupTestingAppConsumer, chainID, providerChain.Vals, providerChain.Signers) - consumerChain := coordinator.GetChain(chainID) - return coordinator, providerChain, consumerChain -} - -// NewCoordinator initializes Coordinator with provider and democracy consumer TestChains -func NewProviderConsumerDemocracyCoordinator(t *testing.T) (*ibctesting.Coordinator, *ibctesting.TestChain, *ibctesting.TestChain) { - coordinator := NewBasicCoordinator(t) - chainID := ibctesting.GetChainID(1) - coordinator.Chains[chainID] = ibctesting.NewTestChain(t, coordinator, SetupTestingappProvider, chainID) - providerChain := coordinator.GetChain(chainID) - chainID = ibctesting.GetChainID(2) - coordinator.Chains[chainID] = ibctesting.NewTestChainWithValSet(t, coordinator, - SetupTestingAppConsumerDemocracy, chainID, providerChain.Vals, providerChain.Signers) - consumerChain := coordinator.GetChain(chainID) - return coordinator, providerChain, consumerChain -} From 8a55b0aca8ccd5baf760779522d112be22d71fc3 Mon Sep 17 00:00:00 2001 From: Shawn Marshall-Spitzbart <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Fri, 11 Nov 2022 15:02:28 -0800 Subject: [PATCH 2/7] mas --- README.md | 2 +- tests/e2e/README.md | 2 +- tests/e2e/instance_test.go | 42 ++++++++----- testutil/ibc_testing/generic_setup.go | 62 +++++++++++++++++++ .../{setup.go => specific_setup.go} | 35 +---------- 5 files changed, 92 insertions(+), 51 deletions(-) create mode 100644 testutil/ibc_testing/generic_setup.go rename testutil/ibc_testing/{setup.go => specific_setup.go} (62%) diff --git a/README.md b/README.md index cc6d7af437..c754ced5d6 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ Unit tests are useful for simple standalone functionality, and CRUD operations. [e2e-tests](./tests/e2e/) utilize the [IBC Testing Package](https://github.com/cosmos/ibc-go/tree/main/testing), and test functionality that is wider in scope than a unit test, but still able to be validated in-memory. Ie. code where advancing blocks would be useful, simulated handshakes, simulated packet relays, etc. -To run e2e tests against your own consumer/provider implementations, use [instance_test.go](./tests/e2e/instance_test.go) as an example. All you'll need to do is make sure your applications implement the necessary interfaces defined in [interfaces.go](./testutil/e2e/interfaces.go), then pass in an appropriate callback to the testing suites. +To run e2e tests against your own consumer/provider implementations, use [instance_test.go](./tests/e2e/instance_test.go) as an example. All you'll need to do is make sure your applications implements the necessary interfaces defined in [interfaces.go](./testutil/e2e/interfaces.go), pattern match [specific_setup.go](./testutil/ibc_testing/specific_setup.go), then pass in an appropriate callback to the testing suites, as is done in `instance_test.go` for the dummy provider/consumer implementations. ### Differential Tests (WIP) diff --git a/tests/e2e/README.md b/tests/e2e/README.md index b8ad9d1970..62f34b59ea 100644 --- a/tests/e2e/README.md +++ b/tests/e2e/README.md @@ -14,4 +14,4 @@ E2e tests are categorized into files as follows: - `normal_operations.go` - e2e tests for _normal operations_ of ICS enabled chains - `instance_test.go` - ties the e2e test structure into golang's standard test mechanism, with appropriate definitions for concrete app types and setup callback -To run the e2e tests defined in this repo on any arbitrary consumer and provider implementation, copy the pattern exemplified in `instance_test.go` +To run the e2e tests defined in this repo on any arbitrary consumer and provider implementation, copy the pattern exemplified in `instance_test.go` and `specific_setup.go` diff --git a/tests/e2e/instance_test.go b/tests/e2e/instance_test.go index eb71a1ea3e..ef8538b597 100644 --- a/tests/e2e/instance_test.go +++ b/tests/e2e/instance_test.go @@ -15,9 +15,9 @@ import ( // This file can be used as an example e2e testing instance for any provider/consumer applications. // In the case of this repo, we're testing the dummy provider/consumer applications, -// but to test any arbitrary app, you only need to replicate this file, and pass in the -// appropriate callback to the testing suites. Note that any provider/consumer applications -// must implement the interfaces defined in /testutil/e2e/interfaces.go +// but to test any arbitrary app, one only needs to replicate this file and "specific_setup.go", +// then pass in the appropriate callback to the testing suites. Note that any provider/consumer +// applications must implement the interfaces defined in /testutil/e2e/interfaces.go to compile. // Executes the standard group of ccv tests against a consumer and provider app.go implementation. func TestCCVTestSuite(t *testing.T) { @@ -30,13 +30,22 @@ func TestCCVTestSuite(t *testing.T) { e2etestutil.ProviderApp, e2etestutil.ConsumerApp, ) { - coordinator, provider := ibctestingutils.NewCoordinatorWithProvider(t) - consumers := ibctestingutils.AddConsumersToCoordinator(coordinator, t, 1, ibctestingutils.ConsumerAppIniter) - consumer := consumers[0] - // Here we pass the concrete types that must implement the necessary interfaces - // to be ran with e2e tests. - // TODO: Allow e2e tests to accept multiple consumers - return coordinator, provider, consumers[0], provider.App.(*appProvider.App), consumer.App.(*appConsumer.App) + // Instantiate the test coordinator. + coordinator := ibctesting.NewCoordinator(t, 0) + + // Add provider to coordinator, store returned test chain and app. + // Concrete provider app type is passed to the generic function here. + provider, providerApp := ibctestingutils.AddProvider[*appProvider.App]( + coordinator, t, ibctestingutils.ProviderAppIniter) + + // Add specified number of consumers to coordinator, store returned test chains and apps. + // Concrete consumer app type is passed to the generic function here. + consumers, consumerApps := ibctestingutils.AddConsumers[*appConsumer.App]( + coordinator, t, 1, ibctestingutils.ConsumerAppIniter) + + // Pass variables to suite. + // TODO: accept multiple consumers here + return coordinator, provider, consumers[0], providerApp, consumerApps[0] }, ) suite.Run(t, ccvSuite) @@ -52,16 +61,15 @@ func TestConsumerDemocracyTestSuite(t *testing.T) { *ibctesting.TestChain, e2etestutil.DemocConsumerApp, ) { + // Instantiate the test coordinator coordinator := ibctesting.NewCoordinator(t, 0) - chainID := ibctesting.GetChainID(2) - democracyConsumer := ibctesting.NewTestChain(t, coordinator, - ibctestingutils.DemocracyConsumerAppIniter, chainID) + // Add single democracy consumer to coordinator, store returned test chain and app. + democConsumer, democConsumerApp := ibctestingutils.AddDemocracyConsumer[*appConsumerDemocracy.App]( + coordinator, t, ibctestingutils.DemocracyConsumerAppIniter) - coordinator.Chains[chainID] = democracyConsumer - // Here we pass the concrete types that must implement the necessary interfaces - // to be ran with e2e tests. - return coordinator, democracyConsumer, democracyConsumer.App.(*appConsumerDemocracy.App) + // Pass variables to suite. + return coordinator, democConsumer, democConsumerApp }, ) suite.Run(t, democSuite) diff --git a/testutil/ibc_testing/generic_setup.go b/testutil/ibc_testing/generic_setup.go new file mode 100644 index 0000000000..7c3234437d --- /dev/null +++ b/testutil/ibc_testing/generic_setup.go @@ -0,0 +1,62 @@ +package ibc_testing + +import ( + "testing" + + ibctesting "github.com/cosmos/ibc-go/v3/testing" + "github.com/cosmos/interchain-security/testutil/e2e" +) + +// Contains generic setup code for running e2e tests against a provider, consumer, +// and/or democracy consumer app.go implementation. You should not need to modify or replicate this file +// to run e2e tests against your app.go implementations! + +var ( + provChainID = ibctesting.GetChainID(1) + democConsumerChainID = ibctesting.GetChainID(2) +) + +// AddProvider adds a new provider chain to the coordinator and returns the test chain and app type +func AddProvider[T e2e.ProviderApp](coordinator *ibctesting.Coordinator, t *testing.T, appIniter ibctesting.AppIniter) ( + *ibctesting.TestChain, T) { + + provider := ibctesting.NewTestChain(t, coordinator, appIniter, provChainID) + coordinator.Chains[provChainID] = provider + + return provider, provider.App.(T) +} + +// AddDemocracyConsumer adds a new democ consumer chain to the coordinator and returns the test chain and app type +func AddDemocracyConsumer[T e2e.DemocConsumerApp](coordinator *ibctesting.Coordinator, t *testing.T, + appIniter ibctesting.AppIniter) (*ibctesting.TestChain, T) { + + democConsumer := ibctesting.NewTestChain(t, coordinator, appIniter, democConsumerChainID) + coordinator.Chains[democConsumerChainID] = democConsumer + + return democConsumer, democConsumer.App.(T) +} + +// AddConsumers adds new consumer chains to the coordinator and returns the test chains and app types +// The new consumers are initialized with the valset of the existing provider chain. +// +// This method must be called after AddProvider. +func AddConsumers[T e2e.ConsumerApp](coordinator *ibctesting.Coordinator, + t *testing.T, numConsumers int, appIniter ibctesting.AppIniter) ([]*ibctesting.TestChain, []T) { + + providerChain := coordinator.GetChain(provChainID) + + // Instantiate specified number of consumers, add them to coordinator, and returned chain/app slices + consumerChains := []*ibctesting.TestChain{} + consumerApps := []T{} + for i := 0; i < numConsumers; i++ { + chainID := ibctesting.GetChainID(i + 2) + testChain := ibctesting.NewTestChainWithValSet(t, coordinator, + appIniter, chainID, providerChain.Vals, providerChain.Signers) + + coordinator.Chains[chainID] = testChain + consumerChains = append(consumerChains, testChain) + consumerApps = append(consumerApps, testChain.App.(T)) + } + + return consumerChains, consumerApps +} diff --git a/testutil/ibc_testing/setup.go b/testutil/ibc_testing/specific_setup.go similarity index 62% rename from testutil/ibc_testing/setup.go rename to testutil/ibc_testing/specific_setup.go index ed9bcc8141..80f847c0a5 100644 --- a/testutil/ibc_testing/setup.go +++ b/testutil/ibc_testing/specific_setup.go @@ -1,10 +1,11 @@ package ibc_testing -// Contains util functions for using the IBC testing package with CCV. +// Contains example setup code for running e2e tests against a provider, consumer, +// and/or democracy consumer app.go implementation. This file is meant to be pattern matched +// for apps running e2e tests against their implementation. import ( "encoding/json" - "testing" "github.com/cosmos/cosmos-sdk/simapp" @@ -19,10 +20,6 @@ import ( appProvider "github.com/cosmos/interchain-security/app/provider" ) -var ( - provChainID = ibctesting.GetChainID(1) -) - // ProviderAppIniter implements ibctesting.AppIniter for a provider app func ProviderAppIniter() (ibctesting.TestingApp, map[string]json.RawMessage) { encoding := cosmoscmd.MakeEncodingConfig(appProvider.ModuleBasics) @@ -46,29 +43,3 @@ func DemocracyConsumerAppIniter() (ibctesting.TestingApp, map[string]json.RawMes simapp.DefaultNodeHome, 5, encoding, simapp.EmptyAppOptions{}).(ibctesting.TestingApp) return testApp, appConsumerDemocracy.NewDefaultGenesisState(encoding.Marshaler) } - -// NewCoordinatorWithProvider initializes an IBC testing Coordinator with a properly setup provider -func NewCoordinatorWithProvider(t *testing.T) (*ibctesting.Coordinator, *ibctesting.TestChain) { - coordinator := ibctesting.NewCoordinator(t, 0) - provider := ibctesting.NewTestChain(t, coordinator, ProviderAppIniter, provChainID) - coordinator.Chains[provChainID] = provider - return coordinator, provider -} - -func AddConsumersToCoordinator(coordinator *ibctesting.Coordinator, - t *testing.T, numConsumers int, appIniter ibctesting.AppIniter) (consumers []*ibctesting.TestChain) { - - providerChain := coordinator.GetChain(provChainID) - - // Instantiate specified number of consumers, add them to the coordinator and returned slice - for i := 0; i < numConsumers; i++ { - chainID := ibctesting.GetChainID(i + 2) - testChain := ibctesting.NewTestChainWithValSet(t, coordinator, - appIniter, chainID, providerChain.Vals, providerChain.Signers) - - coordinator.Chains[chainID] = testChain - consumers = append(consumers, testChain) - } - - return consumers -} From b83d8cbbc9ebe9da7cab534c0bde5bde15f16c6f Mon Sep 17 00:00:00 2001 From: Shawn Marshall-Spitzbart <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Fri, 11 Nov 2022 15:05:21 -0800 Subject: [PATCH 3/7] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c754ced5d6..c07a531254 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ Unit tests are useful for simple standalone functionality, and CRUD operations. [e2e-tests](./tests/e2e/) utilize the [IBC Testing Package](https://github.com/cosmos/ibc-go/tree/main/testing), and test functionality that is wider in scope than a unit test, but still able to be validated in-memory. Ie. code where advancing blocks would be useful, simulated handshakes, simulated packet relays, etc. -To run e2e tests against your own consumer/provider implementations, use [instance_test.go](./tests/e2e/instance_test.go) as an example. All you'll need to do is make sure your applications implements the necessary interfaces defined in [interfaces.go](./testutil/e2e/interfaces.go), pattern match [specific_setup.go](./testutil/ibc_testing/specific_setup.go), then pass in an appropriate callback to the testing suites, as is done in `instance_test.go` for the dummy provider/consumer implementations. +To run e2e tests against your own consumer/provider implementations, use [instance_test.go](./tests/e2e/instance_test.go) as an example. All you'll need to do is make sure your applications implement the necessary interfaces defined in [interfaces.go](./testutil/e2e/interfaces.go), pattern match [specific_setup.go](./testutil/ibc_testing/specific_setup.go), then pass in an appropriate callback to the testing suites, as is done in `instance_test.go` for the dummy provider/consumer implementations. ### Differential Tests (WIP) From 3c5c81765c0c4993fd6babe30655ae0473cb954f Mon Sep 17 00:00:00 2001 From: Shawn Marshall-Spitzbart <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Fri, 11 Nov 2022 19:53:54 -0800 Subject: [PATCH 4/7] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c07a531254..c625a4fc7b 100644 --- a/README.md +++ b/README.md @@ -47,9 +47,9 @@ Inspect the [Makefile](./Makefile) if curious. ### Unit Tests -Unit tests are useful for simple standalone functionality, and CRUD operations. Unit tests should use golang's standard testing package, and be defined in files formatted as ```_test.go``` in the same directory as the file being tested, following standard conventions. +Unit tests are useful for simple standalone functionality, and CRUD operations. Unit tests should use golang's standard testing package, and be defined in files formatted as ```_test.go``` in the same directory as the file being tested, following standard conventions. -[Mocked external keepers](./testutil/keeper/mocks.go) (implemented with [gomock](https://github.com/golang/mock)) are available for testing more complex functionality, but still only relevant to execution within a single node. Ie. no internode or interchain communication. +[Mocked external keepers](./testutil/keeper/mocks.go) (implemented with [gomock](https://github.com/golang/mock)) are available for testing code that briefly interacts with external modules, but still only a single function/method relevant to ccv, and a single chain. Ie. do not use mocked external keepers to test the integration of the ccv module with external modules, or integration between consumer and provider. ### End to End (e2e) Tests From 69596b6a5bb689044e5165b2c05330601b1b9753 Mon Sep 17 00:00:00 2001 From: Shawn Marshall-Spitzbart <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Fri, 11 Nov 2022 20:24:07 -0800 Subject: [PATCH 5/7] sorry for the friday night emails --- README.md | 2 +- tests/e2e/democracy.go | 38 +++++++++++++++++------- tests/e2e/instance_test.go | 59 +++++++++----------------------------- tests/e2e/setup.go | 46 ++++++++++++++++++++++------- 4 files changed, 78 insertions(+), 67 deletions(-) diff --git a/README.md b/README.md index c625a4fc7b..b7623b137e 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ Unit tests are useful for simple standalone functionality, and CRUD operations. [e2e-tests](./tests/e2e/) utilize the [IBC Testing Package](https://github.com/cosmos/ibc-go/tree/main/testing), and test functionality that is wider in scope than a unit test, but still able to be validated in-memory. Ie. code where advancing blocks would be useful, simulated handshakes, simulated packet relays, etc. -To run e2e tests against your own consumer/provider implementations, use [instance_test.go](./tests/e2e/instance_test.go) as an example. All you'll need to do is make sure your applications implement the necessary interfaces defined in [interfaces.go](./testutil/e2e/interfaces.go), pattern match [specific_setup.go](./testutil/ibc_testing/specific_setup.go), then pass in an appropriate callback to the testing suites, as is done in `instance_test.go` for the dummy provider/consumer implementations. +To run e2e tests against your own consumer/provider implementations, use [instance_test.go](./tests/e2e/instance_test.go) as an example. All you'll need to do is make sure your applications implement the necessary interfaces defined in [interfaces.go](./testutil/e2e/interfaces.go), pattern match [specific_setup.go](./testutil/ibc_testing/specific_setup.go), then pass in the appropriate types and parameters to the suite, as is done in `instance_test.go` for the dummy provider/consumer implementations. ### Differential Tests (WIP) diff --git a/tests/e2e/democracy.go b/tests/e2e/democracy.go index 8b4dfda7f9..ddbb9b8b5b 100644 --- a/tests/e2e/democracy.go +++ b/tests/e2e/democracy.go @@ -7,15 +7,14 @@ import ( "time" sdk "github.com/cosmos/cosmos-sdk/types" - ibctesting "github.com/cosmos/ibc-go/v3/testing" + ibctestingutils "github.com/cosmos/interchain-security/testutil/ibc_testing" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" - "github.com/cosmos/cosmos-sdk/x/params/types/proposal" proposaltypes "github.com/cosmos/cosmos-sdk/x/params/types/proposal" - "github.com/cosmos/interchain-security/testutil/e2e" + e2eutil "github.com/cosmos/interchain-security/testutil/e2e" consumertypes "github.com/cosmos/interchain-security/x/ccv/consumer/types" "github.com/stretchr/testify/suite" ) @@ -24,15 +23,32 @@ type ConsumerDemocracyTestSuite struct { suite.Suite coordinator *ibctesting.Coordinator consumerChain *ibctesting.TestChain - consumerApp e2e.DemocConsumerApp + consumerApp e2eutil.DemocConsumerApp setupCallback DemocSetupCallback } // NewCCVTestSuite returns a new instance of ConsumerDemocracyTestSuite, // ready to be tested against using suite.Run(). -func NewConsumerDemocracyTestSuite(setupCallback DemocSetupCallback) *ConsumerDemocracyTestSuite { +func NewConsumerDemocracyTestSuite[T e2eutil.DemocConsumerApp]( + democConsumerAppIniter ibctesting.AppIniter) *ConsumerDemocracyTestSuite { + democSuite := new(ConsumerDemocracyTestSuite) - democSuite.setupCallback = setupCallback + + democSuite.setupCallback = func(t *testing.T) ( + *ibctesting.Coordinator, + *ibctesting.TestChain, + e2eutil.DemocConsumerApp, + ) { + // Instantiate the test coordinator + coordinator := ibctesting.NewCoordinator(t, 0) + + // Add single democracy consumer to coordinator, store returned test chain and app. + democConsumer, democConsumerApp := ibctestingutils.AddDemocracyConsumer[T]( + coordinator, t, democConsumerAppIniter) + + // Pass variables to suite. + return coordinator, democConsumer, democConsumerApp + } return democSuite } @@ -41,7 +57,7 @@ func NewConsumerDemocracyTestSuite(setupCallback DemocSetupCallback) *ConsumerDe type DemocSetupCallback func(t *testing.T) ( coord *ibctesting.Coordinator, consumerChain *ibctesting.TestChain, - consumerApp e2e.DemocConsumerApp, + consumerApp e2eutil.DemocConsumerApp, ) // SetupTest sets up in-mem state before every test relevant to ccv with a democracy consumer @@ -138,8 +154,8 @@ func (s *ConsumerDemocracyTestSuite) TestDemocracyGovernanceWhitelisting() { mintKeeper := s.consumerApp.GetE2eMintKeeper() newAuthParamValue := uint64(128) newMintParamValue := sdk.NewDecWithPrec(1, 1) // "0.100000000000000000" - allowedChange := proposal.ParamChange{Subspace: minttypes.ModuleName, Key: "InflationMax", Value: fmt.Sprintf("\"%s\"", newMintParamValue)} - forbiddenChange := proposal.ParamChange{Subspace: authtypes.ModuleName, Key: "MaxMemoCharacters", Value: fmt.Sprintf("\"%s\"", strconv.FormatUint(newAuthParamValue, 10))} + allowedChange := proposaltypes.ParamChange{Subspace: minttypes.ModuleName, Key: "InflationMax", Value: fmt.Sprintf("\"%s\"", newMintParamValue)} + forbiddenChange := proposaltypes.ParamChange{Subspace: authtypes.ModuleName, Key: "MaxMemoCharacters", Value: fmt.Sprintf("\"%s\"", strconv.FormatUint(newAuthParamValue, 10))} votingAccounts := s.consumerChain.SenderAccounts bondDenom := stakingKeeper.BondDenom(s.consumerCtx()) depositAmount := govKeeper.GetDepositParams(s.consumerCtx()).MinDeposit @@ -203,7 +219,7 @@ func (s *ConsumerDemocracyTestSuite) TestDemocracyGovernanceWhitelisting() { s.Assert().Equal(votersOldBalances, getAccountsBalances(s.consumerCtx(), bankKeeper, bondDenom, votingAccounts)) } -func submitProposalWithDepositAndVote(govKeeper e2e.E2eGovKeeper, ctx sdk.Context, paramChange proposaltypes.ParameterChangeProposal, +func submitProposalWithDepositAndVote(govKeeper e2eutil.E2eGovKeeper, ctx sdk.Context, paramChange proposaltypes.ParameterChangeProposal, accounts []ibctesting.SenderAccount, depositAmount sdk.Coins) error { proposal, err := govKeeper.SubmitProposal(ctx, ¶mChange) if err != nil { @@ -223,7 +239,7 @@ func submitProposalWithDepositAndVote(govKeeper e2e.E2eGovKeeper, ctx sdk.Contex return nil } -func getAccountsBalances(ctx sdk.Context, bankKeeper e2e.E2eBankKeeper, bondDenom string, accounts []ibctesting.SenderAccount) map[string]sdk.Int { +func getAccountsBalances(ctx sdk.Context, bankKeeper e2eutil.E2eBankKeeper, bondDenom string, accounts []ibctesting.SenderAccount) map[string]sdk.Int { accountsBalances := map[string]sdk.Int{} for _, acc := range accounts { accountsBalances[string(acc.SenderAccount.GetAddress())] = diff --git a/tests/e2e/instance_test.go b/tests/e2e/instance_test.go index ef8538b597..553d22dd05 100644 --- a/tests/e2e/instance_test.go +++ b/tests/e2e/instance_test.go @@ -3,12 +3,10 @@ package e2e_test import ( "testing" - ibctesting "github.com/cosmos/ibc-go/v3/testing" appConsumer "github.com/cosmos/interchain-security/app/consumer" appConsumerDemocracy "github.com/cosmos/interchain-security/app/consumer-democracy" appProvider "github.com/cosmos/interchain-security/app/provider" "github.com/cosmos/interchain-security/tests/e2e" - e2etestutil "github.com/cosmos/interchain-security/testutil/e2e" ibctestingutils "github.com/cosmos/interchain-security/testutil/ibc_testing" "github.com/stretchr/testify/suite" ) @@ -16,61 +14,32 @@ import ( // This file can be used as an example e2e testing instance for any provider/consumer applications. // In the case of this repo, we're testing the dummy provider/consumer applications, // but to test any arbitrary app, one only needs to replicate this file and "specific_setup.go", -// then pass in the appropriate callback to the testing suites. Note that any provider/consumer -// applications must implement the interfaces defined in /testutil/e2e/interfaces.go to compile. +// then pass in the appropriate types and parameters to the suite. Note that provider consumer +// applications types must implement the interfaces defined in /testutil/e2e/interfaces.go to compile. // Executes the standard group of ccv tests against a consumer and provider app.go implementation. func TestCCVTestSuite(t *testing.T) { - ccvSuite := e2e.NewCCVTestSuite( - func(t *testing.T) ( - *ibctesting.Coordinator, - *ibctesting.TestChain, - *ibctesting.TestChain, - e2etestutil.ProviderApp, - e2etestutil.ConsumerApp, - ) { - // Instantiate the test coordinator. - coordinator := ibctesting.NewCoordinator(t, 0) + // Pass in concrete app types that implement the interfaces defined in /testutil/e2e/interfaces.go + ccvSuite := e2e.NewCCVTestSuite[*appProvider.App, *appConsumer.App]( + // Pass in ibctesting.AppIniters for provider and consumer. + ibctestingutils.ProviderAppIniter, ibctestingutils.ConsumerAppIniter) - // Add provider to coordinator, store returned test chain and app. - // Concrete provider app type is passed to the generic function here. - provider, providerApp := ibctestingutils.AddProvider[*appProvider.App]( - coordinator, t, ibctestingutils.ProviderAppIniter) - - // Add specified number of consumers to coordinator, store returned test chains and apps. - // Concrete consumer app type is passed to the generic function here. - consumers, consumerApps := ibctestingutils.AddConsumers[*appConsumer.App]( - coordinator, t, 1, ibctestingutils.ConsumerAppIniter) - - // Pass variables to suite. - // TODO: accept multiple consumers here - return coordinator, provider, consumers[0], providerApp, consumerApps[0] - }, - ) + // Run tests suite.Run(t, ccvSuite) } // TODO: Run the gov enabled consumer against the standard suite of tests: https://github.com/cosmos/interchain-security/issues/397 -// Executes a specialized group of tests specific to a democracy consumer, against a democracy consumer app.go implementation. +// Executes a specialized group of tests specific to a democracy consumer, +// against a democracy consumer app.go implementation. func TestConsumerDemocracyTestSuite(t *testing.T) { - democSuite := e2e.NewConsumerDemocracyTestSuite( - func(t *testing.T) ( - *ibctesting.Coordinator, - *ibctesting.TestChain, - e2etestutil.DemocConsumerApp, - ) { - // Instantiate the test coordinator - coordinator := ibctesting.NewCoordinator(t, 0) - // Add single democracy consumer to coordinator, store returned test chain and app. - democConsumer, democConsumerApp := ibctestingutils.AddDemocracyConsumer[*appConsumerDemocracy.App]( - coordinator, t, ibctestingutils.DemocracyConsumerAppIniter) + // Pass in concrete app type that implement the interface defined in /testutil/e2e/interfaces.go + democSuite := e2e.NewConsumerDemocracyTestSuite[*appConsumerDemocracy.App]( + // Pass in ibctesting.AppIniter for democracy consumer. + ibctestingutils.DemocracyConsumerAppIniter) - // Pass variables to suite. - return coordinator, democConsumer, democConsumerApp - }, - ) + // Run tests suite.Run(t, democSuite) } diff --git a/tests/e2e/setup.go b/tests/e2e/setup.go index 83c07ba6c9..1315f2f486 100644 --- a/tests/e2e/setup.go +++ b/tests/e2e/setup.go @@ -1,12 +1,12 @@ package e2e import ( - ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" - "bytes" "testing" - e2e "github.com/cosmos/interchain-security/testutil/e2e" + ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + e2eutil "github.com/cosmos/interchain-security/testutil/e2e" + ibctestingutils "github.com/cosmos/interchain-security/testutil/ibc_testing" ccv "github.com/cosmos/interchain-security/x/ccv/types" "github.com/cosmos/interchain-security/x/ccv/utils" @@ -29,28 +29,54 @@ type CCVTestSuite struct { coordinator *ibctesting.Coordinator providerChain *ibctesting.TestChain consumerChain *ibctesting.TestChain - providerApp e2e.ProviderApp - consumerApp e2e.ConsumerApp + providerApp e2eutil.ProviderApp + consumerApp e2eutil.ConsumerApp path *ibctesting.Path transferPath *ibctesting.Path setupCallback SetupCallback } // NewCCVTestSuite returns a new instance of CCVTestSuite, ready to be tested against using suite.Run(). -func NewCCVTestSuite(setupCallback SetupCallback) *CCVTestSuite { +func NewCCVTestSuite[Tp e2eutil.ProviderApp, Tc e2eutil.ConsumerApp]( + providerAppIniter ibctesting.AppIniter, consumerAppIniter ibctesting.AppIniter) *CCVTestSuite { + ccvSuite := new(CCVTestSuite) - ccvSuite.setupCallback = setupCallback + + ccvSuite.setupCallback = func(t *testing.T) ( + *ibctesting.Coordinator, + *ibctesting.TestChain, + *ibctesting.TestChain, + e2eutil.ProviderApp, + e2eutil.ConsumerApp, + ) { + // Instantiate the test coordinator. + coordinator := ibctesting.NewCoordinator(t, 0) + + // Add provider to coordinator, store returned test chain and app. + // Concrete provider app type is passed to the generic function here. + provider, providerApp := ibctestingutils.AddProvider[Tp]( + coordinator, t, providerAppIniter) + + // Add specified number of consumers to coordinator, store returned test chains and apps. + // Concrete consumer app type is passed to the generic function here. + consumers, consumerApps := ibctestingutils.AddConsumers[Tc]( + coordinator, t, 1, consumerAppIniter) + + // Pass variables to suite. + // TODO: accept multiple consumers here + return coordinator, provider, consumers[0], providerApp, consumerApps[0] + } return ccvSuite } -// Callback for instantiating a new coordinator, provider/consumer test chains, and provider/consumer app +// Callback for instantiating a new coordinator, provider/consumer test chains, and provider/consumer apps // before every test defined on the suite. type SetupCallback func(t *testing.T) ( coord *ibctesting.Coordinator, providerChain *ibctesting.TestChain, consumerChain *ibctesting.TestChain, - providerApp e2e.ProviderApp, - consumerApp e2e.ConsumerApp, + providerApp e2eutil.ProviderApp, + consumerApp e2eutil.ConsumerApp, ) // SetupTest sets up in-mem state before every test From e7cde9e953dc7b577d80b89828a841b68382dd49 Mon Sep 17 00:00:00 2001 From: Shawn Marshall-Spitzbart <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Fri, 11 Nov 2022 20:26:45 -0800 Subject: [PATCH 6/7] Update instance_test.go --- tests/e2e/instance_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/instance_test.go b/tests/e2e/instance_test.go index 553d22dd05..4ef1bd8cd7 100644 --- a/tests/e2e/instance_test.go +++ b/tests/e2e/instance_test.go @@ -14,7 +14,7 @@ import ( // This file can be used as an example e2e testing instance for any provider/consumer applications. // In the case of this repo, we're testing the dummy provider/consumer applications, // but to test any arbitrary app, one only needs to replicate this file and "specific_setup.go", -// then pass in the appropriate types and parameters to the suite. Note that provider consumer +// then pass in the appropriate types and parameters to the suite. Note that provider and consumer // applications types must implement the interfaces defined in /testutil/e2e/interfaces.go to compile. // Executes the standard group of ccv tests against a consumer and provider app.go implementation. From 4c96805c51192a4ce9f104119d30400e4d122fe2 Mon Sep 17 00:00:00 2001 From: Shawn Marshall-Spitzbart <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Tue, 15 Nov 2022 11:05:43 -0800 Subject: [PATCH 7/7] util naming --- app/consumer-democracy/proposals_whitelisting_test.go | 4 ++-- tests/difference/core/driver/setup.go | 6 +++--- tests/e2e/democracy.go | 4 ++-- tests/e2e/instance_test.go | 6 +++--- tests/e2e/setup.go | 6 +++--- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/consumer-democracy/proposals_whitelisting_test.go b/app/consumer-democracy/proposals_whitelisting_test.go index 45cd9496f7..e1a4a489d9 100644 --- a/app/consumer-democracy/proposals_whitelisting_test.go +++ b/app/consumer-democracy/proposals_whitelisting_test.go @@ -5,13 +5,13 @@ import ( ibctesting "github.com/cosmos/ibc-go/v3/testing" appConsumer "github.com/cosmos/interchain-security/app/consumer-democracy" - ibctestingutils "github.com/cosmos/interchain-security/testutil/ibc_testing" + icstestingutils "github.com/cosmos/interchain-security/testutil/ibc_testing" "github.com/stretchr/testify/require" ) func TestDemocracyGovernanceWhitelistingKeys(t *testing.T) { chain := ibctesting.NewTestChain(t, ibctesting.NewCoordinator(t, 0), - ibctestingutils.DemocracyConsumerAppIniter, "test") + icstestingutils.DemocracyConsumerAppIniter, "test") paramKeeper := chain.App.(*appConsumer.App).ParamsKeeper for paramKey := range appConsumer.WhitelistedParams { ss, ok := paramKeeper.GetSubspace(paramKey.Subspace) diff --git a/tests/difference/core/driver/setup.go b/tests/difference/core/driver/setup.go index 3d7ed54102..cc303e9e27 100644 --- a/tests/difference/core/driver/setup.go +++ b/tests/difference/core/driver/setup.go @@ -37,7 +37,7 @@ import ( stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" appConsumer "github.com/cosmos/interchain-security/app/consumer" appProvider "github.com/cosmos/interchain-security/app/provider" - ibctestingutils "github.com/cosmos/interchain-security/testutil/ibc_testing" + icstestingutils "github.com/cosmos/interchain-security/testutil/ibc_testing" simibc "github.com/cosmos/interchain-security/testutil/simibc" consumerkeeper "github.com/cosmos/interchain-security/x/ccv/consumer/keeper" consumertypes "github.com/cosmos/interchain-security/x/ccv/consumer/types" @@ -341,9 +341,9 @@ func (b *Builder) createChains() { // Create validators validators, signers, addresses := b.createValidators() // Create provider - coordinator.Chains[ibctesting.GetChainID(0)] = b.newChain(coordinator, ibctestingutils.ProviderAppIniter, ibctesting.GetChainID(0), validators, signers) + coordinator.Chains[ibctesting.GetChainID(0)] = b.newChain(coordinator, icstestingutils.ProviderAppIniter, ibctesting.GetChainID(0), validators, signers) // Create consumer, using the same validators. - coordinator.Chains[ibctesting.GetChainID(1)] = b.newChain(coordinator, ibctestingutils.ConsumerAppIniter, ibctesting.GetChainID(1), validators, signers) + coordinator.Chains[ibctesting.GetChainID(1)] = b.newChain(coordinator, icstestingutils.ConsumerAppIniter, ibctesting.GetChainID(1), validators, signers) b.coordinator = coordinator b.valAddresses = addresses diff --git a/tests/e2e/democracy.go b/tests/e2e/democracy.go index ddbb9b8b5b..0961a33cbf 100644 --- a/tests/e2e/democracy.go +++ b/tests/e2e/democracy.go @@ -8,7 +8,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ibctesting "github.com/cosmos/ibc-go/v3/testing" - ibctestingutils "github.com/cosmos/interchain-security/testutil/ibc_testing" + icstestingutils "github.com/cosmos/interchain-security/testutil/ibc_testing" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" @@ -43,7 +43,7 @@ func NewConsumerDemocracyTestSuite[T e2eutil.DemocConsumerApp]( coordinator := ibctesting.NewCoordinator(t, 0) // Add single democracy consumer to coordinator, store returned test chain and app. - democConsumer, democConsumerApp := ibctestingutils.AddDemocracyConsumer[T]( + democConsumer, democConsumerApp := icstestingutils.AddDemocracyConsumer[T]( coordinator, t, democConsumerAppIniter) // Pass variables to suite. diff --git a/tests/e2e/instance_test.go b/tests/e2e/instance_test.go index 4ef1bd8cd7..4dc79b0ab7 100644 --- a/tests/e2e/instance_test.go +++ b/tests/e2e/instance_test.go @@ -7,7 +7,7 @@ import ( appConsumerDemocracy "github.com/cosmos/interchain-security/app/consumer-democracy" appProvider "github.com/cosmos/interchain-security/app/provider" "github.com/cosmos/interchain-security/tests/e2e" - ibctestingutils "github.com/cosmos/interchain-security/testutil/ibc_testing" + icstestingutils "github.com/cosmos/interchain-security/testutil/ibc_testing" "github.com/stretchr/testify/suite" ) @@ -23,7 +23,7 @@ func TestCCVTestSuite(t *testing.T) { // Pass in concrete app types that implement the interfaces defined in /testutil/e2e/interfaces.go ccvSuite := e2e.NewCCVTestSuite[*appProvider.App, *appConsumer.App]( // Pass in ibctesting.AppIniters for provider and consumer. - ibctestingutils.ProviderAppIniter, ibctestingutils.ConsumerAppIniter) + icstestingutils.ProviderAppIniter, icstestingutils.ConsumerAppIniter) // Run tests suite.Run(t, ccvSuite) @@ -38,7 +38,7 @@ func TestConsumerDemocracyTestSuite(t *testing.T) { // Pass in concrete app type that implement the interface defined in /testutil/e2e/interfaces.go democSuite := e2e.NewConsumerDemocracyTestSuite[*appConsumerDemocracy.App]( // Pass in ibctesting.AppIniter for democracy consumer. - ibctestingutils.DemocracyConsumerAppIniter) + icstestingutils.DemocracyConsumerAppIniter) // Run tests suite.Run(t, democSuite) diff --git a/tests/e2e/setup.go b/tests/e2e/setup.go index 1315f2f486..48dfb96e4d 100644 --- a/tests/e2e/setup.go +++ b/tests/e2e/setup.go @@ -6,7 +6,7 @@ import ( ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" e2eutil "github.com/cosmos/interchain-security/testutil/e2e" - ibctestingutils "github.com/cosmos/interchain-security/testutil/ibc_testing" + icstestingutils "github.com/cosmos/interchain-security/testutil/ibc_testing" ccv "github.com/cosmos/interchain-security/x/ccv/types" "github.com/cosmos/interchain-security/x/ccv/utils" @@ -54,12 +54,12 @@ func NewCCVTestSuite[Tp e2eutil.ProviderApp, Tc e2eutil.ConsumerApp]( // Add provider to coordinator, store returned test chain and app. // Concrete provider app type is passed to the generic function here. - provider, providerApp := ibctestingutils.AddProvider[Tp]( + provider, providerApp := icstestingutils.AddProvider[Tp]( coordinator, t, providerAppIniter) // Add specified number of consumers to coordinator, store returned test chains and apps. // Concrete consumer app type is passed to the generic function here. - consumers, consumerApps := ibctestingutils.AddConsumers[Tc]( + consumers, consumerApps := icstestingutils.AddConsumers[Tc]( coordinator, t, 1, consumerAppIniter) // Pass variables to suite.