Skip to content

Commit

Permalink
Vendor package dependencies for go chaincode
Browse files Browse the repository at this point in the history
- add dep Gopkg.toml for each go chaincode
- use `dep ensure` to vendor chaincode dependencies
- increase timeout for the fabric-client tests
- update the golang cds fixtures
- filter files related to vendoring from package assertions
- filter directories from _findFileNames

FABN-1357

Signed-off-by: Matthew Sykes <[email protected]>
Change-Id: Ifeef2ba8b28b42fc8094ececbd5702f5beba529c
Signed-off-by: Matthew Sykes <[email protected]>
  • Loading branch information
sykesm committed Sep 5, 2019
1 parent e6cfcfe commit 0a273c9
Show file tree
Hide file tree
Showing 4,759 changed files with 3,689,183 additions and 24 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 1 addition & 1 deletion build/tasks/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ gulp.task('mocha-fabric-ca-client',
gulp.task('mocha-fabric-client',
() => {
return gulp.src(['./fabric-client/test/**/*.js', '!./fabric-client/test/data/**/*.js'], {read: false})
.pipe(mocha({reporter: 'list', exit: true}));
.pipe(mocha({reporter: 'list', exit: true, timeout: 10000}));
}
);

Expand Down
4 changes: 3 additions & 1 deletion fabric-client/lib/Package.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ class Package {
const fileNames = [];
extract.on('entry', (header, stream, next) => {
logger.debug('Package._findFileNames - found entry %s', header.name);
fileNames.push(header.name);
if (header.type === 'file') {
fileNames.push(header.name);
}
stream.on('end', () => {
next();
});
Expand Down
13 changes: 9 additions & 4 deletions fabric-client/test/Package.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ const metadataFileNames = [
'META-INF/statedb/couchdb/indexes/indexOwner.json'
];

const golangFilterRegex = /^src\/golang-contract\/(vendor\/|Gopkg.lock$|Gopkg.toml$)/g;

describe('Package', () => {

let GOPATH;
Expand All @@ -90,7 +92,7 @@ describe('Package', () => {
pkg.getName().should.equal('my-contract');
pkg.getVersion().should.equal('1.2.3');
pkg.getType().should.equal(type);
pkg.getFileNames().should.deep.equal(fileNames[language]);
pkg.getFileNames().filter(name => !name.match(golangFilterRegex)).should.deep.equal(fileNames[language]);
});

it(`should load a smart contract package from a buffer with metadata [${language}]`, async () => {
Expand All @@ -100,7 +102,8 @@ describe('Package', () => {
pkg.getName().should.equal('my-contract');
pkg.getVersion().should.equal('1.2.3');
pkg.getType().should.equal(type);
pkg.getFileNames().should.deep.equal(metadataFileNames.concat(fileNames[language]));
pkg.getFileNames().filter(name => !name.match(golangFilterRegex))
.should.deep.equal(metadataFileNames.concat(fileNames[language]));
});

}
Expand Down Expand Up @@ -168,7 +171,8 @@ describe('Package', () => {
pkg.getName().should.equal('my-contract');
pkg.getVersion().should.equal('1.2.3');
pkg.getType().should.equal(type);
pkg.getFileNames().should.deep.equal(fileNames[language]);
pkg.getFileNames().filter(name => !name.match(golangFilterRegex))
.should.deep.equal(fileNames[language]);
});

it(`should create a smart contract package from a directory with metadata [${language}]`, async () => {
Expand All @@ -183,7 +187,8 @@ describe('Package', () => {
pkg.getName().should.equal('my-contract');
pkg.getVersion().should.equal('1.2.3');
pkg.getType().should.equal(type);
pkg.getFileNames().should.deep.equal(metadataFileNames.concat(fileNames[language]));
pkg.getFileNames().filter(name => !name.match(golangFilterRegex))
.should.deep.equal(metadataFileNames.concat(fileNames[language]));
});

}
Expand Down
149 changes: 149 additions & 0 deletions fabric-client/test/data/go/src/golang-contract/Gopkg.lock

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

15 changes: 15 additions & 0 deletions fabric-client/test/data/go/src/golang-contract/Gopkg.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright IBM Corp All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0

[[constraint]]
branch = "master"
name = "github.com/hyperledger/fabric-chaincode-go"

[[constraint]]
branch = "master"
name = "github.com/hyperledger/fabric-protos-go"

[prune]
go-tests = true
unused-packages = true
4 changes: 2 additions & 2 deletions fabric-client/test/data/go/src/golang-contract/chaincode.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ package main
import (
"fmt"

"github.com/hyperledger/fabric/core/chaincode/shim"
sc "github.com/hyperledger/fabric/protos/peer"
"github.com/hyperledger/fabric-chaincode-go/shim"
sc "github.com/hyperledger/fabric-protos-go/peer"
)

// Chaincode is the definition of the chaincode structure.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ package main
import (
"testing"

"github.com/hyperledger/fabric/core/chaincode/shim"
"github.com/hyperledger/fabric-chaincode-go/shim"
)

func TestInit(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion fabric-client/test/data/go/src/golang-contract/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

package main

import "github.com/hyperledger/fabric/core/chaincode/shim"
import "github.com/hyperledger/fabric-chaincode-go/shim"

func main() {
err := shim.Start(new(Chaincode))
Expand Down

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

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

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

Loading

0 comments on commit 0a273c9

Please sign in to comment.