-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Test Network Testing Framework #6489
Merged
Merged
Changes from 27 commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
c9d5b34
Init commit
alexanderbez 1e651e8
Remove script
alexanderbez 9d8494f
Merge branch 'master' into bez/in-process-test-framework
alexanderbez cd2ec2d
Fix IBC codec bug
alexanderbez ecfa3c8
go mod tidy + codec fixes attempt
alexanderbez c7e9b60
Change base dir to use chain-id
alexanderbez f5deb8d
Add trap signal call
alexanderbez 7f51e12
Add godoc
alexanderbez b7c2cca
Merge branch 'master' into bez/in-process-test-framework
alexanderbez ec88212
Updates
alexanderbez 4f43424
Tweaks
alexanderbez e8f5176
Fix fn name
alexanderbez 433b67e
Cleanup
alexanderbez f7758f7
Only allow 1st val to serve rpc/api
alexanderbez 4bc56bd
use pkg lock
alexanderbez d430884
Merge branch 'master' into bez/in-process-test-framework
alexanderbez c389c81
lint++
alexanderbez a6f8fe3
lint++
alexanderbez 9442a8b
Remove use of errgroup
alexanderbez 0aff4e4
ci: remove -race flag from tests
alexanderbez 69603bc
Merge branch 'master' into bez/in-process-test-framework
alexanderbez 6d1719f
Add doc
alexanderbez c53831d
Merge branch 'master' into bez/in-process-test-framework
alexanderbez ff14f0d
Merge branch 'master' into bez/in-process-test-framework
fedekunze 93454e5
cl++
alexanderbez 52aa585
Add section to godoc
alexanderbez f889a0b
testutil: address comments
alexanderbez cdc9db6
Update testutil/doc.go
alexanderbez 8aa5c71
Update testutil/doc.go
alexanderbez 426505e
Update testutil/doc.go
alexanderbez c6a208a
testutil: make app confiruable
alexanderbez 05fd4a7
testutil: update go doc
alexanderbez 38aac75
Merge branch 'bez/in-process-test-framework' of github.com:cosmos/cos…
alexanderbez 195447e
testutil: revise app con
alexanderbez 939b6c3
testutil: update go doc
alexanderbez 9c77941
Fixes
alexanderbez 89a447d
Merge branch 'master' into bez/in-process-test-framework
alexanderbez df0b1b6
Merge branch 'master' into bez/in-process-test-framework
mergify[bot] ddb342b
Merge branch 'master' into bez/in-process-test-framework
mergify[bot] 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 was deleted.
Oops, something went wrong.
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
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,65 @@ | ||
/* | ||
Package testutil implements and exposes a fully operational in-process Tendermint | ||
test network that consists of at least one or potentially many validators. This | ||
test network can be used primarily for integration tests or unit test suites. | ||
|
||
The testnetwork utilizes SimApp as the ABCI application and uses all the modules | ||
defined in the Cosmos SDK. An in-process test network can be configured with any | ||
number of validators as well as account funds and even custom genesis state. | ||
|
||
When creating a test network, a series of Validator objects are returned. Each | ||
Validator objects has useful information such as their address and pubkey. A | ||
alexanderbez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Validator will also provide its RPC, P2P, and API addresses that can be useful | ||
for integration testing. In addition, a Tendermint local RPC client also provided | ||
alexanderbez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
which can be handy for making direct RPC calls to Tendermint. | ||
|
||
Note, due to limitations in concurrency and the design of the RPC layer in | ||
Tendermint, only the first Validator objects will have an RPC and API client | ||
alexanderbez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
exposed. Due to this exact same limitation, only a single test network can exist | ||
at a time. A caller must be certain it calls Cleanup after it no longer needs | ||
the network. | ||
|
||
A typical testing flow might look like the following: | ||
|
||
type IntegrationTestSuite struct { | ||
suite.Suite | ||
|
||
cfg testutil.Config | ||
network *testutil.Network | ||
} | ||
|
||
func (s *IntegrationTestSuite) SetupSuite() { | ||
s.T().Log("setting up integration test suite") | ||
|
||
cfg := testutil.DefaultConfig() | ||
cfg.NumValidators = 1 | ||
|
||
s.cfg = cfg | ||
s.network = testutil.NewTestNetwork(s.T(), cfg) | ||
|
||
_, err := s.network.WaitForHeight(1) | ||
s.Require().NoError(err) | ||
} | ||
|
||
func (s *IntegrationTestSuite) TearDownSuite() { | ||
s.T().Log("tearing down integration test suite") | ||
|
||
// This is important and must be called to ensure other tests can create | ||
// a network! | ||
s.network.Cleanup() | ||
} | ||
|
||
func (s *IntegrationTestSuite) TestQueryBalancesRequestHandlerFn() { | ||
val := s.network.Validators[0] | ||
baseURL := val.APIAddress | ||
|
||
// Use baseURL to make API HTTP requests or use val.RPCClient to make direct | ||
// Tendermint RPC calls. | ||
// ... | ||
} | ||
|
||
func TestIntegrationTestSuite(t *testing.T) { | ||
suite.Run(t, new(IntegrationTestSuite)) | ||
} | ||
*/ | ||
package testutil |
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.
I did not realize Tendermint HTTP client actually blocks -- this fixes that so we can properly cleanup below.