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

chore: Replace testify with gotest.tools in store tests #14497

Merged
merged 3 commits into from
Jan 5, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.DeepEqual(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.DeepEqual(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.DeepEqual(t, ver0+10, app.LastBlockHeight())
likhita-809 marked this conversation as resolved.
Show resolved Hide resolved
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")))
}