How to use the fabric-client.addConfigFile 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 / e2e / update-channel.js View on Github external
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();

	var caRootsPath = ORGS.orderer.tls_cacerts;
	let data = fs.readFileSync(path.join(__dirname, caRootsPath));
	let caroots = Buffer.from(data).toString();

	var orderer = client.newOrderer(
		ORGS.orderer.url,
		{
			'pem': caroots,
github hyperledger / fabric-sdk-node / test / integration / e2e / create-channel.js View on Github external
test('\n\n***** SDK Built config update create flow *****\n\n', async (t) => {
	testUtil.resetDefaults();
	Client.addConfigFile(path.join(__dirname, './config.json'));
	const ORGS = Client.getConfigSetting('test-network');

	const client = new Client();

	const caRootsPath = ORGS.orderer.tls_cacerts;
	const data = fs.readFileSync(path.join(__dirname, caRootsPath));
	const caroots = Buffer.from(data).toString();

	const signatures = [];

	// Acting as a client in org1 when creating the channel
	const org = ORGS.org1.name;

	utils.setConfigSetting('key-value-store', 'fabric-common/lib/impl/FileKeyValueStore.js');

	const tlsInfo = await e2eUtils.tlsEnroll('org1');
github hyperledger / composer-tools / packages / fabric-dev-servers / fabric-scripts / hlfv1-node / hlfv1 / join-channel.js View on Github external
let tx_id = null;
let nonce = null;
let keystore = homedir() + '/.hfc-key-store';

let channel = 'mychannel';

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

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

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

/**
 * join channel
 * @param {any} org org
 * @returns {Promise} promise
 */
function joinChannel(org) {
    console.log(util.format('Calling peers in organization "%s" to join the channel'));

    //
    // Create and configure the test chain
    //
    let client = new hfc();
    let chain = client.newChain(channel);
github hyperledger / fabric-sdk-node / examples / balance-transfer / app / invoke-transaction.js View on Github external
*  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 path = require('path');
var fs = require('fs');
var util = require('util');
var hfc = require('fabric-client');
var Peer = require('fabric-client/lib/Peer.js');
var config = require('../config.json');
var helper = require('./helper.js');
var logger = helper.getLogger('invoke-chaincode');
var EventHub = require('fabric-client/lib/EventHub.js');
hfc.addConfigFile(path.join(__dirname, 'network-config.json'));
var ORGS = hfc.getConfigSetting('network-config');

var invokeChaincode = function(peersUrls, channelName, chaincodeName, fcn, args, username, org) {
	logger.debug(util.format('\n============ invoke transaction on organization %s ============\n', org));
	var client = helper.getClientForOrg(org);
	var channel = helper.getChannelForOrg(org);
	var targets = helper.newPeers(peersUrls);
	var tx_id = null;

	return helper.getRegisteredUsers(username, org).then((user) => {
		tx_id = client.newTransactionID();
		logger.debug(util.format('Sending transaction "%j"', tx_id));
		// send proposal to endorser
		var request = {
			targets: targets,
			chaincodeId: chaincodeName,
github hyperledger / fabric-sdk-node / test / integration / e2e / e2eUtils.js View on Github external
function init() {
	if (!ORGS) {
		Client.addConfigFile(path.join(__dirname, './config.json'));
		ORGS = Client.getConfigSetting('test-network');
	}
}
github hyperledger / fabric-sdk-node / test / integration / invoke.js View on Github external
function init() {
	if (!ORGS) {
		Client.addConfigFile(path.join(__dirname, 'e2e', './config.json'));
		ORGS = Client.getConfigSetting('test-network');
	}

	for (const key in ORGS) {
		if (Object.prototype.hasOwnProperty.call(ORGS, key) && typeof ORGS[key].peer1 !== 'undefined') {
			const data = fs.readFileSync(path.join(__dirname, 'e2e', ORGS[key].peer1.tls_cacerts));
			const org = ORGS[key].peer1;
			org.pem = Buffer.from(data).toString();
			peers.push(org);
		}
	}
}
github accordproject / concerto / packages / composer-systests / hlfv1 / create-channel.js View on Github external
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';

let client = new hfc();
let chain = client.newChain(channel);

if (useTls) {
    let caRootsPath = ORGS.orderer.tls_cacerts;
    let data = fs.readFileSync(path.join(__dirname, caRootsPath));
    //let data = fs.readFileSync(caRootsPath);

    let caroots = Buffer.from(data).toString();
github hyperledger / fabric-sdk-node / test / integration / query.js View on Github external
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;
var chain = client.newChain(chain_id);
hfc.addConfigFile(path.join(__dirname, 'e2e', 'config.json'));
var ORGS = hfc.getConfigSetting('test-network');
var org = 'org1';
var orgName = ORGS[org].name;

var e2e = testUtil.END2END;

var the_user = null;
var tx_id = null;

var nonce = null;

var querys = [];
if (process.argv.length > 2) {
	for (let i=2; i
github hyperledger-archives / caliper / src / fabric / e2eUtils.js View on Github external
function init(config_path) {
	Client.addConfigFile(config_path);
	ORGS = Client.getConfigSetting('fabric').network;
}
module.exports.init = init;