diff --git a/README.md b/README.md
index b5e1a78ec0..9241b09f35 100644
--- a/README.md
+++ b/README.md
@@ -31,7 +31,15 @@ In the project root folder:
The following tests require setting up a local blockchain network as the target. Because v1.0 is still in active development, you still need the vagrant environment to build the necessary Docker images needed to run the network. Follow the steps below to set it up.
* You will need the COP server (new implementation of the member service) to run the tests. Because the COP project's build script does not yet produce a docker image, you'd need to run the COP server as a native process inside vagrant
-* git clone both the *fabric* and *fabric-cop* repositories into the $GOPATH/src/github.com/hyperledger folder in your native host (MacOS, Windows or Ubuntu, etc)
+* git clone both the *fabric* and *fabric-cop* repositories into the $GOPATH/src/github.com/hyperledger folder in your native host (MacOS, Windows or Ubuntu, etc).
+
+If you are using a Mac and would like to build the docker images and run them natively instead of using vagrant, do the following:
+* If docker is installed and it’s not ‘Docker for Mac’, uninstall and follow Docker’s clean up instructions to uninstall completely.
+* Install ‘Docker for Mac’.
+* Install Brew: http://brew.sh
+* run `brew install gnu-tar —-with-default-names`
+
+* To use vagrant, do the following:
* `cd fabric/devenv`
* Open the file `Vagrantfile` and insert the following statement below the existing `config.vm.network` statements:
* ` config.vm.network :forwarded_port, guest: 7056, host: 7056 # Openchain gRPC services`
@@ -41,7 +49,7 @@ The following tests require setting up a local blockchain network as the target.
* Once inside vagrant, follow these steps to start the COP server and the Peers network with orderer
* start COP (new membership service)
* cd `$GOPATH/src/github.com/hyperledger/fabric-cop
- * follow the instructions in [fabric-cop README](https://github.com/hyperledger/fabric-cop) to build the COP binary
+ * run `make cop` to build the COP binary or follow the instructions in [fabric-cop README](https://github.com/hyperledger/fabric-cop)
* from the `fabric-cop` folder, launch the following command to start the COP server. The ec.pem and ec-key.pem certificates sets up the COP server as the trusted root that the Peer nodes have been statically configured as a temporary measure. In other words, the Peers will be able to trust any user certificates that have been signed by the COP server. This is important because the endorser code inside the Peer will need to validate the user certificate issued by COP before using it to verify the signature of the transaction proposal.
* `bin/cop server start -address "" -ca testdata/ec.pem -ca-key testdata/ec-key.pem -config testdata/testconfig.json`
* start the Peer network
@@ -50,7 +58,7 @@ The following tests require setting up a local blockchain network as the target.
* create a docker-compose.yml file in home directory (/home/vagrant), and copy [docker-compose.yml](https://raw.githubusercontent.com/hyperledger/fabric-sdk-node/master/test/fixtures/docker-compose.yml) file content into the file
* from /home/vagrant, run `docker-compose up --force-recreate` to launch the network
* Back in your native host (MacOS, or Windows, or Ubuntu, etc), run the following tests:
- * Clear out your previous keyvalue store if needed (rm -fr /tmp/hfc-*)
+ * Clear out your previous keyvalue store if needed for fabric-sdk-node (rm -fr /tmp/hfc-*) and for fabric-cop (rm $HOME/.cop/cop.db)
* Run `gulp test` to run the entire test bucket and generate coverage reports (both in console output and HTMLs)
* Test user management with a member services, run `node test/unit/ca-tests.js`
* Test happy path from end to end, run `node test/unit/end-to-end.js`
diff --git a/hfc/lib/Chain.js b/hfc/lib/Chain.js
index b0359b2146..0b76c61342 100644
--- a/hfc/lib/Chain.js
+++ b/hfc/lib/Chain.js
@@ -287,7 +287,6 @@ var Chain = class {
* Sends a deployment proposal to one or more endorsing peers.
*
* @param {Object} request - An object containing the following fields:
- *
`targets` : required - An array or single Endorsing {@link Peer} objects as the targets of the request
*
`chaincodePath` : required - String of the path to location of the source code of the chaincode
*
`chaincodeId` : required - String of the name of the chaincode
*
`chainId` : required - String of the name of the chain
@@ -302,6 +301,13 @@ var Chain = class {
sendDeploymentProposal(request) {
var errorMsg = null;
+ // Verify that a Peer has been added
+ if (this.getPeers().length < 1) {
+ errorMsg = 'Missing peer objects in Deployment proposal chain';
+ logger.error('Chain.sendDeploymentProposal error '+ errorMsg);
+ return Promise.reject(new Error(errorMsg));
+ }
+
// Verify that chaincodePath is being passed
if (request && (!request.chaincodePath || request.chaincodePath === '')) {
errorMsg = 'Missing chaincodePath parameter in Deployment proposal request';
@@ -376,7 +382,7 @@ var Chain = class {
proposal = self._buildProposal(lcccSpec, header);
let signed_proposal = self._signProposal(userContext.getEnrollment(), proposal);
- return Chain._sendPeersProposal(request.targets, signed_proposal);
+ return Chain._sendPeersProposal(self.getPeers(), signed_proposal);
}
).then(
function(responses) {
@@ -404,7 +410,6 @@ var Chain = class {
* Sends a transaction proposal to one or more endorsing peers.
*
* @param {Object} request
- *
`targets` : An array or single Endorsing {@link Peer} objects as the targets of the request
*
`chaincodeId` : The id of the chaincode to perform the transaction proposal
*
`chainId` : required - String of the name of the chain
*
`txId` : required - String of the transaction id
@@ -415,6 +420,14 @@ var Chain = class {
sendTransactionProposal(request) {
logger.debug('Chain.sendTransactionProposal - start');
var errorMsg = null;
+
+ // Verify that a Peer has been added
+ if (this.getPeers().length < 1) {
+ errorMsg = 'Missing peer objects in Transaction proposal chain';
+ logger.error('Chain.sendDeploymentProposal error '+ errorMsg);
+ return Promise.reject(new Error(errorMsg));
+ }
+
// args is not optional because we need for transaction to execute
if (request && !request.args) {
errorMsg = 'Missing "args" in Transaction proposal request';
@@ -456,7 +469,7 @@ var Chain = class {
proposal = self._buildProposal(invokeSpec, header);
let signed_proposal = self._signProposal(userContext.getEnrollment(), proposal);
- return Chain._sendPeersProposal(request.targets, signed_proposal);
+ return Chain._sendPeersProposal(self.getPeers(), signed_proposal);
}
).then(
function(responses) {
@@ -604,7 +617,7 @@ var Chain = class {
function(results) {
var responses = results[0];
var proposal = results[1];
- logger.debug('Member-sendQueryProposal - response %j', responses);
+ logger.debug('Chain-queryByChaincode - response %j', responses);
if(responses && Array.isArray(responses)) {
var results = [];
for(let i = 0; i < responses.length; i++) {
@@ -696,7 +709,7 @@ var Chain = class {
}
).catch(
function(err) {
- logger.error('Member-sendPeersProposal - Promise is rejected: %s',err.stack ? err.stack : err);
+ logger.error('Chain-sendPeersProposal - Promise is rejected: %s',err.stack ? err.stack : err);
return reject(err);
}
);
@@ -710,10 +723,10 @@ var Chain = class {
.then(function (results) {
results.forEach(function (result) {
if (result.isFulfilled()) {
- logger.debug('Member-sendPeersProposal - Promise is fulfilled: '+result.value());
+ logger.debug('Chain-sendPeersProposal - Promise is fulfilled: '+result.value());
responses.push(result.value());
} else {
- logger.debug('Member-sendPeersProposal - Promise is rejected: '+result.reason());
+ logger.debug('Chain-sendPeersProposal - Promise is rejected: '+result.reason());
responses.push(result.reason());
}
});
@@ -752,8 +765,6 @@ var Chain = class {
errorMsg = 'Missing "chaincodeId" parameter in the proposal request';
} else if(!request.chainId) {
errorMsg = 'Missing "chainId" parameter in the proposal request';
- } else if(!request.targets) {
- errorMsg = 'Missing "targets" parameter in the proposal request';
} else if(!request.txId) {
errorMsg = 'Missing "txId" parameter in the proposal request';
} else if(!request.nonce) {
diff --git a/test/unit/end-to-end.js b/test/unit/end-to-end.js
index e5ed344341..97604c2060 100644
--- a/test/unit/end-to-end.js
+++ b/test/unit/end-to-end.js
@@ -74,10 +74,11 @@ test('End-to-end flow of chaincode deploy, transaction invocation, and query', f
webUser = admin;
tx_id = utils.buildTransactionID({length:12});
nonce = utils.getNonce();
+ chain.addPeer(peer0);
+ chain.addPeer(peer1);
// send proposal to endorser
var request = {
- targets: [peer0, peer1],
chaincodePath: testUtil.CHAINCODE_PATH,
chaincodeId: chaincode_id,
fcn: 'init',
@@ -181,9 +182,10 @@ test('End-to-end flow of chaincode deploy, transaction invocation, and query', f
function() {
tx_id = utils.buildTransactionID({length:12});
nonce = utils.getNonce();
+ chain.addPeer(peer0);
+ chain.addPeer(peer1);
// send proposal to endorser
var request = {
- targets: [peer0, peer1],
chaincodeId : chaincode_id,
fcn: 'invoke',
args: ['move', 'a', 'b','100'],
diff --git a/test/unit/endorser-tests.js b/test/unit/endorser-tests.js
index 0aecce7d7b..6582637a44 100644
--- a/test/unit/endorser-tests.js
+++ b/test/unit/endorser-tests.js
@@ -50,9 +50,10 @@ test('\n\n** TEST ** endorse chaincode deployment good test', function(t) {
function(admin) {
t.pass('Successfully enrolled user \'admin\'');
+ chain.addPeer(new Peer('grpc://localhost:7051'));
+ chain.addPeer(new Peer('grpc://localhost:7056'));
// send proposal to endorser
var request = {
- targets: [new Peer('grpc://localhost:7051'), new Peer('grpc://localhost:7056')],
chaincodePath: testUtil.CHAINCODE_PATH,
chaincodeId: 'mycc',
fcn: 'init',
diff --git a/test/unit/headless-tests.js b/test/unit/headless-tests.js
index 77d7176893..0d1028a6b8 100644
--- a/test/unit/headless-tests.js
+++ b/test/unit/headless-tests.js
@@ -541,6 +541,8 @@ test('\n\n ** User - constructor set get tests **\n\n', function (t) {
test('\n\n ** Chain sendDeploymentProposal() tests **\n\n', function (t) {
var c = new Chain('does not matter', client);
+ var peer = new Peer('grpc://localhost:7051');
+ c.addPeer(peer);
var p1 = c.sendDeploymentProposal({
targets: [new Peer('grpc://localhost:7051')],
@@ -554,9 +556,9 @@ test('\n\n ** Chain sendDeploymentProposal() tests **\n\n', function (t) {
t.fail('Should not have been able to resolve the promise because of missing "chaincodePath" parameter');
}).catch(function (err) {
if (err.message.indexOf('Missing chaincodePath parameter in Deployment proposal request') >= 0) {
- t.pass('Successfully caught missing peer error');
+ t.pass('Successfully caught missing chaincodePath error');
} else {
- t.fail('Failed to catch the missing peer error. Error: ' + err.stack ? err.stask : err);
+ t.fail('Failed to catch the missing chaincodePath error. Error: ' + err.stack ? err.stack : err);
}
});
@@ -574,7 +576,7 @@ test('\n\n ** Chain sendDeploymentProposal() tests **\n\n', function (t) {
if (err.message.indexOf('Missing "chainId" parameter in the proposal request') >= 0) {
t.pass('Successfully caught missing chainId error');
} else {
- t.fail('Failed to catch the missing chainId error. Error: ' + err.stack ? err.stask : err);
+ t.fail('Failed to catch the missing chainId error. Error: ' + err.stack ? err.stack : err);
}
});
@@ -592,10 +594,11 @@ test('\n\n ** Chain sendDeploymentProposal() tests **\n\n', function (t) {
if (err.message.indexOf('Missing "chaincodeId" parameter in the proposal request') >= 0) {
t.pass('Successfully caught missing chaincodeId error');
} else {
- t.fail('Failed to catch the missing chaincodeId error. Error: ' + err.stack ? err.stask : err);
+ t.fail('Failed to catch the missing chaincodeId error. Error: ' + err.stack ? err.stack : err);
}
});
+ c.removePeer(peer);
var p4 = c.sendDeploymentProposal({
chaincodePath: 'blah',
chaincodeId: 'blah',
@@ -605,15 +608,17 @@ test('\n\n ** Chain sendDeploymentProposal() tests **\n\n', function (t) {
txId: 'blah',
nonce: 'blah'
}).then(function () {
- t.fail('Should not have been able to resolve the promise because of missing "targets" parameter');
+ t.fail('Should not have been able to resolve the promise because of missing "peer" objects on chain');
}).catch(function (err) {
- if (err.message.indexOf('Missing "targets" parameter in the proposal request') >= 0) {
- t.pass('Successfully caught missing targets error');
+ var msg = 'Missing peer objects in Deployment proposal chain';
+ if (err.message.indexOf(msg) >= 0) {
+ t.pass('Successfully caught error: '+msg);
} else {
- t.fail('Failed to catch the missing targets error. Error: ' + err.stack ? err.stask : err);
+ t.fail('Failed to catch error: '+msg+'. Error: ' + err.stack ? err.stack : err);
}
});
+ c.addPeer(peer);
var p5 = c.sendDeploymentProposal({
targets: [new Peer('grpc://localhost:7051')],
chaincodePath: 'blah',
@@ -628,7 +633,7 @@ test('\n\n ** Chain sendDeploymentProposal() tests **\n\n', function (t) {
if (err.message.indexOf('Missing "txId" parameter in the proposal request') >= 0) {
t.pass('Successfully caught missing txId error');
} else {
- t.fail('Failed to catch the missing txId error. Error: ' + err.stack ? err.stask : err);
+ t.fail('Failed to catch the missing txId error. Error: ' + err.stack ? err.stack : err);
}
});
@@ -646,7 +651,7 @@ test('\n\n ** Chain sendDeploymentProposal() tests **\n\n', function (t) {
if (err.message.indexOf('Missing "nonce" parameter in the proposal request') >= 0) {
t.pass('Successfully caught missing nonce error');
} else {
- t.fail('Failed to catch the missing nonce error. Error: ' + err.stack ? err.stask : err);
+ t.fail('Failed to catch the missing nonce error. Error: ' + err.stack ? err.stack : err);
}
});
@@ -656,7 +661,7 @@ test('\n\n ** Chain sendDeploymentProposal() tests **\n\n', function (t) {
if (err.message.indexOf('Missing input request object on the proposal request') >= 0) {
t.pass('Successfully caught missing request error');
} else {
- t.fail('Failed to catch the missing request error. Error: ' + err.stack ? err.stask : err);
+ t.fail('Failed to catch the missing request error. Error: ' + err.stack ? err.stack : err);
}
});
@@ -667,7 +672,7 @@ test('\n\n ** Chain sendDeploymentProposal() tests **\n\n', function (t) {
}
).catch(
function (err) {
- t.fail(err.stack ? err.stack : err);
+ t.fail('Chain sendDeploymentProposal() tests, Promise.all: '+err.stack ? err.stack : err);
t.end();
}
);
@@ -677,9 +682,10 @@ test('\n\n ** Chain sendDeploymentProposal() tests **\n\n', function (t) {
test('\n\n ** Chain sendTransactionProposal() tests **\n\n', function (t) {
var c = new Chain('does not matter', client);
+ var peer = new Peer('grpc://localhost:7051');
+ c.addPeer(peer);
var p1 = c.sendTransactionProposal({
- targets: [new Peer('grpc://localhost:7051')],
chaincodeId : 'blah',
fcn: 'invoke',
chainId: 'blah',
@@ -688,15 +694,15 @@ test('\n\n ** Chain sendTransactionProposal() tests **\n\n', function (t) {
}).then(function () {
t.fail('Should not have been able to resolve the promise because of missing "args" parameter');
}).catch(function (err) {
- if (err.message.indexOf('Missing "targets" for endorser peer objects in the Transaction proposal request')) {
- t.pass('Successfully caught missing targets error');
+ var msg = 'Missing "args" in Transaction proposal request';
+ if (err.message.indexOf(msg) >= 0) {
+ t.pass('Successfully caught error: '+msg);
} else {
- t.fail('Failed to catch the missing targets error. Error: ' + err.stack ? err.stask : err);
+ t.fail('Failed to catch error: '+msg+'. Error: ' + err.stack ? err.stack : err);
}
});
var p2 = c.sendTransactionProposal({
- targets: [new Peer('grpc://localhost:7051')],
chaincodeId: 'blah',
fcn: 'init',
args: ['a', '100', 'b', '200'],
@@ -708,12 +714,11 @@ test('\n\n ** Chain sendTransactionProposal() tests **\n\n', function (t) {
if (err.message.indexOf('Missing "chainId" parameter in the proposal request') >= 0) {
t.pass('Successfully caught missing chainId error');
} else {
- t.fail('Failed to catch the missing chainId error. Error: ' + err.stack ? err.stask : err);
+ t.fail('Failed to catch the missing chainId error. Error: ' + err.stack ? err.stack : err);
}
});
var p3 = c.sendTransactionProposal({
- targets: [new Peer('grpc://localhost:7051')],
chainId: 'blah',
fcn: 'init',
args: ['a', '100', 'b', '200'],
@@ -725,10 +730,11 @@ test('\n\n ** Chain sendTransactionProposal() tests **\n\n', function (t) {
if (err.message.indexOf('Missing "chaincodeId" parameter in the proposal request') >= 0) {
t.pass('Successfully caught missing chaincodeId error');
} else {
- t.fail('Failed to catch the missing chaincodeId error. Error: ' + err.stack ? err.stask : err);
+ t.fail('Failed to catch the missing chaincodeId error. Error: ' + err.stack ? err.stack : err);
}
});
+ c.removePeer(peer);
var p4 = c.sendTransactionProposal({
chaincodeId: 'blah',
chainId: 'blah',
@@ -737,17 +743,18 @@ test('\n\n ** Chain sendTransactionProposal() tests **\n\n', function (t) {
txId: 'blah',
nonce: 'blah'
}).then(function () {
- t.fail('Should not have been able to resolve the promise because of missing "targets" parameter');
+ t.fail('Should not have been able to resolve the promise because of missing "peer" objects on chain');
}).catch(function (err) {
- if (err.message.indexOf('Missing "targets" parameter in the proposal request') >= 0) {
- t.pass('Successfully caught missing targets error');
+ var msg = 'Missing peer objects in Transaction proposal chain';
+ if (err.message.indexOf(msg) >= 0) {
+ t.pass('Successfully caught error: '+msg);
} else {
- t.fail('Failed to catch the missing targets error. Error: ' + err.stack ? err.stask : err);
+ t.fail('Failed to catch error: '+msg+'. Error: ' + err.stack ? err.stack : err);
}
});
+ c.addPeer(peer);
var p5 = c.sendTransactionProposal({
- targets: [new Peer('grpc://localhost:7051')],
chaincodeId: 'blah',
chainId: 'blah',
fcn: 'init',
@@ -759,12 +766,11 @@ test('\n\n ** Chain sendTransactionProposal() tests **\n\n', function (t) {
if (err.message.indexOf('Missing "txId" parameter in the proposal request') >= 0) {
t.pass('Successfully caught missing txId error');
} else {
- t.fail('Failed to catch the missing txId error. Error: ' + err.stack ? err.stask : err);
+ t.fail('Failed to catch the missing txId error. Error: ' + err.stack ? err.stack : err);
}
});
var p6 = c.sendTransactionProposal({
- targets: [new Peer('grpc://localhost:7051')],
chaincodeId: 'blah',
chainId: 'blah',
fcn: 'init',
@@ -776,7 +782,7 @@ test('\n\n ** Chain sendTransactionProposal() tests **\n\n', function (t) {
if (err.message.indexOf('Missing "nonce" parameter in the proposal request') >= 0) {
t.pass('Successfully caught missing nonce error');
} else {
- t.fail('Failed to catch the missing nonce error. Error: ' + err.stack ? err.stask : err);
+ t.fail('Failed to catch the missing nonce error. Error: ' + err.stack ? err.stack : err);
}
});
@@ -786,7 +792,7 @@ test('\n\n ** Chain sendTransactionProposal() tests **\n\n', function (t) {
if (err.message.indexOf('Missing input request object on the proposal request') >= 0) {
t.pass('Successfully caught missing request error');
} else {
- t.fail('Failed to catch the missing request error. Error: ' + err.stack ? err.stask : err);
+ t.fail('Failed to catch the missing request error. Error: ' + err.stack ? err.stack : err);
}
});
@@ -797,7 +803,7 @@ test('\n\n ** Chain sendTransactionProposal() tests **\n\n', function (t) {
}
).catch(
function (err) {
- t.fail(err.stack ? err.stack : err);
+ t.fail('Chain sendTransactionProposal() tests, Promise.all: '+err.stack ? err.stack : err);
t.end();
}
);
@@ -807,58 +813,59 @@ test('\n\n ** Chain sendTransactionProposal() tests **\n\n', function (t) {
test('\n\n ** Client queryByChaincode() tests **\n\n', function (t) {
var c = client.newChain('any chain goes');
+ var peer = new Peer('grpc://localhost:7051');
+ c.addPeer(peer);
var p1 = c.queryByChaincode({
- targets: [new Peer('grpc://localhost:7051')],
chaincodeId : 'blah',
fcn: 'invoke',
chainId: 'blah',
txId: 'blah',
nonce: 'blah'
}).then(function () {
- t.fail('Should not have been able to resolve the promise because of missing "args" parameter');
+ t.fail('Should not have been able to resolve the promise because of missing "args" parameter in queryByChaincode');
}).catch(function (err) {
- if (err.message.indexOf('Missing "targets" for endorser peer objects in the Transaction proposal request')) {
- t.pass('Successfully caught missing targets error');
+ var msg = 'Missing "args" in Transaction proposal request';
+ if (err.message.indexOf(msg) >= 0 ) {
+ t.pass('Successfully caught error: '+msg);
} else {
- t.fail('Failed to catch the missing targets error. Error: ' + err.stack ? err.stask : err);
+ t.fail('Failed to catch queryByChaincode error: '+msg+'. Error: ' + err.stack ? err.stack : err);
}
});
var p2 = c.queryByChaincode({
- targets: [new Peer('grpc://localhost:7051')],
chaincodeId: 'blah',
fcn: 'init',
args: ['a', '100', 'b', '200'],
txId: 'blah',
nonce: 'blah'
}).then(function () {
- t.fail('Should not have been able to resolve the promise because of missing "chainId" parameter');
+ t.fail('Should not have been able to resolve the promise because of missing "chainId" parameter in queryByChaincode');
}).catch(function (err) {
if (err.message.indexOf('Missing "chainId" parameter in the proposal request') >= 0) {
t.pass('Successfully caught missing chainId error');
} else {
- t.fail('Failed to catch the missing chainId error. Error: ' + err.stack ? err.stask : err);
+ t.fail('Failed to catch the queryByChaincode missing chainId error. Error: ' + err.stack ? err.stack : err);
}
});
var p3 = c.queryByChaincode({
- targets: [new Peer('grpc://localhost:7051')],
chainId: 'blah',
fcn: 'init',
args: ['a', '100', 'b', '200'],
txId: 'blah',
nonce: 'blah'
}).then(function () {
- t.fail('Should not have been able to resolve the promise because of missing "chaincodeId" parameter');
+ t.fail('Should not have been able to resolve the promise because of missing "chaincodeId" parameter in queryByChaincode');
}).catch(function (err) {
if (err.message.indexOf('Missing "chaincodeId" parameter in the proposal request') >= 0) {
t.pass('Successfully caught missing chaincodeId error');
} else {
- t.fail('Failed to catch the missing chaincodeId error. Error: ' + err.stack ? err.stask : err);
+ t.fail('Failed to catch the queryByChaincode missing chaincodeId error. Error: ' + err.stack ? err.stack : err);
}
});
+ c.removePeer(peer);
var p4 = c.queryByChaincode({
chaincodeId: 'blah',
chainId: 'blah',
@@ -867,56 +874,56 @@ test('\n\n ** Client queryByChaincode() tests **\n\n', function (t) {
txId: 'blah',
nonce: 'blah'
}).then(function () {
- t.fail('Should not have been able to resolve the promise because of missing "targets" parameter');
+ t.fail('Should not have been able to resolve the promise because of missing "peers" on chain in queryByChaincode');
}).catch(function (err) {
- if (err.message.indexOf('Missing "targets" parameter in the proposal request') >= 0) {
- t.pass('Successfully caught missing targets error');
+ var msg = 'Missing peer objects in Transaction proposal chain';
+ if (err.message.indexOf(msg) >= 0) {
+ t.pass('Successfully caught error: '+msg);
} else {
- t.fail('Failed to catch the missing targets error. Error: ' + err.stack ? err.stask : err);
+ t.fail('Failed to catch queryByChaincode error: '+msg+'. Error: ' + err.stack ? err.stack : err);
}
});
+ c.addPeer(peer);
var p5 = c.queryByChaincode({
- targets: [new Peer('grpc://localhost:7051')],
chaincodeId: 'blah',
chainId: 'blah',
fcn: 'init',
args: ['a', '100', 'b', '200'],
nonce: 'blah'
}).then(function () {
- t.fail('Should not have been able to resolve the promise because of missing "txId" parameter');
+ t.fail('Should not have been able to resolve the promise because of missing "txId" parameter in queryByChaincode');
}).catch(function (err) {
if (err.message.indexOf('Missing "txId" parameter in the proposal request') >= 0) {
t.pass('Successfully caught missing txId error');
} else {
- t.fail('Failed to catch the missing txId error. Error: ' + err.stack ? err.stask : err);
+ t.fail('Failed to catch the queryByChaincode missing txId error. Error: ' + err.stack ? err.stack : err);
}
});
var p6 = c.queryByChaincode({
- targets: [new Peer('grpc://localhost:7051')],
chaincodeId: 'blah',
chainId: 'blah',
fcn: 'init',
args: ['a', '100', 'b', '200'],
txId: 'blah'
}).then(function () {
- t.fail('Should not have been able to resolve the promise because of missing "nonce" parameter');
+ t.fail('Should not have been able to resolve the promise because of missing "nonce" parameter in queryByChaincode');
}).catch(function (err) {
if (err.message.indexOf('Missing "nonce" parameter in the proposal request') >= 0) {
t.pass('Successfully caught missing nonce error');
} else {
- t.fail('Failed to catch the missing nonce error. Error: ' + err.stack ? err.stask : err);
+ t.fail('Failed to catch the queryByChaincode missing nonce error. Error: ' + err.stack ? err.stack : err);
}
});
var p7 = c.queryByChaincode().then(function () {
- t.fail('Should not have been able to resolve the promise because of missing request parameter');
+ t.fail('Should not have been able to resolve the promise because of missing request parameter in queryByChaincode');
}).catch(function (err) {
if (err.message.indexOf('Missing input request object on the proposal request') >= 0) {
t.pass('Successfully caught missing request error');
} else {
- t.fail('Failed to catch the missing request error. Error: ' + err.stack ? err.stask : err);
+ t.fail('Failed to catch the queryByChaincode missing request error. Error: ' + err.stack ? err.stack : err);
}
});
@@ -927,7 +934,7 @@ test('\n\n ** Client queryByChaincode() tests **\n\n', function (t) {
}
).catch(
function (err) {
- t.fail(err.stack ? err.stack : err);
+ t.fail('Client queryByChaincode() tests, Promise.all: '+err.stack ? err.stack : err);
t.end();
}
);
@@ -947,7 +954,7 @@ test('\n\n ** Chain sendTransaction() tests **\n\n', function (t) {
if (err.message.indexOf('Missing input request object on the proposal request') >= 0) {
t.pass('Successfully caught missing request error');
} else {
- t.fail('Failed to catch the missing request error. Error: ' + err.stack ? err.stask : err);
+ t.fail('Failed to catch the missing request error. Error: ' + err.stack ? err.stack : err);
}
});
@@ -961,7 +968,7 @@ test('\n\n ** Chain sendTransaction() tests **\n\n', function (t) {
if (err.message.indexOf('Missing "proposalResponse" parameter in transaction request') >= 0) {
t.pass('Successfully caught missing proposalResponse error');
} else {
- t.fail('Failed to catch the missing proposalResponse error. Error: ' + err.stack ? err.stask : err);
+ t.fail('Failed to catch the missing proposalResponse error. Error: ' + err.stack ? err.stack : err);
}
});
@@ -975,7 +982,7 @@ test('\n\n ** Chain sendTransaction() tests **\n\n', function (t) {
if (err.message.indexOf('Missing "proposal" parameter in transaction request') >= 0) {
t.pass('Successfully caught missing proposal error');
} else {
- t.fail('Failed to catch the missing proposal error. Error: ' + err.stack ? err.stask : err);
+ t.fail('Failed to catch the missing proposal error. Error: ' + err.stack ? err.stack : err);
}
});
@@ -989,7 +996,7 @@ test('\n\n ** Chain sendTransaction() tests **\n\n', function (t) {
if (err.message.indexOf('Missing "header" parameter in transaction request') >= 0) {
t.pass('Successfully caught missing header error');
} else {
- t.fail('Failed to catch the missing header error. Error: ' + err.stack ? err.stask : err);
+ t.fail('Failed to catch the missing header error. Error: ' + err.stack ? err.stack : err);
}
});
@@ -1000,7 +1007,7 @@ test('\n\n ** Chain sendTransaction() tests **\n\n', function (t) {
}
).catch(
function (err) {
- t.fail(err.stack ? err.stack : err);
+ t.fail('Chain sendTransaction() tests, Promise.all: '+err.stack ? err.stack : err);
t.end();
}
);