コード例 #1
0
ファイル: ledger_test.go プロジェクト: Colearo/fabric
		ledgerPtr := InitSpec()
		It("creates, populates, finishes, commits and validates a batch", func() {
			Expect(ledgerPtr.BeginTxBatch(0)).To(BeNil())
			ledgerPtr.TxBegin("txUuid1")
			ledgerPtr.SetStateMultipleKeys("chaincodeID", map[string][]byte{"key1": []byte("value1"), "key2": []byte("value2")})
			ledgerPtr.TxFinished("txUuid1", true)
			uuid := util.GenerateUUID()
			tx, err := protos.NewTransaction(protos.ChaincodeID{Path: "testUrl"}, uuid, "anyfunction", []string{"param1, param2"})
			Expect(err).To(BeNil())
			err = ledgerPtr.CommitTxBatch(0, []*protos.Transaction{tx}, nil, []byte("proof"))
			Expect(err).To(BeNil())
		})
		It("copies state without error and validates values are equal", func() {
			Expect(ledgerPtr.BeginTxBatch(1)).To(BeNil())
			ledgerPtr.TxBegin("txUuid1")
			ledgerPtr.CopyState("chaincodeID", "chaincodeID2")
			ledgerPtr.TxFinished("txUuid1", true)
			uuid := util.GenerateUUID()
			tx, err := protos.NewTransaction(protos.ChaincodeID{Path: "testUrl"}, uuid, "anyfunction", []string{"param1, param2"})
			Expect(err).To(BeNil())
			err = ledgerPtr.CommitTxBatch(1, []*protos.Transaction{tx}, nil, []byte("proof"))
			Expect(err).To(BeNil())
			values, err := ledgerPtr.GetStateMultipleKeys("chaincodeID2", []string{"key1", "key2"}, true)
			Expect(err).To(BeNil())
			Expect(values).To(Equal([][]byte{[]byte("value1"), []byte("value2")}))
		})
	})

	Describe("Ledger EmptyArrayValue", func() {
		ledgerPtr := InitSpec()
		It("creates, populates, finishes, commits and validates a batch", func() {