本文整理匯總了Golang中github.com/hyperledger/fabric/core/ledger/testutil.AssertNil函數的典型用法代碼示例。如果您正苦於以下問題:Golang AssertNil函數的具體用法?Golang AssertNil怎麽用?Golang AssertNil使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了AssertNil函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestStateImpl_DB_Changes
func TestStateImpl_DB_Changes(t *testing.T) {
// number of buckets at each level 26,9,3,1
testHasher, stateImplTestWrapper, stateDelta := createFreshDBAndInitTestStateImplWithCustomHasher(t, 26, 3)
// populate hash fucntion such that
// ["chaincodeID1", "key1"] is bucketized to bucket 1
testHasher.populate("chaincodeID1", "key1", 0)
testHasher.populate("chaincodeID1", "key2", 0)
testHasher.populate("chaincodeID2", "key1", 1)
testHasher.populate("chaincodeID2", "key3", 3)
testHasher.populate("chaincodeID10", "key10", 24)
// prepare stateDelta
stateDelta.Set("chaincodeID1", "key1", []byte("value1"), nil)
stateDelta.Set("chaincodeID1", "key2", []byte("value2"), nil)
stateDelta.Set("chaincodeID2", "key1", []byte("value3"), nil)
stateDelta.Set("chaincodeID2", "key3", []byte("value4"), nil)
stateImplTestWrapper.prepareWorkingSetAndComputeCryptoHash(stateDelta)
stateImplTestWrapper.persistChangesAndResetInMemoryChanges()
// Read state from DB
testutil.AssertEquals(t, stateImplTestWrapper.get("chaincodeID1", "key1"), []byte("value1"))
testutil.AssertEquals(t, stateImplTestWrapper.get("chaincodeID2", "key1"), []byte("value3"))
// fetch datanode from DB
dataNodeFromDB, _ := fetchDataNodeFromDB(newDataKey("chaincodeID2", "key1"))
testutil.AssertEquals(t, dataNodeFromDB, newDataNode(newDataKey("chaincodeID2", "key1"), []byte("value3")))
//fetch non-existing data node from DB
dataNodeFromDB, _ = fetchDataNodeFromDB(newDataKey("chaincodeID10", "key10"))
t.Logf("isNIL...[%t]", dataNodeFromDB == nil)
testutil.AssertNil(t, dataNodeFromDB)
// fetch all data nodes from db that belong to bucket 1 at lowest level
dataNodesFromDB, _ := fetchDataNodesFromDBFor(newBucketKeyAtLowestLevel(1))
testutil.AssertContainsAll(t, dataNodesFromDB,
dataNodes{newDataNode(newDataKey("chaincodeID1", "key1"), []byte("value1")),
newDataNode(newDataKey("chaincodeID1", "key2"), []byte("value2"))})
// fetch all data nodes from db that belong to bucket 2 at lowest level
dataNodesFromDB, _ = fetchDataNodesFromDBFor(newBucketKeyAtLowestLevel(2))
testutil.AssertContainsAll(t, dataNodesFromDB,
dataNodes{newDataNode(newDataKey("chaincodeID2", "key1"), []byte("value3"))})
// fetch first bucket at second level
bucketNodeFromDB, _ := fetchBucketNodeFromDB(newBucketKey(2, 1))
testutil.AssertEquals(t, bucketNodeFromDB.bucketKey, newBucketKey(2, 1))
//check childrenCryptoHash entries in the bucket node from DB
testutil.AssertEquals(t, bucketNodeFromDB.childrenCryptoHash[0],
expectedBucketHashForTest([]string{"chaincodeID1", "key1", "value1", "key2", "value2"}))
testutil.AssertEquals(t, bucketNodeFromDB.childrenCryptoHash[1],
expectedBucketHashForTest([]string{"chaincodeID2", "key1", "value3"}))
testutil.AssertNil(t, bucketNodeFromDB.childrenCryptoHash[2])
// third bucket at second level should be nil
bucketNodeFromDB, _ = fetchBucketNodeFromDB(newBucketKey(2, 3))
testutil.AssertNil(t, bucketNodeFromDB)
}
示例2: TestDeletes
// TestDeletes tests deteles
func TestDeletes(t *testing.T, db statedb.VersionedDB) {
db.Open()
defer db.Close()
batch := statedb.NewUpdateBatch()
vv1 := statedb.VersionedValue{Value: []byte("value1"), Version: version.NewHeight(1, 1)}
vv2 := statedb.VersionedValue{Value: []byte("value2"), Version: version.NewHeight(1, 2)}
vv3 := statedb.VersionedValue{Value: []byte("value1"), Version: version.NewHeight(1, 3)}
vv4 := statedb.VersionedValue{Value: []byte("value2"), Version: version.NewHeight(1, 4)}
batch.Put("ns", "key1", vv1.Value, vv1.Version)
batch.Put("ns", "key2", vv2.Value, vv2.Version)
batch.Put("ns", "key3", vv2.Value, vv3.Version)
batch.Put("ns", "key4", vv2.Value, vv4.Version)
batch.Delete("ns", "key3", version.NewHeight(1, 5))
savePoint := version.NewHeight(1, 5)
err := db.ApplyUpdates(batch, savePoint)
testutil.AssertNoError(t, err, "")
vv, _ := db.GetState("ns", "key2")
testutil.AssertEquals(t, vv, &vv2)
vv, err = db.GetState("ns", "key3")
testutil.AssertNoError(t, err, "")
testutil.AssertNil(t, vv)
batch = statedb.NewUpdateBatch()
batch.Delete("ns", "key2", version.NewHeight(1, 6))
err = db.ApplyUpdates(batch, savePoint)
testutil.AssertNoError(t, err, "")
vv, err = db.GetState("ns", "key2")
testutil.AssertNoError(t, err, "")
testutil.AssertNil(t, vv)
}
示例3: TestStateSnapshotIterator
func TestStateSnapshotIterator(t *testing.T) {
testDBWrapper.CreateFreshDB(t)
stateTrieTestWrapper := newStateTrieTestWrapper(t)
stateTrie := stateTrieTestWrapper.stateTrie
stateDelta := statemgmt.NewStateDelta()
// insert keys
stateDelta.Set("chaincodeID1", "key1", []byte("value1"), nil)
stateDelta.Set("chaincodeID2", "key2", []byte("value2"), nil)
stateDelta.Set("chaincodeID3", "key3", []byte("value3"), nil)
stateDelta.Set("chaincodeID4", "key4", []byte("value4"), nil)
stateDelta.Set("chaincodeID5", "key5", []byte("value5"), nil)
stateDelta.Set("chaincodeID6", "key6", []byte("value6"), nil)
stateTrie.PrepareWorkingSet(stateDelta)
stateTrieTestWrapper.PersistChangesAndResetInMemoryChanges()
//check that the key is persisted
testutil.AssertEquals(t, stateTrieTestWrapper.Get("chaincodeID1", "key1"), []byte("value1"))
testutil.AssertEquals(t, stateTrieTestWrapper.Get("chaincodeID2", "key2"), []byte("value2"))
testutil.AssertEquals(t, stateTrieTestWrapper.Get("chaincodeID3", "key3"), []byte("value3"))
testutil.AssertEquals(t, stateTrieTestWrapper.Get("chaincodeID4", "key4"), []byte("value4"))
testutil.AssertEquals(t, stateTrieTestWrapper.Get("chaincodeID5", "key5"), []byte("value5"))
testutil.AssertEquals(t, stateTrieTestWrapper.Get("chaincodeID6", "key6"), []byte("value6"))
// take db snapeshot
dbSnapshot := db.GetDBHandle().GetSnapshot()
stateDelta1 := statemgmt.NewStateDelta()
// delete a few keys
stateDelta1.Delete("chaincodeID1", "key1", nil)
stateDelta1.Delete("chaincodeID3", "key3", nil)
stateDelta1.Delete("chaincodeID4", "key4", nil)
stateDelta1.Delete("chaincodeID6", "key6", nil)
// update remaining keys
stateDelta1.Set("chaincodeID2", "key2", []byte("value2_new"), nil)
stateDelta1.Set("chaincodeID5", "key5", []byte("value5_new"), nil)
stateTrie.PrepareWorkingSet(stateDelta1)
stateTrieTestWrapper.PersistChangesAndResetInMemoryChanges()
//check that the keys are updated
testutil.AssertNil(t, stateTrieTestWrapper.Get("chaincodeID1", "key1"))
testutil.AssertNil(t, stateTrieTestWrapper.Get("chaincodeID3", "key3"))
testutil.AssertNil(t, stateTrieTestWrapper.Get("chaincodeID4", "key4"))
testutil.AssertNil(t, stateTrieTestWrapper.Get("chaincodeID6", "key6"))
testutil.AssertEquals(t, stateTrieTestWrapper.Get("chaincodeID2", "key2"), []byte("value2_new"))
testutil.AssertEquals(t, stateTrieTestWrapper.Get("chaincodeID5", "key5"), []byte("value5_new"))
itr, err := newStateSnapshotIterator(dbSnapshot)
testutil.AssertNoError(t, err, "Error while getting state snapeshot iterator")
stateDeltaFromSnapshot := statemgmt.NewStateDelta()
for itr.Next() {
keyBytes, valueBytes := itr.GetRawKeyValue()
t.Logf("key=[%s], value=[%s]", string(keyBytes), string(valueBytes))
chaincodeID, key := statemgmt.DecodeCompositeKey(keyBytes)
stateDeltaFromSnapshot.Set(chaincodeID, key, valueBytes, nil)
}
testutil.AssertEquals(t, stateDelta, stateDeltaFromSnapshot)
}
示例4: testBlockStream
func testBlockStream(t *testing.T, numFiles int) {
env := newTestEnv(t)
defer env.Cleanup()
w := newTestBlockfileWrapper(t, env)
defer w.close()
blockfileMgr := w.blockfileMgr
numBlocksInEachFile := 10
bg := testutil.NewBlockGenerator(t)
for i := 0; i < numFiles; i++ {
blocks := bg.NextTestBlocks(numBlocksInEachFile)
w.addBlocks(blocks)
blockfileMgr.moveToNextFile()
}
s, err := newBlockStream(blockfileMgr.rootDir, 0, 0, numFiles-1)
defer s.close()
testutil.AssertNoError(t, err, "Error in constructing new block stream")
blockCount := 0
for {
blockBytes, err := s.nextBlockBytes()
testutil.AssertNoError(t, err, "Error in getting next block")
if blockBytes == nil {
break
}
blockCount++
}
// After the stream has been exhausted, both blockBytes and err should be nil
blockBytes, err := s.nextBlockBytes()
testutil.AssertNil(t, blockBytes)
testutil.AssertNoError(t, err, "Error in getting next block after exhausting the file")
testutil.AssertEquals(t, blockCount, numFiles*numBlocksInEachFile)
}
示例5: TestLedgerPutRawBlock
func TestLedgerPutRawBlock(t *testing.T) {
ledgerTestWrapper := createFreshDBAndTestLedgerWrapper(t)
ledger := ledgerTestWrapper.ledger
block := new(protos.Block)
block.PreviousBlockHash = []byte("foo")
block.StateHash = []byte("bar")
ledger.PutRawBlock(block, 4)
testutil.AssertEquals(t, ledgerTestWrapper.GetBlockByNumber(4), block)
ledger.BeginTxBatch(1)
ledger.TxBegin("txUuid")
ledger.SetState("chaincode1", "key1", []byte("value1"))
ledger.TxFinished("txUuid", true)
transaction, _ := buildTestTx(t)
ledger.CommitTxBatch(1, []*protos.Transaction{transaction}, nil, []byte("proof"))
previousHash, _ := block.GetHash()
newBlock := ledgerTestWrapper.GetBlockByNumber(5)
if !bytes.Equal(newBlock.PreviousBlockHash, previousHash) {
t.Fatalf("Expected new block to properly set its previous hash")
}
// Assert that a non-existent block is nil
testutil.AssertNil(t, ledgerTestWrapper.GetBlockByNumber(2))
}
示例6: TestLedgerRollbackWithHash
func TestLedgerRollbackWithHash(t *testing.T) {
ledgerTestWrapper := createFreshDBAndTestLedgerWrapper(t)
ledger := ledgerTestWrapper.ledger
ledger.BeginTxBatch(0)
ledger.TxBegin("txUuid")
ledger.SetState("chaincode0", "key1", []byte("value1"))
ledger.SetState("chaincode0", "key2", []byte("value2"))
ledger.SetState("chaincode0", "key3", []byte("value3"))
ledger.TxFinished("txUuid", true)
ledger.RollbackTxBatch(0)
hash0 := ledgerTestWrapper.GetTempStateHash()
ledger.BeginTxBatch(1)
ledger.TxBegin("txUuid")
ledger.SetState("chaincode1", "key1", []byte("value1"))
ledger.SetState("chaincode2", "key2", []byte("value2"))
ledger.SetState("chaincode3", "key3", []byte("value3"))
ledger.TxFinished("txUuid", true)
hash1 := ledgerTestWrapper.GetTempStateHash()
testutil.AssertNotEquals(t, hash1, hash0)
ledger.RollbackTxBatch(1)
hash1 = ledgerTestWrapper.GetTempStateHash()
testutil.AssertEquals(t, hash1, hash0)
testutil.AssertNil(t, ledgerTestWrapper.GetState("chaincode1", "key1", false))
}
示例7: TestBasicRW
// TestBasicRW tests basic read-write
func TestBasicRW(t *testing.T, db statedb.VersionedDB) {
db.Open()
defer db.Close()
val, err := db.GetState("ns", "key1")
testutil.AssertNoError(t, err, "")
testutil.AssertNil(t, val)
batch := statedb.NewUpdateBatch()
vv1 := statedb.VersionedValue{Value: []byte("value1"), Version: version.NewHeight(1, 1)}
vv2 := statedb.VersionedValue{Value: []byte("value2"), Version: version.NewHeight(1, 2)}
vv3 := statedb.VersionedValue{Value: []byte("value3"), Version: version.NewHeight(1, 3)}
vv4 := statedb.VersionedValue{Value: []byte{}, Version: version.NewHeight(1, 4)}
batch.Put("ns1", "key1", vv1.Value, vv1.Version)
batch.Put("ns1", "key2", vv2.Value, vv2.Version)
batch.Put("ns2", "key3", vv3.Value, vv3.Version)
batch.Put("ns2", "key4", vv4.Value, vv4.Version)
savePoint := version.NewHeight(2, 5)
db.ApplyUpdates(batch, savePoint)
vv, _ := db.GetState("ns1", "key1")
testutil.AssertEquals(t, vv, &vv1)
vv, _ = db.GetState("ns2", "key4")
testutil.AssertEquals(t, vv, &vv4)
sp, err := db.GetLatestSavePoint()
testutil.AssertNoError(t, err, "")
testutil.AssertEquals(t, sp, savePoint)
}
示例8: TestBlockChain_SimpleChain
func TestBlockChain_SimpleChain(t *testing.T) {
testDBWrapper.CleanDB(t)
blockchainTestWrapper := newTestBlockchainWrapper(t)
blockchain := blockchainTestWrapper.blockchain
allBlocks, allStateHashes, err := blockchainTestWrapper.populateBlockChainWithSampleData()
if err != nil {
t.Logf("Error populating block chain with sample data: %s", err)
t.Fail()
}
testutil.AssertEquals(t, blockchain.getSize(), uint64(len(allBlocks)))
testutil.AssertEquals(t, blockchainTestWrapper.fetchBlockchainSizeFromDB(), uint64(len(allBlocks)))
for i := range allStateHashes {
t.Logf("Checking state hash for block number = [%d]", i)
testutil.AssertEquals(t, blockchainTestWrapper.getBlock(uint64(i)).GetStateHash(), allStateHashes[i])
}
for i := range allBlocks {
t.Logf("Checking block hash for block number = [%d]", i)
blockhash, _ := blockchainTestWrapper.getBlock(uint64(i)).GetHash()
expectedBlockHash, _ := allBlocks[i].GetHash()
testutil.AssertEquals(t, blockhash, expectedBlockHash)
}
testutil.AssertNil(t, blockchainTestWrapper.getBlock(uint64(0)).PreviousBlockHash)
i := 1
for i < len(allBlocks) {
t.Logf("Checking previous block hash for block number = [%d]", i)
expectedPreviousBlockHash, _ := allBlocks[i-1].GetHash()
testutil.AssertEquals(t, blockchainTestWrapper.getBlock(uint64(i)).PreviousBlockHash, expectedPreviousBlockHash)
i++
}
}
示例9: testBlockfileStream
func testBlockfileStream(t *testing.T, numBlocks int) {
env := newTestEnv(t)
defer env.Cleanup()
w := newTestBlockfileWrapper(t, env)
blockfileMgr := w.blockfileMgr
blocks := testutil.ConstructTestBlocks(t, numBlocks)
w.addBlocks(blocks)
w.close()
s, err := newBlockfileStream(blockfileMgr.rootDir, 0, 0)
defer s.close()
testutil.AssertNoError(t, err, "Error in constructing blockfile stream")
blockCount := 0
for {
blockBytes, err := s.nextBlockBytes()
testutil.AssertNoError(t, err, "Error in getting next block")
if blockBytes == nil {
break
}
blockCount++
}
// After the stream has been exhausted, both blockBytes and err should be nil
blockBytes, err := s.nextBlockBytes()
testutil.AssertNil(t, blockBytes)
testutil.AssertNoError(t, err, "Error in getting next block after exhausting the file")
testutil.AssertEquals(t, blockCount, numBlocks)
}
示例10: testTxSimulatorWithNoExistingData
func testTxSimulatorWithNoExistingData(t *testing.T, env testEnv) {
txMgr := env.getTxMgr()
s, _ := txMgr.NewTxSimulator()
value, err := s.GetState("ns1", "key1")
testutil.AssertNoError(t, err, fmt.Sprintf("Error in GetState(): %s", err))
testutil.AssertNil(t, value)
s.SetState("ns1", "key1", []byte("value1"))
s.SetState("ns1", "key2", []byte("value2"))
s.SetState("ns2", "key3", []byte("value3"))
s.SetState("ns2", "key4", []byte("value4"))
value, _ = s.GetState("ns2", "key3")
testutil.AssertEquals(t, value, []byte("value3"))
s.DeleteState("ns2", "key3")
value, _ = s.GetState("ns2", "key3")
testutil.AssertNil(t, value)
}
示例11: TestDeleteAllStateKeysAndValues
func TestDeleteAllStateKeysAndValues(t *testing.T) {
ledgerTestWrapper := createFreshDBAndTestLedgerWrapper(t)
ledger := ledgerTestWrapper.ledger
ledger.BeginTxBatch(1)
ledger.TxBegin("txUuid1")
ledger.SetState("chaincode1", "key1", []byte("value1"))
ledger.SetState("chaincode2", "key2", []byte("value2"))
ledger.SetState("chaincode3", "key3", []byte("value3"))
ledger.TxFinished("txUuid1", true)
transaction, _ := buildTestTx(t)
ledger.CommitTxBatch(1, []*protos.Transaction{transaction}, nil, []byte("proof"))
// Confirm values are present in state
testutil.AssertEquals(t, ledgerTestWrapper.GetState("chaincode1", "key1", true), []byte("value1"))
testutil.AssertEquals(t, ledgerTestWrapper.GetState("chaincode2", "key2", true), []byte("value2"))
testutil.AssertEquals(t, ledgerTestWrapper.GetState("chaincode3", "key3", true), []byte("value3"))
// Delete all keys/values
err := ledger.DeleteALLStateKeysAndValues()
if err != nil {
t.Fatalf("Error calling deleting all keys/values from state: %s", err)
}
// Confirm values are deleted
testutil.AssertNil(t, ledgerTestWrapper.GetState("chaincode1", "key1", true))
testutil.AssertNil(t, ledgerTestWrapper.GetState("chaincode2", "key2", true))
testutil.AssertNil(t, ledgerTestWrapper.GetState("chaincode3", "key3", true))
// Test that we can now store new stuff in the state
ledger.BeginTxBatch(2)
ledger.TxBegin("txUuid1")
ledger.SetState("chaincode1", "key1", []byte("value1"))
ledger.SetState("chaincode2", "key2", []byte("value2"))
ledger.SetState("chaincode3", "key3", []byte("value3"))
ledger.TxFinished("txUuid1", true)
transaction, _ = buildTestTx(t)
ledger.CommitTxBatch(2, []*protos.Transaction{transaction}, nil, []byte("proof"))
// Confirm values are present in state
testutil.AssertEquals(t, ledgerTestWrapper.GetState("chaincode1", "key1", true), []byte("value1"))
testutil.AssertEquals(t, ledgerTestWrapper.GetState("chaincode2", "key2", true), []byte("value2"))
testutil.AssertEquals(t, ledgerTestWrapper.GetState("chaincode3", "key3", true), []byte("value3"))
}
示例12: testItr
func testItr(t *testing.T, itr statedb.ResultsIterator, expectedKeys []string) {
defer itr.Close()
for _, expectedKey := range expectedKeys {
vkv, _ := itr.Next()
key := vkv.Key
testutil.AssertEquals(t, key, expectedKey)
}
last, err := itr.Next()
testutil.AssertNoError(t, err, "")
testutil.AssertNil(t, last)
}
示例13: TestStateChanges
func TestStateChanges(t *testing.T) {
stateTestWrapper, state := createFreshDBAndConstructState(t)
// add keys
state.TxBegin("txUuid")
state.Set("chaincode1", "key1", []byte("value1"))
state.Set("chaincode1", "key2", []byte("value2"))
state.TxFinish("txUuid", true)
//chehck in-memory
testutil.AssertEquals(t, stateTestWrapper.get("chaincode1", "key1", false), []byte("value1"))
testutil.AssertNil(t, stateTestWrapper.get("chaincode1", "key1", true))
delta := state.getStateDelta()
// save to db
stateTestWrapper.persistAndClearInMemoryChanges(0)
testutil.AssertEquals(t, stateTestWrapper.get("chaincode1", "key1", true), []byte("value1"))
testutil.AssertEquals(t, stateTestWrapper.fetchStateDeltaFromDB(0), delta)
// make changes when data is already in db
state.TxBegin("txUuid")
state.Set("chaincode1", "key1", []byte("new_value1"))
state.TxFinish("txUuid", true)
testutil.AssertEquals(t, stateTestWrapper.get("chaincode1", "key1", false), []byte("new_value1"))
state.TxBegin("txUuid")
state.Delete("chaincode1", "key2")
state.TxFinish("txUuid", true)
testutil.AssertNil(t, stateTestWrapper.get("chaincode1", "key2", false))
state.TxBegin("txUuid")
state.Set("chaincode2", "key3", []byte("value3"))
state.Set("chaincode2", "key4", []byte("value4"))
state.TxFinish("txUuid", true)
delta = state.getStateDelta()
stateTestWrapper.persistAndClearInMemoryChanges(1)
testutil.AssertEquals(t, stateTestWrapper.fetchStateDeltaFromDB(1), delta)
testutil.AssertEquals(t, stateTestWrapper.get("chaincode1", "key1", true), []byte("new_value1"))
testutil.AssertNil(t, stateTestWrapper.get("chaincode1", "key2", true))
testutil.AssertEquals(t, stateTestWrapper.get("chaincode2", "key3", true), []byte("value3"))
}
示例14: TestLedgerRollback
func TestLedgerRollback(t *testing.T) {
ledgerTestWrapper := createFreshDBAndTestLedgerWrapper(t)
ledger := ledgerTestWrapper.ledger
ledger.BeginTxBatch(1)
ledger.TxBegin("txUuid")
ledger.SetState("chaincode1", "key1", []byte("value1"))
ledger.SetState("chaincode2", "key2", []byte("value2"))
ledger.SetState("chaincode3", "key3", []byte("value3"))
ledger.TxFinished("txUuid", true)
ledger.RollbackTxBatch(1)
testutil.AssertNil(t, ledgerTestWrapper.GetState("chaincode1", "key1", false))
}
示例15: TestDeleteState
func TestDeleteState(t *testing.T) {
stateTestWrapper, state := createFreshDBAndConstructState(t)
// Add keys
state.TxBegin("txUuid")
state.Set("chaincode1", "key1", []byte("value1"))
state.Set("chaincode1", "key2", []byte("value2"))
state.TxFinish("txUuid", true)
state.getStateDelta()
stateTestWrapper.persistAndClearInMemoryChanges(0)
// confirm keys are present
testutil.AssertEquals(t, stateTestWrapper.get("chaincode1", "key1", true), []byte("value1"))
testutil.AssertEquals(t, stateTestWrapper.get("chaincode1", "key2", true), []byte("value2"))
// Delete the State
err := state.DeleteState()
if err != nil {
t.Fatalf("Error deleting the state: %s", err)
}
// confirm the values are empty
testutil.AssertNil(t, stateTestWrapper.get("chaincode1", "key1", false))
testutil.AssertNil(t, stateTestWrapper.get("chaincode1", "key2", false))
testutil.AssertNil(t, stateTestWrapper.get("chaincode1", "key1", true))
testutil.AssertNil(t, stateTestWrapper.get("chaincode1", "key2", true))
// Confirm that we can now store new stuff in the state
state.TxBegin("txUuid")
state.Set("chaincode1", "key1", []byte("value1"))
state.Set("chaincode1", "key2", []byte("value2"))
state.TxFinish("txUuid", true)
state.getStateDelta()
stateTestWrapper.persistAndClearInMemoryChanges(1)
// confirm keys are present
testutil.AssertEquals(t, stateTestWrapper.get("chaincode1", "key1", true), []byte("value1"))
testutil.AssertEquals(t, stateTestWrapper.get("chaincode1", "key2", true), []byte("value2"))
}