Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test('\n\n ** Logging utility tests - test setting an invalid external logger **\n\n', function (t) {
// construct an invalid logger
var logger = {
inf: function () { console.log('info'); },
};
try {
hfc.setLogger(logger);
t.fail('Should not have allowed an invalid logger to be set');
t.end();
} catch (err) {
var er1 = err.toString();
if (er1.indexOf('debug()') > 0 &&
er1.indexOf('info()') > 0 &&
er1.indexOf('warn()') > 0 &&
er1.indexOf('error()') > 0) {
t.pass('Successfully tested thrown error for an invalid logger to set on the HFC SDK');
t.end();
} else {
t.fail('Failed to catch all errors for an invalid logger missing required methods');
t.end();
}
}
});
test('\n\n ** Logging utility tests - test setting an invalid external logger **\n\n', (t) => {
console.log(' ***** logger.js - test external *****'); // eslint-disable-line
// construct an invalid logger
const logger = {
inf: function () {
t.comment('info');
},
};
try {
hfc.setLogger(logger);
t.fail('Should not have allowed an invalid logger to be set');
t.end();
} catch (err) {
const er1 = err.toString();
if (er1.indexOf('debug()') > 0 &&
er1.indexOf('info()') > 0 &&
er1.indexOf('warn()') > 0 &&
er1.indexOf('error()') > 0) {
t.pass('Successfully tested thrown error for an invalid logger to set on the HFC SDK');
t.end();
} else {
t.fail('Failed to catch all errors for an invalid logger missing required methods');
t.end();
}
}
});
test('\n\n ** Logging utility tests - test setting an external logger based on log4js **\n\n', (t) => {
console.log(' ***** logger.js - test log4js *****'); // eslint-disable-line
const logger = log4js.getLogger();
logger.level = 'info'; // Set level in order to output logs because by default it is OFF
hfc.setLogger(logger);
testLogger(t, true);
t.end();
});
// in a happy-path scenario
'use strict';
process.env.HFC_LOGGING = '{"debug": "console"}';
var tape = require('tape');
var _test = require('tape-promise');
var test = _test(tape);
var log4js = require('log4js');
var logger = log4js.getLogger('E2E');
logger.setLevel('DEBUG');
var path = require('path');
var hfc = require('fabric-client');
hfc.setLogger(logger);
var util = require('util');
var testUtil = require('../unit/util.js');
var utils = require('fabric-client/lib/utils.js');
var Peer = require('fabric-client/lib/Peer.js');
var Orderer = require('fabric-client/lib/Orderer.js');
var EventHub = require('fabric-client/lib/EventHub.js');
var chaincode_id = 'end2end';
var chaincode_version = 'v0';
var chain_id = 'testchainid';
var client = new hfc();
var chain = client.newChain(chain_id);
var tx_id = null;
* node pte-execRequest.js pid Nid uiFile tStart
* - action: deploy, invoke, query
* - recurrence: integer number
*/
// This is an end-to-end test that focuses on exercising all parts of the fabric APIs
// in a happy-path scenario
'use strict';
var log4js = require('log4js');
var logger = log4js.getLogger('E2E');
logger.setLevel('ERROR');
var path = require('path');
var hfc = require('fabric-client');
hfc.setLogger(logger);
var fs = require('fs');
var grpc = require('grpc');
var util = require('util');
var testUtil = require('./pte-util.js');
var utils = require('fabric-client/lib/utils.js');
var Peer = require('fabric-client/lib/Peer.js');
var Orderer = require('fabric-client/lib/Orderer.js');
var EventHub = require('fabric-client/lib/EventHub.js');
var FabricCAServices = require('fabric-ca-client/lib/FabricCAClientImpl');
var FabricCAClient = FabricCAServices.FabricCAClient;
var User = require('fabric-client/lib/User.js');
var Client = require('fabric-client/lib/Client.js');
var _commonProto = grpc.load(path.join(__dirname, 'node_modules/fabric-client/lib/protos/common/common.proto')).common;
const crypto = require('crypto');
'use strict';
var log4js = require('log4js');
var logger = log4js.getLogger('Helper');
logger.setLevel('DEBUG');
var path = require('path');
var util = require('util');
var fs = require('fs-extra');
var User = require('fabric-client/lib/User.js');
var crypto = require('crypto');
var FabricCAService = require('fabric-ca-client');
var config = require('../config.json');
var hfc = require('fabric-client');
hfc.addConfigFile(path.join(__dirname, 'network-config.json'));
hfc.setLogger(logger);
var ORGS = hfc.getConfigSetting('network-config');
var clients = {};
var channels = {};
var caClients = {};
// set up the client and channel objects for each org
for (let key in ORGS) {
if (key.indexOf('org') === 0) {
let client = new hfc();
let cryptoSuite = hfc.newCryptoSuite();
cryptoSuite.setCryptoKeyStore(hfc.newCryptoKeyStore({ path: getKeyStoreForOrg(ORGS[key].name) }));
client.setCryptoSuite(cryptoSuite);
channels[key] = {};
for (let index in config.channelsList) {
var path = require('path');
var util = require('util');
var fs = require('fs-extra');
var User = require('fabric-client/lib/User.js');
var crypto = require('crypto');
var FabricCAService = require('fabric-ca-client');
var config = require('../config.json');
var hfc = require('fabric-client');
if(config.enableTls){
hfc.addConfigFile(path.join(__dirname, 'network-config-tls.json'));
}else{
hfc.addConfigFile(path.join(__dirname, 'network-config.json'));
}
hfc.setLogger(logger);
var ORGS = hfc.getConfigSetting('network-config');
var clients = {};
var channels = {};
var caClients = {};
// set up the client and channel objects for each org
for (let key in ORGS) {
if (key.indexOf('org') === 0) {
let client = new hfc();
let cryptoSuite = hfc.newCryptoSuite();
cryptoSuite.setCryptoKeyStore(hfc.newCryptoKeyStore({path: getKeyStoreForOrg(ORGS[key].name)}));
client.setCryptoSuite(cryptoSuite);
channels[key] = {};
for (let index in config.channelsList) {
'use strict';
var log4js = require('log4js');
var logger = log4js.getLogger('Helper');
logger.setLevel('DEBUG');
var path = require('path');
var util = require('util');
var fs = require('fs-extra');
var User = require('fabric-client/lib/User.js');
var crypto = require('crypto');
var copService = require('fabric-ca-client');
var config = require('../config.json');
var hfc = require('fabric-client');
hfc.addConfigFile(path.join(__dirname, 'network-config.json'));
hfc.setLogger(logger);
var ORGS = hfc.getConfigSetting('network-config');
var clients = {};
var channels = {};
var caClients = {};
// set up the client and channel objects for each org
for (let key in ORGS) {
if (key.indexOf('org') === 0) {
let client = new hfc();
let cryptoSuite = hfc.newCryptoSuite();
cryptoSuite.setCryptoKeyStore(hfc.newCryptoKeyStore({path: getKeyStoreForOrg(ORGS[key].name)}));
client.setCryptoSuite(cryptoSuite);
let channel = client.newChannel(config.channelName);
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';
var tape = require('tape');
var _test = require('tape-promise');
var test = _test(tape);
var log4js = require('log4js');
var logger = log4js.getLogger('E2E');
logger.setLevel('DEBUG');
var Client = require('fabric-client');
Client.setLogger(logger);
var Peer = require('fabric-client/lib/Peer');
var copService = require('fabric-ca-client');
var util = require('util');
var fs = require('fs');
var testUtil = require('../unit/util.js');
var utils = require('fabric-client/lib/utils.js');
var keyValStorePath = testUtil.KVS;
var chaincode_id = 'endorsertest';
var chaincode_version = 'endorser-v0';
var chain_id = 'testchainid';
var tx_id = null;
var nonce = null;
var the_user = null;
testUtil.setupChaincodeDeploy();
test('\n\n ** Logging utility tests - test setting an external logger based on log4js **\n\n', function (t) {
var logger = log4js.getLogger();
hfc.setLogger(logger);
testLogger(t, true);
t.end();
});