How to use the fabric-shim/lib/iterators.js.StateQueryIterator function in fabric-shim

To help you get started, we’ve selected a few fabric-shim 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-chaincode-node / test / unit / handler.js View on Github external
# SPDX-License-Identifier: Apache-2.0
*/
'use strict';

const test = require('../base.js');
const sinon = require('sinon');
const rewire = require('rewire');
const Handler = rewire('fabric-shim/lib/handler.js');
const Stub = require('fabric-shim/lib/stub.js');
const MsgQueueHandler = Handler.__get__('MsgQueueHandler');
const QMsg = Handler.__get__('QMsg');

const grpc = require('grpc');
const path = require('path');

const StateQueryIterator = require('fabric-shim/lib/iterators.js').StateQueryIterator;
const HistoryQueryIterator = require('fabric-shim/lib/iterators.js').HistoryQueryIterator;

//chaincode object to handle chaincode interface calls Init() and Invoke()
const chaincodeObj = {
	Init: function() {},
	Invoke: function() {}
};

function getPeerAddress(isSecure) {
	let address = 'grpc://localhost:7051';
	if (isSecure && isSecure === true) {
		address = address.replace(/grpc/gi, 'grpcs');
	}
	return address;
}
let sandbox = sinon.sandbox.create();
github hyperledger / fabric-chaincode-node / test / unit / stub.js View on Github external
/*
# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
*/
'use strict';

const ByteBuffer = require('bytebuffer');
const test = require('../base.js');
const sinon = require('sinon');
const rewire = require('rewire');
const testutil = require('./util.js');

const Stub = rewire('fabric-shim/lib/stub.js');
const Handler = require('fabric-shim/lib/handler.js');
const StateQueryIterator = require('fabric-shim/lib/iterators.js').StateQueryIterator;
const HistoryQueryIterator = require('fabric-shim/lib/iterators.js').HistoryQueryIterator;

const grpc = require('grpc');
const path = require('path');

const _commonProto = grpc.load({
	root: path.join(__dirname, '../../src/lib/protos'),
	file: 'common/common.proto'
}).common;

const _proposalProto = grpc.load({
	root: path.join(__dirname, '../../src/lib/protos'),
	file: 'peer/proposal.proto'
}).protos;

const _cclProto = grpc.load({