Prathamesh Musale
8c0540bdb5
- The E2E tests sometimes fail with error `timeout exceeded waiting for block` in CI (always passed locally) - The error occurs in the test network (provided in cosmos-sdk) creation when [waiting](https://github.com/cosmos/cosmos-sdk/blob/v0.50.3/testutil/network/network.go#L622) for the first block because of block timeout being too short ([hardcoded](https://github.com/cosmos/cosmos-sdk/blob/v0.50.3/testutil/network/network.go#L670) to 5s) - Copy over this network setup in the repo and patch to skip this check; we are waiting for a block to appear after the network creation anyway Reviewed-on: deep-stack/laconic2d#18 Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com> Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
68 lines
2.2 KiB
Go
68 lines
2.2 KiB
Go
package e2e
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"cosmossdk.io/log"
|
|
pruningtypes "cosmossdk.io/store/pruning/types"
|
|
|
|
dbm "github.com/cosmos/cosmos-db"
|
|
bam "github.com/cosmos/cosmos-sdk/baseapp"
|
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
|
servertypes "github.com/cosmos/cosmos-sdk/server/types"
|
|
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
|
"github.com/cosmos/cosmos-sdk/types/module/testutil"
|
|
"github.com/cosmos/cosmos-sdk/x/auth"
|
|
"github.com/cosmos/cosmos-sdk/x/staking"
|
|
|
|
laconicApp "git.vdb.to/cerc-io/laconic2d/app"
|
|
auctionmodule "git.vdb.to/cerc-io/laconic2d/x/auction/module"
|
|
bondmodule "git.vdb.to/cerc-io/laconic2d/x/bond/module"
|
|
registrymodule "git.vdb.to/cerc-io/laconic2d/x/registry/module"
|
|
|
|
_ "git.vdb.to/cerc-io/laconic2d/app/params" // import for side-effects (see init)
|
|
"git.vdb.to/cerc-io/laconic2d/testutil/network"
|
|
)
|
|
|
|
// NewTestNetworkFixture returns a new LaconicApp AppConstructor for network simulation tests
|
|
func NewTestNetworkFixture() network.TestFixture {
|
|
dir, err := os.MkdirTemp("", "laconic")
|
|
if err != nil {
|
|
panic(fmt.Sprintf("failed creating temporary directory: %v", err))
|
|
}
|
|
defer os.RemoveAll(dir)
|
|
|
|
app, err := laconicApp.NewLaconicApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, simtestutil.NewAppOptionsWithFlagHome(dir))
|
|
if err != nil {
|
|
panic(fmt.Sprintf("failed to create laconic app: %v", err))
|
|
}
|
|
|
|
appCtr := func(val network.ValidatorI) servertypes.Application {
|
|
app, err := laconicApp.NewLaconicApp(
|
|
val.GetCtx().Logger, dbm.NewMemDB(), nil, true,
|
|
simtestutil.NewAppOptionsWithFlagHome(val.GetCtx().Config.RootDir),
|
|
bam.SetPruning(pruningtypes.NewPruningOptionsFromString(val.GetAppConfig().Pruning)),
|
|
bam.SetMinGasPrices(val.GetAppConfig().MinGasPrices),
|
|
bam.SetChainID(val.GetCtx().Viper.GetString(flags.FlagChainID)),
|
|
)
|
|
if err != nil {
|
|
panic(fmt.Sprintf("failed creating temporary directory: %v", err))
|
|
}
|
|
|
|
return app
|
|
}
|
|
|
|
return network.TestFixture{
|
|
AppConstructor: appCtr,
|
|
GenesisState: app.DefaultGenesis(),
|
|
EncodingConfig: testutil.MakeTestEncodingConfig(
|
|
auth.AppModuleBasic{},
|
|
staking.AppModuleBasic{},
|
|
auctionmodule.AppModule{},
|
|
bondmodule.AppModule{},
|
|
registrymodule.AppModule{},
|
|
),
|
|
}
|
|
}
|