mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-18 23:51:21 +00:00
Remove Prev from Iterator
This commit is contained in:
@ -66,7 +66,6 @@ func TestPrefixIteratorMatches1N(t *testing.T) {
|
||||
db.SetSync(bz("a/1"), bz("value_1"))
|
||||
db.SetSync(bz("a/3"), bz("value_3"))
|
||||
itr := IteratePrefix(db, []byte("a/"))
|
||||
itr.Seek(bz("a/1"))
|
||||
|
||||
checkValid(t, itr, true)
|
||||
checkItem(t, itr, bz("a/1"), bz("value_1"))
|
||||
@ -82,32 +81,6 @@ func TestPrefixIteratorMatches1N(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// Search for a/1, fail by too much Prev()
|
||||
func TestPrefixIteratorMatches1P(t *testing.T) {
|
||||
for backend, _ := range backends {
|
||||
t.Run(fmt.Sprintf("Prefix w/ backend %s", backend), func(t *testing.T) {
|
||||
db := newTempDB(t, backend)
|
||||
db.SetSync(bz("a/1"), bz("value_1"))
|
||||
db.SetSync(bz("a/3"), bz("value_3"))
|
||||
itr := IteratePrefix(db, []byte("a/"))
|
||||
itr.Seek(bz("a/1"))
|
||||
|
||||
checkValid(t, itr, true)
|
||||
checkItem(t, itr, bz("a/1"), bz("value_1"))
|
||||
checkNext(t, itr, true)
|
||||
checkItem(t, itr, bz("a/3"), bz("value_3"))
|
||||
checkPrev(t, itr, true)
|
||||
checkItem(t, itr, bz("a/1"), bz("value_1"))
|
||||
|
||||
// Bad!
|
||||
checkPrev(t, itr, false)
|
||||
|
||||
// Once invalid...
|
||||
checkInvalid(t, itr)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Search for a/2, fail by too much Next()
|
||||
func TestPrefixIteratorMatches2N(t *testing.T) {
|
||||
for backend, _ := range backends {
|
||||
@ -116,13 +89,11 @@ func TestPrefixIteratorMatches2N(t *testing.T) {
|
||||
db.SetSync(bz("a/1"), bz("value_1"))
|
||||
db.SetSync(bz("a/3"), bz("value_3"))
|
||||
itr := IteratePrefix(db, []byte("a/"))
|
||||
itr.Seek(bz("a/2"))
|
||||
|
||||
checkValid(t, itr, true)
|
||||
checkItem(t, itr, bz("a/3"), bz("value_3"))
|
||||
checkPrev(t, itr, true)
|
||||
checkItem(t, itr, bz("a/1"), bz("value_1"))
|
||||
checkNext(t, itr, true)
|
||||
checkValid(t, itr, true)
|
||||
checkItem(t, itr, bz("a/3"), bz("value_3"))
|
||||
|
||||
// Bad!
|
||||
@ -134,30 +105,6 @@ func TestPrefixIteratorMatches2N(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// Search for a/2, fail by too much Prev()
|
||||
func TestPrefixIteratorMatches2P(t *testing.T) {
|
||||
for backend, _ := range backends {
|
||||
t.Run(fmt.Sprintf("Prefix w/ backend %s", backend), func(t *testing.T) {
|
||||
db := newTempDB(t, backend)
|
||||
db.SetSync(bz("a/1"), bz("value_1"))
|
||||
db.SetSync(bz("a/3"), bz("value_3"))
|
||||
itr := IteratePrefix(db, []byte("a/"))
|
||||
itr.Seek(bz("a/2"))
|
||||
|
||||
checkValid(t, itr, true)
|
||||
checkItem(t, itr, bz("a/3"), bz("value_3"))
|
||||
checkPrev(t, itr, true)
|
||||
checkItem(t, itr, bz("a/1"), bz("value_1"))
|
||||
|
||||
// Bad!
|
||||
checkPrev(t, itr, false)
|
||||
|
||||
// Once invalid...
|
||||
checkInvalid(t, itr)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Search for a/3, fail by too much Next()
|
||||
func TestPrefixIteratorMatches3N(t *testing.T) {
|
||||
for backend, _ := range backends {
|
||||
@ -166,11 +113,8 @@ func TestPrefixIteratorMatches3N(t *testing.T) {
|
||||
db.SetSync(bz("a/1"), bz("value_1"))
|
||||
db.SetSync(bz("a/3"), bz("value_3"))
|
||||
itr := IteratePrefix(db, []byte("a/"))
|
||||
itr.Seek(bz("a/3"))
|
||||
|
||||
checkValid(t, itr, true)
|
||||
checkItem(t, itr, bz("a/3"), bz("value_3"))
|
||||
checkPrev(t, itr, true)
|
||||
checkItem(t, itr, bz("a/1"), bz("value_1"))
|
||||
checkNext(t, itr, true)
|
||||
checkItem(t, itr, bz("a/3"), bz("value_3"))
|
||||
@ -183,27 +127,3 @@ func TestPrefixIteratorMatches3N(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Search for a/3, fail by too much Prev()
|
||||
func TestPrefixIteratorMatches3P(t *testing.T) {
|
||||
for backend, _ := range backends {
|
||||
t.Run(fmt.Sprintf("Prefix w/ backend %s", backend), func(t *testing.T) {
|
||||
db := newTempDB(t, backend)
|
||||
db.SetSync(bz("a/1"), bz("value_1"))
|
||||
db.SetSync(bz("a/3"), bz("value_3"))
|
||||
itr := IteratePrefix(db, []byte("a/"))
|
||||
itr.Seek(bz("a/3"))
|
||||
|
||||
checkValid(t, itr, true)
|
||||
checkItem(t, itr, bz("a/3"), bz("value_3"))
|
||||
checkPrev(t, itr, true)
|
||||
checkItem(t, itr, bz("a/1"), bz("value_1"))
|
||||
|
||||
// Bad!
|
||||
checkPrev(t, itr, false)
|
||||
|
||||
// Once invalid...
|
||||
checkInvalid(t, itr)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user