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(tests/systemtests): remove v2 checks #23098

Merged
merged 13 commits into from
Jan 9, 2025
Merged
Changes from 9 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
2 changes: 1 addition & 1 deletion systemtests/system.go
aljo242 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -733,7 +733,7 @@ func (s *SystemUnderTest) AddFullnode(t *testing.T, beforeStart ...func(nodeNumb
configFile := filepath.Join(configPath, tomlFile)
_ = os.Remove(configFile)
_ = MustCopyFile(filepath.Join(WorkDir, s.nodePath(0), "config", tomlFile), configFile)
if tomlFile == "app.toml" && IsV2() {
if tomlFile == "app.toml" {
file := filepath.Join(WorkDir, s.nodePath(nodeNumber), "config", tomlFile)
EditToml(file, func(doc *tomledit.Document) {
SetValue(doc, fmt.Sprintf("%s:%d", node.IP, DefaultApiPort+nodeNumber), "grpc-gateway", "address")
2 changes: 1 addition & 1 deletion systemtests/test_runner.go
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ func RunTests(m *testing.M) {
waitTime := flag.Duration("wait-time", DefaultWaitTime, "time to wait for chain events")
nodesCount := flag.Int("nodes-count", 4, "number of nodes in the cluster")
blockTime := flag.Duration("block-time", 1000*time.Millisecond, "block creation time")
execBinary := flag.String("binary", "simd", "executable binary for server/ client side")
execBinary := flag.String("binary", "simdv2", "executable binary for server/ client side")
bech32Prefix := flag.String("bech32", "cosmos", "bech32 prefix to be used with addresses")
flag.BoolVar(&Verbose, "verbose", false, "verbose output")
flag.Parse()
20 changes: 2 additions & 18 deletions systemtests/testnet_init.go
Original file line number Diff line number Diff line change
@@ -13,12 +13,6 @@ import (
"github.com/creachadair/tomledit/parser"
)

// IsV2 checks if the tests run with simapp v2
func IsV2() bool {
buildOptions := os.Getenv("COSMOS_BUILD_OPTIONS")
return strings.Contains(buildOptions, "v2")
}

// SingleHostTestnetCmdInitializer default testnet cmd that supports the --single-host param
type SingleHostTestnetCmdInitializer struct {
execBinary string
@@ -75,12 +69,7 @@ func (s SingleHostTestnetCmdInitializer) Initialize() {
"--keyring-backend=test",
"--commit-timeout=" + s.commitTimeout.String(),
"--single-host",
}

if IsV2() {
args = append(args, "--server.minimum-gas-prices="+s.minGasPrice)
} else {
args = append(args, "--minimum-gas-prices="+s.minGasPrice)
"--server.minimum-gas-prices=" + s.minGasPrice,
}

s.log(fmt.Sprintf("+++ %s %s\n", s.execBinary, strings.Join(args, " ")))
@@ -127,12 +116,7 @@ func (s ModifyConfigYamlInitializer) Initialize() {
"--output-dir=" + s.outputDir,
"--v=" + strconv.Itoa(s.initialNodesCount),
"--keyring-backend=test",
}

if IsV2() {
args = append(args, "--server.minimum-gas-prices="+s.minGasPrice)
} else {
args = append(args, "--minimum-gas-prices="+s.minGasPrice)
"--server.minimum-gas-prices=" + s.minGasPrice,
}

s.log(fmt.Sprintf("+++ %s %s\n", s.execBinary, strings.Join(args, " ")))
2 changes: 1 addition & 1 deletion tests/systemtests/README.md
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ Or via manual steps
```shell
make build
mkdir -p ./tests/systemtests/binaries
cp ./build/simd ./tests/systemtests/binaries/
cp ./build/simdv2 ./tests/systemtests/binaries/
```

### Manual test run
4 changes: 0 additions & 4 deletions tests/systemtests/bankv2_test.go
Original file line number Diff line number Diff line change
@@ -13,10 +13,6 @@ import (
)

func TestBankV2SendTxCmd(t *testing.T) {
// Currently only run with app v2
if !systest.IsV2() {
t.Skip()
}
// scenario: test bank send command
// given a running chain

7 changes: 1 addition & 6 deletions tests/systemtests/cometbft_client_test.go
Original file line number Diff line number Diff line change
@@ -27,12 +27,7 @@ func TestQueryStatus(t *testing.T) {
cli := systest.NewCLIWrapper(t, systest.Sut, systest.Verbose)
systest.Sut.StartChain(t)

var resp string
if systest.IsV2() {
resp = cli.CustomQuery("comet", "status")
} else {
resp = cli.CustomQuery("status")
}
resp := cli.CustomQuery("comet", "status")

// make sure the output has the validator moniker.
assert.Contains(t, resp, "\"moniker\":\"node0\"")
20 changes: 13 additions & 7 deletions tests/systemtests/go.mod
Original file line number Diff line number Diff line change
@@ -3,11 +3,21 @@ module github.com/cosmos/cosmos-sdk/tests/systemtests
go 1.23

require (
cosmossdk.io/math v1.4.0
cosmossdk.io/math v1.5.0
cosmossdk.io/systemtests v1.0.0
github.com/cosmos/cosmos-sdk v0.50.11
)

require (
github.com/cockroachdb/apd/v3 v3.2.1 // indirect
github.com/cometbft/cometbft/api v1.0.0-rc.1 // indirect
github.com/creachadair/tomledit v0.0.27 // indirect
github.com/google/orderedcode v0.0.1 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/lib/pq v1.10.9 // indirect
github.com/minio/highwayhash v1.0.3 // indirect
)

require (
cosmossdk.io/api v0.7.6 // indirect
cosmossdk.io/collections v0.4.0 // indirect
@@ -38,7 +48,6 @@ require (
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
github.com/cometbft/cometbft v0.38.15 // indirect
github.com/cometbft/cometbft-db v0.14.1 // indirect
github.com/cometbft/cometbft/api v1.0.0-rc.1 // indirect
github.com/cosmos/btcutil v1.0.5 // indirect
github.com/cosmos/cosmos-db v1.1.1 // indirect
github.com/cosmos/cosmos-proto v1.0.0-beta.5 // indirect
@@ -48,7 +57,6 @@ require (
github.com/cosmos/iavl v1.2.2 // indirect
github.com/cosmos/ics23/go v0.11.0 // indirect
github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect
github.com/creachadair/tomledit v0.0.27 // indirect
github.com/danieljoos/wincred v1.1.2 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect
@@ -75,7 +83,6 @@ require (
github.com/google/btree v1.1.3 // indirect
github.com/google/flatbuffers v1.12.1 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/orderedcode v0.0.1 // indirect
github.com/gorilla/handlers v1.5.1 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
@@ -87,7 +94,6 @@ require (
github.com/hashicorp/go-metrics v0.5.3 // indirect
github.com/hashicorp/go-plugin v1.6.2 // indirect
github.com/hashicorp/golang-lru v1.0.2 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/yamux v0.1.2 // indirect
github.com/hdevalence/ed25519consensus v0.1.0 // indirect
@@ -100,12 +106,10 @@ require (
github.com/klauspost/cpuid/v2 v2.2.9 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/lib/pq v1.10.9 // indirect
github.com/linxGnu/grocksdb v1.9.7 // indirect
github.com/magiconair/properties v1.8.9 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/minio/highwayhash v1.0.3 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mtibben/percent v0.2.1 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
@@ -167,3 +171,5 @@ require (
pgregory.net/rapid v1.1.0 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)

replace cosmossdk.io/systemtests => ../../systemtests
8 changes: 4 additions & 4 deletions tests/systemtests/go.sum
Original file line number Diff line number Diff line change
@@ -12,12 +12,10 @@ cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0=
cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U=
cosmossdk.io/log v1.5.0 h1:dVdzPJW9kMrnAYyMf1duqacoidB9uZIl+7c6z0mnq0g=
cosmossdk.io/log v1.5.0/go.mod h1:Tr46PUJjiUthlwQ+hxYtUtPn4D/oCZXAkYevBeh5+FI=
cosmossdk.io/math v1.4.0 h1:XbgExXFnXmF/CccPPEto40gOO7FpWu9yWNAZPN3nkNQ=
cosmossdk.io/math v1.4.0/go.mod h1:O5PkD4apz2jZs4zqFdTr16e1dcaQCc5z6lkEnrrppuk=
cosmossdk.io/math v1.5.0 h1:sbOASxee9Zxdjd6OkzogvBZ25/hP929vdcYcBJQbkLc=
cosmossdk.io/math v1.5.0/go.mod h1:AAwwBmUhqtk2nlku174JwSll+/DepUXW3rWIXN5q+Nw=
cosmossdk.io/store v1.1.1 h1:NA3PioJtWDVU7cHHeyvdva5J/ggyLDkyH0hGHl2804Y=
cosmossdk.io/store v1.1.1/go.mod h1:8DwVTz83/2PSI366FERGbWSH7hL6sB7HbYp8bqksNwM=
cosmossdk.io/systemtests v1.0.0 h1:VuEj4aA//v1icbMoA6UMuWOwO6ejb6uK7PzSBT+Y460=
cosmossdk.io/systemtests v1.0.0/go.mod h1:6kl2MKa7tLoW8vgKx4ZgwAqWVD1T7eAiL5mc/9R7XGY=
cosmossdk.io/x/tx v1.0.0-alpha.3 h1:+55/JFH5QRqnFhOI2heH3DKsaNL0RpXcJOQNzUvHiaQ=
cosmossdk.io/x/tx v1.0.0-alpha.3/go.mod h1:h4pQ/j6Gfu8goB1R3Jbl4qY4RjYVNAsoylcleTXdSRg=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
@@ -115,6 +113,8 @@ github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWH
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/cockroachdb/apd/v2 v2.0.2 h1:weh8u7Cneje73dDh+2tEVLUvyBc89iwepWCD8b8034E=
github.com/cockroachdb/apd/v2 v2.0.2/go.mod h1:DDxRlzC2lo3/vSlmSoS7JkqbbrARPuFOGr0B9pvN3Gw=
github.com/cockroachdb/apd/v3 v3.2.1 h1:U+8j7t0axsIgvQUqthuNm82HIrYXodOV2iWLWtEaIwg=
github.com/cockroachdb/apd/v3 v3.2.1/go.mod h1:klXJcjp+FffLTHlhIG69tezTDvdP065naDsHzKhYSqc=
github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8=
github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f h1:otljaYPt5hWxV3MUfO5dFPFiOXg9CyG5/kCfayTqsJ4=
github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU=
21 changes: 5 additions & 16 deletions tests/systemtests/group_test.go
Original file line number Diff line number Diff line change
@@ -63,15 +63,9 @@ func TestGroupCommands(t *testing.T) {
rsp = cli.RunAndWait(policyCmd...)
systest.RequireTxSuccess(t, rsp)

// TODO: remove isV2() check once v2 is integrated with grpc gateway
var groupPoliciesResp, policyAddrQuery string
if systest.IsV2() {
groupPoliciesResp = cli.CustomQuery("q", "group", "group-policies-by-group", groupId)
policyAddrQuery = fmt.Sprintf("group_policies.#(decision_policy.value.threshold==%d).address", threshold)
} else {
groupPoliciesResp = string(systest.GetRequest(t, fmt.Sprintf("%s/cosmos/group/v1/group_policies_by_group/%s", baseurl, groupId)))
policyAddrQuery = fmt.Sprintf("group_policies.#(decision_policy.threshold==%d).address", threshold)
}
groupPoliciesResp := string(systest.GetRequest(t, fmt.Sprintf("%s/cosmos/group/v1/group_policies_by_group/%s", baseurl, groupId)))
policyAddrQuery := fmt.Sprintf("group_policies.#(decision_policy.threshold==%d).address", threshold)

require.Equal(t, gjson.Get(groupPoliciesResp, "pagination.total").Int(), int64(threshold))
policyAddr := gjson.Get(groupPoliciesResp, policyAddrQuery).String()
require.NotEmpty(t, policyAddr)
@@ -122,12 +116,7 @@ func TestGroupCommands(t *testing.T) {
systest.RequireTxSuccess(t, rsp)

// query votes
// TODO: remove isV2() check once v2 is integrated with grpc gateway
var voteResp string
if systest.IsV2() {
voteResp = cli.CustomQuery("q", "group", "vote", proposalId, valAddr)
} else {
voteResp = string(systest.GetRequest(t, fmt.Sprintf("%s/cosmos/group/v1/vote_by_proposal_voter/%s/%s", baseurl, proposalId, valAddr)))
}
voteResp := string(systest.GetRequest(t, fmt.Sprintf("%s/cosmos/group/v1/vote_by_proposal_voter/%s/%s", baseurl, proposalId, valAddr)))

require.Equal(t, "VOTE_OPTION_YES", gjson.Get(voteResp, "vote.option").String())
}
4 changes: 0 additions & 4 deletions tests/systemtests/mint_test.go
Original file line number Diff line number Diff line change
@@ -74,10 +74,6 @@ func TestMintQueries(t *testing.T) {

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
// TODO: remove below check once grpc gateway is implemented in v2
if systest.IsV2() {
return
}
resp := systest.GetRequestWithHeaders(t, tc.url, tc.headers, http.StatusOK)
require.JSONEq(t, tc.expOut, string(resp))
})
24 changes: 4 additions & 20 deletions tests/systemtests/snapshots_test.go
Original file line number Diff line number Diff line change
@@ -26,18 +26,9 @@ func TestSnapshots(t *testing.T) {
// Stop all nodes
systest.Sut.StopChain()

var (
command string
restoreableDirs []string
)
node0Dir := systest.Sut.NodeDir(0)
if systest.IsV2() {
command = "store"
restoreableDirs = []string{fmt.Sprintf("%s/data/application.db", node0Dir), fmt.Sprintf("%s/data/ss", node0Dir)}
} else {
command = "snapshots"
restoreableDirs = []string{fmt.Sprintf("%s/data/application.db", node0Dir)}
}
command := "store"
restoreableDirs := []string{fmt.Sprintf("%s/data/application.db", node0Dir), fmt.Sprintf("%s/data/ss", node0Dir)}

// export snapshot at height 5
res := cli.RunCommandWithArgs(command, "export", "--height=5", fmt.Sprintf("--home=%s", node0Dir), disabledLog)
@@ -68,9 +59,7 @@ func TestSnapshots(t *testing.T) {
// Remove database
err := os.RemoveAll(fmt.Sprintf("%s/data/application.db", node0Dir))
require.NoError(t, err)
if systest.IsV2() {
require.NoError(t, os.RemoveAll(fmt.Sprintf("%s/data/ss", node0Dir)))
}
require.NoError(t, os.RemoveAll(fmt.Sprintf("%s/data/ss", node0Dir)))

res = cli.RunCommandWithArgs(command, "restore", "5", "3", fmt.Sprintf("--home=%s", node0Dir), disabledLog)
for _, dir := range restoreableDirs {
@@ -95,12 +84,7 @@ func TestPrune(t *testing.T) {
node0Dir := systest.Sut.NodeDir(0)

// prune
var command []string
if systest.IsV2() {
command = []string{"store", "prune", "--store.keep-recent=1"}
} else {
command = []string{"prune", "everything"}
}
command := []string{"store", "prune", "--store.keep-recent=1"}
res := cli.RunCommandWithArgs(append(command, fmt.Sprintf("--home=%s", node0Dir), disabledLog)...)
require.Contains(t, res, "successfully pruned the application root multi stores")
}
7 changes: 2 additions & 5 deletions tests/systemtests/staking_test.go
Original file line number Diff line number Diff line change
@@ -42,11 +42,8 @@ func TestStakeUnstake(t *testing.T) {
assert.Equal(t, int64(8999999), cli.QueryBalance(account1Addr, "stake"))

// check validator has been updated
if systest.IsV2() {
rsp = cli.CustomQuery("q", "comet", "block-results", gjson.Get(rsp, "height").String())
} else {
rsp = cli.CustomQuery("q", "block-results", gjson.Get(rsp, "height").String())
}
rsp = cli.CustomQuery("q", "comet", "block-results", gjson.Get(rsp, "height").String())

Comment on lines +45 to +46
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Remove unnecessary "q" prefix from query command

The "q" prefix in cli.CustomQuery("q", "comet", "block-results", ...) is inconsistent with both the official command pattern and other test files. Remove the prefix to match the standard format seen in cometbft_client_test.go.

🔗 Analysis chain

Verify query path consistency.

While removing version checks simplifies the code, the query path comet block-results differs from the pattern seen in other files (e.g., comet status in cometbft_client_test.go). Please verify if this should be standardized.

Run this script to check query path consistency across the codebase:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for consistency in comet query paths
# Test: Search for all comet query patterns to ensure consistency

echo "Searching for comet query patterns:"
rg -A 1 'CustomQuery\("q",\s*"comet"'

Length of output: 278


Script:

#!/bin/bash
# Search for all query patterns related to comet/cometbft
echo "Searching for all comet/cometbft related queries:"
rg -i "custom.*query.*comet|comet.*status|block.*results" -A 2

# Also search for specific file mentioned in the comment
echo -e "\nChecking cometbft_client_test.go specifically:"
fd "cometbft_client_test.go" --exec cat {}

Length of output: 29481

validatorUpdates := gjson.Get(rsp, "validator_updates").Array()
assert.NotEmpty(t, validatorUpdates)
vpk := gjson.Get(validatorUpdates[0].String(), "pub_key_bytes").String()
7 changes: 3 additions & 4 deletions tests/systemtests/unordered_tx_test.go
Original file line number Diff line number Diff line change
@@ -14,10 +14,9 @@ import (
)

func TestUnorderedTXDuplicate(t *testing.T) {
if systest.IsV2() {
t.Skip("The unordered tx handling is not wired in v2")
return
}
// TODO: remove once unordered tx handling is working in v2
t.Skip("The unordered tx handling is not wired in v2")

// scenario: test unordered tx duplicate
// given a running chain with a tx in the unordered tx pool
// when a new tx with the same hash is broadcasted