How to use the @hyperledger/caliper-core.CaliperUtils.getLogger function in @hyperledger/caliper-core

To help you get started, we’ve selected a few @hyperledger/caliper-core 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 / caliper / packages / caliper-fabric / lib / fabric.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.
*/

'use strict';

const FabricClient = require('fabric-client');
let FabricNetworkAPI = require('fabric-network');
const {google, common} = require('fabric-protos');
const {BlockchainInterface, CaliperUtils, TxStatus, Version, ConfigUtil} = require('@hyperledger/caliper-core');
const logger = CaliperUtils.getLogger('adapters/fabric');

const FabricNetwork = require('./fabricNetwork.js');
const ConfigValidator = require('./configValidator.js');
const fs = require('fs');


//////////////////////
// TYPE DEFINITIONS //
//////////////////////

/**
 * @typedef {Object} EventSource
 *
 * @property {string[]} channel The list of channels this event source listens on. Only meaningful for Fabric v1.0.
 * @property {string} peer The name of the peer the event source connects to.
 * @property {EventHub|ChannelEventHub} eventHub The event hub object representing the connection.
github hyperledger / caliper / packages / caliper-fisco-bcos / lib / common.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.
*/

'use strict';

const isArray = require('isarray');
const path = require('path');
const fs = require('fs');
const CaliperUtils = require('@hyperledger/caliper-core').CaliperUtils;
const commLogger = CaliperUtils.getLogger('common.js');

const TxErrorEnum = {
    NoError: 0,
    SendRawTransactionError: 1
};
module.exports.TxErrorEnum = TxErrorEnum;

