Ejemplo n.º 1
0
		It("creates, populates and finishes a transaction", func() {
			ledgerPtr.TxBegin("txUuid2")
			Expect(ledgerPtr.SetState("chaincode2", "key2", []byte("value2"))).To(BeNil())
			ledgerPtr.TxFinished("txUuid2", true)
		})
		It("creates, but does not populate and finishes a transaction", func() {
			ledgerPtr.TxBegin("txUuid3")
			ledgerPtr.TxFinished("txUuid3", true)
		})
		It("creates, populates and finishes a transaction", func() {
			ledgerPtr.TxBegin("txUuid4")
			Expect(ledgerPtr.SetState("chaincode4", "key4", []byte("value4"))).To(BeNil())
			ledgerPtr.TxFinished("txUuid4", false)
		})
		It("should retrieve the delta state hash array containing expected values", func() {
			_, txDeltaHashes, err := ledgerPtr.GetTempStateHashWithTxDeltaStateHashes()
			Expect(err).To(BeNil())
			Expect(util.ComputeCryptoHash(appendAll([]byte("chaincode1key1value1")))).To(Equal(txDeltaHashes["txUuid1"]))
			Expect(util.ComputeCryptoHash(appendAll([]byte("chaincode2key2value2")))).To(Equal(txDeltaHashes["txUuid2"]))
			Expect(txDeltaHashes["txUuid3"]).To(BeNil())
			_, ok := txDeltaHashes["txUuid4"]
			Expect(ok).To(Equal(false))
		})
		It("should commit the batch", func() {
			Expect(ledgerPtr.CommitTxBatch(1, []*protos.Transaction{}, nil, []byte("proof"))).To(BeNil())
		})
		It("creates, populates and finishes a transaction", func() {
			Expect(ledgerPtr.BeginTxBatch(2)).To(BeNil())
			ledgerPtr.TxBegin("txUuid1")
			Expect(ledgerPtr.SetState("chaincode1", "key1", []byte("value1"))).To(BeNil())
			ledgerPtr.TxFinished("txUuid1", true)