How to use the fabric-network.DefaultQueryHandlerStrategies.MSPID_SCOPE_SINGLE function in fabric-network

To help you get started, we’ve selected a few fabric-network 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 / typescript / integration / network-e2e / query.ts View on Github external
test('\n\n***** Network End-to-end flow: evaluate transaction with MSPID_SCOPE_SINGLE query handler *****\n\n', async (t: tape.Test) => {
	const gateway = new Gateway();

	try {
		const wallet = await createWallet(t);
		const ccp: Buffer = fs.readFileSync(fixtures + '/profiles/network.json');
		const ccpObject = JSON.parse(ccp.toString());

		await gateway.connect(ccpObject, {
			clientTlsIdentity: tlsLabel,
			discovery: {
				enabled: false,
			},
			identity: identityLabel,
			queryHandlerOptions: {
				strategy: DefaultQueryHandlerStrategies.MSPID_SCOPE_SINGLE,
			},
			wallet,
		});
		t.pass('Connected to the gateway');

		const channel = await gateway.getNetwork(channelName);
		t.pass('Initialized the channel, ' + channelName);

		const contract = await channel.getContract(chaincodeId);
		t.pass('Got the contract, ' + chaincodeId);

		await testSuccessfulQuery(t, contract);
		await testQueryErrorResponse(t, contract);
		await testChaincodeRuntimeError(t, contract);
	} catch (err) {
		t.fail('Failed to invoke transaction chaincode on channel. ' + err.stack ? err.stack : err);
github hyperledger / fabric-sdk-node / test / ts-scenario / steps / lib / gateway.ts View on Github external
import Client = require('fabric-client');

const stateStore: StateStore = StateStore.getInstance();
const txnTypes: string[] = ['evaluate', 'submit'];
const txnResponseTypes: string[] = ['evaluate', 'event', 'error', 'submit'];
const supportedWallets: string[] = [Constants.FILE_WALLET as string, Constants.MEMORY_WALLET as string, Constants.COUCH_WALLET as string];

const EventStrategies: any = {
	MSPID_SCOPE_ALLFORTX : DefaultEventHandlerStrategies.MSPID_SCOPE_ALLFORTX,
	MSPID_SCOPE_ANYFORTX : DefaultEventHandlerStrategies.MSPID_SCOPE_ANYFORTX,
	NETWORK_SCOPE_ALLFORTX : DefaultEventHandlerStrategies.NETWORK_SCOPE_ALLFORTX,
	NETWORK_SCOPE_ANYFORTX : DefaultEventHandlerStrategies.NETWORK_SCOPE_ANYFORTX,
};

const QueryStrategies: any = {
	MSPID_SCOPE_SINGLE : DefaultQueryHandlerStrategies.MSPID_SCOPE_SINGLE,
	MSPID_SCOPE_ROUND_ROBIN : DefaultQueryHandlerStrategies.MSPID_SCOPE_ROUND_ROBIN,
};

/**
 * Create a gateway
 * @param {CommonConnectionProfileHelper} ccp The common connection profile
 * @param {Boolean} tls boolean true if tls network; otherwise false
 * @param {String} userName the user name to perform actions with
 * @param {String} orgName the Organization to which the user belongs
 * @param {String} gatewayName the name of the gateway
 * @param {Boolean} useDiscovery toggle discovery on
 * @param {String} walletType the type of wallet to back the gateway with (inMemory, fileBased, couchDB)
 * @return {Gateway} the connected gateway
 */
export async function createGateway(ccp: CommonConnectionProfileHelper, tls: boolean, userName: string, orgName: string, gatewayName: string, useDiscovery: boolean, walletType: string): Promise {