Skip to content

Commit

Permalink
Merge pull request hyperledger-caliper#122 from aklenik/update-worklo…
Browse files Browse the repository at this point in the history
…ad-modules

Update benchmark workload modules to v0.4.0
  • Loading branch information
aklenik authored Oct 6, 2020
2 parents 3b9648d + c82ab6f commit cbbc731
Show file tree
Hide file tree
Showing 37 changed files with 912 additions and 1,229 deletions.
8 changes: 6 additions & 2 deletions benchmarks/api/fabric/lib/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ module.exports.addBatchAssets = async function(bcObj, context, clientIdx, args,
}
}

await bcObj.invokeSmartContract('fixed-asset', undefined, myArgs, undefined, false);
myArgs.contractId = 'fixed-asset';
myArgs.readOnly = false;

await bcObj.sendRequests(myArgs);
} catch (err) {
console.error('Error: ', err);
throw err;
Expand Down Expand Up @@ -176,10 +179,11 @@ module.exports.addMixedBatchAssets = async function(bcObj, context, clientIdx, a
const batch = batches[index];
try {
const myArgs = {
contractId: 'fixed-asset',
contractFunction: 'createAssetsFromBatch',
contractArguments: [JSON.stringify(batch)]
};
await bcObj.invokeSmartContract('fixed-asset', undefined, myArgs, undefined, false);
await bcObj.sendRequests(myArgs);
} catch (err) {
console.error('Error: ', err);
throw err;
Expand Down
7 changes: 5 additions & 2 deletions benchmarks/samples/fabric/fabcar/changeCarOwner.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,18 @@ class ChangeCarOwnerWorkload extends WorkloadModuleBase {
let newCarOwner = owners[Math.floor(Math.random() * owners.length)];

let args = {
contractId: 'fabcar',
contractVersion: 'v1',
contractFunction: 'changeCarOwner',
contractArguments: [carNumber, newCarOwner]
contractArguments: [carNumber, newCarOwner],
timeout: 60
};

if (this.txIndex === this.roundArguments.assets) {
this.txIndex = 0;
}

return this.sutAdapter.invokeSmartContract('fabcar', 'v1', args, 60);
await this.sutAdapter.sendRequests(args);
}
}

Expand Down
7 changes: 5 additions & 2 deletions benchmarks/samples/fabric/fabcar/createCar.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,14 @@ class CreateCarWorkload extends WorkloadModuleBase {
let carOwner = owners[Math.floor(Math.random() * owners.length)];

let args = {
contractId: 'fabcar',
contractVersion: 'v1',
contractFunction: 'createCar',
contractArguments: [carNumber, carMake, carModel, carColor, carOwner]
contractArguments: [carNumber, carMake, carModel, carColor, carOwner],
timeout: 30
};

return this.sutAdapter.invokeSmartContract('fabcar', 'v1', args, 30);
await this.sutAdapter.sendRequests(args);
}
}

Expand Down
7 changes: 5 additions & 2 deletions benchmarks/samples/fabric/fabcar/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@ module.exports.createCar = async function (bc, contx, args, color, make, model,
owner = owners[Math.floor(Math.random() * owners.length)];

let myArgs = {
contractId: 'fabcar',
contractVersion: 'v1',
contractFunction: 'createCar',
contractArguments: [carNumber, make, model, color, owner]
contractArguments: [carNumber, make, model, color, owner],
timeout: 30
};

await bc.invokeSmartContract('fabcar', 'v1', myArgs, 30);
await bc.sendRequests(myArgs);
}

};
8 changes: 6 additions & 2 deletions benchmarks/samples/fabric/fabcar/queryAllCars.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,15 @@ class QueryAllCarsWorkload extends WorkloadModuleBase {
*/
async submitTransaction() {
let args = {
contractId: 'fabcar',
contractVersion: 'v1',
contractFunction: 'queryAllCars',
contractArguments: [this.startingKey, this.endingKey]
contractArguments: [this.startingKey, this.endingKey],
timeout: 60,
readOnly: true
};

return this.sutAdapter.querySmartContract('fabcar', 'v1', args, 60)
await this.sutAdapter.sendRequests(args);
}
}

Expand Down
8 changes: 6 additions & 2 deletions benchmarks/samples/fabric/fabcar/queryCar.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,19 @@ class QueryCarWorkload extends WorkloadModuleBase {
let carNumber = 'Client' + this.workerIndex + '_CAR' + this.txIndex.toString();

let args = {
contractId: 'fabcar',
contractVersion: 'v1',
contractFunction: 'queryCar',
contractArguments: [carNumber]
contractArguments: [carNumber],
timeout: 30,
readOnly: true
};

if (this.txIndex === this.limitIndex) {
this.txIndex = 0;
}

return this.sutAdapter.querySmartContract('fabcar', 'v1', args, 30);
await this.sutAdapter.sendRequests(args);
}
}

Expand Down
24 changes: 8 additions & 16 deletions benchmarks/samples/fabric/marbles/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,15 @@ class InitWorkload extends WorkloadModuleBase {
let marbleSize = (((this.txIndex % 10) + 1) * 10).toString(); // [10, 100]
let marbleOwner = owners[this.txIndex % owners.length];

let args;
if (this.sutAdapter.getType() === 'fabric') {
args = {
contractFunction: 'initMarble',
contractArguments: [marbleName, marbleColor, marbleSize, marbleOwner],
};
} else {
args = {
verb: 'initMarble',
name: marbleName,
color: marbleColor,
size: marbleSize,
owner: marbleOwner
};
}
const args = {
contractId: 'marbles',
contractVersion: 'v1',
contractFunction: 'initMarble',
contractArguments: [marbleName, marbleColor, marbleSize, marbleOwner],
timeout: 30
};

return this.sutAdapter.invokeSmartContract('marbles', 'v1', args, 30);
await this.sutAdapter.sendRequests(args);
}
}

Expand Down
25 changes: 10 additions & 15 deletions benchmarks/samples/fabric/marbles/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,16 @@ class QueryWorkload extends WorkloadModuleBase {
async submitTransaction() {
this.txIndex++;
let marbleOwner = owners[this.txIndex % owners.length];
let args;

if (this.sutAdapter.getType() === 'fabric') {
args = {
contractFunction: 'queryMarblesByOwner',
contractArguments: [marbleOwner]
};
} else {
args = {
verb: 'queryMarblesByOwner',
owner: marbleOwner
};
}

return this.sutAdapter.querySmartContract('marbles', 'v1', args, 120);
const args = {
contractId: 'marbles',
contractVersion: 'v1',
contractFunction: 'queryMarblesByOwner',
contractArguments: [marbleOwner],
timeout: 120,
readOnly: true
};

await this.sutAdapter.sendRequests(args);
}
}

Expand Down
99 changes: 0 additions & 99 deletions benchmarks/samples/fisco-bcos/generate_txs_in_advance/addUser.js

This file was deleted.

37 changes: 0 additions & 37 deletions benchmarks/samples/fisco-bcos/generate_txs_in_advance/config.yaml

This file was deleted.

Loading

0 comments on commit cbbc731

Please sign in to comment.