@hyperledger/caliper-fabric
Advanced tools
Comparing version 0.4.0-unstable-20200629163850 to 0.4.0-unstable-20200630112425
@@ -134,3 +134,3 @@ /* | ||
ConfigValidator.validateChannel(config.channels[channel], orderers, peers, mspIds, takenContractIds, flowOptions, discovery); | ||
takenContractIds.push(config.channels[channel].chaincodes.map(cc => cc.contractID || cc.id)); | ||
takenContractIds.push(config.channels[channel].contracts.map(cc => cc.contractID || cc.id)); | ||
} catch (err) { | ||
@@ -320,3 +320,3 @@ throw new Error(`Invalid "${channel}" channel configuration: ${err.message}`); | ||
// leave this embedded, so the validation error messages are more meaningful | ||
chaincodes: j.array().sparse(false).items(j.object().keys({ | ||
contracts: j.array().sparse(false).items(j.object().keys({ | ||
id: j.string().min(1).required(), | ||
@@ -338,3 +338,3 @@ version: j.string().min(1).required(), | ||
targetPeers: j.array().sparse(false).min(1).unique().items(j.string().valid(validPeers)).optional() | ||
}) // constraints for the chaincode properties | ||
}) // constraints for the contract properties | ||
.with('metadataPath', 'path') // if metadataPath is provided, installation needs the path | ||
@@ -348,3 +348,3 @@ .with('path', 'language') // if path is provided, installation needs the language | ||
.with('endorsement-policy', 'language') | ||
).unique(contractIdComparator).required() // for the chaincodes collection | ||
).unique(contractIdComparator).required() // for the contracts collection | ||
}); | ||
@@ -351,0 +351,0 @@ |
@@ -42,21 +42,21 @@ /* | ||
/** | ||
* @typedef {Object} ChaincodeInvokeSettings | ||
* @typedef {Object} ContractInvokeSettings | ||
* | ||
* @property {string} chaincodeId Required. The name/ID of the chaincode whose function | ||
* @property {string} contractId Required. The name/ID of the contract whose function | ||
* should be invoked. | ||
* @property {string} chaincodeVersion Required. The version of the chaincode whose function | ||
* @property {string} contractVersion Required. The version of the contract whose function | ||
* should be invoked. | ||
* @property {string} chaincodeFunction Required. The name of the function that should be | ||
* invoked in the chaincode. | ||
* @property {string[]} chaincodeArguments Optional. The list of {string} arguments that should | ||
* be passed to the chaincode. | ||
* @property {string} contractFunction Required. The name of the function that should be | ||
* invoked in the contract. | ||
* @property {string[]} contractArguments Optional. The list of {string} arguments that should | ||
* be passed to the contract. | ||
* @property {Map<string, Buffer>} transientMap Optional. The transient map that should be | ||
* passed to the chaincode. | ||
* passed to the contract. | ||
* @property {string} invokerIdentity Required. The name of the client who should invoke the | ||
* chaincode. If an admin is needed, use the organization name prefixed with a # symbol. | ||
* @property {string} channel Required. The name of the channel whose chaincode should be invoked. | ||
* contract. If an admin is needed, use the organization name prefixed with a # symbol. | ||
* @property {string} channel Required. The name of the channel whose contract should be invoked. | ||
* @property {string[]} targetPeers Optional. An array of endorsing | ||
* peer names as the targets of the invoke. When this | ||
* parameter is omitted the target list will include the endorsing peers assigned | ||
* to the target chaincode, or if it is also omitted, to the channel. | ||
* to the target contract, or if it is also omitted, to the channel. | ||
* @property {string} orderer Optional. The name of the orderer to whom the request should | ||
@@ -67,21 +67,21 @@ * be submitted. If omitted, then the first orderer node of the channel will be used. | ||
/** | ||
* @typedef {Object} ChaincodeQuerySettings | ||
* @typedef {Object} ContractQuerySettings | ||
* | ||
* @property {string} chaincodeId Required. The name/ID of the chaincode whose function | ||
* @property {string} contractId Required. The name/ID of the contract whose function | ||
* should be invoked. | ||
* @property {string} chaincodeVersion Required. The version of the chaincode whose function | ||
* @property {string} contractVersion Required. The version of the contract whose function | ||
* should be invoked. | ||
* @property {string} chaincodeFunction Required. The name of the function that should be | ||
* invoked in the chaincode. | ||
* @property {string[]} chaincodeArguments Optional. The list of {string} arguments that should | ||
* be passed to the chaincode. | ||
* @property {string} contractFunction Required. The name of the function that should be | ||
* invoked in the contract. | ||
* @property {string[]} contractArguments Optional. The list of {string} arguments that should | ||
* be passed to the contract. | ||
* @property {Map<string, Buffer>} transientMap Optional. The transient map that should be | ||
* passed to the chaincode. | ||
* passed to the contract. | ||
* @property {string} invokerIdentity Required. The name of the client who should invoke the | ||
* chaincode. If an admin is needed, use the organization name prefixed with a # symbol. | ||
* @property {string} channel Required. The name of the channel whose chaincode should be invoked. | ||
* contract. If an admin is needed, use the organization name prefixed with a # symbol. | ||
* @property {string} channel Required. The name of the channel whose contract should be invoked. | ||
* @property {string[]} targetPeers Optional. An array of endorsing | ||
* peer names as the targets of the invoke. When this | ||
* parameter is omitted the target list will include the endorsing peers assigned | ||
* to the target chaincode, or if it is also omitted, to the channel. | ||
* to the target contract, or if it is also omitted, to the channel. | ||
* @property {boolean} countAsLoad Optional. Indicates whether to count this query as workload. | ||
@@ -326,7 +326,7 @@ */ | ||
const network = await gateway.getNetwork(channel); | ||
// Work on all chaincodes/smart contracts in the channel | ||
const chaincodes = this.networkUtil.getChaincodesOfChannel(channel); | ||
for (const chaincode of chaincodes) { | ||
const contract = await network.getContract(chaincode.id); | ||
contractMap.set(chaincode.id, contract); | ||
// Work on all contracts/smart contracts in the channel | ||
const contracts = this.networkUtil.getContractsOfChannel(channel); | ||
for (const contract of contracts) { | ||
const networkContract = await network.getContract(contract.id); | ||
contractMap.set(contract.id, networkContract); | ||
} | ||
@@ -423,3 +423,3 @@ } | ||
* @param {object} context The context previously created by the Fabric adapter. | ||
* @param {ChaincodeInvokeSettings} invokeSettings The settings associated with the transaction submission. | ||
* @param {ContractInvokeSettings} invokeSettings The settings associated with the transaction submission. | ||
* @param {boolean} isSubmit boolean flag to indicate if the transaction is a submit or evaluate | ||
@@ -432,6 +432,6 @@ * @return {Promise<TxStatus>} The result and stats of the transaction invocation. | ||
// Retrieve the existing contract and a client | ||
const smartContract = await this._getUserContract(invokeSettings.invokerIdentity, invokeSettings.chaincodeId); | ||
const smartContract = await this._getUserContract(invokeSettings.invokerIdentity, invokeSettings.contractId); | ||
// Create a transaction | ||
const transaction = smartContract.createTransaction(invokeSettings.chaincodeFunction); | ||
const transaction = smartContract.createTransaction(invokeSettings.contractFunction); | ||
@@ -472,3 +472,3 @@ // Build the Caliper TxStatus, this is a reduced item when compared to the low level API capabilities | ||
invokeStatus.Set('request_type', 'transaction'); | ||
result = await transaction.submit(...invokeSettings.chaincodeArguments); | ||
result = await transaction.submit(...invokeSettings.contractArguments); | ||
} else { | ||
@@ -480,3 +480,3 @@ const countAsLoad = invokeSettings.countAsLoad === undefined ? this.configCountQueryAsLoad : invokeSettings.countAsLoad; | ||
invokeStatus.Set('request_type', 'query'); | ||
result = await transaction.evaluate(...invokeSettings.chaincodeArguments); | ||
result = await transaction.evaluate(...invokeSettings.contractArguments); | ||
} | ||
@@ -489,3 +489,3 @@ invokeStatus.result = result; | ||
} catch (err) { | ||
logger.error(`Failed to perform ${isSubmit ? 'submit' : 'query' } transaction [${invokeSettings.chaincodeFunction}] using arguments [${invokeSettings.chaincodeArguments}], with error: ${err.stack ? err.stack : err}`); | ||
logger.error(`Failed to perform ${isSubmit ? 'submit' : 'query' } transaction [${invokeSettings.contractFunction}] using arguments [${invokeSettings.contractArguments}], with error: ${err.stack ? err.stack : err}`); | ||
invokeStatus.SetStatusFail(); | ||
@@ -574,3 +574,3 @@ invokeStatus.result = []; | ||
/** | ||
* Initializes the Fabric adapter: sets up clients, admins, registrars, channels and chaincodes. | ||
* Initializes the Fabric adapter: sets up clients, admins, registrars, channels and contracts. | ||
* @param {boolean} workerInit unused | ||
@@ -589,3 +589,3 @@ * @async | ||
/** | ||
* Installs and initializes the specified chaincodes. | ||
* Installs and initializes the specified contracts. | ||
* @async | ||
@@ -598,8 +598,8 @@ */ | ||
/** | ||
* Invokes the specified chaincode according to the provided settings. | ||
* Invokes the specified contract according to the provided settings. | ||
* | ||
* @param {object} context The context previously created by the Fabric adapter. | ||
* @param {string} contractID The unique contract ID of the target chaincode. | ||
* @param {string} contractID The unique contract ID of the target contract. | ||
* @param {string} contractVersion Unused. | ||
* @param {ChaincodeInvokeSettings|ChaincodeInvokeSettings[]} invokeSettings The settings (collection) associated with the (batch of) transactions to submit. | ||
* @param {ContractInvokeSettings|ContractInvokeSettings[]} invokeSettings The settings (collection) associated with the (batch of) transactions to submit. | ||
* @param {number} timeout The timeout override for the whole transaction life-cycle in seconds. | ||
@@ -625,4 +625,4 @@ * @return {Promise<TxStatus[]>} The result and stats of the transaction invocation. | ||
settings.channel = contractDetails.channel; | ||
settings.chaincodeId = contractDetails.id; | ||
settings.chaincodeVersion = contractDetails.version; | ||
settings.contractId = contractDetails.id; | ||
settings.contractVersion = contractDetails.version; | ||
@@ -640,8 +640,8 @@ if (!settings.invokerIdentity) { | ||
/** | ||
* Queries the specified chaincode according to the provided settings. | ||
* Queries the specified contract according to the provided settings. | ||
* | ||
* @param {object} context The context previously created by the Fabric adapter. | ||
* @param {string} contractID The unique contract ID of the target chaincode. | ||
* @param {string} contractID The unique contract ID of the target contract. | ||
* @param {string} contractVersion Unused. | ||
* @param {ChaincodeQuerySettings|ChaincodeQuerySettings[]} querySettings The settings (collection) associated with the (batch of) query to submit. | ||
* @param {ContractQuerySettings|ContractQuerySettings[]} querySettings The settings (collection) associated with the (batch of) query to submit. | ||
* @param {number} timeout Unused - timeouts are set using globally defined values in the gateway construction phase. | ||
@@ -667,4 +667,4 @@ * @return {Promise<TxStatus[]>} The result and stats of the transaction query. | ||
settings.channel = contractDetails.channel; | ||
settings.chaincodeId = contractDetails.id; | ||
settings.chaincodeVersion = contractDetails.version; | ||
settings.contractId = contractDetails.id; | ||
settings.contractVersion = contractDetails.version; | ||
@@ -671,0 +671,0 @@ if (!settings.invokerIdentity) { |
@@ -102,3 +102,3 @@ /* | ||
/** | ||
* Initializes the Fabric adapter and configures the SUT: sets up clients, admins, registrars, channels and chaincodes. | ||
* Initializes the Fabric adapter and configures the SUT: sets up clients, admins, registrars, channels and contracts. | ||
* @param {boolean} workerInit Indicates whether the initialization happens in the worker process. | ||
@@ -112,3 +112,3 @@ * @async | ||
/** | ||
* Installs and initializes the specified chaincodes. | ||
* Installs and initializes the specified contracts. | ||
* @async | ||
@@ -121,8 +121,8 @@ */ | ||
/** | ||
* Invokes the specified chaincode according to the provided settings. | ||
* Invokes the specified contract according to the provided settings. | ||
* | ||
* @param {object} context The context previously created by the Fabric adapter. | ||
* @param {string} contractID The unique contract ID of the target chaincode. | ||
* @param {string} contractID The unique contract ID of the target contract. | ||
* @param {string} contractVersion Unused. | ||
* @param {ChaincodeInvokeSettings|ChaincodeInvokeSettings[]} invokeSettings The settings (collection) associated with the (batch of) transactions to submit. | ||
* @param {ContractInvokeSettings|ContractInvokeSettings[]} invokeSettings The settings (collection) associated with the (batch of) transactions to submit. | ||
* @param {number} timeout The timeout for the whole transaction life-cycle in seconds. | ||
@@ -136,8 +136,8 @@ * @return {Promise<TxStatus[]>} The result and stats of the transaction invocation. | ||
/** | ||
* Queries the specified chaincode according to the provided settings. | ||
* Queries the specified contract according to the provided settings. | ||
* | ||
* @param {object} context The context previously created by the Fabric adapter. | ||
* @param {string} contractID The unique contract ID of the target chaincode. | ||
* @param {string} contractID The unique contract ID of the target contract. | ||
* @param {string} contractVersion Unused. | ||
* @param {ChaincodeQuerySettings|ChaincodeQuerySettings[]} querySettings The settings (collection) associated with the (batch of) query to submit. | ||
* @param {ContractQuerySettings|ContractQuerySettings[]} querySettings The settings (collection) associated with the (batch of) query to submit. | ||
* @param {number} timeout The timeout for the call in seconds. | ||
@@ -144,0 +144,0 @@ * @return {Promise<TxStatus[]>} The result and stats of the transaction query. |
@@ -29,3 +29,3 @@ /* | ||
* @property {boolean} mutualTls Indicates whether mutual TLS communication is configured for the network. | ||
* @property {Map<string, {channel:string, id:string, version:string}>} The mapping of contract IDs to chaincode details. | ||
* @property {Map<string, {channel:string, id:string, version:string}>} The mapping of contract IDs to contract details. | ||
*/ | ||
@@ -102,3 +102,3 @@ class FabricNetwork { | ||
for (const cc of cObj.chaincodes) { | ||
for (const cc of cObj.contracts) { | ||
if (!cc.contractID) { | ||
@@ -327,8 +327,8 @@ cc.contractID = cc.id; | ||
/** | ||
* Gets the chaincode names and versions belonging to the given channel. | ||
* Gets the contract names and versions belonging to the given channel. | ||
* @param {string} channel The channel name. | ||
* @returns {Set<{id: string, version: string}>} The set of chaincode names. | ||
* @returns {Set<{id: string, version: string}>} The set of contract names. | ||
*/ | ||
getChaincodesOfChannel(channel) { | ||
return new Set(this.network.channels[channel].chaincodes.map(cc => { | ||
getContractsOfChannel(channel) { | ||
return new Set(this.network.channels[channel].contracts.map(cc => { | ||
return { | ||
@@ -481,10 +481,10 @@ id: cc.id, | ||
/** | ||
* Constructs an N-of-N endorsement policy for the given chaincode of the given channel. | ||
* Constructs an N-of-N endorsement policy for the given contract of the given channel. | ||
* @param {string} channel The name of the channel. | ||
* @param {{id: string, version: string}} chaincodeInfo The chaincode name and version. | ||
* @param {{id: string, version: string}} contractInfo The contract name and version. | ||
* @return {object} The assembled endorsement policy. | ||
* @private | ||
*/ | ||
getDefaultEndorsementPolicy(channel, chaincodeInfo) { | ||
const targetPeers = this.getTargetPeersOfChaincodeOfChannel(chaincodeInfo, channel); | ||
getDefaultEndorsementPolicy(channel, contractInfo) { | ||
const targetPeers = this.getTargetPeersOfContractOfChannel(contractInfo, channel); | ||
const targetOrgs = new Set(); | ||
@@ -799,12 +799,12 @@ | ||
/** | ||
* Gets the peer names on which the given chaincode of the given channel should be installed and instantiated. | ||
* @param {{id: string, version: string}} chaincodeInfo The chaincode name and version. | ||
* Gets the peer names on which the given contract of the given channel should be installed and instantiated. | ||
* @param {{id: string, version: string}} contractInfo The contract name and version. | ||
* @param {string} channel The channel name. | ||
* @returns {Set<string>} The set of peer names. | ||
*/ | ||
getTargetPeersOfChaincodeOfChannel(chaincodeInfo, channel) { | ||
const cc = this.network.channels[channel].chaincodes.find( | ||
cc => cc.id === chaincodeInfo.id && cc.version === chaincodeInfo.version); | ||
getTargetPeersOfContractOfChannel(contractInfo, channel) { | ||
const cc = this.network.channels[channel].contracts.find( | ||
cc => cc.id === contractInfo.id && cc.version === contractInfo.version); | ||
CaliperUtils.assertDefined(cc, `Could not find the following chaincode in the configuration: ${chaincodeInfo.id}@${chaincodeInfo.version}`); | ||
CaliperUtils.assertDefined(cc, `Could not find the following contract in the configuration: ${contractInfo.id}@${contractInfo.version}`); | ||
// targets are explicitly defined | ||
@@ -872,4 +872,4 @@ if (CaliperUtils.checkProperty(cc, 'targetPeers')) { | ||
/** | ||
* Gets the transient map for the given chaincode for the given channel. | ||
* @param {{id: string, version: string}} chaincode The chaincode name and version. | ||
* Gets the transient map for the given contract for the given channel. | ||
* @param {{id: string, version: string}} contract The contract name and version. | ||
* @param {string} channel The channel name. | ||
@@ -879,6 +879,6 @@ * | ||
*/ | ||
getTransientMapOfChaincodeOfChannel(chaincode, channel) { | ||
getTransientMapOfContractOfChannel(contract, channel) { | ||
const map = {}; | ||
const cc = this.network.channels[channel].chaincodes.find( | ||
cc => cc.id === chaincode.id && cc.version === chaincode.version); | ||
const cc = this.network.channels[channel].contracts.find( | ||
cc => cc.id === contract.id && cc.version === contract.version); | ||
@@ -885,0 +885,0 @@ if (!CaliperUtils.checkProperty(cc, 'initTransientMap')) { |
{ | ||
"name": "@hyperledger/caliper-fabric", | ||
"description": "Hyperledger Fabric connector for Caliper, enabling the running of performance benchmarks that interact with Fabric", | ||
"version": "0.4.0-unstable-20200629163850", | ||
"version": "0.4.0-unstable-20200630112425", | ||
"repository": { | ||
@@ -26,3 +26,3 @@ "type": "git", | ||
"@hapi/joi": "^15.1.1", | ||
"@hyperledger/caliper-core": "0.4.0-unstable-20200629163850", | ||
"@hyperledger/caliper-core": "0.4.0-unstable-20200630112425", | ||
"semver": "7.1.1" | ||
@@ -29,0 +29,0 @@ }, |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
399184
+ Added@hyperledger/caliper-core@0.4.0-unstable-20200630112425(transitive)
- Removed@hyperledger/caliper-core@0.4.0-unstable-20200629163850(transitive)
Updated@hyperledger/caliper-core@0.4.0-unstable-20200630112425