Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getMoveRequest() {
if ( ccType == 'ccchecker') {
arg0 ++;
testInvokeArgs[1] = 'key_'+channelName+'_'+org+'_'+Nid+'_'+pid+'_'+arg0;
// random payload
var r = Math.floor(Math.random() * (payLoadMax - payLoadMin)) + payLoadMin;
var buf = crypto.randomBytes(r);
testInvokeArgs[2] = buf.toString('hex');
}
//console.log('d:id:chan:org=%d:%d:%s:%s getMoveRequest] testInvokeArgs[1]', Nid, pid, channelName, org, testInvokeArgs[1]);
nonce = utils.getNonce();
tx_id = hfc.buildTransactionID(nonce, the_user);
utils.setConfigSetting('E2E_TX_ID', tx_id);
logger.info('setConfigSetting("E2E_TX_ID") = %s', tx_id);
request_invoke = {
chaincodeId : chaincode_id,
chaincodeVersion : chaincode_ver,
chainId: channelName,
fcn: uiContent.invoke.move.fcn,
args: testInvokeArgs,
txId: tx_id,
nonce: nonce
};
if ( inv_m == nRequest ) {
function(admin) {
if (!!admin)
t.pass('Successfully enrolled user \'admin\'');
else {
t.fail('Failed to obtain enrolled user \'admin\'');
t.end();
}
chain.addPeer(new Peer('grpc://localhost:7051'));
chain.addPeer(new Peer('grpc://localhost:7056'));
the_user = admin;
nonce = utils.getNonce();
tx_id = chain.buildTransactionID(nonce, the_user);
// send proposal to endorser
var request = {
chaincodePath: testUtil.CHAINCODE_PATH,
chaincodeId: chaincode_id,
chaincodeVersion: chaincode_version,
txId: tx_id,
nonce: nonce
};
return chain.sendInstallProposal(request);
},
(err) => {
invoke_cc.invoke_chaincode = function (obj, options, cb) {
logger.debug('[fcw] Invoking Chaincode: ' + options.cc_function + '()');
var eventhub;
var chain = obj.chain;
var nonce = utils.getNonce();
var cbCalled = false;
console.log("obj.submitter");
//console.log(obj.submitter);
console.log(nonce);
// send proposal to endorser
var request = {
chainId: options.channel_id,
chaincodeId: options.chaincode_id,
chaincodeVersion: options.chaincode_version,
fcn: options.cc_function,
args: options.cc_args,
txId: chain.buildTransactionID(nonce, obj.submitter),
nonce: nonce,
};
logger.debug('[fcw] Sending invoke req', request);
function (admin) {
logger.info('Successfully obtained enrolled user to deploy the chaincode')
logger.info('Executing Deploy')
tx_id = helper.getTxId()
var nonce = utils.getNonce()
var args = helper.getArgs(config.deployRequest.args)
// send proposal to endorser
var request = {
chaincodePath: config.chaincodePath,
chaincodeId: config.chaincodeID,
fcn: config.deployRequest.functionName,
args: args,
chainId: config.channelID,
txId: tx_id,
nonce: nonce,
'dockerfile-contents': config.dockerfile_contents
}
return chain.sendDeploymentProposal(request)
}
).then(
function (admin) {
logger.info('Successfully obtained enrolled user to perform query')
logger.info('Executing Query')
var targets = []
for (var i = 0; i < config.peers.length; i++) {
targets.push(config.peers[i])
}
var args = helper.getArgs(config.queryRequest.args)
// chaincode query request
var request = {
targets: targets,
chaincodeId: config.chaincodeID,
chainId: config.channelID,
txId: utils.buildTransactionID(),
nonce: utils.getNonce(),
fcn: config.queryRequest.functionName,
args: args
}
// Query chaincode
return chain.queryByChaincode(request)
}
).then(
function(admin) {
logger.info('Successfully obtained enrolled user to deploy the chaincode');
logger.info('Executing Deploy');
tx_id = helper.getTxId();
var nonce = utils.getNonce();
var args = helper.getArgs(config.deployRequest.args);
// send proposal to endorser
var request = {
chaincodePath: config.chaincodePath,
chaincodeId: config.chaincodeID,
fcn: config.deployRequest.functionName,
args: args,
chainId: config.channelID,
txId: tx_id,
nonce: nonce,
};
return chain.sendInstantiateProposal(request);
}
).then(
function getQueryRequest() {
if ( ccType == 'ccchecker') {
arg0 ++;
testQueryArgs[1] = 'key_'+channelName+'_'+org+'_'+Nid+'_'+pid+'_'+arg0;
}
//console.log('d:id:chan:org=%d:%d:%s:%s getQueryRequest] testQueryArgs[1]', Nid, pid, channelName, org, testQueryArgs[1]);
nonce = utils.getNonce();
tx_id = hfc.buildTransactionID(nonce, the_user);
request_query = {
chaincodeId : chaincode_id,
chaincodeVersion : chaincode_ver,
chainId: channelName,
txId: tx_id,
nonce: nonce,
fcn: uiContent.invoke.query.fcn,
args: testQueryArgs
};
//console.log('request_query: ', request_query);
}
.then((admin) => {
console.log('Successfully enrolled user \'admin\'');
the_user = admin;
nonce = utils.getNonce();
tx_id = chain.buildTransactionID(nonce, the_user);
let request = {
targets: targets,
txId: tx_id,
nonce: nonce
};
return chain.joinChannel(request);
}, (err) => {
console.log('Failed to enroll user \'admin\' due to error: ' + err.stack ? err.stack : err);