From b3ed96b9c74e5c26159ebc1dbf3e554c05598c44 Mon Sep 17 00:00:00 2001 From: Sam Yuan Date: Sun, 30 Apr 2023 11:34:08 +0800 Subject: [PATCH] try to use get block instead of sleep Signed-off-by: Sam Yuan --- test/e2e_test.go | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/test/e2e_test.go b/test/e2e_test.go index 3f44bdb..2e12bd8 100644 --- a/test/e2e_test.go +++ b/test/e2e_test.go @@ -35,6 +35,10 @@ const ( channelName = "mychannel" org1MspID = "Org1MSP" org2MspID = "Org2MSP" + osnURL = "https://localhost:7053" + caFile = "../fabric-samples/test-network/organizations/ordererOrganizations/example.com/tlsca/tlsca.example.com-cert.pem" + clientCert = "../fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.crt" + clientKey = "../fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.key" ) type ConnectionDetails struct { @@ -108,7 +112,8 @@ var _ = Describe("e2e", func() { TLSCACert := "../fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" PrivKeyPath := "../fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/priv_sk" SignCert := "../fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts/Admin@org1.example.com-cert.pem" - + tlsClientCert, err := tls.LoadX509KeyPair(clientCert, clientKey) + Expect(err).NotTo(HaveOccurred()) peer1 := network.Node{ Addr: org1PeerAddress, TLSCACert: TLSCACert, @@ -151,17 +156,10 @@ var _ = Describe("e2e", func() { Expect(block).ToNot(BeNil()) //create channel - var caFile, clientCert, clientKey, osnURL string - osnURL = "https://localhost:7053" - caFile = "../fabric-samples/test-network/organizations/ordererOrganizations/example.com/tlsca/tlsca.example.com-cert.pem" - clientCert = "../fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.crt" - clientKey = "../fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.key" caCertPool := x509.NewCertPool() caFilePEM, err := os.ReadFile(caFile) caCertPool.AppendCertsFromPEM(caFilePEM) Expect(err).NotTo(HaveOccurred()) - tlsClientCert, err := tls.LoadX509KeyPair(clientCert, clientKey) - Expect(err).NotTo(HaveOccurred()) resp, err := channel.CreateChannel(osnURL, block, caCertPool, tlsClientCert) Expect(err).NotTo(HaveOccurred()) Expect(resp.StatusCode).Should(Equal(http.StatusCreated)) @@ -260,7 +258,20 @@ var _ = Describe("e2e", func() { Expect(result).NotTo(BeEmpty()) }) - time.Sleep(time.Duration(20) * time.Second) + order := network.Node{ + Addr: "localhost:7050", + TLSCACert: clientCert, + } + err = order.LoadConfig() + Expect(err).NotTo(HaveOccurred()) + ordererConnection, err := network.DialConnection(order) + Expect(err).NotTo(HaveOccurred()) + ctx, cancel := context.WithTimeout(specCtx, 2*time.Minute) + defer cancel() + ordererBlock, err := channel.GetConfigBlockFromOrderer(ctx, ordererConnection, org1MSP, channelName, tlsClientCert) + Expect(err).NotTo(HaveOccurred()) + Expect(ordererBlock).NotTo(BeNil()) + PolicyStr := "AND ('Org1MSP.peer','Org2MSP.peer')" applicationPolicy, err := chaincode.NewApplicationPolicy(PolicyStr, "") Expect(err).NotTo(HaveOccurred())