Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

Commit c0c3cb0

Browse files
author
Firas Qutishat
committed
[FAB-4630] SDK Go -Upgrade to support 1.0.0 beta
Change-Id: If0d3ea8a5de4fb72f7d1cd1300f929d5d03c241f Signed-off-by: Firas Qutishat <firas.qutishat@securekey.com>
1 parent 04b9327 commit c0c3cb0

File tree

242 files changed

+20061
-12120
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

242 files changed

+20061
-12120
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ debug.test
66

77

88
# Files auto-generated by docker-compose
9-
test/fixtures/tls/fabricca/server/org1.example.com-cert.pem
9+
test/fixtures/tls/fabricca/server/*.pem

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@ integration-test: clean depend
5858
integration-tests: integration-test
5959

6060
clean:
61-
rm -Rf /tmp/enroll_user /tmp/keystore /tmp/keyvaluestore
61+
rm -Rf /tmp/enroll_user /tmp/msp /tmp/keyvaluestore
6262
rm -f integration-report.xml report.xml
6363
cd test/fixtures && docker-compose down

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ repository.
3838
### Compatibility
3939

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

4444
### Running the test suite
4545

@@ -135,14 +135,14 @@ Alternatively you can build and run Fabric on your own box using the following c
135135
cd $GOPATH/src/github.com/hyperledger/
136136
git clone https://github.com/hyperledger/fabric
137137
cd $GOPATH/src/github.com/hyperledger/fabric/
138-
git checkout v1.0.0-alpha2
138+
git checkout v1.0.0-beta
139139
make docker
140140
141141
# Build fabric-ca:
142142
cd $GOPATH/src/github.com/hyperledger/
143143
git clone https://github.com/hyperledger/fabric-ca
144144
cd $GOPATH/src/github.com/hyperledger/fabric-ca/
145-
git checkout v1.0.0-alpha2
145+
git checkout v1.0.0-beta
146146
make docker
147147
148148
# Start fabric - latest-env.sh overrides the default docker tags in .env

config/config.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"fmt"
2727
"io/ioutil"
2828
"os"
29+
"path"
2930
"strconv"
3031
"strings"
3132

@@ -253,7 +254,17 @@ func GetFabricCAName() string {
253254

254255
// GetKeyStorePath ...
255256
func GetKeyStorePath() string {
256-
return myViper.GetString("client.keystore.path")
257+
return path.Join(GetFabricCAHomeDir(), GetFabricCAMspDir(), "keystore")
258+
}
259+
260+
// GetFabricCAHomeDir ...
261+
func GetFabricCAHomeDir() string {
262+
return myViper.GetString("client.fabricCA.homeDir")
263+
}
264+
265+
// GetFabricCAMspDir ...
266+
func GetFabricCAMspDir() string {
267+
return myViper.GetString("client.fabricCA.mspDir")
257268
}
258269

259270
// GetCryptoConfigPath ...

fabric-ca-client/fabricca.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ func NewFabricCAClient() (Services, error) {
117117
c.Config.TLS.Enabled = config.GetFabricCATLSEnabledFlag()
118118
fabricCAClient := &services{fabricCAClient: c}
119119
logger.Infof("Constructed fabricCAClient instance: %v", fabricCAClient)
120-
120+
c.HomeDir = config.GetFabricCAHomeDir()
121+
c.Config.MSPDir = config.GetFabricCAMspDir()
121122
c.Config.CSP = config.GetCSPConfig()
122123

123124
err := c.Init()

fabric-client/chain.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,11 +1599,11 @@ func buildChaincodePolicy(mspid string) (*common.SignaturePolicyEnvelope, error)
15991599

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

16041604
p := &common.SignaturePolicyEnvelope{
16051605
Version: 0,
1606-
Policy: oneOfone,
1606+
Rule: oneOfone,
16071607
Identities: []*mspprotos.MSPPrincipal{onePrn},
16081608
}
16091609
return p, nil
@@ -1815,11 +1815,11 @@ func loadPolicy(configItems *configItems, versionsPolicy *common.ConfigPolicy, k
18151815
switch policyType {
18161816
case common.Policy_SIGNATURE:
18171817
sigPolicyEnv := &common.SignaturePolicyEnvelope{}
1818-
err := proto.Unmarshal(policy.Policy, sigPolicyEnv)
1818+
err := proto.Unmarshal(policy.Value, sigPolicyEnv)
18191819
if err != nil {
18201820
return fmt.Errorf("Unable to unmarshal SignaturePolicyEnvelope from config policy: %v", err)
18211821
}
1822-
logger.Debugf("loadConfigPolicy - %s - policy SIGNATURE :: %v", groupName, sigPolicyEnv.Policy)
1822+
logger.Debugf("loadConfigPolicy - %s - policy SIGNATURE :: %v", groupName, sigPolicyEnv.Rule)
18231823
// TODO: Do something with this value
18241824
break
18251825

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

18311831
case common.Policy_IMPLICIT_META:
18321832
implicitMetaPolicy := &common.ImplicitMetaPolicy{}
1833-
err := proto.Unmarshal(policy.Policy, implicitMetaPolicy)
1833+
err := proto.Unmarshal(policy.Value, implicitMetaPolicy)
18341834
if err != nil {
18351835
return fmt.Errorf("Unable to unmarshal ImplicitMetaPolicy from config policy: %v", err)
18361836
}

fabric-client/mockdata.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,8 @@ func (b *MockConfigGroupBuilder) buildSignatureConfigPolicy() *common.ConfigPoli
280280

281281
func (b *MockConfigGroupBuilder) buildSignaturePolicy() *common.Policy {
282282
return &common.Policy{
283-
Type: int32(common.Policy_SIGNATURE),
284-
Policy: MarshalOrPanic(b.buildSignedBySignaturePolicy()),
283+
Type: int32(common.Policy_SIGNATURE),
284+
Value: MarshalOrPanic(b.buildSignedBySignaturePolicy()),
285285
}
286286
}
287287

fabric-client/mockendorserserver.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ import (
2323
"github.com/golang/protobuf/proto"
2424
"golang.org/x/net/context"
2525

26-
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/rwset"
26+
rwsetutil "github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/rwsetutil"
27+
kvrwset "github.com/hyperledger/fabric/protos/ledger/rwset/kvrwset"
28+
2729
pb "github.com/hyperledger/fabric/protos/peer"
2830
)
2931

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

5456
prp := &pb.ProposalResponsePayload{}
5557
ccAction := &pb.ChaincodeAction{}
56-
var nsReadWriteSet []*rwset.NsReadWriteSet
57-
var kvWrite []*rwset.KVWrite
58+
txRwSet := &rwsetutil.TxRwSet{}
59+
5860
if m.AddkvWrite {
59-
kvWrite = append(kvWrite, &rwset.KVWrite{Key: "write", Value: []byte("value")})
60-
} else {
61-
kvWrite = nil
61+
txRwSet.NsRwSets = []*rwsetutil.NsRwSet{
62+
&rwsetutil.NsRwSet{NameSpace: "ns1", KvRwSet: &kvrwset.KVRWSet{
63+
Reads: []*kvrwset.KVRead{&kvrwset.KVRead{Key: "key1", Version: &kvrwset.Version{BlockNum: 1, TxNum: 1}}},
64+
Writes: []*kvrwset.KVWrite{&kvrwset.KVWrite{Key: "key2", IsDelete: false, Value: []byte("value2")}},
65+
}}}
6266
}
63-
nsReadWriteSet = append(nsReadWriteSet, &rwset.NsReadWriteSet{Writes: kvWrite})
64-
txRWSet := &rwset.TxReadWriteSet{NsRWs: nsReadWriteSet}
65-
txRWSetBytes, err := txRWSet.Marshal()
67+
68+
txRWSetBytes, err := txRwSet.ToProtoBytes()
6669
if err != nil {
6770
return nil
6871
}

test/fixtures/.env

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
# Fabric fixtures. The images and tags can be overriden using environment
2222
# variables. See docker compose documentation.
2323

24-
FABRIC_CA_FIXTURE_TAG=x86_64-1.0.0-alpha2
25-
FABRIC_ORDERER_FIXTURE_TAG=x86_64-1.0.0-alpha2
26-
FABRIC_PEER_FIXTURE_TAG=x86_64-1.0.0-alpha2
27-
FABRIC_COUCHDB_FIXTURE_TAG=x86_64-1.0.0-alpha2
28-
FABRIC_BUILDER_FIXTURE_TAG=x86_64-1.0.0-alpha2
24+
FABRIC_CA_FIXTURE_TAG=x86_64-1.0.0-beta
25+
FABRIC_ORDERER_FIXTURE_TAG=x86_64-1.0.0-beta
26+
FABRIC_PEER_FIXTURE_TAG=x86_64-1.0.0-beta
27+
FABRIC_COUCHDB_FIXTURE_TAG=x86_64-1.0.0-beta
28+
FABRIC_BUILDER_FIXTURE_TAG=x86_64-1.0.0-beta
2929

3030
FABRIC_CA_FIXTURE_IMAGE=hyperledger/fabric-ca
3131
FABRIC_ORDERER_FIXTURE_IMAGE=hyperledger/fabric-orderer

test/fixtures/config/config_test.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,14 @@ client:
4848
tlsEnabled: true
4949
id: "Org1MSP"
5050
name: "ca-org1"
51+
homeDir: "/tmp/"
52+
mspDir: "msp"
5153
serverURL: "https://localhost:7054"
5254
certfiles :
5355
- "$GOPATH/src/github.com/hyperledger/fabric-sdk-go/test/fixtures/tls/fabricca/ca/ca_root.pem"
5456
client:
5557
keyfile: "$GOPATH/src/github.com/hyperledger/fabric-sdk-go/test/fixtures/tls/fabricca/client/client_client1-key.pem"
5658
certfile: "$GOPATH/src/github.com/hyperledger/fabric-sdk-go/test/fixtures/tls/fabricca/client/client_client1.pem"
5759

58-
keystore:
59-
path: "/tmp/keystore"
60-
6160
cryptoconfig:
6261
path: "$GOPATH/src/github.com/hyperledger/fabric-sdk-go/test/fixtures/channel/crypto-config"

0 commit comments

Comments
 (0)