Skip to content

Commit

Permalink
Merge pull request neutron-org#586 from neutron-org/test/fmt
Browse files Browse the repository at this point in the history
Feemarket e2e tests
  • Loading branch information
pr0n00gler authored Jun 17, 2024
2 parents d2b4130 + 171bde5 commit 51f9cb6
Show file tree
Hide file tree
Showing 5 changed files with 2,306 additions and 5 deletions.
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ build-static-linux-amd64: go.sum $(BUILDDIR)/
$(DOCKER) cp neutronbinary:/bin/neutrond $(BUILDDIR)/neutrond-linux-amd64
$(DOCKER) rm -f neutronbinary

build-slinky-e2e-docker-image: go.sum $(BUILDDIR)/
build-e2e-docker-image: go.sum $(BUILDDIR)/
$(DOCKER) buildx create --name neutronbuilder || true
$(DOCKER) buildx use neutronbuilder
$(DOCKER) buildx build \
Expand All @@ -136,7 +136,12 @@ build-slinky-e2e-docker-image: go.sum $(BUILDDIR)/
-f Dockerfile.builder .

slinky-e2e-test:
cd ./tests/slinky && go mod tidy && go test -v -race -timeout 40m -count=1 ./...
@echo "Running e2e slinky tests..."
cd ./tests/slinky && go mod tidy && go test -v -race -timeout 30m -count=1 ./...

feemarket-e2e-test:
@echo "Running e2e feemarket tests..."
@cd ./tests/feemarket && go mod tidy && go test -p 1 -v -race -timeout 30m -count=1 ./...

install-test-binary: check_version go.sum
go install -mod=readonly $(BUILD_FLAGS_TEST_BINARY) ./cmd/neutrond
Expand Down
4 changes: 1 addition & 3 deletions tests/e2e/interchain_security_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"
appProvider "github.com/cosmos/interchain-security/v5/app/provider"
e2e "github.com/cosmos/interchain-security/v5/tests/integration"
icssimapp "github.com/cosmos/interchain-security/v5/testutil/ibc_testing"
"github.com/stretchr/testify/suite"

e2e "github.com/cosmos/interchain-security/v5/tests/integration"

appConsumer "github.com/neutron-org/neutron/v4/app"

appparams "github.com/neutron-org/neutron/v4/app/params"
"github.com/neutron-org/neutron/v4/testutil"
)
Expand Down
146 changes: 146 additions & 0 deletions tests/feemarket/e2e_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
package feemarket_test

import (
"fmt"
"strconv"
"strings"
"testing"

sdkmath "cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module/testutil"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/bank"
"github.com/cosmos/cosmos-sdk/x/gov"
"github.com/skip-mev/feemarket/tests/e2e"
feemarketmodule "github.com/skip-mev/feemarket/x/feemarket"
feemarkettypes "github.com/skip-mev/feemarket/x/feemarket/types"
marketmapmodule "github.com/skip-mev/slinky/x/marketmap"
"github.com/skip-mev/slinky/x/oracle"
interchaintest "github.com/strangelove-ventures/interchaintest/v8"
"github.com/strangelove-ventures/interchaintest/v8/chain/cosmos"
"github.com/strangelove-ventures/interchaintest/v8/ibc"
"github.com/stretchr/testify/suite"
)

func init() {
cfg := sdk.GetConfig()
cfg.SetBech32PrefixForAccount("neutron", "neutronpub")
cfg.Seal()
}

var (
minBaseGasPrice = sdkmath.LegacyMustNewDecFromStr("0.001")
baseGasPrice = sdkmath.LegacyMustNewDecFromStr("0.01")

image = ibc.DockerImage{
Repository: "neutron-node",
Version: "latest",
UidGid: "1025:1025",
}

oracleImage = ibc.DockerImage{
Repository: "ghcr.io/skip-mev/slinky-sidecar",
Version: "latest",
UidGid: "1000:1000",
}

numValidators = 4
numFullNodes = 0
noHostMount = false
gasAdjustment = 2.0

encodingConfig = testutil.MakeTestEncodingConfig(
bank.AppModuleBasic{},
oracle.AppModuleBasic{},
gov.AppModuleBasic{},
auth.AppModuleBasic{},
feemarketmodule.AppModuleBasic{},
marketmapmodule.AppModuleBasic{},
)

defaultGenesisKV = []cosmos.GenesisKV{
{
Key: "consensus.params.abci.vote_extensions_enable_height",
Value: "2",
},
{
Key: "consensus.params.block.max_gas",
Value: strconv.Itoa(int(feemarkettypes.DefaultMaxBlockUtilization)),
},
{
Key: "app_state.feemarket.params",
Value: feemarkettypes.Params{
Alpha: feemarkettypes.DefaultAlpha,
Beta: feemarkettypes.DefaultBeta,
Gamma: feemarkettypes.DefaultAIMDGamma,
Delta: feemarkettypes.DefaultDelta,
MinBaseGasPrice: minBaseGasPrice,
MinLearningRate: feemarkettypes.DefaultMinLearningRate,
MaxLearningRate: feemarkettypes.DefaultMaxLearningRate,
MaxBlockUtilization: 15_000_000,
Window: feemarkettypes.DefaultWindow,
FeeDenom: denom,
Enabled: true,
DistributeFees: false,
},
},
{
Key: "app_state.feemarket.state",
Value: feemarkettypes.State{
BaseGasPrice: baseGasPrice,
LearningRate: feemarkettypes.DefaultMaxLearningRate,
Window: make([]uint64, feemarkettypes.DefaultWindow),
Index: 0,
},
},
}

denom = "untrn"
spec = &interchaintest.ChainSpec{
ChainName: "feemarket",
Name: "feemarket",
NumValidators: &numValidators,
NumFullNodes: &numFullNodes,
Version: "latest",
NoHostMount: &noHostMount,
ChainConfig: ibc.ChainConfig{
EncodingConfig: &encodingConfig,
Images: []ibc.DockerImage{
image,
},
Type: "cosmos",
Name: "feemarket",
Denom: denom,
ChainID: "chain-id-feemarket",
Bin: "neutrond",
Bech32Prefix: "neutron",
CoinType: "118",
GasAdjustment: gasAdjustment,
GasPrices: fmt.Sprintf("10%s", denom),
TrustingPeriod: "48h",
NoHostMount: noHostMount,
ModifyGenesis: cosmos.ModifyGenesis(defaultGenesisKV),
SkipGenTx: true,
},
}

txCfg = e2e.TestTxConfig{
SmallSendsNum: 1,
LargeSendsNum: 325,
TargetIncreaseGasPrice: sdkmath.LegacyMustNewDecFromStr("0.0011"),
}
)

func TestE2ETestSuite(t *testing.T) {
s := e2e.NewIntegrationSuite(
spec,
oracleImage,
txCfg,
e2e.WithInterchainConstructor(e2e.CCVInterchainConstructor),
e2e.WithChainConstructor(e2e.CCVChainConstructor),
e2e.WithDenom(denom),
e2e.WithGasPrices(strings.Join([]string{"0.0uatom"}, ",")),
)
suite.Run(t, s)
}
Loading

0 comments on commit 51f9cb6

Please sign in to comment.