How to use the @hyperledger/caliper-core.CaliperUtils 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-fisco-bcos / lib / fiscoBcosApi.js View on Github external
* Licensed under the Apache License, Version 2.0 (the "License");
* 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 fs = require('fs');
const path = require('path');
const childProcess = require('child_process');
const ora = require('ora');
const isArray = require('isarray');
const web3Sync = require('./web3lib/web3sync');
const channelPromise = require('./channelPromise');
const requestPromise = require('request-promise');
const assert = require('assert');
const events = require('events');
const commLogger = CaliperUtils.getLogger('fiscoBcosApi.js');

/**
 * Compile solidity contract locally
 * @param {String} contractPath Contract path
 * @param {String} outputDir Output directory
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-fabric / lib / fabricNetwork.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 fs = require('fs');
const CaliperUtils = require('@hyperledger/caliper-core').CaliperUtils;

/**
 * Utility class for accessing information in a Common Connection Profile configuration
 * (and the Caliper specific extensions) without relying on its structure.
 *
 * @property {object} network The loaded network configuration object.
 * @property {object} clientConfigs The map of client names to their client configuration objects.
 * @property {boolean} compatibilityMode Indicates whether the configuration describes a v1.0 Fabric network.
 * @property {boolean} tls Indicates whether TLS communication is configured for the network.
 * @property {boolean} mutualTls Indicates whether mutual TLS communication is configured for the network.
 * @property {Map} The mapping of contract IDs to chaincode details.
 */
class FabricNetwork {
    /**
     * Loads and verifies the Common Connection Profile settings.
     *
github hyperledger / caliper / packages / caliper-fisco-bcos / lib / installSmartContract.js View on Github external
* Licensed under the Apache License, Version 2.0 (the "License");
* 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 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)) {
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) => {
github hyperledger / caliper / packages / caliper-samples / src / contract / sawtooth / smallbank / SmallBankBatchBuilder.js View on Github external
* Licensed under the Apache License, Version 2.0 (the "License");
* 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':
github hyperledger / caliper / packages / caliper-sawtooth / lib / batch / BatchBuilderFactory.js View on Github external
* Licensed under the Apache License, Version 2.0 (the "License");
* 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;

/**
 * @abstract class has static method getBatchBuilder()
 * @returns {object} with specific builder instance.
 */
class BatchBuilderFactory {

    /**
     * static factory method which will return batch builder instance based on family name and
     * family version. This is dependent upon your configuration.
     * @param {string} familyName transaction family name
     * @param {string} familyVersion transaction family version
     * @param {object} config the configuration
     * @param {string} workspaceRoot the worksapce root
     * @returns {object} with specific builder instance.
     */