Skip to content

Commit

Permalink
test(integration): port x/staking tests to server v2 (#22813)
Browse files Browse the repository at this point in the history
  • Loading branch information
akhilkumarpilli authored Dec 18, 2024
1 parent 771d662 commit 8a11925
Show file tree
Hide file tree
Showing 20 changed files with 1,074 additions and 1,113 deletions.
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
iCtx, ok := ctx.Value(contextKey).(*integrationContext)
if !ok {
return s.executionService.OpenKVStore(ctx)
Expand Down
Loading

0 comments on commit 8a11925

Please sign in to comment.