How to use the fabric-protos.common.HeaderType function in fabric-protos

To help you get started, we’ve selected a few fabric-protos 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 / unit / read-configtx.js View on Github external
test('\n\n***** READ in the genesis block *****\n\n', (t) => {
	testUtil.resetDefaults();

	// readin the envelope to send to the orderer
	const normalPath = path.normalize(path.join(__dirname, '../fixtures/crypto-material/config-base/twoorgs.genesis.block'));
	const data = fs.readFileSync(normalPath);

	const channel = new Channel('test', 'fake');

	const block = _commonProto.Block.decode(data);
	const envelope = _commonProto.Envelope.decode(block.data.data[0]);
	const payload = _commonProto.Payload.decode(envelope.payload);
	const channel_header = _commonProto.ChannelHeader.decode(payload.header.channel_header);
	if (channel_header.type !== _commonProto.HeaderType.CONFIG) {
		logger.error('Block must be of type "CONFIG"');
	}

	const config_envelope = _configtxProto.ConfigEnvelope.decode(payload.data);
	channel.loadConfigEnvelope(config_envelope);
	t.pass(' Loaded the geneisis block from the configtx tool');
	t.end();
});
github hyperledger / fabric-sdk-node / test / integration / e2e / updateAnchorPeers.js View on Github external
const block_registration_number = eventHub.registerBlockEvent((block) => {
			if (block.data.data.length !== 1) {
				t.comment('Config block must only contain one transaction');
				return;
			}
			const envelope = block.data.data[0];
			const channel_header = envelope.payload.header.channel_header;
			t.comment(JSON.stringify(channel_header));

			if (channel_header.type !== _commonProto.HeaderType.CONFIG) {
				t.comment(`expect block of type "CONFIG" (${_commonProto.HeaderType.CONFIG}), but got "${channel_header.type}" instead`);
				return;
			}

			t.pass('Successfully update anchor peers.');
			eventHub.unregisterBlockEvent(block_registration_number, true);
			eventHub.disconnect();
			resolve(block);
		}, (err) => {
			t.fail(`err caught in blockEvent: after update anchor peers, ${err}`);
github hyperledger / fabric-sdk-node / test / integration / e2e / updateAnchorPeers.js View on Github external
const block_registration_number = eventHub.registerBlockEvent((block) => {
			if (block.data.data.length !== 1) {
				t.comment('Config block must only contain one transaction');
				return;
			}
			const envelope = block.data.data[0];
			const channel_header = envelope.payload.header.channel_header;
			t.comment(JSON.stringify(channel_header));

			if (channel_header.type !== _commonProto.HeaderType.CONFIG) {
				t.comment(`expect block of type "CONFIG" (${_commonProto.HeaderType.CONFIG}), but got "${channel_header.type}" instead`);
				return;
			}

			t.pass('Successfully update anchor peers.');
			eventHub.unregisterBlockEvent(block_registration_number, true);
			eventHub.disconnect();
			resolve(block);
		}, (err) => {
			t.fail(`err caught in blockEvent: after update anchor peers, ${err}`);
github hyperledger / fabric-sdk-node / test / integration / perf / peer.js View on Github external
const arg_bytes = [];
	for (let i = 0; i < args.length; i++) {
		arg_bytes.push(Buffer.from(args[i], 'utf8'));
	}
	const invokeSpec = {
		type: ccProto.ChaincodeSpec.Type.GOLANG,
		chaincode_id: {
			name: testUtil.END2END.chaincodeId
		},
		input: {
			args: arg_bytes,
		}
	};

	const channelHeader = clientUtils.buildChannelHeader(
		commonProto.HeaderType.ENDORSER_TRANSACTION,
		testUtil.END2END.channel,
		tx_id.getTransactionID(),
		null,
		testUtil.END2END.chaincodeId
	);
	const header = clientUtils.buildHeader(signer.getIdentity(), channelHeader, tx_id.getNonce());
	const proposal = clientUtils.buildProposal(invokeSpec, header);
	const signed_proposal = clientUtils.signProposal(signer.getSigningIdentity(), proposal);

	return signed_proposal;
}
github hyperledger / fabric-sdk-node / test / integration / perf / orderer.js View on Github external
function makeMessageEnvelope(signer) {
	return makeEnvelope(signer, commonProto.HeaderType.MESSAGE);
}
github hyperledger / fabric-sdk-node / test / integration / perf / orderer.js View on Github external
function makeTransactionEnvelope(signer) {
	return makeEnvelope(signer, commonProto.HeaderType.ENDORSER_TRANSACTION);
}