chore: remove simapp v1 (#23009)
This commit is contained in:
@@ -1,85 +0,0 @@
|
||||
package rootmulti_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
abci "github.com/cometbft/cometbft/api/cometbft/abci/v1"
|
||||
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1"
|
||||
"gotest.tools/v3/assert"
|
||||
|
||||
coretesting "cosmossdk.io/core/testing"
|
||||
"cosmossdk.io/log"
|
||||
"cosmossdk.io/simapp"
|
||||
|
||||
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
)
|
||||
|
||||
func TestRollback(t *testing.T) {
|
||||
db := coretesting.NewMemDB()
|
||||
options := simapp.SetupOptions{
|
||||
Logger: log.NewNopLogger(),
|
||||
DB: db,
|
||||
AppOpts: simtestutil.NewAppOptionsWithFlagHome(t.TempDir()),
|
||||
}
|
||||
app := simapp.NewSimappWithCustomOptions(t, false, options)
|
||||
ver0 := app.LastBlockHeight()
|
||||
// commit 10 blocks
|
||||
for i := int64(1); i <= 10; i++ {
|
||||
header := cmtproto.Header{
|
||||
Height: ver0 + i,
|
||||
AppHash: app.LastCommitID().Hash,
|
||||
}
|
||||
|
||||
_, err := app.FinalizeBlock(&abci.FinalizeBlockRequest{
|
||||
Height: header.Height,
|
||||
})
|
||||
assert.NilError(t, err)
|
||||
ctx := app.NewContextLegacy(false, header)
|
||||
store := ctx.KVStore(app.GetKey("bank"))
|
||||
store.Set([]byte("key"), []byte(fmt.Sprintf("value%d", i)))
|
||||
_, err = app.FinalizeBlock(&abci.FinalizeBlockRequest{
|
||||
Height: header.Height,
|
||||
})
|
||||
assert.NilError(t, err)
|
||||
_, err = app.Commit()
|
||||
assert.NilError(t, err)
|
||||
}
|
||||
|
||||
assert.Equal(t, ver0+10, app.LastBlockHeight())
|
||||
store := app.NewContext(true).KVStore(app.GetKey("bank"))
|
||||
assert.DeepEqual(t, []byte("value10"), store.Get([]byte("key")))
|
||||
|
||||
// rollback 5 blocks
|
||||
target := ver0 + 5
|
||||
assert.NilError(t, app.CommitMultiStore().RollbackToVersion(target))
|
||||
assert.Equal(t, target, app.LastBlockHeight())
|
||||
|
||||
// recreate app to have clean check state
|
||||
app = simapp.NewSimApp(options.Logger, options.DB, nil, true, simtestutil.NewAppOptionsWithFlagHome(t.TempDir()))
|
||||
store = app.NewContext(true).KVStore(app.GetKey("bank"))
|
||||
assert.DeepEqual(t, []byte("value5"), store.Get([]byte("key")))
|
||||
|
||||
// commit another 5 blocks with different values
|
||||
for i := int64(6); i <= 10; i++ {
|
||||
header := cmtproto.Header{
|
||||
Height: ver0 + i,
|
||||
AppHash: app.LastCommitID().Hash,
|
||||
}
|
||||
_, err := app.FinalizeBlock(&abci.FinalizeBlockRequest{Height: header.Height})
|
||||
assert.NilError(t, err)
|
||||
ctx := app.NewContextLegacy(false, header)
|
||||
store := ctx.KVStore(app.GetKey("bank"))
|
||||
store.Set([]byte("key"), []byte(fmt.Sprintf("VALUE%d", i)))
|
||||
_, err = app.FinalizeBlock(&abci.FinalizeBlockRequest{
|
||||
Height: header.Height,
|
||||
})
|
||||
assert.NilError(t, err)
|
||||
_, err = app.Commit()
|
||||
assert.NilError(t, err)
|
||||
}
|
||||
|
||||
assert.Equal(t, ver0+10, app.LastBlockHeight())
|
||||
store = app.NewContext(true).KVStore(app.GetKey("bank"))
|
||||
assert.DeepEqual(t, []byte("VALUE10"), store.Get([]byte("key")))
|
||||
}
|
||||
@@ -247,7 +247,7 @@ func (s *IntegrationTestSuite) setupStakingParams(ctx context.Context, sk *staki
|
||||
require.NoError(s.T(), err)
|
||||
|
||||
// update unbonding time
|
||||
params.UnbondingTime = time.Duration(time.Second * 10)
|
||||
params.UnbondingTime = time.Second * 10
|
||||
err = sk.Params.Set(ctx, params)
|
||||
require.NoError(s.T(), err)
|
||||
}
|
||||
|
||||
@@ -104,8 +104,8 @@ type StartupConfig struct {
|
||||
GasService gas.Service
|
||||
}
|
||||
|
||||
func DefaultStartUpConfig(t testing.TB) StartupConfig {
|
||||
t.Helper()
|
||||
func DefaultStartUpConfig(tb testing.TB) StartupConfig {
|
||||
tb.Helper()
|
||||
|
||||
priv := secp256k1.GenPrivKey()
|
||||
ba := authtypes.NewBaseAccount(
|
||||
@@ -120,8 +120,8 @@ func DefaultStartUpConfig(t testing.TB) StartupConfig {
|
||||
sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100000000000000)),
|
||||
),
|
||||
}
|
||||
homedir := t.TempDir()
|
||||
t.Logf("generated integration test app config; HomeDir=%s", homedir)
|
||||
homedir := tb.TempDir()
|
||||
tb.Logf("generated integration test app config; HomeDir=%s", homedir)
|
||||
return StartupConfig{
|
||||
ValidatorSet: CreateRandomValidatorSet,
|
||||
GenesisBehavior: Genesis_COMMIT,
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
"cosmossdk.io/math"
|
||||
storetypes "cosmossdk.io/store/types"
|
||||
_ "cosmossdk.io/x/accounts" // import as blank for app wiring
|
||||
_ "cosmossdk.io/x/bank" // import as blank for app wiring
|
||||
bankkeeper "cosmossdk.io/x/bank/keeper"
|
||||
@@ -45,9 +44,8 @@ var (
|
||||
type fixture struct {
|
||||
app *integration.App
|
||||
|
||||
ctx context.Context
|
||||
cdc codec.Codec
|
||||
keys map[string]*storetypes.KVStoreKey
|
||||
ctx context.Context
|
||||
cdc codec.Codec
|
||||
|
||||
queryClient stakingkeeper.Querier
|
||||
|
||||
|
||||
Reference in New Issue
Block a user