-
Notifications
You must be signed in to change notification settings - Fork 138
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
testutils refactors and cleanup #467
Closed
Closed
Changes from 5 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
471a59b
refactors
shaspitz c1592a9
finished refactors
shaspitz 4e35138
smalls
shaspitz 87c6462
final
shaspitz 1e38f28
Merge branch 'main' into e2e-improvements
danwt 31d7cb6
refactors
shaspitz 992f530
finished refactors
shaspitz 51cc874
smalls
shaspitz dff8bce
final
shaspitz 279e2e5
split out
shaspitz 1862f65
Merge branch 'e2e-improvements' of https://github.com/cosmos/intercha…
shaspitz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
testutil/simibc/ordered_link.go → testutil/ibc_testing_utils/ordered_link.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
testutil/simibc/relay_util.go → testutil/ibc_testing_utils/relay_util.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package simibc | ||
package ibc_testing_utils | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
2 changes: 1 addition & 1 deletion
2
testutil/simibc/relayed_path.go → testutil/ibc_testing_utils/relayed_path.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package simibc | ||
package ibc_testing_utils | ||
|
||
import ( | ||
"time" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package ibc_testing_utils | ||
|
||
// 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 | ||
} | ||
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, I like this split of creating the app and adding the consumers separately 👍