Skip to content

Commit

Permalink
add gov test
Browse files Browse the repository at this point in the history
  • Loading branch information
sontrinh16 committed Dec 12, 2024
1 parent 13e3e21 commit ccd0132
Show file tree
Hide file tree
Showing 13 changed files with 1,963 additions and 8 deletions.
6 changes: 5 additions & 1 deletion runtime/v2/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"cosmossdk.io/core/branch"
"cosmossdk.io/core/comet"
"cosmossdk.io/core/event"
"cosmossdk.io/core/gas"
"cosmossdk.io/core/header"
"cosmossdk.io/core/registry"
"cosmossdk.io/core/router"
Expand Down Expand Up @@ -214,6 +215,7 @@ func ProvideEnvironment(
kvService store.KVStoreService,
memKvService store.MemoryStoreService,
headerService header.Service,
gasService gas.Service,
eventService event.Service,
branchService branch.Service,
routerBuilder RouterServiceBuilder,
Expand All @@ -222,7 +224,7 @@ func ProvideEnvironment(
Logger: logger,
BranchService: branchService,
EventService: eventService,
GasService: stf.NewGasMeterService(),
GasService: gasService,
HeaderService: headerService,
QueryRouterService: routerBuilder.BuildQueryRouter(),
MsgRouterService: routerBuilder.BuildMsgRouter([]byte(key.Name())),
Expand Down Expand Up @@ -296,6 +298,7 @@ func DefaultServiceBindings() depinject.Config {
eventService = services.NewGenesisEventService(stf.NewEventService())
storeBuilder = root.NewBuilder()
branchService = stf.BranchService{}
gasService = stf.NewGasMeterService()
)
return depinject.Supply(
kvServiceFactory,
Expand All @@ -305,5 +308,6 @@ func DefaultServiceBindings() depinject.Config {
eventService,
storeBuilder,
branchService,
gasService,
)
}
9 changes: 8 additions & 1 deletion tests/integration/v2/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
corebranch "cosmossdk.io/core/branch"
"cosmossdk.io/core/comet"
corecontext "cosmossdk.io/core/context"
"cosmossdk.io/core/gas"
"cosmossdk.io/core/header"
"cosmossdk.io/core/server"
corestore "cosmossdk.io/core/store"
Expand Down Expand Up @@ -99,6 +100,8 @@ type StartupConfig struct {
RouterServiceBuilder runtime.RouterServiceBuilder
// HeaderService defines the custom header service to be used in the app.
HeaderService header.Service

GasService gas.Service
}

func DefaultStartUpConfig(t *testing.T) StartupConfig {
Expand Down Expand Up @@ -129,6 +132,7 @@ func DefaultStartUpConfig(t *testing.T) StartupConfig {
stf.NewMsgRouterService, stf.NewQueryRouterService(),
),
HeaderService: services.NewGenesisHeaderService(stf.HeaderService{}),
GasService: stf.NewGasMeterService(),
}
}

Expand Down Expand Up @@ -193,9 +197,11 @@ func NewApp(
startupConfig.BranchService,
startupConfig.RouterServiceBuilder,
startupConfig.HeaderService,
startupConfig.GasService,
),
depinject.Invoke(
std.RegisterInterfaces,
std.RegisterLegacyAminoCodec,
),
),
append(extraOutputs, &appBuilder, &cdc, &txConfigOptions, &txConfig, &storeBuilder)...); err != nil {
Expand Down Expand Up @@ -336,10 +342,11 @@ func (a *App) Deliver(
require.NoError(t, err)
a.lastHeight++

// update block height if integration context is present
// update block height and block time if integration context is present
iCtx, ok := ctx.Value(contextKey).(*integrationContext)
if ok {
iCtx.header.Height = int64(a.lastHeight)
iCtx.header.Time = time.Now()

Check warning

Code scanning / CodeQL

Calling the system time Warning test

Calling the system time may be a possible source of non-determinism
}
return resp, state
}
Expand Down
6 changes: 6 additions & 0 deletions tests/integration/v2/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ type genesisTxCodec struct {
tx.ConfigOptions
}

func NewGenesisTxCodec(txConfigOptions tx.ConfigOptions) *genesisTxCodec {
return &genesisTxCodec{
txConfigOptions,
}
}

// Decode implements transaction.Codec.
func (t *genesisTxCodec) Decode(bz []byte) (stateMachineTx, error) {
var out stateMachineTx
Expand Down
Loading

0 comments on commit ccd0132

Please sign in to comment.