How to use the fabric-common.Utils.getLogger function in fabric-common

To help you get started, we’ve selected a few fabric-common 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 / discovery.js View on Github external
/**
 * Copyright 2018 IBM All Rights Reserved.
 *
 * SPDX-License-Identifier: Apache-2.0
 */
'use strict';

const {Utils:utils} = require('fabric-common');
const logger = utils.getLogger('DISCOVERY');

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

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

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

test('\n\n***** D I S C O V E R Y  *****\n\n', async (t) => {

	// this will use the connection profile to set up the client
	const client_org1 = await testUtil.getClientForOrg(t, 'org1');
	const client_org2 = await testUtil.getClientForOrg(t, 'org2');
	let channel_org1 = null;
github hyperledger / fabric-sdk-node / test / integration / nodechaincode / install-chaincode.js View on Github external
/**
 * Copyright 2017 IBM All Rights Reserved.
 *
 * SPDX-License-Identifier: Apache-2.0
 */

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

const {Utils:utils} = require('fabric-common');
const logger = utils.getLogger('E2E install-chaincode');

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

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

test('\n\n***** Node-Chaincode End-to-end flow: chaincode install *****\n\n', (t) => {
	e2eUtils.installChaincode('org1', testUtil.NODE_CHAINCODE_PATH, testUtil.METADATA_PATH, version, 'node', t, true)
		.then(() => {
			t.pass('Successfully installed chaincode in peers of organization "org1"');
			return e2eUtils.installChaincode('org2', testUtil.NODE_CHAINCODE_PATH, testUtil.METADATA_PATH, version, 'node', t, true);
		}, (err) => {
			t.fail('Failed to install chaincode in peers of organization "org1". ' + err.stack ? err.stack : err);
github hyperledger / fabric-sdk-node / test / integration / get-config.js View on Github external
/**
 * Copyright 2016 IBM All Rights Reserved.
 *
 * SPDX-License-Identifier: Apache-2.0
 */

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

const {Utils: utils} = require('fabric-common');
const logger = utils.getLogger('get-config');

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

const path = require('path');
const fs = require('fs');
const e2eUtils = require('./e2e/e2eUtils.js');

const Client = require('fabric-client');
const testUtil = require('./util.js');
const Peer = require('fabric-client/lib/Peer.js');
const Orderer = require('fabric-client/lib/Orderer.js');


const client = new Client();
github hyperledger / fabric-sdk-node / test / integration / only-admin.js View on Github external
/**
 * Copyright 2018 IBM All Rights Reserved.
 *
 * SPDX-License-Identifier: Apache-2.0
 */
'use strict';

const {Utils:utils} = require('fabric-common');
const logger = utils.getLogger('ONLY-ADMIN');

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

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

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

// Testing will demostrate how the connetion profile configuration may hold a
// admin user identity and it will be used for all fabric interactions.
// However since the network is using mutual TLS, the TLS connection will get
// valid certificates from the CertificateAuthority as a testing convenience.
// The CertificateAuthority will not be used to get the required signing certificates
// for the fabric requests.
github hyperledger / fabric-sdk-node / test / integration / query.js View on Github external
* Copyright 2017 IBM All Rights Reserved.
 *
 * SPDX-License-Identifier: Apache-2.0
 */

// 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';

const {Utils:utils} = require('fabric-common');
const logger = utils.getLogger('query');

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

const path = require('path');
const util = require('util');
const e2eUtils = require('./e2e/e2eUtils.js');
const fs = require('fs');

const testUtil = require('./util.js');
const Client = require('fabric-client');
const Peer = require('fabric-client/lib/Peer.js');
const Orderer = require('fabric-client/lib/Orderer.js');
const BlockDecoder = require('fabric-client/lib/BlockDecoder.js');
github hyperledger / fabric-sdk-node / fabric-client / lib / client-utils.js View on Github external
/**
 * Copyright 2018 IBM All Rights Reserved.
 *
 * SPDX-License-Identifier: Apache-2.0
 */

'use strict';

const settle = require('promise-settle');
const util = require('util');
const {Utils: utils} = require('fabric-common');
const logger = utils.getLogger('client-utils.js');

const fabprotos = require('fabric-protos');

/*
 * This function will build the proposal
 */
module.exports.buildProposal = (chaincodeSpec, header, transientMap) => {
	// construct the ChaincodeInvocationSpec
	const cciSpec = new fabprotos.protos.ChaincodeInvocationSpec();
	cciSpec.setChaincodeSpec(chaincodeSpec);

	const cc_payload = new fabprotos.protos.ChaincodeProposalPayload();
	cc_payload.setInput(cciSpec.toBuffer());

	if (typeof transientMap === 'object') {
		logger.debug('buildProposal - adding in transientMap %s', util.inspect(transientMap));
github hyperledger / fabric-sdk-node / test / unit / read-configtx.js View on Github external
/**
 * Copyright 2016 IBM All Rights Reserved.
 *
 * SPDX-License-Identifier: Apache-2.0
 */
'use strict';

if (global && global.hfc) {
	global.hfc.config = undefined;
}
require('nconf').reset();

const {Utils:utils} = require('fabric-common');
const logger = utils.getLogger('E2E create-channel');
const fs = require('fs');
const path = require('path');
const tape = require('tape');
const _test = require('tape-promise').default;
const test = _test(tape);

const Channel = require('fabric-client/lib/Channel.js');

const _commonProto   = require('fabric-protos').common;
const _configtxProto = require('fabric-protos').common;

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

test('\n\n***** READ in the genesis block *****\n\n', (t) => {
	testUtil.resetDefaults();
github hyperledger / fabric-sdk-node / test / integration / configtxlator.js View on Github external
* SPDX-License-Identifier: Apache-2.0
 */
'use strict';

/*
 *   This test case requires that the 'configtxlator' tool be running locally and on port 7059
 *   see:
 *   https://hyperledger-fabric.readthedocs.io/en/latest/commands/configtxlator.html
 *
 *   This test case also requires two node packages to make it easier to make REST calls to
 *   the 'configtxlator'
 *        superagent
 *        superagent-promise
 */
const {Utils:utils} = require('fabric-common');
const logger = utils.getLogger('configinator');

const tape = require('tape');
const _test = require('tape-promise').default;
const test = _test(tape);
const superagent = require('superagent');
const agent = require('superagent-promise')(require('superagent'), Promise);
const requester = require('request');

const Client = require('fabric-client');
const fs = require('fs');
const path = require('path');

const testUtil = require('../unit/util.js');
const e2eUtils = require('./e2e/e2eUtils.js');
github hyperledger / fabric-sdk-node / fabric-ca-client / lib / CertificateService.js View on Github external
/**
 * Copyright 2018 Zhao Chaoyi All Rights Reserved.
 *
 * SPDX-License-Identifier: Apache-2.0
 */

const querystring = require('querystring');
const {Utils} = require('fabric-common');

const logger = Utils.getLogger('CertificateService');
const checkRegistrar = require('./helper').checkRegistrar;

class CertificateService {
	constructor(client) {
		if (!client) {
			throw new Error('Missing Required Argument client');
		}
		this.client = client;
	}

	/**
	 * @typedef {Object} GetCertificatesRequest
	 * @property {string} id The enrollment ID that uniquely identifies an identity
	 * @property {string} aki Authority Key Identifier string, hex encoded, for the specific certificate
	 * @property {string} serial The serial number for a certificate
	 * @property {string} revoked_start Get revoked certificates starting at the specified time,
github hyperledger / fabric-sdk-node / fabric-client / lib / TransactionID.js View on Github external
/*
 Copyright 2017, 2018 IBM All Rights Reserved.

 SPDX-License-Identifier: Apache-2.0

*/

'use strict';


const {Utils: utils, HashPrimitives, User} = require('fabric-common');
const logger = utils.getLogger('TransactionID.js');

/**
 * The class representing the transaction identifier. Provides for
 * automatically creating the `nonce` value when an instance of this
 * object is created.
 *
 * @class
 */
class TransactionID {

	/**
	 * Builds a new transaction Id based on a user's certificate and an automatically
	 * generates a nonce value.
	 * @param {Identity} signer_or_userContext - An instance of {@link Identity} that provides an unique
	 *                 base for this transaction id. This also may be an instance of a {@User}.
	 * @param {boolean} admin - Indicates that this instance will be used for administrative  transactions.