module.exports.findContractAddress = function(workspaceRoot, smartContracts, contractID) {
    if (!isArray(smartContracts)) {
        commLogger.error('smartContracts should be an array');
        return null;
    }

    let smartContract = smartContracts.find(smartContract => {
        return smartContract.id === contractID;
    });
github hyperledger / caliper / packages / caliper-sawtooth / lib / sawtooth.js View on Github external
* 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';

const { BlockchainInterface, CaliperUtils, TxStatus }= require('@hyperledger/caliper-core');
const logger = CaliperUtils.getLogger('sawtooth.js');

const BatchBuilderFactory = require('./batch/BatchBuilderFactory.js');

const { Stream } = require('sawtooth-sdk/messaging/stream');
const {
    Message,
    EventList,
    EventSubscription,
    ClientEventsSubscribeRequest,
    ClientEventsSubscribeResponse,
    ClientEventsUnsubscribeRequest,
    ClientEventsUnsubscribeResponse
} = require('sawtooth-sdk/protobuf');

const request = require('request-promise');
const _ = require('lodash');
github hyperledger / caliper / packages / caliper-composer / lib / composer_utils.js View on Github external
* 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';

const AdminConnection = require('composer-admin').AdminConnection;
const BusinessNetworkDefinition = require('composer-admin').BusinessNetworkDefinition;
const BusinessNetworkConnection = require('composer-client').BusinessNetworkConnection;
const IdCard = require('composer-common').IdCard;

const CaliperUtils= require('@hyperledger/caliper-core').CaliperUtils;
const logger = CaliperUtils.getLogger('composer_utils.js');
const fs = require('fs');
const path = require('path');
const childProcess = require('child_process');
const ora = require('ora');

/**
 * Run a command within a child process and return upon Promise completion. Promise will be rejected on error, or
 * non-zero return code.
 * @param {String} command The command to run
 * @return {Promise} The promise for the child process executing the passed command
 */
function runCommand(command) {

    return new Promise( (resolve, reject) => {

        let stderr = '';
github hyperledger / caliper / packages / caliper-fisco-bcos / lib / installSmartContract.js View on Github external
* 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';

const CaliperUtils = require('@hyperledger/caliper-core').CaliperUtils;
const isArray = require('isarray');
const fs = require('fs-extra');
const path = require('path');
const fiscoBcosApi = require('./fiscoBcosApi');
const assert = require('assert');
const commLogger = CaliperUtils.getLogger('installSmartContract.js');

module.exports.run = async function (fiscoBcosSettings, workspaceRoot) {
    const fiscoBcosConfig = fiscoBcosSettings.config;
    const account = fiscoBcosConfig.account;
    const privateKey = fiscoBcosConfig.privateKey;

    const networkConfig = fiscoBcosSettings.network;
    const smartContracts = fiscoBcosSettings.smartContracts;

    if (!isArray(smartContracts)) {
        throw new Error('No available configuration for smart contracts');
    }

    commLogger.info('Deploying smart contracts ...');

    for (let smartContract of smartContracts) {
github hyperledger / caliper / packages / caliper-samples / src / contract / sawtooth / smallbank / SmallBankBatchBuilder.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';

const CaliperUtils = require('@hyperledger/caliper-core').CaliperUtils;
const logger = CaliperUtils.getLogger('SmallBankBatchBuilder.js');
const BatchBuilder = require('@hyperledger/caliper-sawtooth').BatchBuilder;
const protosPath = '../src/contract/sawtooth/smallbank/protos/smallbank.proto';

/**
 * get the list of customer ids from the list of small bank transactions
 * @param {object} args list of small bank transactions
 * @returns {object} list of customer ids
 */
function getCustomerIds(args) {
    let cust_ids = [];
    //Based on the payload type get the customer ids
    switch(args.transaction_type) {
    case 'create_account':
    case 'deposit_checking':
    case 'write_check':
    case 'transact_savings':
github hyperledger / caliper / packages / caliper-fisco-bcos / lib / invokeSmartContract.js View on Github external
* 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';

const {
    CaliperUtils,
    TxStatus
} = require('@hyperledger/caliper-core');
const fiscoBcosApi = require('./fiscoBcosApi');
const { TxErrorEnum, findContractAddress } = require('./common');
const commLogger = CaliperUtils.getLogger('invokeSmartContract.js');

module.exports.run = async function (context, fiscoBcosSettings, contractID, fcn, args, workspaceRoot, readOnly = false) {
    let smartContracts = fiscoBcosSettings.smartContracts;
    let address = findContractAddress(workspaceRoot, smartContracts, contractID);
    if (address === null) {
        throw new Error(`Can't invoke smart contract ${contractID}`);
    }

    const networkConfig = fiscoBcosSettings.network;
    const account = fiscoBcosSettings.config.account;

    let invokeStatus = new TxStatus(account);
    invokeStatus.SetFlag(TxErrorEnum.NoError);
    let receipt = null;

    try {
github hyperledger / caliper / packages / caliper-cli / lib / benchmark / lib / runBenchmark.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';

const {CaliperEngine, CaliperUtils, ConfigUtil} = require('@hyperledger/caliper-core');
const logger = CaliperUtils.getLogger('CLI');
const path = require('path');
const fs = require('fs');
/**
 * Caliper benchmark Run command
 * @private
 */
class RunBenchmark {

    /**
    * Command process for run benchmark command
    * @param {string} argv argument list from caliper benchmark command
    */
    static async handler(argv) {
        let workspacePath = ConfigUtil.get(ConfigUtil.keys.Workspace);
        let benchmarkConfigPath = ConfigUtil.get(ConfigUtil.keys.BenchConfig);
        let networkConfigPath = ConfigUtil.get(ConfigUtil.keys.NetworkConfig);
github hyperledger / caliper / packages / caliper-fisco-bcos / lib / generateRawTransactions.js View on Github external
*
* 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';

const fs = require('fs');
const { CaliperUtils, TxStatus } = require('@hyperledger/caliper-core');
const { TxErrorEnum, findContractAddress } = require('./common');
const uuid = require('uuid/v4');
const fiscoBcosApi = require('./fiscoBcosApi');
const commLogger = CaliperUtils.getLogger('generateRawTransactions.js');

module.exports.run = async function (fiscoBcosSettings, workspaceRoot, context, contractID, arg, file) {
    if (context && context.engine) {
        context.engine.submitCallback(1);
    }

    let smartContracts = fiscoBcosSettings.smartContracts;
    let address = findContractAddress(workspaceRoot, smartContracts, contractID);
    let account = fiscoBcosSettings.config.account;
    let privateKey = fiscoBcosSettings.config.privateKey;
    let network = fiscoBcosSettings.network;
    let invokeStatus = new TxStatus(uuid());

    try {
        let fcn = null;
        let fcArgs = [];
github hyperledger / caliper / packages / caliper-burrow / lib / burrow.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.
*/

'use strict';

const fs = require('fs');
const monax = require('@monax/burrow');
const { BlockchainInterface, CaliperUtils, TxStatus } = require('@hyperledger/caliper-core');
const logger = CaliperUtils.getLogger('burrow.js');

/**
    Read the connection details from the config file.
    @param {object} config Adapter config.
    @param {string} workspace_root The absolute path to the root location for the configuration files.
    @return {object} url, account Connection settings.
*/
function burrowConnect(config, workspace_root) {
    let host = config.burrow.network.validator.host;
    if (host === null) {
        throw new Error('host url not set');
    }

    let port = config.burrow.network.validator.port;
    if (port === null) {
        throw new Error('grpc port not set');