Skip to content

Commit

Permalink
rocksdb test
Browse files Browse the repository at this point in the history
  • Loading branch information
cool-develope committed Dec 5, 2023
1 parent 19d0cd2 commit 64dc3c9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
7 changes: 1 addition & 6 deletions store/storage/rocksdb/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,7 @@ func (db *Database) Close() error {
}

func (db *Database) NewBatch(version uint64) (store.Batch, error) {
batch, err := NewBatch(db, version)
if err != nil {
return nil, err
}

return batch, nil
return NewBatch(db, version), nil
}

func (db *Database) getSlice(storeKey string, version uint64, key []byte) (*grocksdb.Slice, error) {
Expand Down
6 changes: 3 additions & 3 deletions store/storage/rocksdb/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ func TestDatabase_ReverseIterator(t *testing.T) {
require.NoError(t, err)
defer db.Close()

cs := store.NewChangeset(map[string]store.KVPairs{storeKey1: {}})
batch := NewBatch(db, 1)
for i := 0; i < 100; i++ {
key := fmt.Sprintf("key%03d", i) // key000, key001, ..., key099
val := fmt.Sprintf("val%03d", i) // val000, val001, ..., val099

cs.AddKVPair(storeKey1, store.KVPair{Key: []byte(key), Value: []byte(val)})
require.NoError(t, batch.Set(storeKey1, byte(key), []byte(val)))
}

require.NoError(t, db.ApplyChangeset(1, cs))
require.NoError(t, b.Write())

// reverse iterator without an end key
iter, err := db.ReverseIterator(storeKey1, 1, []byte("key000"), nil)
Expand Down

0 comments on commit 64dc3c9

Please sign in to comment.