Skip to content

Commit

Permalink
test(testnode): configure custom min gas price on v1.x (#3674)
Browse files Browse the repository at this point in the history
Unit test to help prevent regressions on v1.x. This is motivated by
debugging integration tests on
celestiaorg/celestia-node#3453
  • Loading branch information
rootulp authored Jul 15, 2024
1 parent 2cb54a5 commit 0a6d65e
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 49 deletions.
47 changes: 47 additions & 0 deletions app/test/testnode_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package app_test

import (
"context"
"fmt"
"testing"

"github.com/celestiaorg/celestia-app/app"
"github.com/celestiaorg/celestia-app/test/util/testnode"
nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node"
sdktypes "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"google.golang.org/grpc"
)

func Test_testnode(t *testing.T) {
t.Run("testnode can start a network with default chain ID", func(t *testing.T) {
testnode.NewNetwork(t, testnode.DefaultConfig())
})
t.Run("testnode can start with a custom MinGasPrice", func(t *testing.T) {
wantMinGasPrice := float64(0.003)
appConfig := testnode.DefaultAppConfig()
appConfig.MinGasPrices = fmt.Sprintf("%v%s", wantMinGasPrice, app.BondDenom)
config := testnode.DefaultConfig().WithAppConfig(appConfig)
cctx, _, _ := testnode.NewNetwork(t, config)

got, err := queryMinimumGasPrice(cctx.GoContext(), cctx.GRPCClient)
require.NoError(t, err)
assert.Equal(t, wantMinGasPrice, got)
})
}

func queryMinimumGasPrice(ctx context.Context, grpcConn *grpc.ClientConn) (float64, error) {
resp, err := nodeservice.NewServiceClient(grpcConn).Config(ctx, &nodeservice.ConfigRequest{})
if err != nil {
return 0, err
}

minGasCoins, err := sdktypes.ParseDecCoins(resp.MinimumGasPrice)
if err != nil {
return 0, err
}

minGasPrice := minGasCoins.AmountOf(app.BondDenom).MustFloat64()
return minGasPrice, nil
}
31 changes: 16 additions & 15 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/ethereum/go-ethereum v1.13.2
github.com/gogo/protobuf v1.3.3
github.com/golang/protobuf v1.5.4
github.com/google/uuid v1.4.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/mux v1.8.0
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/pkg/errors v0.9.1 // indirect
Expand All @@ -19,8 +19,8 @@ require (
golang.org/x/net v0.23.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/term v0.18.0 // indirect
google.golang.org/genproto v0.0.0-20231106174013-bbf56f31fb17 // indirect
google.golang.org/grpc v1.60.0
google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect
google.golang.org/grpc v1.64.0
)

require (
Expand All @@ -37,7 +37,7 @@ require (
github.com/spf13/pflag v1.0.5
github.com/tendermint/tendermint v0.34.29
golang.org/x/exp v0.0.0-20230905200255-921286631fa9
google.golang.org/genproto/googleapis/api v0.0.0-20231106174013-bbf56f31fb17
google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237
gopkg.in/yaml.v2 v2.4.0
)

Expand Down Expand Up @@ -65,6 +65,8 @@ require (
github.com/opencontainers/image-spec v1.1.0-rc2 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/supranational/blst v0.3.11 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.18.0 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect
Expand All @@ -73,16 +75,16 @@ require (
golang.org/x/mod v0.12.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.13.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
)

require (
cloud.google.com/go v0.110.10 // indirect
cloud.google.com/go/compute v1.23.3 // indirect
cloud.google.com/go v0.112.1 // indirect
cloud.google.com/go/compute v1.25.1 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
cloud.google.com/go/iam v1.1.5 // indirect
cloud.google.com/go/storage v1.35.1 // indirect
cloud.google.com/go/iam v1.1.6 // indirect
cloud.google.com/go/storage v1.38.0 // indirect
filippo.io/edwards25519 v1.0.0-rc.1 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.1 // indirect
Expand Down Expand Up @@ -120,7 +122,7 @@ require (
github.com/docker/docker v24.0.7+incompatible
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/dvsekhvalnov/jose2go v1.6.0 // indirect
github.com/felixge/httpsnoop v1.0.1 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-kit/kit v0.12.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
Expand All @@ -130,14 +132,14 @@ require (
github.com/go-stack/stack v1.8.1 // indirect
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
github.com/gogo/gateway v1.1.0 // indirect
github.com/golang/glog v1.1.2 // indirect
github.com/golang/glog v1.2.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
github.com/google/btree v1.1.2 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/orderedcode v0.0.1 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/googleapis/gax-go/v2 v2.12.0 // indirect
github.com/googleapis/gax-go/v2 v2.12.2 // indirect
github.com/gorilla/handlers v1.5.1 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
Expand Down Expand Up @@ -204,10 +206,9 @@ require (
go.etcd.io/bbolt v1.3.6 // indirect
go.opencensus.io v0.24.0 // indirect
golang.org/x/oauth2 v0.18.0 // indirect
golang.org/x/sync v0.5.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/api v0.152.0 // indirect
google.golang.org/api v0.169.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/protobuf v1.33.0
gopkg.in/ini.v1 v1.67.0 // indirect
Expand Down
Loading

0 comments on commit 0a6d65e

Please sign in to comment.