func TestInitRepository_WithFileDB(t *testing.T) {
	assert := assert.New(t)
	chainConfig := config.RepositoryConfig{
		PluginName:    PLUGIN_LEVELDB,
		StateDataPath: "/tmp/state",
		BlockDataPath: "/tmp/block",
	}
	err := InitRepository(chainConfig, &eventCenter{})
	assert.Nil(err)
}
test init repository with file database.
package repository
import (
	"crypto/sha256"
	"fmt"
	"github.com/DSiSc/craft/types"
	"github.com/DSiSc/monkey"
	"github.com/DSiSc/repository/common"
	"github.com/DSiSc/repository/config"
	"github.com/stretchr/testify/assert"
	"math/big"
	"os"
	"reflect"
	"testing"
)
func TestMain(m *testing.M) {
	chainConfig := config.RepositoryConfig{
		PluginName:    PLUGIN_MEMDB,
		StateDataPath: "/tmp/state",
		BlockDataPath: "/tmp/block",
	}
	err := InitRepository(chainConfig, &eventCenter{})
	if err != nil {
		fmt.Print(err)
		os.Exit(1)
	}
	m.Run()
}
func mockBlock() *types.Block {
	header := &types.Header{}
	block := &types.Block{
		Header: header,
	}
	return block
}
func mockWriteBlock(t *testing.T, bc *Repository) {
	assert := assert.New(t)
	block := mockBlock()
	block.Header.Height = bc.GetCurrentBlockHeight() + 1
	block.Header.StateRoot = bc.IntermediateRoot(false)
	block.HeaderHash = common.HeaderHash(block)
	err := bc.WriteBlock(block)
	assert.Nil(err)
}
func mockBlockWithTx() (*types.Block, types.Transaction) {
	block := mockBlock()
	address := common.HexToAddress("")
	txHash := common.HexToHash("")
	tx := types.Transaction{
		Data: types.TxData{
			AccountNonce: 1,
			Recipient:    &address,
			From:         &address,
			Payload:      nil,
			Amount:       big.NewInt(100),
			GasLimit:     0,
			Price:        big.NewInt(100),
			V:            big.NewInt(100),
			R:            big.NewInt(100),
			S:            big.NewInt(100),
			Hash:         &txHash,
		},
	}
	block.Transactions = []*types.Transaction{&tx}
	return block, tx
}
func mockReceipts() []*types.Receipt {
	receipt := types.Receipt{
		Status: 1,
	}
	return []*types.Receipt{&receipt}
}
func TestInitBlockChain_WithMemDB(t *testing.T) {
	assert := assert.New(t)
	chainConfig := config.RepositoryConfig{
		PluginName:    PLUGIN_MEMDB,
		StateDataPath: "",
		BlockDataPath: "",
	}
	err := InitRepository(chainConfig, &eventCenter{})
	assert.Nil(err)
}