diff --git a/build/tasks/eslint.js b/build/tasks/eslint.js index 8e0905dc51..b28d45ee57 100644 --- a/build/tasks/eslint.js +++ b/build/tasks/eslint.js @@ -11,8 +11,6 @@ gulp.task('lint', function () { '**/*.js', 'fabric-client/**/*.js', 'fabric-ca-client/lib/*.js', - 'examples/**/*.js', - '!examples/balance-transfer/node_modules/**', '!node_modules/**', '!fabric-client/node_modules/**', '!fabric-ca-client/node_modules/**', @@ -45,10 +43,9 @@ gulp.task('lint', function () { 'ignoreRegExpLiterals': true, }, ], - }, - fix: true, + } } )) .pipe(eslint.format()) .pipe(eslint.failAfterError()); -}); \ No newline at end of file +}); diff --git a/build/tasks/test.js b/build/tasks/test.js index ac2a920ea4..5419c89ccf 100644 --- a/build/tasks/test.js +++ b/build/tasks/test.js @@ -23,8 +23,8 @@ var debugPath = path.join(testConstants.tempdir, 'test-log/debug.log'); process.env.HFC_LOGGING = util.format('{"debug":"%s"}', escapeWindowsPath(debugPath)); function escapeWindowsPath(p) { - if (path.sep == "/") return p - return p.replace(/\\/g, "\\\\") + if (path.sep == '/') return p; + return p.replace(/\\/g, '\\\\'); } console.log('\n####################################################'); diff --git a/fabric-ca-client/lib/FabricCAClientImpl.js b/fabric-ca-client/lib/FabricCAClientImpl.js index c1bbf2518b..24eb004920 100644 --- a/fabric-ca-client/lib/FabricCAClientImpl.js +++ b/fabric-ca-client/lib/FabricCAClientImpl.js @@ -77,7 +77,7 @@ var FabricCAServices = class extends BaseClient { url = url_p.url; tlsOptions = url_p.tlsOptions; caName = url_p.caName; - cryptoSuite = url_p.cryptoSuite + cryptoSuite = url_p.cryptoSuite; } else { url = url_p; tlsOptions = tlsOptions_p; diff --git a/fabric-client/lib/BlockDecoder.js b/fabric-client/lib/BlockDecoder.js index 61d2e9b1fd..1e6bc3bd00 100644 --- a/fabric-client/lib/BlockDecoder.js +++ b/fabric-client/lib/BlockDecoder.js @@ -1334,26 +1334,26 @@ var HeaderType = class { static decodePayloadBasedOnType(proto_data, type) { let result = null; switch(type) { - case 1: - result = decodeConfigEnvelope(proto_data); - break; - case 2: - result = decodeConfigUpdateEnvelope(proto_data); - break; - case 3: - result = decodeEndorserTransaction(proto_data); - break; - default: - logger.debug(' ***** found a header type of %s :: %s', type, HeaderType.convertToString(type)); - // return empty data on types we do not know so that - // event processing may continue on blocks we do not - // care about - result = {}; + case 1: + result = decodeConfigEnvelope(proto_data); + break; + case 2: + result = decodeConfigUpdateEnvelope(proto_data); + break; + case 3: + result = decodeEndorserTransaction(proto_data); + break; + default: + logger.debug(' ***** found a header type of %s :: %s', type, HeaderType.convertToString(type)); + // return empty data on types we do not know so that + // event processing may continue on blocks we do not + // care about + result = {}; } return result; } -} +}; module.exports = BlockDecoder; module.exports.HeaderType = HeaderType; diff --git a/fabric-client/lib/Channel.js b/fabric-client/lib/Channel.js index eb32d4e2e1..32c6f5ce38 100755 --- a/fabric-client/lib/Channel.js +++ b/fabric-client/lib/Channel.js @@ -126,7 +126,7 @@ var Channel = class { logger.info('close - closing connections'); var closer = function (ep) { ep.close(); - } + }; this._peers.map(closer); this._orderers.map(closer); } diff --git a/fabric-client/lib/ChannelEventHub.js b/fabric-client/lib/ChannelEventHub.js index f48c859761..76549046aa 100644 --- a/fabric-client/lib/ChannelEventHub.js +++ b/fabric-client/lib/ChannelEventHub.js @@ -619,7 +619,7 @@ var ChannelEventHub = class { if(have_end_block) { if(have_start_block && converted_options.start_block.greaterThan(converted_options.end_block)) { - throw new Error(util.format('"startBlock" (%s) must not be larger than "endBlock" (%s)',converted_options.start_block,converted_options.end_block)) + throw new Error(util.format('"startBlock" (%s) must not be larger than "endBlock" (%s)', converted_options.start_block, converted_options.end_block)); } this._ending_block_number = converted_options.end_block; this._allowRegistration = false; @@ -821,7 +821,7 @@ var ChannelEventHub = class { self.unregisterChaincodeEvent(chaincode_reg); }; } - this._checkConnection() + this._checkConnection(); return chaincode_reg; } @@ -912,8 +912,7 @@ var ChannelEventHub = class { self.unregisterBlockEvent(block_registration_number); }; } - this._checkConnection() - + this._checkConnection(); return block_registration_number; } @@ -988,7 +987,7 @@ var ChannelEventHub = class { self.unregisterTxEvent(txid); }; } - this._checkConnection() + this._checkConnection(); return txid; } @@ -1136,7 +1135,7 @@ var ChannelEventHub = class { logger.debug('_processChaincodeEvents - no transactions or transaction actions'); } } else { - logger.debug('_processChaincodeEvents - block is not endorser transaction type') + logger.debug('_processChaincodeEvents - block is not endorser transaction type'); } } catch (err) { logger.error('on.data - Error unmarshalling transaction=', err); @@ -1226,18 +1225,18 @@ function getStreamState(self) { /* * Utility method to get the string state from an integer */ - function getStateText(state) { - let result = null; - try { - result = CONNECTION_STATE[state]; - } catch(error) { - logger.error('Connection state conversion - unknown state - %s',state); - } - if(!result) { - result = 'UNKNOWN_STATE'; - } - return result; - } +function getStateText(state) { + let result = null; + try { + result = CONNECTION_STATE[state]; + } catch(error) { + logger.error('Connection state conversion - unknown state - %s',state); + } + if(!result) { + result = 'UNKNOWN_STATE'; + } + return result; +} /* * The ChaincodeRegistration is used internal to the ChannelEventHub to hold chaincode * event registration callbacks. diff --git a/fabric-client/lib/Client.js b/fabric-client/lib/Client.js index 0d07240943..ae6e28eb53 100644 --- a/fabric-client/lib/Client.js +++ b/fabric-client/lib/Client.js @@ -399,7 +399,7 @@ var Client = class extends BaseClient { let connection_options = ca.getConnectionOptions(); let verify = true; //default if not found if(connection_options && typeof connection_options.verify === 'boolean') { - verify = connection_options.verify + verify = connection_options.verify; } tls_options = { trustedRoots: tlsCACerts, diff --git a/fabric-client/lib/Organization.js b/fabric-client/lib/Organization.js index 4fd473d23b..164d827bb5 100644 --- a/fabric-client/lib/Organization.js +++ b/fabric-client/lib/Organization.js @@ -178,7 +178,7 @@ var Organization = class { toString() { var peers = ''; this._peers.forEach((peer) => {peers = peers + peer.toString() + ',';}); - var ehs = '' + var ehs = ''; this._event_hubs.forEach((event_hub) => {ehs = ehs + event_hub.toString() + ',';}); var cas = ''; this._certificateAuthorities.forEach((ca) => {cas = cas + ca.toString() + ',';}); diff --git a/fabric-client/lib/Remote.js b/fabric-client/lib/Remote.js index 0bfe7603ad..cb20970939 100644 --- a/fabric-client/lib/Remote.js +++ b/fabric-client/lib/Remote.js @@ -192,7 +192,7 @@ var Endpoint = class { throw new Error('PEM encoded clientKey and clientCert are required.'); } } else { - throw new Error('clientKey and clientCert are both required.') + throw new Error('clientKey and clientCert are both required.'); } } else { var pembuf = Buffer.concat([Buffer.from(pem), Buffer.from('\0')]); diff --git a/fabric-client/lib/impl/bccsp_pkcs11.js b/fabric-client/lib/impl/bccsp_pkcs11.js index 5b26c5be2d..a723c6c2bf 100644 --- a/fabric-client/lib/impl/bccsp_pkcs11.js +++ b/fabric-client/lib/impl/bccsp_pkcs11.js @@ -108,7 +108,7 @@ var CryptoSuite_PKCS11 = class extends api.CryptoSuite { if (typeof pkcs11Lib === 'undefined' || pkcs11Lib === null) pkcs11Lib = utils.getConfigSetting('crypto-pkcs11-lib'); if (typeof pkcs11Lib === 'undefined' || pkcs11Lib === null || - typeof pkcs11Lib !== 'string') + typeof pkcs11Lib !== 'string') throw new Error(__func() + 'PKCS11 library path must be specified'); logger.info(__func() + 'PKCS11 library: ' + pkcs11Lib); /* @@ -130,7 +130,7 @@ var CryptoSuite_PKCS11 = class extends api.CryptoSuite { if (typeof pkcs11Pin === 'undefined' || pkcs11Pin === null) pkcs11Pin = utils.getConfigSetting('crypto-pkcs11-pin'); if (typeof pkcs11Pin === 'undefined' || pkcs11Pin === null || - typeof pkcs11Pin !== 'string') + typeof pkcs11Pin !== 'string') throw new Error(__func() + 'PKCS11 PIN must be set'); @@ -153,21 +153,21 @@ var CryptoSuite_PKCS11 = class extends api.CryptoSuite { } switch (this._hashAlgo.toLowerCase() + '-' + this._keySize) { - case 'sha3-256': - this._hashFunction = hashPrimitives.sha3_256; - break; - case 'sha3-384': - this._hashFunction = hashPrimitives.sha3_384; - break; - case 'sha2-256': - this._hashFunction = hashPrimitives.sha2_256; - break; - case 'sha2-384': - this._hashFunction = hashPrimitives.sha2_384; - break; - default: - throw Error(util.format('Unsupported hash algorithm and key size pair: %s-%s', this._hashAlgo, this._keySize)); - } + case 'sha3-256': + this._hashFunction = hashPrimitives.sha3_256; + break; + case 'sha3-384': + this._hashFunction = hashPrimitives.sha3_384; + break; + case 'sha2-256': + this._hashFunction = hashPrimitives.sha2_256; + break; + case 'sha2-384': + this._hashFunction = hashPrimitives.sha2_384; + break; + default: + throw Error(util.format('Unsupported hash algorithm and key size pair: %s-%s', this._hashAlgo, this._keySize)); + } /* * Load native PKCS11 library, open PKCS11 session and login. @@ -237,7 +237,7 @@ var CryptoSuite_PKCS11 = class extends api.CryptoSuite { try { // Getting info about PKCS11 Module logger.debug(__func() + 'C_GetInfo: ' + - util.inspect(pkcs11.C_GetInfo(), {depth: null})); + util.inspect(pkcs11.C_GetInfo(), {depth: null})); // Getting list of slots var slots = pkcs11.C_GetSlotList(true); @@ -245,18 +245,18 @@ var CryptoSuite_PKCS11 = class extends api.CryptoSuite { throw new Error(__func() + 'PKCS11 slot number non-exist'); var slot = slots[pkcs11Slot]; logger.debug(__func() + 'C_GetSlotList: ' + - util.inspect(slots, {depth: null})); + util.inspect(slots, {depth: null})); // Getting info about slot logger.debug(__func() + 'C_GetSlotInfo(' + pkcs11Slot + '): ' + - util.inspect(pkcs11.C_GetSlotInfo(slot), + util.inspect(pkcs11.C_GetSlotInfo(slot), {depth: null})); // Getting info about token logger.debug(__func() + 'C_GetTokenInfo(' + pkcs11Slot + '): ' + - util.inspect(pkcs11.C_GetTokenInfo(slot), + util.inspect(pkcs11.C_GetTokenInfo(slot), {depth: null})); // Getting info about Mechanism logger.debug(__func() + 'C_GetMechanismList(' + pkcs11Slot + '): ' + - util.inspect(pkcs11.C_GetMechanismList(slot), + util.inspect(pkcs11.C_GetMechanismList(slot), {depth: null})); /* * Open session. @@ -265,16 +265,16 @@ var CryptoSuite_PKCS11 = class extends api.CryptoSuite { slot, pkcs11js.CKF_RW_SESSION|pkcs11js.CKF_SERIAL_SESSION); // Getting info about Session logger.debug(__func() + 'C_GetSessionInfo(' + - util.inspect( - this._pkcs11Session, {depth: null}) + '): ' + - util.inspect(pkcs11.C_GetSessionInfo( - this._pkcs11Session), {depth: null})); + util.inspect( + this._pkcs11Session, {depth: null}) + '): ' + + util.inspect(pkcs11.C_GetSessionInfo( + this._pkcs11Session), {depth: null})); /* * Login with PIN. Error will be thrown if wrong PIN. */ pkcs11.C_Login(this._pkcs11Session, - 1/*pkcs11js.CKU_USER*/, pkcs11Pin); + 1/*pkcs11js.CKU_USER*/, pkcs11Pin); this._pkcs11Login = true; logger.info(__func() + 'session login successful'); @@ -414,15 +414,15 @@ var CryptoSuite_PKCS11 = class extends api.CryptoSuite { * Get the public key EC point. */ var ecpt = - (this._pkcs11GetAttributeValue( - pkcs11, pkcs11Session, handles.publicKey, - [{ type:pkcs11js.CKA_EC_POINT }]))[0].value; + (this._pkcs11GetAttributeValue( + pkcs11, pkcs11Session, handles.publicKey, + [{ type:pkcs11js.CKA_EC_POINT }]))[0].value; /* * Workaround for opencryptoki bug reporting wrong ecpt length. */ ecpt = this._fixEcpt(ecpt); logger.debug(__func() + 'ecpt[' + ecpt.length + ']: ' + - util.inspect(ecpt, { depth: null })); + util.inspect(ecpt, { depth: null })); /* * Set CKA_ID of public and private key to be SKI. */ @@ -502,13 +502,13 @@ var CryptoSuite_PKCS11 = class extends api.CryptoSuite { * Get EC params (to derive key size) and EC point. */ var attribs = - this._pkcs11GetAttributeValue( - this._pkcs11, this._pkcs11Session, publicKey, - [ { type:pkcs11js.CKA_EC_PARAMS }, - { type:pkcs11js.CKA_EC_POINT }, - ]); + this._pkcs11GetAttributeValue( + this._pkcs11, this._pkcs11Session, publicKey, + [ { type:pkcs11js.CKA_EC_PARAMS }, + { type:pkcs11js.CKA_EC_POINT }, + ]); logger.debug(__func() + 'attribuites: ' + - util.inspect(attribs, { depth: null} )); + util.inspect(attribs, { depth: null} )); var ecparams, ecpt; if (attribs[0].type == pkcs11js.CKA_EC_PARAMS) { @@ -543,7 +543,7 @@ var CryptoSuite_PKCS11 = class extends api.CryptoSuite { var sig = pkcs11.C_Sign(pkcs11Session, digest, Buffer.alloc(this._keySize)); logger.debug(__func() + 'ECDSA RAW signature: ' + - util.inspect(sig, {depth: null})); + util.inspect(sig, {depth: null})); /* * ASN1 DER encoding against malleability. */ @@ -552,7 +552,7 @@ var CryptoSuite_PKCS11 = class extends api.CryptoSuite { var sig = _preventMalleability({r: r, s: s}, this._ecdsaCurve); var der = (new ecsig({ r: sig.r, s: sig.s})).toDER(); logger.debug(__func() + 'ECDSA DER signature: ' + - util.inspect(Buffer.from(der), {depth: null})); + util.inspect(Buffer.from(der), {depth: null})); return Buffer.from(der); } catch(e) { @@ -571,17 +571,17 @@ var CryptoSuite_PKCS11 = class extends api.CryptoSuite { */ var rns = new ecsig(signature, 'hex'); logger.debug(__func() + 'ECDSA R+S signature: ' + - util.inspect(rns, {depth: null})); + util.inspect(rns, {depth: null})); var sig = Buffer.concat([ rns.r.toArrayLike(Buffer, '', 0), rns.s.toArrayLike(Buffer, '', 0)]); logger.debug(__func() + 'ECDSA RAW signature: ' + - util.inspect(sig, {depth: null})); + util.inspect(sig, {depth: null})); /* * key can be either a private or a public key. */ pkcs11.C_VerifyInit(pkcs11Session, - { mechanism: pkcs11js.CKM_ECDSA }, - key._handle); + { mechanism: pkcs11js.CKM_ECDSA }, + key._handle); return pkcs11.C_Verify(pkcs11Session, digest, sig); } catch(e) { @@ -604,9 +604,9 @@ var CryptoSuite_PKCS11 = class extends api.CryptoSuite { var iv = pkcs11.C_GenerateRandom(pkcs11Session, Buffer.alloc(16)); pkcs11.C_EncryptInit(pkcs11Session, - { mechanism: pkcs11js.CKM_AES_CBC_PAD, - parameter: iv }, - key._handle); + { mechanism: pkcs11js.CKM_AES_CBC_PAD, + parameter: iv }, + key._handle); /* * Prepend iv to ciphertext. */ @@ -632,9 +632,9 @@ var CryptoSuite_PKCS11 = class extends api.CryptoSuite { var iv = cipherText.slice(0, 16); pkcs11.C_DecryptInit(pkcs11Session, - { mechanism: pkcs11js.CKM_AES_CBC_PAD, - parameter: iv }, - key._handle); + { mechanism: pkcs11js.CKM_AES_CBC_PAD, + parameter: iv }, + key._handle); return pkcs11.C_Decrypt(pkcs11Session, cipherText.slice(16, cipherText.length), @@ -666,9 +666,9 @@ var CryptoSuite_PKCS11 = class extends api.CryptoSuite { pkcs11Session, { mechanism: pkcs11js.CKM_ECDH1_DERIVE, parameter: { type: pkcs11js.CK_PARAMS_EC_DH, - kdf: pkcs11js.CKD_SHA256_KDF, - publicData: pub._ecpt, - } + kdf: pkcs11js.CKD_SHA256_KDF, + publicData: pub._ecpt, + } }, key._handle, derivedKeyTemplate); } @@ -737,10 +737,10 @@ var CryptoSuite_PKCS11 = class extends api.CryptoSuite { { type: pkcs11js.CKA_ID }, ]; logger.debug(__func() + 'obj: ' + - util.inspect(obj, { depth: null })); + util.inspect(obj, { depth: null })); logger.debug(__func() + 'attr: ' + util.inspect( this._pkcs11GetAttributeValue(pkcs11, pkcs11Session, obj, - objectTemplate))); + objectTemplate))); objs.push(obj); obj = pkcs11.C_FindObjects(pkcs11Session); } @@ -771,13 +771,13 @@ var CryptoSuite_PKCS11 = class extends api.CryptoSuite { opts.algorithm = 'ECDSA'; } if (typeof opts === 'undefined' || opts === null || - typeof opts.algorithm === 'undefined' || opts.algorithm === null || - typeof opts.algorithm !== 'string') + typeof opts.algorithm === 'undefined' || opts.algorithm === null || + typeof opts.algorithm !== 'string') return Promise.reject(Error(__func() + - 'opts.algorithm must be String type')); + 'opts.algorithm must be String type')); var token = (opts.ephemeral !== 'undefined' && - opts.ephemeral === false) ? true : false; + opts.ephemeral === false) ? true : false; var self = this; switch (opts.algorithm.toUpperCase()) { @@ -840,7 +840,7 @@ var CryptoSuite_PKCS11 = class extends api.CryptoSuite { var hit = this._skiToKey[ski.toString('hex')]; if (hit !== undefined) { logger.debug(__func() + 'cache hit ' + - util.inspect(hit, { depth: null })); + util.inspect(hit, { depth: null })); return Promise.resolve(hit); } if (typeof ski == 'string') { @@ -876,12 +876,12 @@ var CryptoSuite_PKCS11 = class extends api.CryptoSuite { attr.ecparams.toString('hex'). toUpperCase()]; if (keySize === undefined || - keySize != self._keySize) { + keySize != self._keySize) { throw new Error(__func() + 'key size mismatch, class: ' + self._keySize + ', ski: ' + keySize); } key = new ecdsaKey({ ski: ski, ecpt: attr.ecpt, - pub: handle.publicKey, - priv: handle.privateKey }, + pub: handle.publicKey, + priv: handle.privateKey }, self._keySize); } /* @@ -905,11 +905,11 @@ var CryptoSuite_PKCS11 = class extends api.CryptoSuite { */ sign(key, digest, opts) { if (typeof key === 'undefined' || key === null || - !(key instanceof ecdsaKey) || !key.isPrivate()) + !(key instanceof ecdsaKey) || !key.isPrivate()) throw new Error(__func() + 'key must be PKCS11_ECDSA_KEY type private key'); if (typeof digest === 'undefined' || digest === null || - !(digest instanceof Buffer)) + !(digest instanceof Buffer)) throw new Error(__func() + 'digest must be Buffer type'); return this._pkcs11Sign(this._pkcs11, this._pkcs11Session, key, digest); @@ -921,13 +921,13 @@ var CryptoSuite_PKCS11 = class extends api.CryptoSuite { */ verify(key, signature, digest) { if (typeof key === 'undefined' || key === null || - !(key instanceof ecdsaKey || key instanceof ECDSAKey)) + !(key instanceof ecdsaKey || key instanceof ECDSAKey)) throw new Error(__func() + 'key must be PKCS11_ECDSA_KEY type or ECDSA_KEY type'); if (typeof signature === 'undefined' || signature === null || - !(signature instanceof Buffer)) + !(signature instanceof Buffer)) throw new Error(__func() + 'signature must be Buffer type'); if (typeof digest === 'undefined' || digest === null || - !(digest instanceof Buffer)) + !(digest instanceof Buffer)) throw new Error(__func() + 'digest must be Buffer type'); if (key instanceof ECDSAKey) { @@ -949,7 +949,7 @@ var CryptoSuite_PKCS11 = class extends api.CryptoSuite { if (typeof key === 'undefined' || key === null || !(key instanceof aesKey)) throw new Error(__func() + 'key must be PKCS11_AES_KEY type'); if (typeof plainText === 'undefined' || plainText === null || - !(plainText instanceof Buffer)) + !(plainText instanceof Buffer)) throw new Error(__func() + 'plainText must be Buffer type'); return this._pkcs11Encrypt(this._pkcs11, this._pkcs11Session, key, @@ -965,7 +965,7 @@ var CryptoSuite_PKCS11 = class extends api.CryptoSuite { if (typeof key === 'undefined' || key === null || !(key instanceof aesKey)) throw new Error(__func() + 'key must be PKCS11_AES_KEY type'); if (typeof cipherText === 'undefined' || cipherText === null || - !(cipherText instanceof Buffer)) + !(cipherText instanceof Buffer)) throw new Error(__func() + 'cipherText must be Buffer type'); return this._pkcs11Decrypt(this._pkcs11, this._pkcs11Session, key, @@ -992,19 +992,19 @@ var CryptoSuite_PKCS11 = class extends api.CryptoSuite { if (typeof raw === 'undefined' || raw === null || !(raw instanceof Buffer || typeof raw === 'string')) return Promise.reject(Error(__func() + 'raw must be Buffer type or String type')); if (typeof opts === 'undefined' || opts === null || - typeof opts.algorithm === 'undefined' || opts.algorithm === null || - typeof opts.algorithm !== 'string') + typeof opts.algorithm === 'undefined' || opts.algorithm === null || + typeof opts.algorithm !== 'string') return Promise.reject(Error(__func() + - 'opts.algorithm must be String type')); + 'opts.algorithm must be String type')); var token = (typeof opts.ephemeral !== 'undefined' && - opts.ephemeral) ? false : true; + opts.ephemeral) ? false : true; var self = this; switch (opts.algorithm.toUpperCase()) { case 'X509CERTIFICATE': var key = KEYUTIL.getKey(raw); - var theKey = new ECDSAKey(key); + var theKey = new ECDSAKey(key); if (token) { return Promise.resolve(theKey); } else { @@ -1033,10 +1033,10 @@ var CryptoSuite_PKCS11 = class extends api.CryptoSuite { }); case 'ECDSA': return Promise.reject(Error(__func() + - 'ECDSA key not yet supported')); + 'ECDSA key not yet supported')); default: return Promise.reject(Error(__func() + - 'only AES or ECDSA key supported')); + 'only AES or ECDSA key supported')); } } diff --git a/fabric-client/lib/utils.js b/fabric-client/lib/utils.js index 14c20468b0..e3f75422c3 100644 --- a/fabric-client/lib/utils.js +++ b/fabric-client/lib/utils.js @@ -547,4 +547,4 @@ module.exports.convertToLong = function(value) { } return result; -} +}; diff --git a/test/integration/e2e/install-chaincode.js b/test/integration/e2e/install-chaincode.js index 9fb67e1e0e..3f5f6d01f7 100644 --- a/test/integration/e2e/install-chaincode.js +++ b/test/integration/e2e/install-chaincode.js @@ -28,7 +28,7 @@ var test = _test(tape); var e2eUtils = require('./e2eUtils.js'); var testUtil = require('../../unit/util.js'); -var version = 'v0' +var version = 'v0'; test('\n\n***** End-to-end flow: chaincode install *****\n\n', (t) => { testUtil.setupChaincodeDeploy(); diff --git a/test/integration/fabric-ca-affiliation-service-tests.js b/test/integration/fabric-ca-affiliation-service-tests.js index 1e2e2fcd2a..46737d7ef8 100644 --- a/test/integration/fabric-ca-affiliation-service-tests.js +++ b/test/integration/fabric-ca-affiliation-service-tests.js @@ -58,7 +58,7 @@ test('\n\n ** HFCAIdentityService Test **\n\n', (t) => { ORGS = FabricCAServices.getConfigSetting('test-network'); let fabricCAEndpoint = ORGS[userOrg].ca.url; - + FabricCAServices.getConfigSetting('crypto-keysize', '256'); //force for gulp test FabricCAServices.setConfigSetting('crypto-hash-algo', 'SHA2'); //force for gulp test @@ -85,7 +85,7 @@ test('\n\n ** HFCAIdentityService Test **\n\n', (t) => { const forceUpdatedAffiliation = { name: 'org4', force: true, - } + }; // If there are any child affiliations or any identities are associated with // this affiliation or child affiliations, force causes these identities and @@ -148,7 +148,7 @@ test('\n\n ** HFCAIdentityService Test **\n\n', (t) => { return affiliationService.update('org3', forceUpdatedAffiliation, admin); }).then((resp) => { checkResponse(resp, forceUpdatedAffiliation.name, t); - t.pass(`Successfully force updated affiliation 'org3' to 'org4', now check all its children have been updated too`); + t.pass('Successfully force updated affiliation \'org3\' to \'org4\', now check all its children have been updated too'); return affiliationService.getAll(admin); }).then((resp) => { @@ -156,7 +156,7 @@ test('\n\n ** HFCAIdentityService Test **\n\n', (t) => { const org4 = resp.result.affiliations.find((affiliation) => affiliation.name === 'org4'); checkExist(org4, 'org4.department1', t); checkNotExist(resp.result, 'org3', t); - t.pass(`After force update, 'org3' has been renamed to 'org4', 'org3.department1' has been renamed to 'org4.department1'`); + t.pass('After force update, \'org3\' has been renamed to \'org4\', \'org3.department1\' has been renamed to \'org4.department1\''); return affiliationService.delete(updatedAffiliation, admin); }).then((resp) => { @@ -172,7 +172,7 @@ test('\n\n ** HFCAIdentityService Test **\n\n', (t) => { }).then((resp) => { t.equal(resp.success, true); checkNotExist(resp.result, 'org4', t); - t.pass(`After force delete, 'org4' and all its child affiliations are deleted`); + t.pass('After force delete, \'org4\' and all its child affiliations are deleted'); t.end(); }) diff --git a/test/integration/network-config.js b/test/integration/network-config.js index 4406354300..827c0ddbc8 100644 --- a/test/integration/network-config.js +++ b/test/integration/network-config.js @@ -431,7 +431,7 @@ test('\n\n***** use the connection profile file *****\n\n', function(t) { ' message:' + proposal_response.response.message); } else { t.fail('transaction response was unknown' ); - logger.error('transaction response was unknown %s', proposal_response) + logger.error('transaction response was unknown %s', proposal_response); } } all_good = all_good & one_good; diff --git a/test/unit/channel-event-hub.js b/test/unit/channel-event-hub.js index 257b2ae300..bfc60083e6 100644 --- a/test/unit/channel-event-hub.js +++ b/test/unit/channel-event-hub.js @@ -171,7 +171,7 @@ test('\n\n** ChannelEventHub tests\n\n', (t) => { if(converted.equals(Long.fromValue(1))) { t.pass('Successfully utils.convertToLong strings to long'); } else { - t.fail('utils.convertToLong did not work for strings') + t.fail('utils.convertToLong did not work for strings'); } t.throws( @@ -202,33 +202,33 @@ test('\n\n** ChannelEventHub tests\n\n', (t) => { if(converted.equals(Long.fromValue(1))) { t.pass('Successfully utils.convertToLong integer to long'); } else { - t.fail('utils.convertToLong did not work for integer') + t.fail('utils.convertToLong did not work for integer'); } - let some_long = Long.fromValue(2) + let some_long = Long.fromValue(2); converted = utils.convertToLong(some_long); if(converted.equals(Long.fromValue(2))) { t.pass('Successfully utils.convertToLong a long'); } else { - t.fail('utils.convertToLong did not work for long') + t.fail('utils.convertToLong did not work for long'); } - some_long = Long.fromValue(0) + some_long = Long.fromValue(0); converted = utils.convertToLong(some_long); if(converted.equals(Long.fromValue(0))) { t.pass('Successfully utils.convertToLong a long'); } else { - t.fail('utils.convertToLong did not work for long') + t.fail('utils.convertToLong did not work for long'); } - some_long = Long.fromValue('0') + some_long = Long.fromValue('0'); converted = utils.convertToLong(some_long); if(converted.equals(Long.fromValue(0))) { t.pass('Successfully utils.convertToLong a long'); } else { - t.fail('utils.convertToLong did not work for long') + t.fail('utils.convertToLong did not work for long'); } t.end(); @@ -292,7 +292,7 @@ test('\n\n** ChannelEventHub block callback with replay \n\n', (t) => { t.fail('Failed if the block event with a replay is registered after another block event'); } catch(error) { if(error.toString().indexOf('Only one event registration is allowed')) { - t.pass('Should not be able to register for more than one with replay') + t.pass('Should not be able to register for more than one with replay'); } else { t.fail('Should have gotten the only one event registration error ::'+error.toString()); } @@ -312,7 +312,7 @@ test('\n\n** ChannelEventHub block callback with replay \n\n', (t) => { ); t.pass('Successfully registered a playback block event'); } catch(error) { - t.fail( 'Failed - Should be able to register with replay') + t.fail( 'Failed - Should be able to register with replay'); } t.equal(index, 2, 'Check the first block listener is at index 2'); @@ -391,7 +391,7 @@ test('\n\n** ChannelEventHub transaction callback with replay \n\n', (t) => { t.fail('Failed if the transaction event with a replay is registered after another transaction event'); } catch(error) { if(error.toString().indexOf('Only one event registration is allowed')) { - t.pass('Should not be able to register for more than one with replay') + t.pass('Should not be able to register for more than one with replay'); } else { t.fail('Should have gotten the only one event registration error ::'+error.toString()); } @@ -411,7 +411,7 @@ test('\n\n** ChannelEventHub transaction callback with replay \n\n', (t) => { ); t.pass('Successfully registered a playback transaction event'); } catch(error) { - t.fail( 'Failed - Should be able to register with replay') + t.fail( 'Failed - Should be able to register with replay'); } t.equal(Object.keys(eh._transactionRegistrations).length, 1, 'Check the size of the transactionOnEvents'); @@ -508,7 +508,7 @@ test('\n\n** ChannelEventHub chaincode callback with replay \n\n', (t) => { t.fail('Failed if the chaincode event with a replay is registered after another chaincode event'); } catch(error) { if(error.toString().indexOf('Only one event registration is allowed')) { - t.pass('Should not be able to register for more than one with replay') + t.pass('Should not be able to register for more than one with replay'); } else { t.fail('Should have gotten the only one event registration error ::'+error.toString()); } @@ -528,7 +528,7 @@ test('\n\n** ChannelEventHub chaincode callback with replay \n\n', (t) => { ); t.pass('Successfully registered a playback chaincode event'); } catch(error) { - t.fail( 'Failed - Should be able to register with replay') + t.fail( 'Failed - Should be able to register with replay'); } t.equal(Object.keys(eh._chaincodeRegistrants).length, 1, 'Check the size of the _chaincodeRegistrants'); @@ -752,7 +752,7 @@ test('\n\n** ChannelEventHub test connect failure on transaction registration \n event_hub = channel.newChannelEventHub(peer); event_hub.registerTxEvent('123', (tx_id, code) => { - t.fail('Failed callback should not have been called - tx test 2') + t.fail('Failed callback should not have been called - tx test 2'); t.end(); }, (error) => { @@ -799,7 +799,7 @@ test('\n\n** EventHub test reconnect on block registration \n\n', (t) => { t.doesNotThrow( () => { event_hub.registerBlockEvent((tx_id, code) => { - t.fail('Failed callback should not have been called - block test 1') + t.fail('Failed callback should not have been called - block test 1'); }); }, null, @@ -809,7 +809,7 @@ test('\n\n** EventHub test reconnect on block registration \n\n', (t) => { event_hub = channel.newChannelEventHub(peer); event_hub.registerBlockEvent( (tx_id, code) => { - t.fail('Failed callback should not have been called - block test 2') + t.fail('Failed callback should not have been called - block test 2'); t.end(); }, (error) =>{ diff --git a/test/unit/event-hub.js b/test/unit/event-hub.js index ac062691ce..a083abb103 100644 --- a/test/unit/event-hub.js +++ b/test/unit/event-hub.js @@ -525,7 +525,7 @@ test('\n\n** EventHub test actions when connect failures on transaction registra t.doesNotThrow( () => { event_hub.registerTxEvent('123', (tx_id, code) => { - t.fail('Failed callback should not have been called - tx test 1') + t.fail('Failed callback should not have been called - tx test 1'); }); }, null, @@ -540,7 +540,7 @@ test('\n\n** EventHub test actions when connect failures on transaction registra () => { event_hub.registerTxEvent('123', (tx_id, code) => { - t.fail('Failed callback should not have been called - tx test 2') + t.fail('Failed callback should not have been called - tx test 2'); }, (error) =>{ if(error.toString().indexOf('Connect Failed')) { @@ -569,7 +569,7 @@ test('\n\n** EventHub test actions when connect failures on transaction registra t.throws( () => { event_hub.registerTxEvent('123', (tx_id, code) => { - t.fail('Failed callback should not have been called - tx test 3') + t.fail('Failed callback should not have been called - tx test 3'); }); }, /The event hub has not been connected to the event source/, @@ -592,7 +592,7 @@ test('\n\n** EventHub test actions when connect failures on transaction registra () => { event_hub.registerTxEvent('123', (tx_id, code) => { - t.fail('Failed callback should not have been called - tx test 4') + t.fail('Failed callback should not have been called - tx test 4'); }, (error) =>{ if(error.toString().indexOf('Connect Failed')) { @@ -640,7 +640,7 @@ test('\n\n** EventHub test actions when connect failures on block registration \ t.doesNotThrow( () => { event_hub.registerBlockEvent((tx_id, code) => { - t.fail('Failed callback should not have been called - block test 1') + t.fail('Failed callback should not have been called - block test 1'); }); }, null, @@ -655,7 +655,7 @@ test('\n\n** EventHub test actions when connect failures on block registration \ () => { event_hub.registerBlockEvent( (tx_id, code) => { - t.fail('Failed callback should not have been called - block test 2') + t.fail('Failed callback should not have been called - block test 2'); }, (error) =>{ if(error.toString().indexOf('Connect Failed')) { @@ -684,7 +684,7 @@ test('\n\n** EventHub test actions when connect failures on block registration \ t.throws( () => { event_hub.registerBlockEvent((tx_id, code) => { - t.fail('Failed callback should not have been called - block test 3') + t.fail('Failed callback should not have been called - block test 3'); }); }, /The event hub has not been connected to the event source/, @@ -707,7 +707,7 @@ test('\n\n** EventHub test actions when connect failures on block registration \ () => { event_hub.registerBlockEvent( (tx_id, code) => { - t.fail('Failed callback should not have been called - block test 4') + t.fail('Failed callback should not have been called - block test 4'); }, (error) =>{ if(error.toString().indexOf('Connect Failed')) { @@ -755,7 +755,7 @@ test('\n\n** EventHub test actions when connect failures on chaincode registrati t.doesNotThrow( () => { event_hub.registerChaincodeEvent('123', 'event', (tx_id, code) => { - t.fail('Failed callback should not have been called - chaincode test 1') + t.fail('Failed callback should not have been called - chaincode test 1'); }); }, null, @@ -770,7 +770,7 @@ test('\n\n** EventHub test actions when connect failures on chaincode registrati () => { event_hub.registerChaincodeEvent('123', 'event', (tx_id, code) => { - t.fail('Failed callback should not have been called - chaincode test 2') + t.fail('Failed callback should not have been called - chaincode test 2'); }, (error) =>{ if(error.toString().indexOf('Connect Failed')) { @@ -799,7 +799,7 @@ test('\n\n** EventHub test actions when connect failures on chaincode registrati t.throws( () => { event_hub.registerChaincodeEvent('123', 'event', (tx_id, code) => { - t.fail('Failed callback should not have been called - chaincode test 3') + t.fail('Failed callback should not have been called - chaincode test 3'); }); }, /The event hub has not been connected to the event source/, @@ -822,7 +822,7 @@ test('\n\n** EventHub test actions when connect failures on chaincode registrati () => { event_hub.registerChaincodeEvent('123', 'event', (tx_id, code) => { - t.fail('Failed callback should not have been called - chaincode test 4') + t.fail('Failed callback should not have been called - chaincode test 4'); }, (error) =>{ if(error.toString().indexOf('Connect Failed')) { diff --git a/test/unit/fabric-ca-client.js b/test/unit/fabric-ca-client.js index a473bb912b..47d39485b7 100644 --- a/test/unit/fabric-ca-client.js +++ b/test/unit/fabric-ca-client.js @@ -273,7 +273,7 @@ test('FabricCAServices: Test newCryptoKeyStore() function', function(t) { test('FabricCAServices: Test optional constructor', function(t) { let opts = { url : 'http://localhost:7054' - } + }; t.doesNotThrow( function () { diff --git a/test/unit/network-config.js b/test/unit/network-config.js index b488cd7e69..a26ecbf072 100644 --- a/test/unit/network-config.js +++ b/test/unit/network-config.js @@ -128,7 +128,7 @@ test.skip('\n\n ** configuration testing **\n\n', function (t) { t.equals('grpcs://localhost:8051', peers[0].getUrl(), ' Check to see if we got the right peer for org2 that is endorsing and on the channel'); client.loadFromConfig('test/fixtures/org1.yaml'); peers = client.getPeersForOrgOnChannel(['mychannel2']); - t.equals(1, peers.length, 'Check to see that we got 1 peer') + t.equals(1, peers.length, 'Check to see that we got 1 peer'); t.equals('grpcs://localhost:7051', peers[0].getUrl(), ' Check to see if we got the right peer for org1 that is endorsing and on the channel'); peers = client.getPeersForOrgOnChannel([]); t.equals(0, peers.length, ' Check to see that we got no peers'); @@ -136,13 +136,13 @@ test.skip('\n\n ** configuration testing **\n\n', function (t) { t.equals(1, peers.length, ' Check to see that we got 1 peer'); t.equals('grpcs://localhost:7051', peers[0].getUrl(), ' Check to see if we got the right peer for org1 that is endorsing and on the channel'); - var client2 = Client.loadFromConfig('test/fixtures/network2.yaml') - client2.loadFromConfig('test/fixtures/org1.yaml') - t.equals(client2.getPeersForOrg().length, 3, ' Check to see that we got 3 peers for Org1') - t.equals(client2.getPeersForOrgOnChannel(['mychannel3']).length, 2, ' Check to see that we got 2 peers for Org2 on "mychannel3"') - client2.loadFromConfig('test/fixtures/org2.yaml') - t.equals(client2.getPeersForOrg().length, 1, ' Check to see that we got 1 peer for Org2') - t.equals(client2.getPeersForOrgOnChannel(['mychannel3']).length, 1, ' Check to see that we got 1 peers for Org2 on "mychannel3"') + var client2 = Client.loadFromConfig('test/fixtures/network2.yaml'); + client2.loadFromConfig('test/fixtures/org1.yaml'); + t.equals(client2.getPeersForOrg().length, 3, ' Check to see that we got 3 peers for Org1'); + t.equals(client2.getPeersForOrgOnChannel(['mychannel3']).length, 2, ' Check to see that we got 2 peers for Org2 on "mychannel3"'); + client2.loadFromConfig('test/fixtures/org2.yaml'); + t.equals(client2.getPeersForOrg().length, 1, ' Check to see that we got 1 peer for Org2'); + t.equals(client2.getPeersForOrgOnChannel(['mychannel3']).length, 1, ' Check to see that we got 1 peers for Org2 on "mychannel3"'); let opts = {somesetting : 4}; client._network_config.addTimeout(opts,1); diff --git a/test/unit/packager.js b/test/unit/packager.js index 4365885c9b..13b357df4f 100644 --- a/test/unit/packager.js +++ b/test/unit/packager.js @@ -96,19 +96,19 @@ function check(data, checkFcn) { checkFcn(); resolve(); }); - }) + }); } test('\n\n** Node.js Packager tests **\n\n', function(t) { Packager.package(testutil.NODE_CHAINCODE_PATH, 'node', true) .then((data) => { t.equal(data, null, 'Should return null when packaging for dev mode'); - return Packager.package('blah', 'node', false); - }).then((data)=>{ + return Packager.package('blah', 'node', false); + }).then((data)=>{ t.fail('Packager.package() should have rejected a call that does not have valid chaincodePath parameter'); t.end(); - },(err)=>{ - let msg = 'ENOENT: no such file or directory'; + },(err)=>{ + let msg = 'ENOENT: no such file or directory'; if (err.message.indexOf(msg) >= 0) { t.pass('Should throw error: ' + msg); } else { @@ -116,15 +116,15 @@ test('\n\n** Node.js Packager tests **\n\n', function(t) { t.end(); } - fs.removeSync(destDir); - fs.copySync(testutil.NODE_CHAINCODE_PATH, destDir); + fs.removeSync(destDir); + fs.copySync(testutil.NODE_CHAINCODE_PATH, destDir); - fs.outputFileSync(path.join(destDir, '.npmignore'), npmignore1); - fs.outputFileSync(path.join(destDir, 'node_modules/dummy/package.json'), 'dummy package.json content'); + fs.outputFileSync(path.join(destDir, '.npmignore'), npmignore1); + fs.outputFileSync(path.join(destDir, 'node_modules/dummy/package.json'), 'dummy package.json content'); - return Packager.package(destDir, 'node', false); + return Packager.package(destDir, 'node', false); - }).then((data) => { + }).then((data) => { return check(data, () => { let checkPath = path.join(targzDir, 'src', 'chaincode.js'); t.equal(fs.existsSync(checkPath), true, 'The tar.gz file produced by Packager.package() has the "src/chaincode.js" file'); diff --git a/test/unit/pkcs11.js b/test/unit/pkcs11.js index 6c57d15949..13d4ce8999 100644 --- a/test/unit/pkcs11.js +++ b/test/unit/pkcs11.js @@ -311,14 +311,14 @@ test('\n\n**PKCS11 - Test Client.createUser with existing PKCS11 key.\n\n', (t) client.setCryptoSuite(cryptoUtils); return client.createUser( { - username: "pkcs11user", - mspid: "pkcs11MSP", + username: 'pkcs11user', + mspid: 'pkcs11MSP', skipPersistence: true, cryptoContent: { privateKeyObj: pkcs11Key, - signedCertPEM: "-----BEGIN CERTIFICATE-----MIIB8TCCAZegAwIBAgIUasxwoRvBrGrdyg9+HtdJ3brpcuMwCgYIKoZIzj0EAwIwfzELMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBGcmFuY2lzY28xHzAdBgNVBAoTFkludGVybmV0IFdpZGdldHMsIEluYy4xDDAKBgNVBAsTA1dXVzEUMBIGA1UEAxMLZXhhbXBsZS5jb20wHhcNMTcwMTE5MTk1NjAwWhcNMTcxMjE5MDM1NjAwWjAQMQ4wDAYDVQQDEwVhZG1pbjBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABPHym/0MIKF/AehrshFR/bPsZOYLeTZOXx7sNYD19nhykv292TRkyBBkqjwabrU1JO4cxnzOne5mftA5wKbC4OCjYDBeMA4GA1UdDwEB/wQEAwICBDAMBgNVHRMBAf8EAjAAMB0GA1UdDgQWBBQtEfVCvKOzNSiTgpaWzaYVm6eaBzAfBgNVHSMEGDAWgBQXZ0I9qp6CP8TFHZ9bw5nRtZxIEDAKBggqhkjOPQQDAgNIADBFAiEAvGd5YDIBeQZWpP9wEHFmezvSCjrzy8VcvH/7Yuv3vcoCICy5ssNrEHEyWXqBqeKfU/zrPhHsWJFIaJEDQLRQE05l-----END CERTIFICATE-----" + signedCertPEM: '-----BEGIN CERTIFICATE-----MIIB8TCCAZegAwIBAgIUasxwoRvBrGrdyg9+HtdJ3brpcuMwCgYIKoZIzj0EAwIwfzELMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBGcmFuY2lzY28xHzAdBgNVBAoTFkludGVybmV0IFdpZGdldHMsIEluYy4xDDAKBgNVBAsTA1dXVzEUMBIGA1UEAxMLZXhhbXBsZS5jb20wHhcNMTcwMTE5MTk1NjAwWhcNMTcxMjE5MDM1NjAwWjAQMQ4wDAYDVQQDEwVhZG1pbjBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABPHym/0MIKF/AehrshFR/bPsZOYLeTZOXx7sNYD19nhykv292TRkyBBkqjwabrU1JO4cxnzOne5mftA5wKbC4OCjYDBeMA4GA1UdDwEB/wQEAwICBDAMBgNVHRMBAf8EAjAAMB0GA1UdDgQWBBQtEfVCvKOzNSiTgpaWzaYVm6eaBzAfBgNVHSMEGDAWgBQXZ0I9qp6CP8TFHZ9bw5nRtZxIEDAKBggqhkjOPQQDAgNIADBFAiEAvGd5YDIBeQZWpP9wEHFmezvSCjrzy8VcvH/7Yuv3vcoCICy5ssNrEHEyWXqBqeKfU/zrPhHsWJFIaJEDQLRQE05l-----END CERTIFICATE-----' } - }); + }); }) .then((user) => { if (user) { diff --git a/test/unit/util.js b/test/unit/util.js index 073c925924..598aa03bf3 100644 --- a/test/unit/util.js +++ b/test/unit/util.js @@ -47,10 +47,10 @@ module.exports.NODE_CHAINCODE_UPGRADE_PATH_V2 = path.resolve(__dirname, '../fixt module.exports.NODE_END2END = { - channel: 'mychannel', - chaincodeId: 'e2enodecc', - chaincodeLanguage: 'node', - chaincodeVersion: 'v0' + channel: 'mychannel', + chaincodeId: 'e2enodecc', + chaincodeLanguage: 'node', + chaincodeVersion: 'v0' }; // all temporary files and directories are created under here