Exemple #1
0
			tx, err := protos.NewTransaction(protos.ChaincodeID{Path: "testUrl"}, uuid, "anyfunction", []string{"param1, param2"})
			Expect(err).To(BeNil())
			err = ledgerPtr.CommitTxBatch(2, []*protos.Transaction{tx}, nil, []byte("proof"))
			Expect(err).To(BeNil())

			var count = 0
			for snapshot.Next() {
				//_, _ := snapshot.GetRawKeyValue()
				//t.Logf("Key %v, Val %v", k, v)
				count++
			}
			Expect(count).To(Equal(3))
			Expect(snapshot.GetBlockNumber()).To(Equal(uint64(0)))
		})
		It("deletes all state, keys and values from ledger without error", func() {
			Expect(ledgerPtr.DeleteALLStateKeysAndValues()).To(BeNil())
			state, _ := ledgerPtr.GetState("chaincode1", "key1", true)
			Expect(state).To(BeNil())
			state, _ = ledgerPtr.GetState("chaincode2", "key2", true)
			Expect(state).To(BeNil())
			state, _ = ledgerPtr.GetState("chaincode3", "key3", true)
			Expect(state).To(BeNil())
			// Test that we can now store new stuff in the state
			Expect(ledgerPtr.BeginTxBatch(2)).To(BeNil())
			ledgerPtr.TxBegin("txUuid1")
			Expect(ledgerPtr.SetState("chaincode1", "key1", []byte("value1"))).To(BeNil())
			Expect(ledgerPtr.SetState("chaincode2", "key2", []byte("value2"))).To(BeNil())
			Expect(ledgerPtr.SetState("chaincode3", "key3", []byte("value3"))).To(BeNil())
			ledgerPtr.TxFinished("txUuid1", true)
			uuid := util.GenerateUUID()
			tx, err := protos.NewTransaction(protos.ChaincodeID{Path: "testUrl"}, uuid, "anyfunction", []string{"param1, param2"})