Skip to content

Commit

Permalink
nodeSDK Rename Deployment to Instantiate
Browse files Browse the repository at this point in the history
The function sendDeploymentProposal needs to
be renamed to sendInstantiateProposal to
conform with the fabric naming convention.
Other miscellaneous changes are included
from deploy to instantiate.

Change-Id: I346732b2c16984917570786cc14f05a25c26cd45
Signed-off-by: cdaughtr <cdaughtr@us.ibm.com>
  • Loading branch information
cdaughtr committed Feb 21, 2017
1 parent 0344555 commit 1e3c1b2
Show file tree
Hide file tree
Showing 16 changed files with 78 additions and 71 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ To build and test, the following pre-requisites must be installed first:
Clone the project and launch the following commands to install the dependencies and perform various tasks.

This project publishes two separate npm packages:
* `fabric-client` - main client for the Hyperledger Fabric. Applications can use this package to deploy chaincodes, submit transactions and make queries against a Hyperledger Fabric-based blockchain network.
* `fabric-client` - main client for the Hyperledger Fabric. Applications can use this package to install and instantiate chaincodes, submit transactions and make queries against a Hyperledger Fabric-based blockchain network.
* `fabric-ca-client` - client for the optional component in Hyperledger Fabric, [fabric-ca](https://github.com/hyperledger/fabric-ca). The fabric-ca component allows applications to enroll Peers and application users to establish trusted identities on the blockchain network. It also provides support for pseudonymous transaction submissions with Transaction Certificates. If the target blockchain network is configured with standard Certificate Authorities for trust anchors, then the application does not need to use this package.

In the project root folder:
Expand Down
1 change: 0 additions & 1 deletion build/tasks/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ gulp.task('test', ['lint', 'test-headless'], function() {
// 'test/integration/ca-tests.js',
'test/integration/chain-fabriccop-tests.js',
'test/integration/endorser-tests.js',
'test/integration/orderer-tests.js',
'test/integration/orderer-chain-tests.js'
])
.pipe(tape({
Expand Down
2 changes: 1 addition & 1 deletion examples/balance-transfer/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ hfc.newDefaultKeyValueStore({
txId: tx_id,
nonce: nonce,
};
return chain.sendDeploymentProposal(request);
return chain.sendInstantiateProposal(request);
}
).then(
function(results) {
Expand Down
2 changes: 1 addition & 1 deletion fabric-client/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## Hyperledger Fabric Client for Node.js

This package encapsulates the APIs to interact with Peers and Orderers of the Fabric network to deploy chaincodes, send transaction invocations and perform chaincode queries. There is a separate package that interacts with the Fabric member service to manage user certificates lifecycle such as register, enroll, renew and revoke, and that is called `fabric-ca-client`.
This package encapsulates the APIs to interact with Peers and Orderers of the Fabric network to install and instantiate chaincodes, send transaction invocations and perform chaincode queries. There is a separate package that interacts with the Fabric member service to manage user certificates lifecycle such as register, enroll, renew and revoke, and that is called `fabric-ca-client`.

For application developer documentations, please visit [http://fabric-sdk-node.readthedocs.io/en/master/](http://fabric-sdk-node.readthedocs.io/en/master/)
28 changes: 14 additions & 14 deletions fabric-client/lib/Chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -1145,7 +1145,7 @@ var Chain = class {
logger.error('Chain.sendInstallProposal error ' + errorMsg);
return Promise.reject(new Error(errorMsg));
}
errorMsg = Chain._checkInstallDeployRequest(request);
errorMsg = Chain._checkInstallInstantiateRequest(request);
if (errorMsg) {
logger.error('Chain.sendInstallProposal error ' + errorMsg);
return Promise.reject(new Error(errorMsg));
Expand Down Expand Up @@ -1228,7 +1228,7 @@ var Chain = class {
}

/**
* Sends a deployment / initialize proposal to one or more endorsing peers.
* Sends an instantiate proposal to one or more endorsing peers.
*
* @param {Object} request - An object containing the following fields:
* <br>`chaincodePath` : required - String of the path to location of
Expand All @@ -1239,13 +1239,13 @@ var Chain = class {
* <br>`txId` : required - String of the transaction id
* <br>`nonce` : required - Integer of the once time number
* <br>`fcn` : optional - String of the function to be called on
* the chaincode once deployed (default 'init')
* the chaincode once instantiated (default 'init')
* <br>`args` : optional - String Array arguments specific to
* the chaincode being deployed
* the chaincode being instantiated
* @returns {Promise} A Promise for a `ProposalResponse`
* @see /protos/peer/fabric_proposal_response.proto
*/
sendDeploymentProposal(request) {
sendInstantiateProposal(request) {
var errorMsg = null;

var peers = null;
Expand All @@ -1255,7 +1255,7 @@ var Chain = class {
for (let p = 0; p < peers.length; p++) {
if (!this.isValidPeer(peers[p])) {
errorMsg = 'Request targets peer object '+ peers[p] +' not in chain';
logger.error('Chain.sendDeploymentProposal error '+ errorMsg);
logger.error('Chain.sendInstantiateProposal error '+ errorMsg);
return Promise.reject(new Error(errorMsg));
}
}
Expand All @@ -1266,19 +1266,19 @@ var Chain = class {
}
// Verify that a Peer has been added
if (peers.length < 1) {
errorMsg = 'Missing peer objects in Deployment proposal chain';
logger.error('Chain.sendDeploymentProposal error '+ errorMsg);
errorMsg = 'Missing peer objects in Instantiate proposal chain';
logger.error('Chain.sendInstantiateProposal error '+ errorMsg);
return Promise.reject(new Error(errorMsg));
}

errorMsg = Chain._checkProposalRequest(request);
if (errorMsg) {
logger.error('Chain.sendDeploymentProposal error ' + errorMsg);
logger.error('Chain.sendInstantiateProposal error ' + errorMsg);
return Promise.reject(new Error(errorMsg));
}
errorMsg = Chain._checkInstallDeployRequest(request);
errorMsg = Chain._checkInstallInstantiateRequest(request);
if (errorMsg) {
logger.error('Chain.sendDeploymentProposal error ' + errorMsg);
logger.error('Chain.sendInstantiateProposal error ' + errorMsg);
return Promise.reject(new Error(errorMsg));
}

Expand Down Expand Up @@ -1708,7 +1708,7 @@ var Chain = class {
/*
* @private
*/
static _checkInstallDeployRequest(request) {
static _checkInstallInstantiateRequest(request) {
var errorMsg = null;

if (request) {
Expand Down Expand Up @@ -1815,7 +1815,7 @@ function packageChaincode(devmode, request) {

if (!request.chaincodePath || request.chaincodePath === '') {
// Verify that chaincodePath is being passed
return reject(new Error('Missing chaincodePath parameter in Deployment proposal request'));
return reject(new Error('Missing chaincodePath parameter in Install proposal request'));
}

var chaincodePath = request.chaincodePath;
Expand All @@ -1841,7 +1841,7 @@ function packageChaincode(devmode, request) {
let targzFilePath = path.join(folder, 'deployment-package.tar.gz');
return utils.generateTarGz(folder, targzFilePath)
.then(function() {
logger.debug('Chain.sendDeployment- Successfully generated chaincode deploy archive %s and name (%s)', targzFilePath, chaincodeId);
logger.debug('Chain.sendInstantiateProposal - Successfully generated chaincode instantiate archive %s and name (%s)', targzFilePath, chaincodeId);
return readFile(targzFilePath)
.then((data) => {
return resolve(data);
Expand Down
2 changes: 1 addition & 1 deletion fabric-client/lib/EventHub.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ var EventHub = class {
/**
* Register a callback function to receive transactional events.<p>
* Note: transactional event registration is primarily used by
* the sdk to track deploy and invoke completion events. Nodejs
* the sdk to track instantiate and invoke completion events. Nodejs
* clients generally should not need to call directly.
* @param {string} txid string transaction id
* @param {function} callback Function that takes a single parameter which
Expand Down
2 changes: 1 addition & 1 deletion fabric-client/lib/Peer.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ var Peer = class extends Remote {
/**
* A network call that discovers if at least one listener has been connected to the target
* Peer for a given event. This helps application instance to decide whether it needs to
* connect to the event source in a crash recovery or multiple instance deployment.
* connect to the event source in a crash recovery or multiple instance instantiation.
* @param {string} eventName required
* @param {Chain} chain optional
* @result {boolean} Whether the said event has been listened on by some application instance on that chain.
Expand Down
7 changes: 4 additions & 3 deletions fabric-client/lib/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ var LocalMSP = require('./msp/msp.js');
* The User class represents users that have been enrolled and represented by
* an enrollment certificate (ECert) and a signing key. The ECert must have
* been signed by one of the CAs the blockchain network has been configured to trust.
* An enrolled user (having a signing key and ECert) can conduct chaincode deployments,
* An enrolled user (having a signing key and ECert) can conduct chaincode instantiate,
* transactions and queries with the Chain.
*
* User ECerts can be obtained from a CA beforehand as part of deploying the application,
* or it can be obtained from the optional Fabric CA service via its enrollment process.
* User ECerts can be obtained from a CA beforehand as part of installing and instantiating
* the application, or it can be obtained from the optional Fabric CA service via its
* enrollment process.
*
* Sometimes User identities are confused with Peer identities. User identities represent
* signing capability because it has access to the private key, while Peer identities in
Expand Down
2 changes: 1 addition & 1 deletion fabric-client/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ module.exports.getConfig = function() {
module.exports.generateTarGz = function(src, dest) {
// A list of file extensions that should be packaged into the .tar.gz.
// Files with all other file extenstions will be excluded to minimize the size
// of the deployment transaction payload.
// of the install payload.
var keep = [
'.go',
'.yaml',
Expand Down
24 changes: 12 additions & 12 deletions test/integration/end-to-end.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ chain.addOrderer(new Orderer('grpc://localhost:7050'));
chain.addPeer(peer0);
chain.addPeer(peer1);

test('End-to-end flow of chaincode install, deploy, transaction invocation, and query', (t) => {
test('End-to-end flow of chaincode install, instantiate, transaction invocation, and query', (t) => {

hfc.newDefaultKeyValueStore({
path: testUtil.KVS
Expand Down Expand Up @@ -172,7 +172,7 @@ test('End-to-end flow of chaincode install, deploy, transaction invocation, and
nonce: nonce
};

return chain.sendDeploymentProposal(request);
return chain.sendInstantiateProposal(request);

},
(err) => {
Expand All @@ -188,9 +188,9 @@ test('End-to-end flow of chaincode install, deploy, transaction invocation, and
let one_good = false;
if (proposalResponses && proposalResponses[0].response && proposalResponses[0].response.status === 200) {
one_good = true;
logger.info('deploy proposal was good');
logger.info('instantiate proposal was good');
} else {
logger.error('deploy proposal was bad');
logger.error('instantiate proposal was bad');
}
all_good = all_good & one_good;
}
Expand All @@ -210,7 +210,7 @@ test('End-to-end flow of chaincode install, deploy, transaction invocation, and
var handle = setTimeout(reject, 30000);

eh.registerTxEvent(deployId, (tx) => {
t.pass('The chaincode deploy transaction has been successfully committed');
t.pass('The chaincode instantiate transaction has been successfully committed');
clearTimeout(handle);
eh.unregisterTxEvent(deployId);

Expand All @@ -227,27 +227,27 @@ test('End-to-end flow of chaincode install, deploy, transaction invocation, and
return Promise.all([sendPromise, txPromise]).then((results) => {
return results[0]; // the first returned value is from the 'sendPromise' which is from the 'sendTransaction()' call
}).catch((err) => {
t.fail('Failed to send deploy transaction and get notifications within the timeout period. ');
t.fail('Failed to send instantiate transaction and get notifications within the timeout period. ');
t.end();
});
} else {
t.fail('Failed to send Proposal or receive valid response. Response null or status is not 200. exiting...');
t.fail('Failed to send instantiate Proposal or receive valid response. Response null or status is not 200. exiting...');
t.end();
}
},
(err) => {
t.fail('Failed to send deployment proposal due to error: ' + err.stack ? err.stack : err);
t.fail('Failed to send instantiate proposal due to error: ' + err.stack ? err.stack : err);
t.end();
}).then((response) => {
if (response.status === 'SUCCESS') {
t.pass('Successfully sent deployment transaction to the orderer.');
t.pass('Successfully sent instantiate transaction to the orderer.');
} else {
t.fail('Failed to order the deployment endorsement. Error code: ' + response.status);
t.fail('Failed to order the instantiate endorsement. Error code: ' + response.status);
t.end();
}
},
(err) => {
t.fail('Failed to send deployment e due to error: ' + err.stack ? err.stack : err);
t.fail('Failed to send instantiate due to error: ' + err.stack ? err.stack : err);
t.end();
});
}
Expand Down Expand Up @@ -305,7 +305,7 @@ test('End-to-end flow of chaincode install, deploy, transaction invocation, and
var handle = setTimeout(reject, 30000);

eh.registerTxEvent(txId.toString(), (tx) => {
t.pass('The chaincode deploy transaction has been successfully committed');
t.pass('The chaincode instantiate transaction has been successfully committed');
clearTimeout(handle);
eh.unregisterTxEvent(txId);

Expand Down
10 changes: 5 additions & 5 deletions test/integration/endorser-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ testUtil.setupChaincodeDeploy();
//
// Run the endorser good tests
//
test('\n\n** TEST ** endorse chaincode deployment good test', function(t) {
test('\n\n** TEST ** endorse chaincode install good test', function(t) {
//
// Create and configure the test chain
//
Expand All @@ -72,7 +72,7 @@ test('\n\n** TEST ** endorse chaincode deployment good test', function(t) {

chain.addPeer(new Peer('grpc://localhost:7051'));
chain.addPeer(new Peer('grpc://localhost:7056'));
///

the_user = admin;
nonce = utils.getNonce();
tx_id = chain.buildTransactionID(nonce, the_user);
Expand Down Expand Up @@ -139,7 +139,7 @@ test('\n\n** TEST ** endorse chaincode deployment good test', function(t) {
nonce: nonce
};

return chain.sendDeploymentProposal(request);
return chain.sendInstantiateProposal(request);
},
function(err) {
t.fail('Failed to enroll user \'admin\'. ' + err);
Expand All @@ -161,7 +161,7 @@ test('\n\n** TEST ** endorse chaincode deployment good test', function(t) {
t.end();
},
function(err) {
t.fail('Failed to send deployment proposal due to error: ' + err.stack ? err.stack : err);
t.fail('Failed to send instantiate proposal due to error: ' + err.stack ? err.stack : err);
t.end();
}
).catch(
Expand All @@ -172,7 +172,7 @@ test('\n\n** TEST ** endorse chaincode deployment good test', function(t) {
);
}).catch(
function(err) {
t.fail('Failed to send deployment proposal. ' + err.stack ? err.stack : err);
t.fail('Failed to send instantiate proposal. ' + err.stack ? err.stack : err);
t.end();
}
);
Expand Down
12 changes: 6 additions & 6 deletions test/integration/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ chain.addOrderer(new Orderer('grpc://localhost:7050'));
chain.addPeer(peer0);
chain.addPeer(peer1);

test('Test chaincode deploy with event, transaction invocation with chaincode event, and query number of chaincode events', (t) => {
test('Test chaincode instantiate with event, transaction invocation with chaincode event, and query number of chaincode events', (t) => {
hfc.newDefaultKeyValueStore({
path: testUtil.KVS
}).then((store) => {
Expand Down Expand Up @@ -108,7 +108,7 @@ test('Test chaincode deploy with event, transaction invocation with chaincode ev
nonce: nonce
};

return chain.sendDeploymentProposal(request);
return chain.sendInstantiateProposal(request);
},
(err) => {
t.fail('Failed to enroll user \'admin\'. ' + err);
Expand All @@ -122,9 +122,9 @@ test('Test chaincode deploy with event, transaction invocation with chaincode ev
let one_good = false;
if (proposalResponses && proposalResponses[0].response && proposalResponses[0].response.status === 200) {
one_good = true;
logger.info('deploy proposal was good');
logger.info('instantiate proposal was good');
} else {
logger.error('deploy proposal was bad');
logger.error('instantiate proposal was bad');
}
all_good = all_good & one_good;
}
Expand All @@ -148,15 +148,15 @@ test('Test chaincode deploy with event, transaction invocation with chaincode ev
}
},
(err) => {
t.fail('Failed to send deployment proposal due to error: ' + err.stack ? err.stack : err);
t.fail('Failed to send instantiate proposal due to error: ' + err.stack ? err.stack : err);
t.end();
}).then((results) => {
if (steps.length === 1 && steps[0] === 'step1') {
t.end();
}
},
(err) => {
t.fail('Failed to send deployment proposal due to error: ' + err.stack ? err.stack : err);
t.fail('Failed to send instantiate proposal due to error: ' + err.stack ? err.stack : err);
t.end();
});
}
Expand Down
8 changes: 4 additions & 4 deletions test/integration/marbles.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ chain.setKeyValueStore(hfc.newKeyValueStore({

chain.setOrderer('grpc://localhost:7050');

test('End-to-end flow of chaincode deploy, transaction invocation, and query', function(t) {
test('End-to-end flow of chaincode instantiate, transaction invocation, and query', function(t) {
var promise = testUtil.getSubmitter(chain, t);

if (steps.length === 0 || steps.indexOf('step1') >= 0) {
Expand All @@ -82,7 +82,7 @@ test('End-to-end flow of chaincode deploy, transaction invocation, and query', f
nonce: nonce
};

return admin.sendDeploymentProposal(request);
return admin.sendInstantiateProposal(request);
},
function(err) {
t.fail('Failed to enroll user \'admin\'. ' + err);
Expand All @@ -106,7 +106,7 @@ test('End-to-end flow of chaincode deploy, transaction invocation, and query', f
}
},
function(err) {
t.fail('Failed to send deployment proposal due to error: ' + err.stack ? err.stack : err);
t.fail('Failed to send instantiate proposal due to error: ' + err.stack ? err.stack : err);
t.end();
}
);
Expand All @@ -117,7 +117,7 @@ test('End-to-end flow of chaincode deploy, transaction invocation, and query', f
promise = promise.then(
function(response) {
if (response.Status === 'SUCCESS') {
t.pass('Successfully ordered deployment endorsement.');
t.pass('Successfully ordered instantiate endorsement.');
console.log(' need to wait now for the committer to catch up');
return sleep(20000);
} else {
Expand Down
Loading

0 comments on commit 1e3c1b2

Please sign in to comment.