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

test: fix test with nightly #597

Merged
merged 1 commit into from
Jul 25, 2024
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
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ test-count:
go test -mod=readonly -cpu 1 -count 1 -cover ./... | grep -v 'types\|cli\|no test files'

test-nightly:
@TEST_INTEGRATION=true go test -mod=readonly -v -run TestIntegrationTest ./tests
@TEST_CROSSCHAIN=true go test -mod=readonly -v -run TestCrosschainKeeperTestSuite ./x/crosschain/...
@TEST_INTEGRATION=true go test -mod=readonly -cpu 4 -v -run TestIntegrationTest ./tests
@TEST_CROSSCHAIN=true go test -mod=readonly -cpu 4 -v -run TestCrosschainKeeperTestSuite ./x/crosschain/...

mocks:
@go install go.uber.org/mock/[email protected]
Expand Down
16 changes: 6 additions & 10 deletions tests/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,10 @@ func (suite *TestSuite) SetupSuite() {
suite.T().Log("setting up integration test suite")

numValidators := suite.numValidator
timeoutCommit := time.Millisecond
suite.timeoutCommit = time.Millisecond
if numValidators > 1 {
timeoutCommit = 500 * time.Millisecond
suite.timeoutCommit = 500 * time.Millisecond
}
suite.timeoutCommit = timeoutCommit

ibcGenesisOpt := func(config *network.Config) {
config.GenesisState = testutil.IbcGenesisState(encCfg.Codec, config.GenesisState)
Expand All @@ -93,7 +92,7 @@ func (suite *TestSuite) SetupSuite() {
govGenesisOpt := func(config *network.Config) {
votingPeriod := time.Millisecond
if numValidators > 1 {
votingPeriod = time.Duration(numValidators*5) * timeoutCommit
votingPeriod = time.Duration(numValidators*5) * suite.timeoutCommit
}
config.GenesisState = testutil.GovGenesisState(encCfg.Codec, config.GenesisState, votingPeriod)
}
Expand All @@ -105,7 +104,7 @@ func (suite *TestSuite) SetupSuite() {
}

cfg := testutil.DefaultNetworkConfig(encCfg, ibcGenesisOpt, bankGenesisOpt, govGenesisOpt, slashingGenesisOpt)
cfg.TimeoutCommit = timeoutCommit
cfg.TimeoutCommit = suite.timeoutCommit
cfg.NumValidators = numValidators
cfg.EnableJSONRPC = true
if suite.enableTMLogging {
Expand All @@ -117,10 +116,7 @@ func (suite *TestSuite) SetupSuite() {
suite.network, err = network.New(suite.T(), baseDir, cfg)
suite.Require().NoError(err)

time.Sleep(timeoutCommit * 10)
for suite.BlockNumber() <= 3 {
time.Sleep(timeoutCommit * 2)
}
_, err = suite.network.WaitForHeight(3)
suite.Require().NoError(err)
}

Expand Down Expand Up @@ -278,7 +274,7 @@ func (suite *TestSuite) BroadcastTx(privKey cryptotypes.PrivKey, msgList ...sdk.
txResponse, err := grpcClient.BroadcastTx(txRaw)
suite.NoError(err)
suite.NotNil(txResponse) // txResponse might be nil, but error is also nil
txResponse, err = grpcClient.WaitMined(txResponse.TxHash, 10*time.Second, 1*time.Second)
txResponse, err = grpcClient.WaitMined(txResponse.TxHash, 200*suite.timeoutCommit, 10*suite.timeoutCommit)
suite.NoError(err)
suite.T().Log("broadcast tx", "msg:", sdk.MsgTypeURL(msgList[0]), "height:", txResponse.Height, "txHash:", txResponse.TxHash)
suite.NoError(suite.network.WaitForNextBlock())
Expand Down