You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
642 B

  1. // +build boltdb
  2. package db
  3. import (
  4. "fmt"
  5. "os"
  6. "testing"
  7. "github.com/stretchr/testify/require"
  8. cmn "github.com/tendermint/tendermint/libs/common"
  9. )
  10. func TestBoltDBNewBoltDB(t *testing.T) {
  11. name := fmt.Sprintf("test_%x", cmn.RandStr(12))
  12. dir := os.TempDir()
  13. defer cleanupDBDir(dir, name)
  14. db, err := NewBoltDB(name, dir)
  15. require.NoError(t, err)
  16. db.Close()
  17. }
  18. func BenchmarkBoltDBRandomReadsWrites(b *testing.B) {
  19. name := fmt.Sprintf("test_%x", cmn.RandStr(12))
  20. db, err := NewBoltDB(name, "")
  21. if err != nil {
  22. b.Fatal(err)
  23. }
  24. defer func() {
  25. db.Close()
  26. cleanupDBDir("", name)
  27. }()
  28. benchmarkRandomReadsWrites(b, db)
  29. }