From 71a9991a6104639d296abfe79597cebbd3f9c897 Mon Sep 17 00:00:00 2001 From: Andrey Bogatyr285 Bogatyrev Date: Tue, 26 Oct 2021 14:51:44 +0300 Subject: [PATCH] small test coverage improvements --- gateway/service/service_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/gateway/service/service_test.go b/gateway/service/service_test.go index 740733c4..f34bc55a 100644 --- a/gateway/service/service_test.go +++ b/gateway/service/service_test.go @@ -6,10 +6,12 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + "google.golang.org/protobuf/types/known/timestamppb" "github.com/golang/protobuf/ptypes/empty" "github.com/s7techlab/cckit/examples/cpaper_asservice" + "github.com/s7techlab/cckit/examples/cpaper_asservice/schema" cpservice "github.com/s7techlab/cckit/examples/cpaper_asservice/service" "github.com/s7techlab/cckit/gateway/service" "github.com/s7techlab/cckit/gateway/service/mock" @@ -58,6 +60,30 @@ var _ = Describe(`Service`, func() { Expect(pp.Items).To(HaveLen(0)) }) + It("Invoke chaincode with 'tx waiter' in context", func() { + ctx = service.ContextWithTxWaiter(ctx, "all") + _, err := cPaperGateway.Issue(ctx, &schema.IssueCommercialPaper{ + Issuer: "issuer", + PaperNumber: "1337", + ExternalId: "228", + IssueDate: timestamppb.Now(), + MaturityDate: timestamppb.Now(), + FaceValue: 2, + }) + Expect(err).NotTo(HaveOccurred()) + }) + + It("Invoke chaincode with custom identity in context", func() { + signer := idtestdata.Certificates[1].MustIdentity(idtestdata.DefaultMSP) + ctx = service.ContextWithDefaultSigner(ctx, signer) + + _, err := cPaperGateway.Delete(ctx, &schema.CommercialPaperId{ + Issuer: "issuer", + PaperNumber: "1337", + }) + Expect(err).NotTo(HaveOccurred()) + }) + It("Allow to imitate error while access to peer", func() { cPaperService.Invoker = mock.FailChaincode(ChaincodeName)