Skip to content

Commit

Permalink
refactor: use chaintestutil for integration test setup (#46)
Browse files Browse the repository at this point in the history
* clean

* fix

* state query

* test:

* wip

* remove test

* fix

* fix

* wip

* wrong

* working

* fix

* fix

* refactor to use params

* clean

* wip

* fix

* refactor

* fix

* fix

* rename

* rename

* sample

* encoding

* sample

* use sample

* add

* network suite

* wip

* refactor

* add feemarket

* init integration pkg

* update to latest commit

* go mod tidy

* lint fix

* use encoding

* init

* refactor

* clean

* refactor

* refactor

* refactor

* refactor clean

* format

* use sample

* encoding

* remove network

* refactor keeper

* fix

* clean

* use repo

* remove

* clean
  • Loading branch information
Alex Johnson authored Dec 12, 2023
1 parent 2d6929c commit 206525e
Show file tree
Hide file tree
Showing 19 changed files with 131 additions and 725 deletions.
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ require (
github.com/golang/protobuf v1.5.3
github.com/golangci/golangci-lint v1.55.3-0.20231203192459-84442f26446b
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/skip-mev/chaintestutil v0.0.0-20231207155412-975710cc9051
github.com/spf13/cobra v1.8.0
github.com/spf13/viper v1.17.0
github.com/stretchr/testify v1.8.4
Expand All @@ -26,6 +27,7 @@ require (
google.golang.org/grpc v1.59.0
google.golang.org/protobuf v1.31.0
mvdan.cc/gofumpt v0.5.0
pgregory.net/rapid v1.1.0
)

require (
Expand Down Expand Up @@ -316,7 +318,6 @@ require (
mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b // indirect
mvdan.cc/unparam v0.0.0-20221223090309-7455f1af531d // indirect
nhooyr.io/websocket v1.8.6 // indirect
pgregory.net/rapid v1.1.0 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)

Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1394,6 +1394,8 @@ github.com/sivchari/nosnakecase v1.7.0 h1:7QkpWIRMe8x25gckkFd2A5Pi6Ymo0qgr4JrhGt
github.com/sivchari/nosnakecase v1.7.0/go.mod h1:CwDzrzPea40/GB6uynrNLiorAlgFRvRbFSgJx2Gs+QY=
github.com/sivchari/tenv v1.7.1 h1:PSpuD4bu6fSmtWMxSGWcvqUUgIn7k3yOJhOIzVWn8Ak=
github.com/sivchari/tenv v1.7.1/go.mod h1:64yStXKSOxDfX47NlhVwND4dHwfZDdbp2Lyl018Icvg=
github.com/skip-mev/chaintestutil v0.0.0-20231207155412-975710cc9051 h1:ZTD4dFUTv+h+BgGTv4PtXnSxgMTUrCvGX+NQjNo/hqA=
github.com/skip-mev/chaintestutil v0.0.0-20231207155412-975710cc9051/go.mod h1:P7icBoBSf+Ci1b2moqSXQZTThtBs33eJ8dPajce2ViQ=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
Expand Down
11 changes: 6 additions & 5 deletions tests/e2e/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ replace (
require (
github.com/cometbft/cometbft v0.37.2
github.com/cosmos/cosmos-sdk v0.47.6
github.com/skip-mev/chaintestutil v0.0.0-20231207155412-975710cc9051
github.com/skip-mev/feemarket v0.0.0-00010101000000-000000000000
github.com/strangelove-ventures/interchaintest/v7 v7.0.0
github.com/stretchr/testify v1.8.4
Expand Down Expand Up @@ -214,15 +215,15 @@ require (
go.etcd.io/bbolt v1.3.7 // indirect
go.opencensus.io v0.24.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.15.0 // indirect
golang.org/x/crypto v0.16.0 // indirect
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.18.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/oauth2 v0.12.0 // indirect
golang.org/x/sys v0.14.0 // indirect
golang.org/x/term v0.14.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/term v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.15.0 // indirect
golang.org/x/tools v0.16.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/api v0.143.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
Expand Down
22 changes: 12 additions & 10 deletions tests/e2e/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1228,6 +1228,8 @@ github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrf
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/skip-mev/chaintestutil v0.0.0-20231207155412-975710cc9051 h1:ZTD4dFUTv+h+BgGTv4PtXnSxgMTUrCvGX+NQjNo/hqA=
github.com/skip-mev/chaintestutil v0.0.0-20231207155412-975710cc9051/go.mod h1:P7icBoBSf+Ci1b2moqSXQZTThtBs33eJ8dPajce2ViQ=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
Expand Down Expand Up @@ -1374,8 +1376,8 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y
golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw=
golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA=
golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g=
golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY=
golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/exp v0.0.0-20230224173230-c95f2b4c22f2 h1:Jvc7gsqn21cJHCmAWx0LiimpP18LZmUxkT5Mp7EZ1mI=
golang.org/x/exp v0.0.0-20230224173230-c95f2b4c22f2/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
Expand Down Expand Up @@ -1472,8 +1474,8 @@ golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
golang.org/x/net v0.18.0 h1:mIYleuAkSbHh0tCv7RvjL3F6ZVbLjq4+R7zbOn3Kokg=
golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ=
golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c=
golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U=
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=
Expand Down Expand Up @@ -1622,8 +1624,8 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.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=
Expand All @@ -1632,8 +1634,8 @@ golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY=
golang.org/x/term v0.14.0 h1:LGK9IlZ8T9jvdy6cTdfKUCltatMFOehAQo9SRC46UQ8=
golang.org/x/term v0.14.0/go.mod h1:TySc+nGkYR6qt8km8wUhuFRTVSMIX3XPR58y2lC8vww=
golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4=
golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0=
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=
Expand Down Expand Up @@ -1719,8 +1721,8 @@ golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc
golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA=
golang.org/x/tools v0.3.0/go.mod h1:/rWhSS2+zyEVwoJf8YAX6L2f0ntZ7Kn/mGgAWcipA5k=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.15.0 h1:zdAyfUGbYmuVokhzVmghFl2ZJh5QhcfebBgmVPFYA+8=
golang.org/x/tools v0.15.0/go.mod h1:hpksKq4dtpQWS1uQ61JkdqWM3LscIS6Slf+VVkm+wQk=
golang.org/x/tools v0.16.0 h1:GO788SKMRunPIBCXiQyo2AaexLstOrVhuAL5YwsckQM=
golang.org/x/tools v0.16.0/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
3 changes: 1 addition & 2 deletions tests/e2e/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import (
"testing"
"time"

"github.com/skip-mev/feemarket/testutils/sample"

rpctypes "github.com/cometbft/cometbft/rpc/core/types"
comettypes "github.com/cometbft/cometbft/types"
"github.com/cosmos/cosmos-sdk/client"
Expand All @@ -27,6 +25,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/skip-mev/chaintestutil/sample"
interchaintest "github.com/strangelove-ventures/interchaintest/v7"
"github.com/strangelove-ventures/interchaintest/v7/chain/cosmos"
"github.com/strangelove-ventures/interchaintest/v7/ibc"
Expand Down
32 changes: 16 additions & 16 deletions tests/integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,41 @@ import (

"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/skip-mev/chaintestutil/encoding"
"github.com/stretchr/testify/suite"

appparams "github.com/skip-mev/feemarket/tests/app/params"
"github.com/skip-mev/feemarket/testutils/encoding"
"github.com/skip-mev/feemarket/tests/app"
testkeeper "github.com/skip-mev/feemarket/testutils/keeper"
"github.com/skip-mev/feemarket/x/feemarket/types"
)

type IntegrationTestSuite struct {
suite.Suite
testkeeper.TestKeepers
testkeeper.TestMsgServers

testKeepers testkeeper.TestKeepers
testMsgServers testkeeper.TestMsgServers
encCfg appparams.EncodingConfig
ctx sdk.Context
encCfg encoding.TestEncodingConfig
ctx sdk.Context
}

func TestIntegrationTestSuite(t *testing.T) {
suite.Run(t, new(IntegrationTestSuite))
}

func (s *IntegrationTestSuite) SetupTest() {
s.encCfg = encoding.MakeTestEncodingConfig()
s.encCfg = encoding.MakeTestEncodingConfig(app.ModuleBasics.RegisterInterfaces)

s.ctx, s.testKeepers, s.testMsgServers = testkeeper.NewTestSetup(s.T())
s.ctx, s.TestKeepers, s.TestMsgServers = testkeeper.NewTestSetup(s.T())
}

func (s *IntegrationTestSuite) TestState() {
s.Run("set and get default eip1559 state", func() {
state := types.DefaultState()

err := s.testKeepers.FeeMarketKeeper.SetState(s.ctx, state)
err := s.TestKeepers.FeeMarketKeeper.SetState(s.ctx, state)
s.Require().NoError(err)

gotState, err := s.testKeepers.FeeMarketKeeper.GetState(s.ctx)
gotState, err := s.TestKeepers.FeeMarketKeeper.GetState(s.ctx)
s.Require().NoError(err)

s.Require().EqualValues(state, gotState)
Expand All @@ -48,10 +48,10 @@ func (s *IntegrationTestSuite) TestState() {
s.Run("set and get aimd eip1559 state", func() {
state := types.DefaultAIMDState()

err := s.testKeepers.FeeMarketKeeper.SetState(s.ctx, state)
err := s.TestKeepers.FeeMarketKeeper.SetState(s.ctx, state)
s.Require().NoError(err)

gotState, err := s.testKeepers.FeeMarketKeeper.GetState(s.ctx)
gotState, err := s.TestKeepers.FeeMarketKeeper.GetState(s.ctx)
s.Require().NoError(err)

s.Require().Equal(state, gotState)
Expand All @@ -62,10 +62,10 @@ func (s *IntegrationTestSuite) TestParams() {
s.Run("set and get default params", func() {
params := types.DefaultParams()

err := s.testKeepers.FeeMarketKeeper.SetParams(s.ctx, params)
err := s.TestKeepers.FeeMarketKeeper.SetParams(s.ctx, params)
s.Require().NoError(err)

gotParams, err := s.testKeepers.FeeMarketKeeper.GetParams(s.ctx)
gotParams, err := s.TestKeepers.FeeMarketKeeper.GetParams(s.ctx)
s.Require().NoError(err)

s.Require().EqualValues(params, gotParams)
Expand All @@ -86,10 +86,10 @@ func (s *IntegrationTestSuite) TestParams() {
Enabled: true,
}

err := s.testKeepers.FeeMarketKeeper.SetParams(s.ctx, params)
err := s.TestKeepers.FeeMarketKeeper.SetParams(s.ctx, params)
s.Require().NoError(err)

gotParams, err := s.testKeepers.FeeMarketKeeper.GetParams(s.ctx)
gotParams, err := s.TestKeepers.FeeMarketKeeper.GetParams(s.ctx)
s.Require().NoError(err)

s.Require().EqualValues(params, gotParams)
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ import (
"github.com/skip-mev/feemarket/x/feemarket/types"
)

// QueryTestSuite is a test suite for query tests
// NetworkTestSuite is a test suite for network integration tests.
type NetworkTestSuite struct {
networksuite.NetworkTestSuite
}

// TestQueryTestSuite runs test of the query suite
// TestQueryTestSuite runs test of network integration tests.
func TestNetworkTestSuite(t *testing.T) {
suite.Run(t, new(NetworkTestSuite))
}
Expand Down
28 changes: 0 additions & 28 deletions testutils/encoding/encoding.go

This file was deleted.

21 changes: 0 additions & 21 deletions testutils/keeper/bank.go

This file was deleted.

38 changes: 0 additions & 38 deletions testutils/keeper/bank_test.go

This file was deleted.

Loading

0 comments on commit 206525e

Please sign in to comment.