Skip to content

Commit

Permalink
[FAB-4630] SDK Go -Upgrade to support 1.0.0 beta
Browse files Browse the repository at this point in the history
Change-Id: If0d3ea8a5de4fb72f7d1cd1300f929d5d03c241f
Signed-off-by: Firas Qutishat <firas.qutishat@securekey.com>
  • Loading branch information
fqutishat committed Jun 15, 2017
1 parent 04b9327 commit c0c3cb0
Show file tree
Hide file tree
Showing 242 changed files with 20,061 additions and 12,120 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -6,4 +6,4 @@ debug.test


# Files auto-generated by docker-compose
test/fixtures/tls/fabricca/server/org1.example.com-cert.pem
test/fixtures/tls/fabricca/server/*.pem
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -58,6 +58,6 @@ integration-test: clean depend
integration-tests: integration-test

clean:
rm -Rf /tmp/enroll_user /tmp/keystore /tmp/keyvaluestore
rm -Rf /tmp/enroll_user /tmp/msp /tmp/keyvaluestore
rm -f integration-report.xml report.xml
cd test/fixtures && docker-compose down
8 changes: 4 additions & 4 deletions README.md
Expand Up @@ -38,8 +38,8 @@ repository.
### Compatibility

This client SDK was last tested and found to be compatible with the following Hyperledger Fabric commit levels:
- fabric: v1.0.0-alpha2
- fabric-ca: v1.0.0-alpha2
- fabric: v1.0.0-beta
- fabric-ca: v1.0.0-beta

### Running the test suite

Expand Down Expand Up @@ -135,14 +135,14 @@ Alternatively you can build and run Fabric on your own box using the following c
cd $GOPATH/src/github.com/hyperledger/
git clone https://github.com/hyperledger/fabric
cd $GOPATH/src/github.com/hyperledger/fabric/
git checkout v1.0.0-alpha2
git checkout v1.0.0-beta
make docker
# Build fabric-ca:
cd $GOPATH/src/github.com/hyperledger/
git clone https://github.com/hyperledger/fabric-ca
cd $GOPATH/src/github.com/hyperledger/fabric-ca/
git checkout v1.0.0-alpha2
git checkout v1.0.0-beta
make docker
# Start fabric - latest-env.sh overrides the default docker tags in .env
Expand Down
13 changes: 12 additions & 1 deletion config/config.go
Expand Up @@ -26,6 +26,7 @@ import (
"fmt"
"io/ioutil"
"os"
"path"
"strconv"
"strings"

Expand Down Expand Up @@ -253,7 +254,17 @@ func GetFabricCAName() string {

// GetKeyStorePath ...
func GetKeyStorePath() string {
return myViper.GetString("client.keystore.path")
return path.Join(GetFabricCAHomeDir(), GetFabricCAMspDir(), "keystore")
}

// GetFabricCAHomeDir ...
func GetFabricCAHomeDir() string {
return myViper.GetString("client.fabricCA.homeDir")
}

// GetFabricCAMspDir ...
func GetFabricCAMspDir() string {
return myViper.GetString("client.fabricCA.mspDir")
}

// GetCryptoConfigPath ...
Expand Down
3 changes: 2 additions & 1 deletion fabric-ca-client/fabricca.go
Expand Up @@ -117,7 +117,8 @@ func NewFabricCAClient() (Services, error) {
c.Config.TLS.Enabled = config.GetFabricCATLSEnabledFlag()
fabricCAClient := &services{fabricCAClient: c}
logger.Infof("Constructed fabricCAClient instance: %v", fabricCAClient)

c.HomeDir = config.GetFabricCAHomeDir()
c.Config.MSPDir = config.GetFabricCAMspDir()
c.Config.CSP = config.GetCSPConfig()

err := c.Init()
Expand Down
10 changes: 5 additions & 5 deletions fabric-client/chain.go
Expand Up @@ -1599,11 +1599,11 @@ func buildChaincodePolicy(mspid string) (*common.SignaturePolicyEnvelope, error)

// construct 'one of one' policy
oneOfone := &common.SignaturePolicy{Type: &common.SignaturePolicy_NOutOf_{NOutOf: &common.SignaturePolicy_NOutOf{
N: 1, Policies: []*common.SignaturePolicy{signedBy}}}}
N: 1, Rules: []*common.SignaturePolicy{signedBy}}}}

p := &common.SignaturePolicyEnvelope{
Version: 0,
Policy: oneOfone,
Rule: oneOfone,
Identities: []*mspprotos.MSPPrincipal{onePrn},
}
return p, nil
Expand Down Expand Up @@ -1815,11 +1815,11 @@ func loadPolicy(configItems *configItems, versionsPolicy *common.ConfigPolicy, k
switch policyType {
case common.Policy_SIGNATURE:
sigPolicyEnv := &common.SignaturePolicyEnvelope{}
err := proto.Unmarshal(policy.Policy, sigPolicyEnv)
err := proto.Unmarshal(policy.Value, sigPolicyEnv)
if err != nil {
return fmt.Errorf("Unable to unmarshal SignaturePolicyEnvelope from config policy: %v", err)
}
logger.Debugf("loadConfigPolicy - %s - policy SIGNATURE :: %v", groupName, sigPolicyEnv.Policy)
logger.Debugf("loadConfigPolicy - %s - policy SIGNATURE :: %v", groupName, sigPolicyEnv.Rule)
// TODO: Do something with this value
break

Expand All @@ -1830,7 +1830,7 @@ func loadPolicy(configItems *configItems, versionsPolicy *common.ConfigPolicy, k

case common.Policy_IMPLICIT_META:
implicitMetaPolicy := &common.ImplicitMetaPolicy{}
err := proto.Unmarshal(policy.Policy, implicitMetaPolicy)
err := proto.Unmarshal(policy.Value, implicitMetaPolicy)
if err != nil {
return fmt.Errorf("Unable to unmarshal ImplicitMetaPolicy from config policy: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions fabric-client/mockdata.go
Expand Up @@ -280,8 +280,8 @@ func (b *MockConfigGroupBuilder) buildSignatureConfigPolicy() *common.ConfigPoli

func (b *MockConfigGroupBuilder) buildSignaturePolicy() *common.Policy {
return &common.Policy{
Type: int32(common.Policy_SIGNATURE),
Policy: MarshalOrPanic(b.buildSignedBySignaturePolicy()),
Type: int32(common.Policy_SIGNATURE),
Value: MarshalOrPanic(b.buildSignedBySignaturePolicy()),
}
}

Expand Down
21 changes: 12 additions & 9 deletions fabric-client/mockendorserserver.go
Expand Up @@ -23,7 +23,9 @@ import (
"github.com/golang/protobuf/proto"
"golang.org/x/net/context"

"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/rwset"
rwsetutil "github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/rwsetutil"
kvrwset "github.com/hyperledger/fabric/protos/ledger/rwset/kvrwset"

pb "github.com/hyperledger/fabric/protos/peer"
)

Expand Down Expand Up @@ -53,16 +55,17 @@ func (m *MockEndorserServer) createProposalResponsePayload() []byte {

prp := &pb.ProposalResponsePayload{}
ccAction := &pb.ChaincodeAction{}
var nsReadWriteSet []*rwset.NsReadWriteSet
var kvWrite []*rwset.KVWrite
txRwSet := &rwsetutil.TxRwSet{}

if m.AddkvWrite {
kvWrite = append(kvWrite, &rwset.KVWrite{Key: "write", Value: []byte("value")})
} else {
kvWrite = nil
txRwSet.NsRwSets = []*rwsetutil.NsRwSet{
&rwsetutil.NsRwSet{NameSpace: "ns1", KvRwSet: &kvrwset.KVRWSet{
Reads: []*kvrwset.KVRead{&kvrwset.KVRead{Key: "key1", Version: &kvrwset.Version{BlockNum: 1, TxNum: 1}}},
Writes: []*kvrwset.KVWrite{&kvrwset.KVWrite{Key: "key2", IsDelete: false, Value: []byte("value2")}},
}}}
}
nsReadWriteSet = append(nsReadWriteSet, &rwset.NsReadWriteSet{Writes: kvWrite})
txRWSet := &rwset.TxReadWriteSet{NsRWs: nsReadWriteSet}
txRWSetBytes, err := txRWSet.Marshal()

txRWSetBytes, err := txRwSet.ToProtoBytes()
if err != nil {
return nil
}
Expand Down
10 changes: 5 additions & 5 deletions test/fixtures/.env
Expand Up @@ -21,11 +21,11 @@
# Fabric fixtures. The images and tags can be overriden using environment
# variables. See docker compose documentation.

FABRIC_CA_FIXTURE_TAG=x86_64-1.0.0-alpha2
FABRIC_ORDERER_FIXTURE_TAG=x86_64-1.0.0-alpha2
FABRIC_PEER_FIXTURE_TAG=x86_64-1.0.0-alpha2
FABRIC_COUCHDB_FIXTURE_TAG=x86_64-1.0.0-alpha2
FABRIC_BUILDER_FIXTURE_TAG=x86_64-1.0.0-alpha2
FABRIC_CA_FIXTURE_TAG=x86_64-1.0.0-beta
FABRIC_ORDERER_FIXTURE_TAG=x86_64-1.0.0-beta
FABRIC_PEER_FIXTURE_TAG=x86_64-1.0.0-beta
FABRIC_COUCHDB_FIXTURE_TAG=x86_64-1.0.0-beta
FABRIC_BUILDER_FIXTURE_TAG=x86_64-1.0.0-beta

FABRIC_CA_FIXTURE_IMAGE=hyperledger/fabric-ca
FABRIC_ORDERER_FIXTURE_IMAGE=hyperledger/fabric-orderer
Expand Down
5 changes: 2 additions & 3 deletions test/fixtures/config/config_test.yaml
Expand Up @@ -48,15 +48,14 @@ client:
tlsEnabled: true
id: "Org1MSP"
name: "ca-org1"
homeDir: "/tmp/"
mspDir: "msp"
serverURL: "https://localhost:7054"
certfiles :
- "$GOPATH/src/github.com/hyperledger/fabric-sdk-go/test/fixtures/tls/fabricca/ca/ca_root.pem"
client:
keyfile: "$GOPATH/src/github.com/hyperledger/fabric-sdk-go/test/fixtures/tls/fabricca/client/client_client1-key.pem"
certfile: "$GOPATH/src/github.com/hyperledger/fabric-sdk-go/test/fixtures/tls/fabricca/client/client_client1.pem"

keystore:
path: "/tmp/keystore"

cryptoconfig:
path: "$GOPATH/src/github.com/hyperledger/fabric-sdk-go/test/fixtures/channel/crypto-config"
22 changes: 15 additions & 7 deletions test/fixtures/docker-compose.yaml
Expand Up @@ -6,12 +6,14 @@ services:
environment:
- FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
- FABRIC_CA_SERVER_CA_NAME=ca-org1
- FABRIC_CA_SERVER_CA_CERTFILE=/etc/hyperledger/fabric-ca-server-config/org1.example.com-cert.pem
- FABRIC_CA_SERVER_CA_KEYFILE=/etc/hyperledger/fabric-ca-server-config/a22daf356b2aab5792ea53e35f66fccef1d7f1aa2b3a2b92dbfbf96a448ea26a_sk
- FABRIC_CA_SERVER_TLS_ENABLED=true
- FABRIC_CA_SERVER_TLS_CERTFILE=/etc/hyperledger/fabric-ca-server-config/server_localhost.pem
- FABRIC_CA_SERVER_TLS_KEYFILE=/etc/hyperledger/fabric-ca-server-config/server_localhost-key.pem
ports:
- "7054:7054"
command: sh -c 'fabric-ca-server start --ca.certfile /etc/hyperledger/fabric-ca-server-config/org1.example.com-cert.pem --ca.keyfile /etc/hyperledger/fabric-ca-server-config/a22daf356b2aab5792ea53e35f66fccef1d7f1aa2b3a2b92dbfbf96a448ea26a_sk -b admin:adminpw -d'
command: sh -c 'fabric-ca-server start -b admin:adminpw -d'
volumes:
- ./channel/crypto-config/peerOrganizations/org1.example.com/ca/:/etc/hyperledger/fabric-ca-server-config
- ./tls/fabricca/server:/etc/hyperledger/fabric-ca-server-config
Expand All @@ -22,14 +24,17 @@ services:
environment:
- FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
- FABRIC_CA_SERVER_CA_NAME=ca-org2
- FABRIC_CA_SERVER_CA_CERTFILE=/etc/hyperledger/fabric-ca-server-config/org2.example.com-cert.pem
- FABRIC_CA_SERVER_CA_KEYFILE=/etc/hyperledger/fabric-ca-server-config/464d550fe9bf9e7d8976cdf59d1a5d472598f54c058c3546317c5c5fb0ddfd6e_sk
- FABRIC_CA_SERVER_TLS_ENABLED=true
- FABRIC_CA_SERVER_TLS_CERTFILE=/etc/hyperledger/fabric-ca-server-config/org2.example.com-cert.pem
- FABRIC_CA_SERVER_TLS_KEYFILE=/etc/hyperledger/fabric-ca-server-config/464d550fe9bf9e7d8976cdf59d1a5d472598f54c058c3546317c5c5fb0ddfd6e_sk
- FABRIC_CA_SERVER_TLS_CERTFILE=/etc/hyperledger/fabric-ca-server-config/server_localhost.pem
- FABRIC_CA_SERVER_TLS_KEYFILE=/etc/hyperledger/fabric-ca-server-config/server_localhost-key.pem
ports:
- "8054:7054"
command: sh -c 'fabric-ca-server start --ca.certfile /etc/hyperledger/fabric-ca-server-config/org2.example.com-cert.pem --ca.keyfile /etc/hyperledger/fabric-ca-server-config/464d550fe9bf9e7d8976cdf59d1a5d472598f54c058c3546317c5c5fb0ddfd6e_sk -b admin:adminpw -d'
command: sh -c 'fabric-ca-server start -b admin:adminpw -d'
volumes:
- ./channel/crypto-config/peerOrganizations/org2.example.com/ca/:/etc/hyperledger/fabric-ca-server-config
- ./tls/fabricca/server:/etc/hyperledger/fabric-ca-server-config
container_name: ca_peerOrg2

orderer.example.com:
Expand Down Expand Up @@ -63,6 +68,8 @@ services:
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
- CORE_PEER_ID=peer0.org1.example.com
- CORE_LOGGING_PEER=debug
## the following setting redirects chaincode container logs to the peer container logs
- CORE_VM_DOCKER_ATTACHSTDOUT=true
- CORE_PEER_LOCALMSPID=Org1MSP
- CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/peer/
- CORE_PEER_ADDRESS=peer0.org1.example.com:7051
Expand All @@ -75,7 +82,7 @@ services:
# # https://docs.docker.com/compose/networking/
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=fixtures_default
working_dir: /opt/gopath/src/github.com/hyperledger/fabric
command: peer node start --peer-defaultchain=false
command: peer node start
ports:
- 7051:7051
- 7053:7053
Expand Down Expand Up @@ -104,7 +111,7 @@ services:
# # https://docs.docker.com/compose/networking/
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=fixtures_default
working_dir: /opt/gopath/src/github.com/hyperledger/fabric
command: peer node start --peer-defaultchain=false
command: peer node start
ports:
- 8051:7051
- 8053:7053
Expand All @@ -115,6 +122,7 @@ services:
- orderer.example.com
- builder


# builder is only here to create a dependency on the image (not used as part of compose)
builder:
image: ${FABRIC_BUILDER_FIXTURE_IMAGE}:${FABRIC_BUILDER_FIXTURE_TAG}
image: ${FABRIC_BUILDER_FIXTURE_IMAGE}:${FABRIC_BUILDER_FIXTURE_TAG}
14 changes: 0 additions & 14 deletions test/fixtures/tls/fabricca/server/org1.example.com-cert.pem

This file was deleted.

4 changes: 2 additions & 2 deletions test/scripts/fabric_test_commitlevel.sh
Expand Up @@ -6,5 +6,5 @@ export USE_PREBUILT_IMAGES=true

#file used for automatic integration build test
#This should always match the compatibility specified in the README.md
export FABRIC_COMMIT=v1.0.0-alpha2
export FABRIC_CA_COMMIT=v1.0.0-alpha2
export FABRIC_COMMIT=v1.0.0-beta
export FABRIC_CA_COMMIT=v1.0.0-beta
97 changes: 97 additions & 0 deletions vendor/github.com/docker/docker/pkg/archive/example_changes.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c0c3cb0

Please sign in to comment.