func teardown() {
	block.Finalise()
	blockheader.Finalise()
	storage.Finalise()
	mode.Finalise()
	logger.Finalise()
	removeFiles()
	time.Sleep(25 * time.Millisecond)
}
post test cleanup
package reservoir_test
import (
	"os"
	"testing"
	"time"
	"github.com/golang/mock/gomock"
	"github.com/bitmark-inc/bitmarkd/block"
	"github.com/bitmark-inc/bitmarkd/blockheader"
	"github.com/bitmark-inc/bitmarkd/chain"
	"github.com/bitmark-inc/bitmarkd/mode"
	"github.com/bitmark-inc/bitmarkd/reservoir/mocks"
	"github.com/bitmark-inc/bitmarkd/storage"
	"github.com/bitmark-inc/logger"
)
const (
	testingDirName   = "testing"
	databaseFileName = testingDirName + "/test"
)
func removeFiles() {
	os.RemoveAll(testingDirName)
}
func setup(t *testing.T, theChain ...string) {
	removeFiles()
	os.Mkdir(testingDirName, 0700)
	logging := logger.Configuration{
		Directory: testingDirName,
		File:      "testing.log",
		Size:      1048576,
		Count:     10,
		Console:   false,
		Levels: map[string]string{
			logger.DefaultTag: "critical",
		},
	}
	if err := logger.Initialise(logging); nil != err {
		panic("logger setup failed: " + err.Error())
	}
	if len(theChain) >= 1 {
		mode.Initialise(theChain[0])
	} else {
		mode.Initialise(chain.Bitmark)
	}
	err := storage.Initialise(databaseFileName, false)
	if nil != err {
		t.Fatalf("storage initialise error: %s", err)
	}
	err = blockheader.Initialise()
	if nil != err {
		t.Fatalf("blockheader initialise error: %s", err)
	}
	ctl := gomock.NewController(t)
	defer ctl.Finish()
	handle := mocks.NewMockHandle(ctl)
	handle.EXPECT().LastElement().Return(storage.Element{}, false).Times(1)
	err = block.Initialise(handle)
	if nil != err {
		t.Fatalf("block initialise error: %s", err)
	}
}