From 13a35d037b41c3c73225d99fe6fc1d472a4d9d18 Mon Sep 17 00:00:00 2001 From: Troy Ronda Date: Thu, 29 Jun 2017 18:53:12 -0400 Subject: [PATCH] [FAB-5118] Split fabric-txn into pkg and default impl Change-Id: Ifb1dee8c55868e75da9230a4582a503ef77974e4 Signed-off-by: Troy Ronda --- .../defaultImpl.go => def/fabapi/fabapi.go | 2 +- pkg/config/config_test.go | 12 ------------ .../fabric-txn}/admin/transactionconfig.go | 2 +- {fabric-txn => pkg/fabric-txn}/internal/common.go | 0 {fabric-txn => pkg/fabric-txn}/transaction.go | 2 +- test/integration/base_test_setup.go | 12 ++++++------ test/integration/end_to_end_test.go | 2 +- test/integration/orgs/multiple_orgs_test.go | 2 +- test/integration/orgs/test_setup.go | 2 +- test/integration/utils.go | 4 ++-- 10 files changed, 14 insertions(+), 26 deletions(-) rename fabric-txn/defaultImpl/defaultImpl.go => def/fabapi/fabapi.go (99%) rename {fabric-txn => pkg/fabric-txn}/admin/transactionconfig.go (98%) rename {fabric-txn => pkg/fabric-txn}/internal/common.go (100%) rename {fabric-txn => pkg/fabric-txn}/transaction.go (97%) diff --git a/fabric-txn/defaultImpl/defaultImpl.go b/def/fabapi/fabapi.go similarity index 99% rename from fabric-txn/defaultImpl/defaultImpl.go rename to def/fabapi/fabapi.go index 539b00cfec..6033323011 100644 --- a/fabric-txn/defaultImpl/defaultImpl.go +++ b/def/fabapi/fabapi.go @@ -4,7 +4,7 @@ Copyright SecureKey Technologies Inc. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */ -package defaultimpl +package fabapi import ( "fmt" diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index e1fd17ed5f..7ad95bd773 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -9,7 +9,6 @@ package config import ( "fmt" "os" - "path/filepath" "strings" "testing" @@ -425,17 +424,6 @@ func TestNetworkConfig(t *testing.T) { } } -func TestOrdererConfig(t *testing.T) { - orderers, err := configImpl.OrderersConfig() - if err != nil { - t.Fatal(err) - } - - if !filepath.IsAbs(orderers[0].TLS.Certificate) { - t.Fatal("Expected GOPATH relative path to be replaced") - } -} - func TestMain(m *testing.M) { var err error configImpl, err = InitConfig("../../test/fixtures/config/config_test.yaml") diff --git a/fabric-txn/admin/transactionconfig.go b/pkg/fabric-txn/admin/transactionconfig.go similarity index 98% rename from fabric-txn/admin/transactionconfig.go rename to pkg/fabric-txn/admin/transactionconfig.go index 79da98bf4e..bb8e0137fc 100644 --- a/fabric-txn/admin/transactionconfig.go +++ b/pkg/fabric-txn/admin/transactionconfig.go @@ -13,7 +13,7 @@ import ( "time" api "github.com/hyperledger/fabric-sdk-go/api" - internal "github.com/hyperledger/fabric-sdk-go/fabric-txn/internal" + internal "github.com/hyperledger/fabric-sdk-go/pkg/fabric-txn/internal" "github.com/hyperledger/fabric/protos/common" "github.com/op/go-logging" ) diff --git a/fabric-txn/internal/common.go b/pkg/fabric-txn/internal/common.go similarity index 100% rename from fabric-txn/internal/common.go rename to pkg/fabric-txn/internal/common.go diff --git a/fabric-txn/transaction.go b/pkg/fabric-txn/transaction.go similarity index 97% rename from fabric-txn/transaction.go rename to pkg/fabric-txn/transaction.go index a4fadcb97a..a4345171fa 100644 --- a/fabric-txn/transaction.go +++ b/pkg/fabric-txn/transaction.go @@ -11,7 +11,7 @@ import ( "time" api "github.com/hyperledger/fabric-sdk-go/api" - internal "github.com/hyperledger/fabric-sdk-go/fabric-txn/internal" + internal "github.com/hyperledger/fabric-sdk-go/pkg/fabric-txn/internal" "github.com/op/go-logging" ) diff --git a/test/integration/base_test_setup.go b/test/integration/base_test_setup.go index 215974ad2c..5677e7300e 100644 --- a/test/integration/base_test_setup.go +++ b/test/integration/base_test_setup.go @@ -17,9 +17,9 @@ import ( "github.com/hyperledger/fabric-sdk-go/pkg/fabric-client/orderer" api "github.com/hyperledger/fabric-sdk-go/api" - fabricTxn "github.com/hyperledger/fabric-sdk-go/fabric-txn" - admin "github.com/hyperledger/fabric-sdk-go/fabric-txn/admin" - defaultImpl "github.com/hyperledger/fabric-sdk-go/fabric-txn/defaultImpl" + "github.com/hyperledger/fabric-sdk-go/def/fabapi" + fabricTxn "github.com/hyperledger/fabric-sdk-go/pkg/fabric-txn" + admin "github.com/hyperledger/fabric-sdk-go/pkg/fabric-txn/admin" bccspFactory "github.com/hyperledger/fabric/bccsp/factory" pb "github.com/hyperledger/fabric/protos/peer" ) @@ -53,12 +53,12 @@ func (setup *BaseSetupImpl) Initialize() error { return fmt.Errorf("Failed getting ephemeral software-based BCCSP [%s]", err) } - mspClient, err := defaultImpl.NewCAClient(configImpl, setup.OrgID) + mspClient, err := fabapi.NewCAClient(configImpl, setup.OrgID) if err != nil { return fmt.Errorf("Failed to get default msp client: %v", err) } - client, err := defaultImpl.NewClientWithUser("admin", "adminpw", setup.OrgID, "/tmp/enroll_user", configImpl, mspClient) + client, err := fabapi.NewClientWithUser("admin", "adminpw", setup.OrgID, "/tmp/enroll_user", configImpl, mspClient) if err != nil { return fmt.Errorf("Create client failed: %v", err) } @@ -253,7 +253,7 @@ func (setup *BaseSetupImpl) GetChannel(client api.FabricClient, channelID string return nil, fmt.Errorf("Error reading peer config: %v", err) } for _, p := range peerConfig { - endorser, err := defaultImpl.NewPeer(fmt.Sprintf("%s:%d", p.Host, p.Port), + endorser, err := fabapi.NewPeer(fmt.Sprintf("%s:%d", p.Host, p.Port), p.TLS.Certificate, p.TLS.ServerHostOverride, client.GetConfig()) if err != nil { return nil, fmt.Errorf("NewPeer return error: %v", err) diff --git a/test/integration/end_to_end_test.go b/test/integration/end_to_end_test.go index c0901506c0..eb7c757978 100644 --- a/test/integration/end_to_end_test.go +++ b/test/integration/end_to_end_test.go @@ -13,7 +13,7 @@ import ( "time" "github.com/hyperledger/fabric-sdk-go/api" - fabricTxn "github.com/hyperledger/fabric-sdk-go/fabric-txn" + fabricTxn "github.com/hyperledger/fabric-sdk-go/pkg/fabric-txn" ) func TestChainCodeInvoke(t *testing.T) { diff --git a/test/integration/orgs/multiple_orgs_test.go b/test/integration/orgs/multiple_orgs_test.go index 77215877ec..7b2b9c5137 100644 --- a/test/integration/orgs/multiple_orgs_test.go +++ b/test/integration/orgs/multiple_orgs_test.go @@ -12,7 +12,7 @@ import ( "testing" "github.com/hyperledger/fabric-sdk-go/api" - fabrictxn "github.com/hyperledger/fabric-sdk-go/fabric-txn" + fabrictxn "github.com/hyperledger/fabric-sdk-go/pkg/fabric-txn" ) // TestOrgsEndToEnd creates a channel with two organisations, installs chaincode diff --git a/test/integration/orgs/test_setup.go b/test/integration/orgs/test_setup.go index 4b5c7f0d68..c054c05069 100644 --- a/test/integration/orgs/test_setup.go +++ b/test/integration/orgs/test_setup.go @@ -12,13 +12,13 @@ import ( "time" "github.com/hyperledger/fabric-sdk-go/api" - "github.com/hyperledger/fabric-sdk-go/fabric-txn/admin" "github.com/hyperledger/fabric-sdk-go/pkg/config" client "github.com/hyperledger/fabric-sdk-go/pkg/fabric-client" "github.com/hyperledger/fabric-sdk-go/pkg/fabric-client/channel" "github.com/hyperledger/fabric-sdk-go/pkg/fabric-client/events" "github.com/hyperledger/fabric-sdk-go/pkg/fabric-client/orderer" "github.com/hyperledger/fabric-sdk-go/pkg/fabric-client/peer" + "github.com/hyperledger/fabric-sdk-go/pkg/fabric-txn/admin" "github.com/hyperledger/fabric-sdk-go/test/integration" "github.com/hyperledger/fabric/bccsp/factory" ) diff --git a/test/integration/utils.go b/test/integration/utils.go index 74aa53c4ef..1ca62081db 100644 --- a/test/integration/utils.go +++ b/test/integration/utils.go @@ -14,7 +14,7 @@ import ( "time" api "github.com/hyperledger/fabric-sdk-go/api" - defaultImpl "github.com/hyperledger/fabric-sdk-go/fabric-txn/defaultImpl" + "github.com/hyperledger/fabric-sdk-go/def/fabapi" ) // GetOrdererAdmin returns a pre-enrolled orderer admin user @@ -70,7 +70,7 @@ func getDefaultImplPreEnrolledUser(client api.FabricClient, keyDir string, certD return nil, fmt.Errorf("Error finding the enrollment cert path: %v", err) } - return defaultImpl.NewPreEnrolledUser(client, privateKeyPath, enrollmentCertPath, username, orgName) + return fabapi.NewPreEnrolledUser(client, privateKeyPath, enrollmentCertPath, username, orgName) } // Gets the first path from the dir directory