diff --git a/.gitignore b/.gitignore index f7824d2d66..2a846db758 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ coverage docs/gen node_modules/* +test/fixtures/src/github.com/example_cc/Dockerfile npm-shrinkwrap.json npm-debug.log tmp diff --git a/package.json b/package.json index 74da717c0c..e14b4c7e4b 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,6 @@ }, "devDependencies": { "bunyan": "^1.8.1", - "fs-extra": "^0.30.0", "gulp": "^3.9.1", "gulp-eslint": "^3.0.1", "gulp-istanbul": "^1.1.1", diff --git a/test/fixtures/example_cc.go b/test/fixtures/src/github.com/example_cc/example_cc.go similarity index 100% rename from test/fixtures/example_cc.go rename to test/fixtures/src/github.com/example_cc/example_cc.go diff --git a/test/unit/endorser-tests.js b/test/unit/endorser-tests.js index 2069f72d58..f5ebfced6f 100644 --- a/test/unit/endorser-tests.js +++ b/test/unit/endorser-tests.js @@ -22,9 +22,12 @@ var test = _test(tape); var hfc = require('../..'); var util = require('util'); var fs = require('fs'); +var testUtil = require('./util.js'); var keyValStorePath = '/tmp/keyValStore'; +testUtil.setupChaincodeDeploy(); + // // Run the endorser test // @@ -51,7 +54,7 @@ test('endorser test', function(t) { // send proposal to endorser var request = { endorserUrl: 'grpc://localhost:7051', - chaincodePath: 'github.com/chaincode_example02', + chaincodePath: testUtil.CHAINCODE_PATH, fcn: 'init', args: ['a', '100', 'b', '200'] }; diff --git a/test/unit/util.js b/test/unit/util.js index 61ee4d6d0f..d6abe79c9f 100644 --- a/test/unit/util.js +++ b/test/unit/util.js @@ -1,28 +1,8 @@ -var fs = require('fs-extra'); var path = require('path'); module.exports.CHAINCODE_PATH = 'github.com/example_cc'; -module.exports.CHAINCODE_FILE = 'example_cc.go'; +// temporarily set $GOPATH to the test fixture folder module.exports.setupChaincodeDeploy = function() { - var gopath = process.env.GOPATH; - - if (!gopath) { - throw new Error('Environment variable $GOPATH must be set for the SDK to deploy chaincode'); - } - var src = path.join(__dirname, '../fixtures/example_cc.go'); - - var fullpath = path.join(gopath, 'src', module.exports.CHAINCODE_PATH); - var target = path.join(fullpath, module.exports.CHAINCODE_FILE); - - fs.mkdirs(fullpath, function(err1) { - if (err1) throw new Error(err1); - - fs.copy(src, target, function(err2) { - if (err2) throw new Error(err2); - - return; - }); - - }); + process.env.GOPATH = path.join(__dirname, '../fixtures'); }; \ No newline at end of file