How to use the fabric-client/lib/utils.js.getLogger function in fabric-client

To help you get started, we’ve selected a few fabric-client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hyperledger / fabric-sdk-node / test / integration / token.js View on Github external
/**
 * Copyright 2019 IBM All Rights Reserved.
 *
 * SPDX-License-Identifier: Apache-2.0
 */

// This includes end-to-end tests for the fabtoken feature, both positive and negative.
'use strict';

const fs = require('fs');
const path = require('path');
const util = require('util');

const utils = require('fabric-client/lib/utils.js');
const tokenUtils = require('fabric-client/lib/token-utils.js');
const logger = utils.getLogger('E2E token');

const tape = require('tape');
const _test = require('tape-promise').default;
const test = _test(tape);

const testUtil = require('../unit/util.js');
const e2eUtils = require('./e2e/e2eUtils.js');

// The channel for token e2e tests which should be created and joined in setup tests
const channel_name = process.env.channel ? process.env.channel : 'tokenchannel';
const channel_path = path.join(__dirname, '../fixtures/crypto-material/config-v2', channel_name + '.tx');

// This setup test creates and joins the "tokenchannel"
test('\n\n***** setup: create and join the token channel  *****\n\n', async (t) => {
	// this will use the connection profile to set up the client
	const client_org1 = await testUtil.getClientForOrg(t, 'org1');
github hyperledger / fabric-sdk-node / test / integration / e2e / update-channel.js View on Github external
// 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 util = require('util');
var fs = require('fs');
var path = require('path');
var tape = require('tape');
var _test = require('tape-promise');
var test = _test(tape);
var e2eUtils = require('./e2eUtils.js');
var testUtil = require('../../unit/util.js');
var Client = require('fabric-client');
var utils = require('fabric-client/lib/utils.js');
var logger = utils.getLogger('End to End');

var the_user = null;

var ORGS;


test('\n\n***** U P D A T E C H A N N E L flow: update channel *****\n\n', (t) => {
	testUtil.resetDefaults();
	Client.addConfigFile(path.join(__dirname, './config.json'));
	ORGS = Client.getConfigSetting('test-network');

	//
	// Create and configure the test channel
	//
	var channel_name = 'mychannel';
	var client = new Client();
github hyperledger / fabric-sdk-node / test / integration / query.js View on Github external
*  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.
 */

// This is an end to end test that focuses on exercising all parts of the fabric APIs
// in a happy-path scenario

// IMPORTANT ------>>>>> MUST RUN e2e.js FIRST
// AND set environment variables indicated in the comments
// at the end of the invoke-transaction run.

'use strict';

var utils = require('fabric-client/lib/utils.js');
var logger = utils.getLogger('query');

var tape = require('tape');
var _test = require('tape-promise');
var test = _test(tape);

var path = require('path');
var util = require('util');
var fs = require('fs');

var testUtil = require('../unit/util.js');
var hfc = require('fabric-client');
var Peer = require('fabric-client/lib/Peer.js');
var Orderer = require('fabric-client/lib/Orderer.js');

var client = new hfc();
var chain_id = testUtil.END2END.channel;
github hyperledger / fabric-sdk-node / test / unit / headless-tests.js View on Github external
} else {
				t.fail('Can not create an empty file to prepare for the rest of this test. ' + err.stack ? err.stack : err);
				t.end();
			}
		}
	};

	let debugPath = '/tmp/hfc-log/debug.log';
	let errorPath = '/tmp/hfc-log/error.log';
	prepareEmptyFile(debugPath);
	prepareEmptyFile(errorPath);

	hfc.setConfigSetting('hfc-logging', util.format('{"debug": "%s", "error": "%s"}', debugPath, errorPath));
	// internal call. clearing the cached logger.
	global.hfc.logger = undefined;
	var log1 = utils.getLogger('testlogger');
	log1.error('Test logger - error');
	log1.warn('Test logger - warn');
	log1.info('Test logger - info');
	log1.debug('Test logger - debug');

	setTimeout(function () {
		var data = fs.readFileSync(debugPath);

		if (data.indexOf('Test logger - error') > 0 &&
			data.indexOf('Test logger - warn') > 0 &&
			data.indexOf('Test logger - info') > 0 &&
			data.indexOf('Test logger - debug') > 0) {
			t.pass('Successfully tested logging to debug file');
		} else {
			t.fail('Failed to validate content in debug log file');
		}
github hyperledger-archives / caliper / src / fabric / instantiate-chaincode.js View on Github external
*
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  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.
 */

// 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 utils = require('fabric-client/lib/utils.js');
var logger = utils.getLogger('E2E instantiate-chaincode');

var tape = require('tape');
var _test = require('tape-promise');
var test = _test(tape);

var e2eUtils = require('./e2eUtils.js');
var Client   = require('fabric-client')

module.exports.run = function (config_path) {
    Client.addConfigFile(config_path);
    var fabricSettings = Client.getConfigSetting('fabric');
    var policy         = fabricSettings['endorsement-policy'];  // TODO: support mulitple policies
    var chaincodes     = fabricSettings.chaincodes;
    if(typeof chaincodes === 'undefined' || chaincodes.length === 0) {
        return Promise.resolve();
    }
github dongmingh / v1performance / pte-main.js View on Github external
var Client = require('fabric-client/lib/Client.js');


utils.setConfigSetting('crypto-keysize', 256);

const child_process = require('child_process');

var webUser = null;
var tmp;
var i=0;
var procDone=0;

// input: userinput json file
var PTEid = parseInt(process.argv[5]);
var loggerMsg='PTE ' + PTEid + ' main';
var logger = utils.getLogger(loggerMsg);

var Nid = parseInt(process.argv[2]);
var uiFile = process.argv[3];
var tStart = parseInt(process.argv[4]);
logger.info('input parameters: Nid=%d, uiFile=%s, tStart=%d PTEid=%d', Nid, uiFile, tStart, PTEid);
var uiContent = JSON.parse(fs.readFileSync(uiFile));

var TLS=uiContent.TLS;
var channelID = uiContent.channelID;
var chaincode_id = uiContent.chaincodeID+channelID;
var chaincode_ver = uiContent.chaincodeVer;
logger.info('Nid: %d, chaincode_id: %s, chaincode_ver: %s', Nid, chaincode_id, chaincode_ver);

var channelOpt=uiContent.channelOpt;
var channelName=channelOpt.name;
var channelOrgName = [];
github dongmingh / v1performance / pte-util.js View on Github external
var fs = require('fs-extra');
var os = require('os');
var util = require('util');

var jsrsa = require('jsrsasign');
var KEYUTIL = jsrsa.KEYUTIL;

var hfc = require('fabric-client');
var copService = require('fabric-ca-client/lib/FabricCAClientImpl.js');
var User = require('fabric-client/lib/User.js');
var CryptoSuite = require('fabric-client/lib/impl/CryptoSuite_ECDSA_AES.js');
var KeyStore = require('fabric-client/lib/impl/CryptoKeyStore.js');
var ecdsaKey = require('fabric-client/lib/impl/ecdsa/key.js');
//var Constants = require('./constants.js');

var logger = require('fabric-client/lib/utils.js').getLogger('PTE util');

module.exports.CHAINCODE_PATH = 'github.com/example_cc';
module.exports.CHAINCODE_UPGRADE_PATH = 'github.com/example_cc1';
module.exports.CHAINCODE_MARBLES_PATH = 'github.com/marbles_cc';
module.exports.END2END = {
	channel: 'mychannel',
	chaincodeId: 'end2end',
	chaincodeVersion: 'v0'
};


// directory for file based KeyValueStore
module.exports.KVS = '/tmp/hfc-test-kvs';
module.exports.storePathForOrg = function(networkid, org) {
	return module.exports.KVS + '_' + networkid + '_' + org;
};
github hyperledger / fabric-sdk-node / test / unit / channel-config.js View on Github external
var rewire = require('rewire');

var tar = require('tar-fs');
var gunzip = require('gunzip-maybe');
var fs = require('fs-extra');
var grpc = require('grpc');

var Client = require('fabric-client');
var client = new Client();

var testutil = require('./util.js');
var ChannelConfig = rewire('fabric-client/lib/ChannelConfig.js');

testutil.resetDefaults();
var utils = require('fabric-client/lib/utils.js');
var logger = utils.getLogger('config-envelope-test');

var grpc = require('grpc');
var commonProto = grpc.load(__dirname + '/../../fabric-client/lib/protos/common/common.proto').common;
var configtxProto = grpc.load(__dirname + '/../../fabric-client/lib/protos/common/configtx.proto').common;

var TWO_ORG_MEMBERS_AND_ADMIN = [{
	role: {
		name: 'member',
		mspId: 'org1'
	}
}, {
	role: {
		name: 'member',
		mspId: 'org2'
	}
}, {
github hyperledger / composer-tools / packages / fabric-dev-servers / fabric-scripts / hlfv1-node / hlfv1 / create-channel.js View on Github external
* See the License for the specific language governing permissions and
 * limitations under the License.
 */

'use strict';

let hfc = require('fabric-client');
let path = require('path');
let fs = require('fs');

let testUtil = require('./setup-utils.js');
let utils = require('fabric-client/lib/utils.js');
let Orderer = require('fabric-client/lib/Orderer.js');
const homedir = require('homedir');

let logger = utils.getLogger('create-channel');


let useTls = (process.env.SYSTEST) ? process.env.SYSTEST.match('tls$') : false;

if (useTls) {
    console.log('using tls connection to create the channel');
    hfc.addConfigFile(path.join(__dirname, './config.tls.json'));
} else {
    console.log('using non-tls connection');
    hfc.addConfigFile(path.join(__dirname, './config.json'));
}
let ORGS = hfc.getConfigSetting('test-network');

//TODO: Need to make this configurable
let keystore = homedir() + '/.hfc-key-store';
let channel = 'mychannel';
github hyperledger-archives / caliper / src / fabric / e2eUtils.js View on Github external
* you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  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 utils = require('fabric-client/lib/utils.js');
var logger = utils.getLogger('E2E testing');

var path = require('path');
var fs = require('fs');
var util = require('util');

var Client = require('fabric-client');
var testUtil = require('./util.js');

var ORGS;
var rootPath = '../..'

var grpc = require('grpc');

var tx_id = null;
var the_user = null;