laconicd/tests/e2e/common.go

70 lines
2.2 KiB
Go
Raw Normal View History

2024-03-01 06:22:37 +00:00
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"
"github.com/cosmos/cosmos-sdk/testutil/network"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
"github.com/cosmos/cosmos-sdk/types/module/testutil"
"github.com/cosmos/cosmos-sdk/x/auth"
2024-03-01 09:26:08 +00:00
"github.com/cosmos/cosmos-sdk/x/staking"
2024-03-01 06:22:37 +00:00
laconicApp "git.vdb.to/cerc-io/laconic2d/app"
2024-03-01 09:26:08 +00:00
"git.vdb.to/cerc-io/laconic2d/app/params"
2024-03-01 06:22:37 +00:00
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"
)
2024-03-01 09:26:08 +00:00
// NewTestNetworkFixture returns a new LaconicApp AppConstructor for network simulation tests
2024-03-01 06:22:37 +00:00
func NewTestNetworkFixture() network.TestFixture {
2024-03-01 09:26:08 +00:00
dir, err := os.MkdirTemp("", "laconic")
2024-03-01 06:22:37 +00:00
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
}
2024-03-01 09:26:08 +00:00
// Update prefixes
params.SetAddressPrefixes()
2024-03-01 06:22:37 +00:00
return network.TestFixture{
AppConstructor: appCtr,
GenesisState: app.DefaultGenesis(),
EncodingConfig: testutil.MakeTestEncodingConfig(
auth.AppModuleBasic{},
2024-03-01 09:26:08 +00:00
staking.AppModuleBasic{},
2024-03-01 06:22:37 +00:00
auctionmodule.AppModule{},
bondmodule.AppModule{},
registrymodule.AppModule{},
),
}
}