Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(integration): port x/staking tests to server v2 #22813

Merged
merged 15 commits into from
Dec 18, 2024
29 changes: 24 additions & 5 deletions baseapp/abci_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/cosmos/gogoproto/proto"

"cosmossdk.io/core/comet"
"cosmossdk.io/core/header"

cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
Expand Down Expand Up @@ -46,11 +47,29 @@ func ValidateVoteExtensions(
valStore ValidatorStore,
extCommit abci.ExtendedCommitInfo,
) error {
// Get values from context
cp := ctx.ConsensusParams() //nolint:staticcheck // ignore linting error
currentHeight := ctx.HeaderInfo().Height
chainID := ctx.HeaderInfo().ChainID
commitInfo := ctx.CometInfo().LastCommit
return ValidateVoteExtensionsWithParams(
ctx,
ctx.ConsensusParams(), //nolint:staticcheck // ignore linting error
ctx.HeaderInfo(),
ctx.CometInfo(),
valStore,
extCommit,
)
}

// ValidateVoteExtensionsWithParams defines a helper function for verifying vote extension
// signatures with consensus params, header info and comet info taken as input
func ValidateVoteExtensionsWithParams(
ctx context.Context,
cp cmtproto.ConsensusParams,
headerInfo header.Info,
cometInfo comet.Info,
valStore ValidatorStore,
extCommit abci.ExtendedCommitInfo,
) error {
currentHeight := headerInfo.Height
chainID := headerInfo.ChainID
commitInfo := cometInfo.LastCommit

// Check that both extCommit + commit are ordered in accordance with vp/address.
if err := validateExtendedCommitAgainstLastCommit(extCommit, commitInfo); err != nil {
Expand Down
31 changes: 0 additions & 31 deletions tests/integration/staking/app_config.go

This file was deleted.

214 changes: 0 additions & 214 deletions tests/integration/staking/keeper/common_test.go

This file was deleted.

32 changes: 0 additions & 32 deletions tests/integration/staking/module_test.go

This file was deleted.

8 changes: 4 additions & 4 deletions tests/integration/v2/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ type StartupConfig struct {
GasService gas.Service
}

func DefaultStartUpConfig(t *testing.T) StartupConfig {
func DefaultStartUpConfig(t testing.TB) StartupConfig {
t.Helper()

priv := secp256k1.GenPrivKey()
Expand Down Expand Up @@ -351,10 +351,10 @@ func (a *App) Deliver(
}

// StateLatestContext creates returns a new context from context.Background() with the latest state.
func (a *App) StateLatestContext(t *testing.T) context.Context {
t.Helper()
func (a *App) StateLatestContext(tb testing.TB) context.Context {
tb.Helper()
_, state, err := a.Store.StateLatest()
require.NoError(t, err)
require.NoError(tb, err)
writeableState := branch.DefaultNewWriterMap(state)
iCtx := &integrationContext{state: writeableState}
return context.WithValue(context.Background(), contextKey, iCtx)
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/v2/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func SetGasMeter(ctx context.Context, meter gas.Meter) context.Context {
}

func (s storeService) OpenKVStore(ctx context.Context) corestore.KVStore {
const gasLimit = 100_000
const gasLimit = 1_000_000
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the increase?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few of deterministic tests are failing with out of gas issue.

iCtx, ok := ctx.Value(contextKey).(*integrationContext)
if !ok {
return s.executionService.OpenKVStore(ctx)
Expand Down
Loading
Loading