Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

try to use get block instead of sleep #120

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions test/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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/[email protected]/msp/keystore/priv_sk"
SignCert := "../fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/users/[email protected]/msp/signcerts/[email protected]"

tlsClientCert, err := tls.LoadX509KeyPair(clientCert, clientKey)
Expect(err).NotTo(HaveOccurred())
peer1 := network.Node{
Addr: org1PeerAddress,
TLSCACert: TLSCACert,
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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())
Expand Down