* mainly sdk.int to cosmossdk.io/math * staking keys * fumpt * var-naming linter errors and a fumpt * Update CHANGELOG.md * Update .golangci.yml * Update CHANGELOG.md * Update test_helpers.go * Update test_helpers.go * fumpt and lint * this lints the db module, and makes it easier to use. It adds breaking name changes * DBConnection -> Connection * previous commit contained a merge error * Update test_helpers.go * Update test_helpers.go * db renamings * merge master * changelog * DBWriter -> Writer * consistent multistore reciever * standard recievers for multistore v2alpha1 * general cleanup of linting issues * more linter fixes * remove prealloc linter * nolint the secp256k1 import * nolint the secp256k1 package * completenolint resulting in a diff that has only nolints
53 lines
1.2 KiB
Go
53 lines
1.2 KiB
Go
package dbtest
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
|
|
dbm "github.com/cosmos/cosmos-sdk/db"
|
|
)
|
|
|
|
func AssertNext(t *testing.T, itr dbm.Iterator, expected bool) {
|
|
t.Helper()
|
|
require.Equal(t, expected, itr.Next())
|
|
}
|
|
|
|
func AssertDomain(t *testing.T, itr dbm.Iterator, start, end []byte) {
|
|
t.Helper()
|
|
ds, de := itr.Domain()
|
|
assert.Equal(t, start, ds, "checkDomain domain start incorrect")
|
|
assert.Equal(t, end, de, "checkDomain domain end incorrect")
|
|
}
|
|
|
|
func AssertItem(t *testing.T, itr dbm.Iterator, key, value []byte) {
|
|
t.Helper()
|
|
assert.Exactly(t, key, itr.Key())
|
|
assert.Exactly(t, value, itr.Value())
|
|
}
|
|
|
|
func AssertInvalid(t *testing.T, itr dbm.Iterator) {
|
|
t.Helper()
|
|
AssertNext(t, itr, false)
|
|
AssertKeyPanics(t, itr)
|
|
AssertValuePanics(t, itr)
|
|
}
|
|
|
|
func AssertKeyPanics(t *testing.T, itr dbm.Iterator) {
|
|
t.Helper()
|
|
assert.Panics(t, func() { itr.Key() }, "checkKeyPanics expected panic but didn't")
|
|
}
|
|
|
|
func AssertValue(t *testing.T, db dbm.Reader, key, valueWanted []byte) {
|
|
t.Helper()
|
|
valueGot, err := db.Get(key)
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, valueWanted, valueGot)
|
|
}
|
|
|
|
func AssertValuePanics(t *testing.T, itr dbm.Iterator) {
|
|
t.Helper()
|
|
assert.Panics(t, func() { itr.Value() })
|
|
}
|