How to use the fabric-common.Utils.newKeyValueStore function in fabric-common

To help you get started, we’ve selected a few fabric-common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hyperledger / fabric-sdk-node / test / integration / fileKeyValueStore-fabricca-tests.js View on Github external
const keyValStorePath = path.join(testUtil.getTempDir(), 'customKeyValStorePath');

	const client = new Client();
	let cryptoSuite, member;

	// clean up
	if (testUtil.existsSync(keyValStorePath)) {
		fs.removeSync(keyValStorePath);
	}

	const	tlsOptions = {
		trustedRoots: [],
		verify: false
	};

	utils.newKeyValueStore({path: keyValStorePath})
		.then(
			(kvs) => {

				member = new User('admin2');
				cryptoSuite = Client.newCryptoSuite();
				cryptoSuite.setCryptoKeyStore(Client.newCryptoKeyStore({path: keyValStorePath}));
				member.setCryptoSuite(cryptoSuite);

				client.setStateStore(kvs);
				if (client.getStateStore() === kvs) {
					t.pass('Successfully set File KeyValueStore for client');
				} else {
					t.fail('File KeyValStore is not set successfully on this client!');
					t.end();
					process.exit(1);
				}
github hyperledger / fabric-sdk-node / test / integration / client.js View on Github external
const sgnCert =  path.join(__dirname, caImport.orgs[userOrg].cryptoContent.signedCert);

	const keyStoreOpts = {path: path.join(testUtil.getTempDir(), caImport.orgs[userOrg].storePath)};
	const client = new Client();
	const cryptoSuite = Client.newCryptoSuite();
	cryptoSuite.setCryptoKeyStore(Client.newCryptoKeyStore(keyStoreOpts));
	client.setCryptoSuite(cryptoSuite);

	logger.debug('try to cleanup kvs Path: ' + keyStoreOpts.path);
	// clean up
	if (testUtil.existsSync(keyStoreOpts.path)) {
		fs.removeSync(keyStoreOpts.path);
		logger.debug('removed kvsPath: ' + keyStoreOpts.path);
	}

	return utils.newKeyValueStore(keyStoreOpts)
		.then((store) => {
			logger.debug('store: %s', store);
			client.setStateStore(store);
			return '';
		}).then(() => {
			return client.createUser(
				{username: caImport.orgs[userOrg].username,
					mspid: caImport.orgs[userOrg].mspid,
					cryptoContent: {privateKey: prvKey, signedCert: sgnCert}
				});
		}, (err) => {
			logger.error(err.stack ? err.stack : err);
			throw new Error('Failed createUser.');
		}).then((user) => {
			if (user) {
				t.pass(tag + ': got user');
github hyperledger / fabric-sdk-node / test / integration / cloudant-fabricca-tests.js View on Github external
.then(() => {
			options = {name: dbname, url: cloudantUrl};
			utils.newKeyValueStore(options)
				.then(
					(kvs) => {
						member = new User('admin2');
						cryptoSuite = Client.newCryptoSuite();
						cryptoSuite.setCryptoKeyStore(Client.newCryptoKeyStore(options));
						client.setCryptoSuite(cryptoSuite);
						member.setCryptoSuite(cryptoSuite);

						client.setStateStore(kvs);
						if (client.getStateStore() === kvs) {
							t.pass('Successfully set Cloudant CouchDB KeyValueStore for client');
						} else {
							t.pass('Cloudant CouchDB KeyValStore is not set successfully on this client!');
							t.end();
							process.exit(1);
						}
github hyperledger / fabric-sdk-node / test / integration / couchdb-fabricca-tests.js View on Github external
.then(() => {
			const options = {name: dbname, url: keyValStorePath};
			utils.newKeyValueStore(options)
				.then(
					(kvs) => {

						member = new User('admin2');
						cryptoSuite = Client.newCryptoSuite(options);
						cryptoSuite.setCryptoKeyStore(Client.newCryptoKeyStore(options));
						client.setCryptoSuite(cryptoSuite);
						member.setCryptoSuite(cryptoSuite);

						client.setStateStore(kvs);
						if (client.getStateStore() === kvs) {
							t.pass('Successfully set CouchDB KeyValueStore for client');
						} else {
							t.fail('CouchDB KeyValStore is not set successfully on this client!');
							t.end();
							process.exit(1);
github hyperledger / fabric-sdk-node / test / integration / client.js View on Github external
.then(() => {
			return utils.newKeyValueStore(keyStoreOpts);
		}).then((store) => {
			logger.debug('store: %s', store);