I'm still on my journey to set up the Caliper for the first time. Hope you can save me :)
Right know I got the error: Transaction returned with failure: User 1 already exists. when I try to launch the caliper benchmark.
Because I do not allow to register users with an existing userID (verified on my chaincode).
This is my test file:
'use strict';
module.exports.info = 'opening accounts';
const { v1: uuidv4 } = require('uuid')
let account_array = [];
let bc, contx;
var txnPerBatch = 1
let j;
module.exports.init = function (blockchain, context, args) {
if (!args.hasOwnProperty('txnPerBatch')) {
args.txnPerBatch = 1;
}
txnPerBatch = args.txnPerBatch;
bc = blockchain;
contx = context;
j = 0;
let workload = [];
workload.push({
chaincodeFunction: 'instantiate',
chaincodeArguments: [],
});
bc.invokeSmartContract(contx, 'loyalty', '1', workload);
return Promise.resolve();
};
function generateWorkload() {
let workload = [];
for (let i = 0; i < txnPerBatch; i++) {
var random = (j+1).toString();
var gam_admin = {
userID: random
};
workload.push({
chaincodeFunction: 'createGamificationAdmin',
chaincodeArguments: [JSON.stringify(gam_admin)],
});
}
return workload;
}
module.exports.run = function () {
let workload = [];
let args = generateWorkload();
return bc.invokeSmartContract(contx, 'loyalty', '1', args);
};
module.exports.end = function () {
return Promise.resolve();
};
module.exports.account_array = account_array;
Do you know how can I solve this? Thanks so much.