github.com/evdatsion/aphelion-dpos-bft@v0.32.1/libs/db/boltdb_test.go (about)

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