1 Star 1 Fork 0

Hyperledger Fabric 国密 / fabric

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
stateleveldb_test_export.go 1.60 KB
一键复制 编辑 原始数据 按行查看 历史
Jtyoui 提交于 2021-07-22 15:59 . 国密
/*
Copyright IBM Corp. 2016 All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package stateleveldb
import (
"os"
"testing"
"gitee.com/hyperledger-fabric-gm/fabric/core/ledger/kvledger/txmgmt/statedb"
"gitee.com/hyperledger-fabric-gm/fabric/core/ledger/ledgerconfig"
)
// TestVDBEnv provides a level db backed versioned db for testing
type TestVDBEnv struct {
t testing.TB
DBProvider statedb.VersionedDBProvider
}
// NewTestVDBEnv instantiates and new level db backed TestVDB
func NewTestVDBEnv(t testing.TB) *TestVDBEnv {
t.Logf("Creating new TestVDBEnv")
removeDBPath(t, "NewTestVDBEnv")
dbProvider := NewVersionedDBProvider()
return &TestVDBEnv{t, dbProvider}
}
// Cleanup closes the db and removes the db folder
func (env *TestVDBEnv) Cleanup() {
env.t.Logf("Cleaningup TestVDBEnv")
env.DBProvider.Close()
removeDBPath(env.t, "Cleanup")
}
func removeDBPath(t testing.TB, caller string) {
dbPath := ledgerconfig.GetStateLevelDBPath()
if err := os.RemoveAll(dbPath); err != nil {
t.Fatalf("Err: %s", err)
t.FailNow()
}
logger.Debugf("Removed folder [%s] for test environment for %s", dbPath, caller)
}
Go
1
https://gitee.com/hyperledger-fabric-gm/fabric.git
git@gitee.com:hyperledger-fabric-gm/fabric.git
hyperledger-fabric-gm
fabric
fabric
v1.4.9

搜索帮助