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

Comments and better panic prints for e2e tests #660

Merged
merged 4 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions tests/e2e/instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
func TestCCVTestSuite(t *testing.T) {

// Pass in concrete app types that implement the interfaces defined in /testutil/e2e/interfaces.go
// IMPORTANT: the concrete app types passed in as type parameters here must match the
// concrete app types returned by the relevant app initers.
ccvSuite := e2e.NewCCVTestSuite[*appProvider.App, *appConsumer.App](
// Pass in ibctesting.AppIniters for provider and consumer.
icstestingutils.ProviderAppIniter, icstestingutils.ConsumerAppIniter, []string{})
Expand All @@ -32,6 +34,8 @@ func TestCCVTestSuite(t *testing.T) {
// Executes a standard suite of tests, against a democracy consumer app.go implementation.
func TestConsumerDemocracyCCVTestSuite(t *testing.T) {
// Pass in concrete app type that implement the interface defined in /testutil/e2e/interfaces.go
// IMPORTANT: the concrete app types passed in as type parameters here must match the
// concrete app types returned by the relevant app initers.
democSuite := e2e.NewCCVTestSuite[*appProvider.App, *appConsumerDemocracy.App](
// Pass in ibctesting.AppIniter for provider and democracy consumer.
// TestRewardsDistribution needs to be skipped since the democracy specific distribution test is in ConsumerDemocracyTestSuite,
Expand All @@ -47,6 +51,8 @@ func TestConsumerDemocracyCCVTestSuite(t *testing.T) {
func TestConsumerDemocracyTestSuite(t *testing.T) {

// Pass in concrete app type that implement the interface defined in /testutil/e2e/interfaces.go
// IMPORTANT: the concrete app type passed in as a type parameter here must match the
// concrete app type returned by the relevant app initer.
democSuite := e2e.NewConsumerDemocracyTestSuite[*appConsumerDemocracy.App](
// Pass in ibctesting.AppIniter for democracy consumer.
icstestingutils.DemocracyConsumerAppIniter)
Expand Down
23 changes: 20 additions & 3 deletions testutil/ibc_testing/generic_setup.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ibc_testing

import (
"fmt"
"testing"

sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -52,7 +53,12 @@ func AddProvider[T e2eutil.ProviderApp](coordinator *ibctesting.Coordinator, t *
provider := ibctesting.NewTestChain(t, coordinator, appIniter, provChainID)
coordinator.Chains[provChainID] = provider

return provider, provider.App.(T)
providerToReturn, ok := provider.App.(T)
if !ok {
panic(fmt.Sprintf("provider app type returned from app initer does not match app type passed in as type param: %T, %T",
provider.App, *new(T)))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
return provider, providerToReturn
}

// AddDemocracyConsumer adds a new democ consumer chain to the coordinator and returns the test chain and app type
Expand All @@ -62,7 +68,12 @@ func AddDemocracyConsumer[T e2eutil.DemocConsumerApp](coordinator *ibctesting.Co
democConsumer := ibctesting.NewTestChain(t, coordinator, appIniter, democConsumerChainID)
coordinator.Chains[democConsumerChainID] = democConsumer

return democConsumer, democConsumer.App.(T)
democConsumerToReturn, ok := democConsumer.App.(T)
if !ok {
panic(fmt.Sprintf("democ consumer app type returned from app initer does not match app type passed in as type param: %T, %T",
democConsumer.App, *new(T)))
}
return democConsumer, democConsumerToReturn
}

// AddConsumer adds a new consumer chain with "testchain<index+2>" as chainID to the coordinator
Expand Down Expand Up @@ -125,8 +136,14 @@ func AddConsumer[Tp e2eutil.ProviderApp, Tc e2eutil.ConsumerApp](
appIniter, chainID, tmtypes.NewValidatorSet(valz), providerChain.Signers)
coordinator.Chains[chainID] = testChain

consumerToReturn, ok := testChain.App.(Tc)
if !ok {
panic(fmt.Sprintf("consumer app type returned from app initer does not match app type passed in as type param: %T, %T",
testChain.App, *new(Tc)))
}

return &ConsumerBundle{
Chain: testChain,
App: testChain.App.(Tc),
App: consumerToReturn,
}
}