-
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: migrate e2e/genutil to systemtest #22325
Merged
Merged
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
5b8f187
genutil tests
hieuvubk fdd414d
remove migrated test
hieuvubk 0423a83
go mod
hieuvubk 2cffb17
Merge branch 'main' into hieu/systemtest/genutil
hieuvubk 243f9c0
refactor
hieuvubk c0dc7b3
split test
hieuvubk 035dd78
check
hieuvubk e6f82dc
home path
hieuvubk cf3e1dc
sleep
hieuvubk 47c47fa
check
hieuvubk 0e28e7b
disable LoadHeight log
hieuvubk 20a7690
update
hieuvubk c7a2c77
un comment
hieuvubk fe5f43e
Merge branch 'main' into hieu/systemtest/genutil
hieuvubk 9471780
clean up
hieuvubk ca0e086
Merge branch 'hieu/systemtest/genutil' of https://github.com/cosmos/c…
hieuvubk 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
//go:build system_test | ||
|
||
package systemtests | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
"github.com/tidwall/gjson" | ||
) | ||
|
||
func TestExportCmd(t *testing.T) { | ||
// scenario: test bank send command | ||
// given a running chain | ||
|
||
sut.ResetChain(t) | ||
cli := NewCLIWrapper(t, sut, verbose) | ||
exportFile := "foobar.json" | ||
|
||
sut.StartChain(t) | ||
|
||
testCases := []struct { | ||
name string | ||
args []string | ||
expErr bool | ||
errMsg string | ||
expZeroHeight bool | ||
}{ | ||
{"invalid home dir", []string{"genesis", "export", "--home=foo"}, true, "no such file or directory", false}, | ||
{"should export correct height", []string{"genesis", "export"}, false, "", false}, | ||
{"should export correct height with --height", []string{"genesis", "export", "--height=5"}, false, "", false}, | ||
{"should export height 0 with --for-zero-height", []string{"genesis", "export", "--for-zero-height=true"}, false, "", true}, | ||
{"should export state to the specified file", []string{"genesis", "export", fmt.Sprintf("--output-document=%s", exportFile)}, false, "", false}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
|
||
// fmt.Println(tc.name, res) | ||
if tc.expErr { | ||
assertOutput := func(_ assert.TestingT, gotErr error, gotOutputs ...interface{}) bool { | ||
require.Contains(t, gotOutputs[0], tc.errMsg) | ||
return false | ||
} | ||
cli.WithRunErrorMatcher(assertOutput).RunCommandWithArgs(tc.args...) | ||
} else { | ||
res := cli.RunCommandWithArgs(tc.args...) | ||
if res == "" { | ||
require.FileExists(t, exportFile) | ||
os.Remove(exportFile) | ||
} else { | ||
height := gjson.Get(res, "initial_height").Int() | ||
if tc.expZeroHeight { | ||
require.Equal(t, height, int64(0)) | ||
} else { | ||
require.Greater(t, height, int64(0)) | ||
} | ||
|
||
// Check consensus params of exported state | ||
maxGas := gjson.Get(res, "consensus.params.block.max_gas").Int() | ||
require.Equal(t, maxGas, int64(MaxGas)) | ||
} | ||
} | ||
} | ||
} |
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
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.
💡 Codebase verification
Inconsistent Usage of Gas Limits Detected
Several hardcoded gas limits found alongside
MaxGas
usage may lead to inconsistencies.x/simulation/simulate.go:40-45
types/tx/types.go:18-19,61-64
server/v2/cometbft/abci_test.go:37,335,374,638
baseapp/abci_utils.go:262,415
🔗 Analysis chain
Usage of
MaxGas
constant inSetupChain
methodThe
MaxGas
constant is now used to set the maximum gas limit in the genesis block configuration. This change improves code consistency and makes it easier to modify the gas limit across the system if needed.However, to ensure this change doesn't have unintended consequences, we should verify its usage across the codebase.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 5558