diff --git a/tests/interchain/chainsuite/chain.go b/tests/interchain/chainsuite/chain.go index cd1e6b5808..b1ffcea871 100644 --- a/tests/interchain/chainsuite/chain.go +++ b/tests/interchain/chainsuite/chain.go @@ -455,3 +455,29 @@ func (c *Chain) AddLinkedChain(ctx context.Context, testName interchaintest.Test return chainB, nil } + +func (c *Chain) ModifyConfig(ctx context.Context, testName interchaintest.TestName, configChanges map[string]testutil.Toml) error { + eg := errgroup.Group{} + for _, val := range c.Validators { + val := val + eg.Go(func() error { + for file, changes := range configChanges { + if err := testutil.ModifyTomlConfigFile( + ctx, GetLogger(ctx), + val.DockerClient, testName.Name(), val.VolumeName, + file, changes, + ); err != nil { + return err + } + } + if err := val.StopContainer(ctx); err != nil { + return err + } + return val.StartContainer(ctx) + }) + } + if err := eg.Wait(); err != nil { + return err + } + return nil +} diff --git a/tests/interchain/go.mod b/tests/interchain/go.mod index 6d0d0fdeb0..eac08fcfc0 100644 --- a/tests/interchain/go.mod +++ b/tests/interchain/go.mod @@ -28,6 +28,8 @@ require ( github.com/docker/docker v27.1.2+incompatible github.com/google/go-github/v62 v62.0.0 github.com/kelseyhightower/envconfig v1.4.0 + github.com/prometheus/client_model v0.6.1 + github.com/prometheus/common v0.60.1 github.com/strangelove-ventures/interchaintest/v8 v8.6.2-0.20240821162827-3ea6fbce13ba github.com/stretchr/testify v1.9.0 github.com/tidwall/gjson v1.17.3 @@ -218,9 +220,7 @@ require ( github.com/pierrec/xxHash v0.1.5 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/prometheus/client_golang v1.20.1 // indirect - github.com/prometheus/client_model v0.6.1 // indirect - github.com/prometheus/common v0.55.0 // indirect + github.com/prometheus/client_golang v1.20.4 // indirect github.com/prometheus/procfs v0.15.1 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect @@ -259,13 +259,13 @@ require ( go.opentelemetry.io/otel v1.28.0 // indirect go.opentelemetry.io/otel/metric v1.28.0 // indirect go.opentelemetry.io/otel/trace v1.28.0 // indirect - golang.org/x/crypto v0.26.0 // indirect + golang.org/x/crypto v0.27.0 // indirect golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa // indirect - golang.org/x/net v0.28.0 // indirect - golang.org/x/oauth2 v0.22.0 // indirect - golang.org/x/sys v0.24.0 // indirect - golang.org/x/term v0.23.0 // indirect - golang.org/x/text v0.17.0 // indirect + golang.org/x/net v0.29.0 // indirect + golang.org/x/oauth2 v0.23.0 // indirect + golang.org/x/sys v0.25.0 // indirect + golang.org/x/term v0.24.0 // indirect + golang.org/x/text v0.18.0 // indirect golang.org/x/time v0.6.0 // indirect golang.org/x/tools v0.24.0 // indirect google.golang.org/api v0.193.0 // indirect diff --git a/tests/interchain/go.sum b/tests/interchain/go.sum index b2d2be54de..19e12a84e8 100644 --- a/tests/interchain/go.sum +++ b/tests/interchain/go.sum @@ -1021,8 +1021,8 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.20.1 h1:IMJXHOD6eARkQpxo8KkhgEVFlBNm+nkrFUyGlIu7Na8= -github.com/prometheus/client_golang v1.20.1/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= +github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI= +github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -1037,8 +1037,8 @@ github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt2 github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc= -github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8= +github.com/prometheus/common v0.60.1 h1:FUas6GcOw66yB/73KC+BOZoFJmbo/1pojoILArPAaSc= +github.com/prometheus/common v0.60.1/go.mod h1:h0LYf1R1deLSKtD4Vdg8gy4RuOvENW2J/h19V5NADQw= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= @@ -1249,8 +1249,8 @@ golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= -golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= +golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A= +golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1351,8 +1351,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= -golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= -golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= +golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= +golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1378,8 +1378,8 @@ golang.org/x/oauth2 v0.0.0-20220822191816-0ebed06d0094/go.mod h1:h4gKUeWbJ4rQPri golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.1.0/go.mod h1:G9FE4dLTsbXUu90h/Pf85g4w1D+SSAgR+q46nJZ8M4A= -golang.org/x/oauth2 v0.22.0 h1:BzDx2FehcG7jJwgWLELCdmLuxk2i+x9UDpSiss2u0ZA= -golang.org/x/oauth2 v0.22.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs= +golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1493,13 +1493,13 @@ golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= -golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= +golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU= -golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk= +golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM= +golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1510,8 +1510,8 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= -golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= +golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= diff --git a/tests/interchain/validator/config_test.go b/tests/interchain/validator/config_test.go new file mode 100644 index 0000000000..9b4891f3de --- /dev/null +++ b/tests/interchain/validator/config_test.go @@ -0,0 +1,268 @@ +package validator_test + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "net" + "net/url" + "strings" + "testing" + "time" + + "github.com/cosmos/gaia/v21/tests/interchain/chainsuite" + "github.com/gorilla/websocket" + dto "github.com/prometheus/client_model/go" + "github.com/prometheus/common/expfmt" + "github.com/strangelove-ventures/interchaintest/v8" + "github.com/strangelove-ventures/interchaintest/v8/chain/cosmos" + "github.com/strangelove-ventures/interchaintest/v8/testutil" + "github.com/stretchr/testify/suite" + "golang.org/x/sync/errgroup" +) + +type ConfigSuite struct { + *chainsuite.Suite +} + +func (s *ConfigSuite) TestNoIndexingTransactions() { + txIndex := make(testutil.Toml) + txIndex["indexer"] = "null" + configToml := make(testutil.Toml) + configToml["tx_index"] = txIndex + s.Require().NoError(s.Chain.ModifyConfig( + s.GetContext(), s.T(), + map[string]testutil.Toml{"config/config.toml": configToml}, + )) + + balanceBefore, err := s.Chain.GetBalance(s.GetContext(), + s.Chain.ValidatorWallets[0].Address, + s.Chain.Config().Denom) + s.Require().NoError(err) + amount := 1_000_000 + cmd := s.Chain.GetNode().TxCommand( + interchaintest.FaucetAccountKeyName, "bank", "send", + interchaintest.FaucetAccountKeyName, s.Chain.ValidatorWallets[0].Address, + fmt.Sprintf("%d%s", amount, s.Chain.Config().Denom), + ) + stdout, _, err := s.Chain.GetNode().Exec(s.GetContext(), cmd, nil) + s.Require().NoError(err) + tx := cosmos.CosmosTx{} + s.Require().NoError(json.Unmarshal(stdout, &tx)) + s.Require().NoError(testutil.WaitForBlocks(s.GetContext(), 2, s.Chain)) + + balanceAfter, err := s.Chain.GetBalance(s.GetContext(), + s.Chain.ValidatorWallets[0].Address, + s.Chain.Config().Denom) + s.Require().NoError(err) + s.Require().Equal(balanceBefore.AddRaw(int64(amount)), balanceAfter) + + _, err = s.Chain.GetTransaction(tx.TxHash) + s.Require().Error(err) + s.Require().Contains(err.Error(), "transaction indexing is disabled") +} + +func (s *ConfigSuite) TestPrometheus() { + err := s.enablePrometheus() + s.Require().NoError(err) + metrics, err := s.getPrometheusMetrics(0) + s.Require().NoError(err) + s.Require().Contains(metrics, "go_gc_duration_seconds") +} + +func (s *ConfigSuite) TestPruningEverything() { + appToml := make(testutil.Toml) + appToml["pruning"] = "everything" + statesync := make(testutil.Toml) + statesync["snapshot-interval"] = 0 + appToml["state-sync"] = statesync + s.Require().NoError(s.Chain.ModifyConfig( + s.GetContext(), s.T(), + map[string]testutil.Toml{"config/app.toml": appToml}, + )) + + s.smokeTestTx() +} + +func (s *ConfigSuite) TestPeerLimit() { + err := s.enablePrometheus() + s.Require().NoError(err) + + metrics, err := s.getPrometheusMetrics(0) + s.Require().NoError(err) + s.Require().Equal(float64(3), metrics["cometbft_p2p_peers"].GetMetric()[0].GetGauge().GetValue()) + + peers := s.Chain.Nodes().PeerString(s.GetContext()) + peerList := strings.Split(peers, ",") + for i, node := range s.Chain.Nodes() { + if i > 0 { + s.Require().NoError(node.SetPeers(s.GetContext(), peerList[0])) + } + } + s.Require().NoError(s.Chain.Validators[0].SetPeers(s.GetContext(), "")) + + p2p := make(testutil.Toml) + p2p["max_num_inbound_peers"] = 2 + // disable pex so that we can control the number of peers + // p2p["pex"] = false + configToml := make(testutil.Toml) + configToml["p2p"] = p2p + err = s.Chain.ModifyConfig( + s.GetContext(), s.T(), + map[string]testutil.Toml{"config/config.toml": configToml}, + ) + if err != nil { + // it's okay if one of the nodes has 0 peers and fails to start + s.Require().Contains(err.Error(), "still catching up") + } + + s.Require().NoError(testutil.WaitForBlocks(s.GetContext(), 4, s.Chain)) + + metrics, err = s.getPrometheusMetrics(0) + s.Require().NoError(err) + s.Require().Equal(float64(2), metrics["cometbft_p2p_peers"].GetMetric()[0].GetGauge().GetValue()) + + foundZero := false + for i := 1; i < len(s.Chain.Validators); i++ { + metrics, err = s.getPrometheusMetrics(i) + s.Require().NoError(err) + metric := metrics["cometbft_p2p_peers"].GetMetric() + if (len(metric) == 0 || metric[0].GetGauge().GetValue() == float64(0)) && !foundZero { + // only one node should have 0 peers + foundZero = true + continue + } + s.Require().GreaterOrEqual(len(metric), 1) + s.Require().GreaterOrEqual(metric[0].GetGauge().GetValue(), float64(1)) + } +} + +func (s *ConfigSuite) TestWSConnectionLimit() { + const connectionCount = 20 + u, err := url.Parse(s.Chain.GetHostRPCAddress()) + s.Require().NoError(err) + u.Scheme = "ws" + u.Path = "/websocket" + var canConnect = func() error { + var eg errgroup.Group + tCtx, tCancel := context.WithTimeout(s.GetContext(), 80*time.Second) + defer tCancel() + for i := 0; i < connectionCount; i++ { + var i = i + eg.Go(func() error { + c, _, err := websocket.DefaultDialer.Dial(u.String(), nil) + if err != nil { + return err + } + defer c.Close() + err = c.WriteMessage( + websocket.TextMessage, + []byte(fmt.Sprintf(`{"jsonrpc":"2.0","method":"subscribe","params":["tm.event='NewBlock'"],"id":%d}`, i)), + ) + if err != nil { + return err + } + for tCtx.Err() == nil { + _, _, err = c.ReadMessage() + if err != nil { + return err + } + } + return c.WriteMessage(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseNormalClosure, "")) + }) + } + return eg.Wait() + } + s.Require().NoError(canConnect()) + + rpc := make(testutil.Toml) + rpc["max_open_connections"] = 10 + configToml := make(testutil.Toml) + configToml["rpc"] = rpc + s.Require().NoError(s.Chain.ModifyConfig( + s.GetContext(), s.T(), + map[string]testutil.Toml{"config/config.toml": configToml}, + )) + + s.Require().Error(canConnect()) +} + +func (s *ConfigSuite) TestDisableAPI() { + _, _, err := s.Chain.Validators[0].Exec(s.GetContext(), []string{"wget", "-O", "-", s.Chain.GetAPIAddress() + "/cosmos/auth/v1beta1/accounts"}, nil) + s.Require().NoError(err) + + apiToml := make(testutil.Toml) + apiToml["enable"] = false + appToml := make(testutil.Toml) + appToml["api"] = apiToml + s.Require().NoError(s.Chain.ModifyConfig( + s.GetContext(), s.T(), + map[string]testutil.Toml{"config/app.toml": appToml}, + )) + + _, _, err = s.Chain.Validators[0].Exec(s.GetContext(), []string{"wget", "-O", "-", s.Chain.GetAPIAddress() + "/cosmos/auth/v1beta1/accounts"}, nil) + s.Require().Error(err) +} + +func TestConfig(t *testing.T) { + nodes := 4 + s := &ConfigSuite{ + Suite: chainsuite.NewSuite(chainsuite.SuiteConfig{ + UpgradeOnSetup: true, + // Chains are gonna be test-scoped so that configuration changes + // don't persist between tests. + Scope: chainsuite.ChainScopeTest, + ChainSpec: &interchaintest.ChainSpec{ + NumValidators: &nodes, + }, + }), + } + suite.Run(t, s) +} + +func (s *ConfigSuite) enablePrometheus() error { + instrumentation := make(testutil.Toml) + instrumentation["prometheus"] = true + configToml := make(testutil.Toml) + configToml["instrumentation"] = instrumentation + return s.Chain.ModifyConfig( + s.GetContext(), s.T(), + map[string]testutil.Toml{"config/config.toml": configToml}, + ) +} + +func (s *ConfigSuite) getPrometheusMetrics(nodeIdx int) (map[string]*dto.MetricFamily, error) { + prometheusHost := s.Chain.Validators[nodeIdx].HostName() + prometheusHost = net.JoinHostPort(prometheusHost, "26660") + stdout, _, err := s.Chain.Validators[nodeIdx].Exec(s.GetContext(), + []string{"wget", "-O", "-", "http://" + prometheusHost}, nil) + if err != nil { + return nil, err + } + + reader := bytes.NewBuffer(stdout) + + var parser expfmt.TextParser + mf, err := parser.TextToMetricFamilies(reader) + if err != nil { + return nil, err + } + + return mf, nil +} + +// smokeTestTx does a basic bank send to verify that the validator is still working. +func (s *ConfigSuite) smokeTestTx() { + txhash, err := s.Chain.GetNode().ExecTx( + s.GetContext(), interchaintest.FaucetAccountKeyName, + "bank", "send", interchaintest.FaucetAccountKeyName, + s.Chain.ValidatorWallets[0].Address, "100"+s.Chain.Config().Denom, + ) + s.Require().NoError(err) + + tx, err := s.Chain.GetTransaction(txhash) + s.Require().NoError(err) + s.Require().Equal(uint32(0), tx.Code) + s.Require().Greater(tx.Height, int64(1)) +} diff --git a/tests/interchain/feemarket_test.go b/tests/interchain/validator/feemarket_test.go similarity index 88% rename from tests/interchain/feemarket_test.go rename to tests/interchain/validator/feemarket_test.go index 06097cb1d6..aa2d52b121 100644 --- a/tests/interchain/feemarket_test.go +++ b/tests/interchain/validator/feemarket_test.go @@ -1,4 +1,4 @@ -package interchain_test +package validator_test import ( "encoding/json" @@ -186,29 +186,11 @@ done } func (s *FeemarketSuite) setCommitTimeout(timeout time.Duration) { - eg := errgroup.Group{} - for _, val := range s.Chain.Validators { - val := val - eg.Go(func() error { - configToml := make(testutil.Toml) - consensusToml := make(testutil.Toml) - consensusToml["timeout_commit"] = timeout.String() - configToml["consensus"] = consensusToml - if err := testutil.ModifyTomlConfigFile( - s.GetContext(), chainsuite.GetLogger(s.GetContext()), - val.DockerClient, s.T().Name(), val.VolumeName, - "config/config.toml", configToml, - ); err != nil { - return err - } - if err := val.StopContainer(s.GetContext()); err != nil { - return err - } - return val.StartContainer(s.GetContext()) - }) - } - s.Require().NoError(eg.Wait()) - s.Require().NoError(testutil.WaitForBlocks(s.GetContext(), 1, s.Chain)) + configToml := make(testutil.Toml) + consensusToml := make(testutil.Toml) + consensusToml["timeout_commit"] = timeout.String() + configToml["consensus"] = consensusToml + s.Chain.ModifyConfig(s.GetContext(), s.T(), map[string]testutil.Toml{"config/config.toml": configToml}) } func TestFeemarket(t *testing.T) {