-
Notifications
You must be signed in to change notification settings - Fork 290
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(testnode): configure custom min gas price on v1.x (#3674)
Unit test to help prevent regressions on v1.x. This is motivated by debugging integration tests on celestiaorg/celestia-node#3453
- Loading branch information
Showing
8 changed files
with
103 additions
and
49 deletions.
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,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 | ||
} |
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.