示例#1
0
func TestBucketCache(t *testing.T) {
	testutil.SetLogLevel(logging.INFO, "buckettree")
	rootHash1, rootHash2, rootHash3, rootHash4 := testGetRootHashes(t, false)
	rootHash5, rootHash6, rootHash7, rootHash8 := testGetRootHashes(t, true)
	testutil.AssertEquals(t, rootHash1, rootHash5)
	testutil.AssertEquals(t, rootHash2, rootHash6)
	testutil.AssertEquals(t, rootHash3, rootHash7)
	testutil.AssertEquals(t, rootHash4, rootHash8)
}
示例#2
0
func disableLogging() {
	testutil.SetLogLevel(logging.ERROR, "indexes")
	testutil.SetLogLevel(logging.ERROR, "ledger")
	testutil.SetLogLevel(logging.INFO, "state")
	testutil.SetLogLevel(logging.ERROR, "statemgmt")
	testutil.SetLogLevel(logging.INFO, "buckettree")
	testutil.SetLogLevel(logging.INFO, "db")
}
示例#3
0
func BenchmarkStateHash(b *testing.B) {
	b.StopTimer()
	b.Logf("testParams:%q", testParams)
	flags := flag.NewFlagSet("testParams", flag.ExitOnError)
	numBuckets := flags.Int("NumBuckets", 10009, "Number of buckets")
	maxGroupingAtEachLevel := flags.Int("MaxGroupingAtEachLevel", 10, "max grouping at each level")
	chaincodeIDPrefix := flags.String("ChaincodeIDPrefix", "cID", "The chaincodeID used in the generated workload will be  ChaincodeIDPrefix_1, ChaincodeIDPrefix_2, and so on")
	numChaincodes := flags.Int("NumChaincodes", 1, "Number of chaincodes to assume")
	maxKeySuffix := flags.Int("MaxKeySuffix", 1, "the keys are appended with _1, _2,.. upto MaxKeySuffix")
	numKeysToInsert := flags.Int("NumKeysToInsert", 1, "how many keys to insert in a single batch")
	kvSize := flags.Int("KVSize", 1000, "size of the value")
	debugMsgsOn := flags.Bool("DebugOn", false, "Trun on/off debug messages during benchmarking")
	flags.Parse(testParams)

	b.Logf(`Running test with params:
		numbBuckets=%d, maxGroupingAtEachLevel=%d, chaincodeIDPrefix=%s, numChaincodes=%d, maxKeySuffix=%d, numKeysToInsert=%d, valueSize=%d, debugMsgs=%t`,
		*numBuckets, *maxGroupingAtEachLevel, *chaincodeIDPrefix, *numChaincodes, *maxKeySuffix, *numKeysToInsert, *kvSize, *debugMsgsOn)

	if !*debugMsgsOn {
		testutil.SetLogLevel(logging.ERROR, "statemgmt")
		testutil.SetLogLevel(logging.ERROR, "buckettree")
		testutil.SetLogLevel(logging.ERROR, "db")
	}

	stateImplTestWrapper := newStateImplTestWrapperWithCustomConfig(b, *numBuckets, *maxGroupingAtEachLevel)
	for i := 0; i < b.N; i++ {
		b.StopTimer()
		delta := statemgmt.ConstructRandomStateDelta(b, *chaincodeIDPrefix, *numChaincodes, *maxKeySuffix, *numKeysToInsert, *kvSize)
		b.StartTimer()
		stateImplTestWrapper.prepareWorkingSet(delta)
		stateImplTestWrapper.computeCryptoHash()
		if i == b.N-1 {
			stateImplTestWrapper.persistChangesAndResetInMemoryChanges()
			testDBWrapper.CloseDB(b)
		}
	}
}