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 ) {
if (invokeCheck.toUpperCase() == 'TRUE') {
console.log('request_invoke: ', request_invoke);
test('\n\n** TEST ** new channel - channel.createChannel() fail due to already exist', function(t) {
//
// Create and configure the test channel
//
utils.setConfigSetting('key-value-store','fabric-client/lib/impl/FileKeyValueStore.js');
hfc.newDefaultKeyValueStore({path: testUtil.storePathForOrg(orgName)}
)
.then(
function (store) {
client.setStateStore(store);
var cryptoSuite = client.newCryptoSuite();
cryptoSuite.setCryptoKeyStore(client.newCryptoKeyStore({path: testUtil.storePathForOrg(orgName)}));
client.setCryptoSuite(cryptoSuite);
return testUtil.getSubmitter(client, t, org);
}
)
.then(
function(admin) {
t.pass('Successfully enrolled user \'admin\'');
the_user = admin;
t.equal(cs instanceof CryptoSuite_ECDSA_AES, true, 'Should return an instance of CryptoSuite_ECDSA_AES');
t.equal(cs._keySize, 256, 'Returned instance should have keysize of 256');
t.equal(cs._storePath, keyValStorePath5, 'Returned instance should have store path of ' + keyValStorePath5);
// each app instance is expected to use either HSM or software-based key management, as such this question
// is answered with a config setting rather than controlled on a case-by-case basis
utils.setConfigSetting('crypto-hsm', true);
t.throws(
() => {
cs = utils.getCryptoSuite({lib: '/usr/local/lib', slot: 0, pin: '1234' });
},
/Error:.*\/usr\/local\/lib/,
'Should attempt to load the bccsp_pkcs11 module and fail because of the dummy library path'
);
utils.setConfigSetting('crypto-hsm', false);
t.throws(
() => {
cs = utils.getCryptoSuite({lib: '/usr/local/lib', slot: 0, pin: '1234' });
},
/^Error: The "kvsPath" parameter for this constructor, if specified, must be a string specifying a file system path/,
'Should attempt to load the CryptoSuite_ECDSA_AES module and fail because of the invalid file store path'
);
t.end();
});
}],
policies : {
Readers : {threshold : 'ANY'},
Writers : {threshold : 'ANY'},
Admins : {threshold : 'ANY'}
},
}
}
};
var signatures = [];
// Acting as a client in org1 when creating the channel
var org = ORGS.org1.name;
utils.setConfigSetting('key-value-store', 'fabric-client/lib/impl/FileKeyValueStore.js');
return Client.newDefaultKeyValueStore({
path: testUtil.storePathForOrg(org)
}).then((store) => {
client.setStateStore(store);
return testUtil.getSubmitter(client, t, 'org1');
}).then((admin) => {
t.pass('Successfully enrolled user \'admin\'');
the_user = admin;
client.addMSP( e2eUtils.loadMSPConfig('Org2MSP', '../../fixtures/channel/crypto-config/peerOrganizations/org2.example.com/msp/'));
t.pass('only have to add in the new msps, existing MSPs will be read from the channel');
var channel = client.newChannel(channel_name);
channel.addOrderer(orderer);
async function run(config_path, root_path) {
const fabric = CaliperUtils.parseYaml(config_path).fabric;
const channels = fabric.channel;
if(!channels || channels.length === 0) {
return Promise.reject(new Error('No channel information found'));
}
try {
let ORGS = fabric.network;
let caRootsPath = ORGS.orderer.tls_cacerts;
let data = fs.readFileSync(CaliperUtils.resolvePath(caRootsPath, root_path));
let caroots = Buffer.from(data).toString();
utils.setConfigSetting('key-value-store', 'fabric-client/lib/impl/FileKeyValueStore.js');
for (const channel of channels) {
if(channel.deployed) {
continue;
}
commLogger.info(`Creating ${channel.name}...`);
// Acting as a client in first org when creating the channel
const client = new Client();
const org = channel.organizations[0];
// Conditional action on TLS enablement
if(fabric.network.orderer.url.toString().startsWith('grpcs')){
const fabricCAEndpoint = fabric.network[org].ca.url;
const caName = fabric.network[org].ca.name;
}).then((admin) => {
logger.info('Successfully enrolled user \'admin\'');
adminUser = admin;
nonce = utils.getNonce();
tx_id = chain.buildTransactionID(nonce, adminUser);
utils.setConfigSetting('E2E_TX_ID', tx_id);
logger.info('setConfigSetting("E2E_TX_ID") = %s', tx_id);
logger.debug(util.format('Sending transaction "%s"', tx_id));
// send proposal to endorser
var request = {
chaincodeId: config.chaincodeId,
chaincodeVersion: config.chaincodeVersion,
chainId: config.channelName,
fcn: config.invokeRequest.functionName,
args: helper.getArgs(config.invokeRequest.args),
txId: tx_id,
nonce: nonce
};
return chain.sendTransactionProposal(request);
}, (err) => {
async function run(config_path) {
const fabric = commUtils.parseYaml(config_path).fabric;
const channels = fabric.channel;
if(!channels || channels.length === 0) {
throw new Error('No channel information found');
}
let ORGS = fabric.network;
let caRootsPath = ORGS.orderer.tls_cacerts;
let data = fs.readFileSync(commUtils.resolvePath(caRootsPath));
let caroots = Buffer.from(data).toString();
utils.setConfigSetting('key-value-store', 'fabric-client/lib/impl/FileKeyValueStore.js');
try {
for (let channel of channels) {
if(channel.deployed) {
continue;
}
commLogger.info(`Creating ${channel.name}...`);
// Acting as a client in first org when creating the channel
let client = new Client();
let org = channel.organizations[0];
let orderer = client.newOrderer(
ORGS.orderer.url,
{
'pem': caroots,
}
}
} else if ( ccType == 'marblescc' ) {
arg0 ++;
for ( i=0; i
test('Attempt to use FabricCAServices',function(t){
var client = new Client();
utils.setConfigSetting('crypto-keysize', 256);
hfc.newDefaultKeyValueStore({
path: keyValStorePath
})
.then(
function(kvs) {
client.setStateStore(kvs);
var copService = new FabricCAServices('http://localhost:7054');
var member;
copService.enroll({
enrollmentID: 'admin',
enrollmentSecret: 'adminpw'
})
.then(
function(testUser) {