Skip to content

Commit

Permalink
chore: Replace testify with gotest.tools in store tests (cosmos#14497)
Browse files Browse the repository at this point in the history
  • Loading branch information
likhita-809 authored Jan 5, 2023
1 parent 0a7bcd2 commit 8c6739a
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions tests/integration/store/rootmulti/rollback_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import (

"cosmossdk.io/simapp"
dbm "github.com/cosmos/cosmos-db"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/log"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
"gotest.tools/v3/assert"

simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
)

func TestRollback(t *testing.T) {
Expand All @@ -36,19 +37,19 @@ func TestRollback(t *testing.T) {
app.Commit()
}

require.Equal(t, ver0+10, app.LastBlockHeight())
assert.Equal(t, ver0+10, app.LastBlockHeight())
store := app.NewContext(true, tmproto.Header{}).KVStore(app.GetKey("bank"))
require.Equal(t, []byte("value10"), store.Get([]byte("key")))
assert.DeepEqual(t, []byte("value10"), store.Get([]byte("key")))

// rollback 5 blocks
target := ver0 + 5
require.NoError(t, app.CommitMultiStore().RollbackToVersion(target))
require.Equal(t, target, app.LastBlockHeight())
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, tmproto.Header{}).KVStore(app.GetKey("bank"))
require.Equal(t, []byte("value5"), store.Get([]byte("key")))
assert.DeepEqual(t, []byte("value5"), store.Get([]byte("key")))

// commit another 5 blocks with different values
for i := int64(6); i <= 10; i++ {
Expand All @@ -63,7 +64,7 @@ func TestRollback(t *testing.T) {
app.Commit()
}

require.Equal(t, ver0+10, app.LastBlockHeight())
assert.Equal(t, ver0+10, app.LastBlockHeight())
store = app.NewContext(true, tmproto.Header{}).KVStore(app.GetKey("bank"))
require.Equal(t, []byte("VALUE10"), store.Get([]byte("key")))
assert.DeepEqual(t, []byte("VALUE10"), store.Get([]byte("key")))
}

0 comments on commit 8c6739a

Please sign in to comment.