How to use the @hyperledger/caliper-core.CaliperUtils.checkDefined 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 / fabricNetwork.js View on Github external
if (CaliperUtils.checkProperty(cc, 'targetPeers')) {
            return new Set(cc.targetPeers);
        }

        // we need to gather the target peers from the channel's peer section
        // based on their provided functionality (endorsing and cc query)
        let results = new Set();
        let peers = this.network.channels[channel].peers;
        for (let key in peers) {
            if (!peers.hasOwnProperty(key)) {
                continue;
            }

            let peer = peers[key];
            // if only the peer name is present in the config, then it is a target based on the default values
            if (!CaliperUtils.checkDefined(peer)) {
                results.add(key.toString());
            }

            // the default value of 'endorsingPeer' is true, or it's explicitly set to true
            if (!CaliperUtils.checkProperty(peer, 'endorsingPeer') ||
                (CaliperUtils.checkProperty(peer, 'endorsingPeer') && peer.endorsingPeer)) {
                results.add(key.toString());
                continue;
            }

            // the default value of 'chaincodeQuery' is true, or it's explicitly set to true
            if (!CaliperUtils.checkProperty(peer, 'chaincodeQuery') ||
                (CaliperUtils.checkProperty(peer, 'chaincodeQuery') && peer.chaincodeQuery)) {
                results.add(key.toString());
            }
        }