* Add CacheDB & SimpleMap
* Generic memBatch; Fix cLevelDB tests
* CacheWrap() for CacheDB and MemDB
* Change Iterator to match LeviGo Iterator
* Fixes from review
* cacheWrapWriteMutex and some race fixes
* Use tmlibs/common
* NewCWWMutex is exposed.  DB can be CacheWrap'd
* Remove GetOK, not needed
* Fsdb (#72)
* Add FSDB
* Review fixes from Anton
* Review changes
* Fixes from review
This commit is contained in:
Jae Kwon
2017-11-09 17:42:32 -05:00
committed by GitHub
parent 176c2ceed6
commit 8481c49c82
23 changed files with 1699 additions and 354 deletions

43
db/backend_test.go Normal file
View File

@ -0,0 +1,43 @@
package db
import (
"fmt"
"testing"
"github.com/stretchr/testify/require"
cmn "github.com/tendermint/tmlibs/common"
)
func testBackend(t *testing.T, backend string) {
// Default
dir, dirname := cmn.Tempdir(fmt.Sprintf("test_backend_%s_", backend))
defer dir.Close()
db := NewDB("testdb", backend, dirname)
require.Nil(t, db.Get([]byte("")))
require.Nil(t, db.Get(nil))
// Set empty ("")
db.Set([]byte(""), []byte(""))
require.NotNil(t, db.Get([]byte("")))
require.NotNil(t, db.Get(nil))
require.Empty(t, db.Get([]byte("")))
require.Empty(t, db.Get(nil))
// Set empty (nil)
db.Set([]byte(""), nil)
require.NotNil(t, db.Get([]byte("")))
require.NotNil(t, db.Get(nil))
require.Empty(t, db.Get([]byte("")))
require.Empty(t, db.Get(nil))
// Delete
db.Delete([]byte(""))
require.Nil(t, db.Get([]byte("")))
require.Nil(t, db.Get(nil))
}
func TestBackends(t *testing.T) {
testBackend(t, CLevelDBBackendStr)
testBackend(t, GoLevelDBBackendStr)
testBackend(t, MemDBBackendStr)
}