From 0598995961c184932a4addbf19f3cbf01bea772d Mon Sep 17 00:00:00 2001 From: Cool Developer Date: Tue, 5 Dec 2023 16:14:01 -0500 Subject: [PATCH] rocksdb test --- store/storage/rocksdb/db.go | 7 +------ store/storage/rocksdb/db_test.go | 6 +++--- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/store/storage/rocksdb/db.go b/store/storage/rocksdb/db.go index 8ae5146d7b12..d1806cce1e2d 100644 --- a/store/storage/rocksdb/db.go +++ b/store/storage/rocksdb/db.go @@ -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) { diff --git a/store/storage/rocksdb/db_test.go b/store/storage/rocksdb/db_test.go index 9810bd08bb20..8788bfe632e2 100644 --- a/store/storage/rocksdb/db_test.go +++ b/store/storage/rocksdb/db_test.go @@ -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, batch.Write()) // reverse iterator without an end key iter, err := db.ReverseIterator(storeKey1, 1, []byte("key000"), nil)