Skip to content

Commit

Permalink
[FABCN-241] Remove to.be.ok (#204)
Browse files Browse the repository at this point in the history
Signed-off-by: lesleyannj <lesleyannj@hotmail.com>
  • Loading branch information
lesleyannjordan committed Sep 9, 2020
1 parent c9a1f5d commit 58387e8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 18 deletions.
2 changes: 0 additions & 2 deletions libraries/fabric-shim-crypto/test/shim-crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,6 @@ describe('enc-sign', () => {
sinon.stub(KEYUTIL, 'getKey').returns(mockKey);

expect(importKey('some raw content') instanceof ECDSAKey).to.be.true;
expect(mockECDSAKey.calledWithNew).to.be.ok; // Believe wrong
expect(mockECDSAKey.calledWithNew()).to.be.false;
expect(mockECDSAKey.firstCall.args).to.deep.equal([mockKey]);

Expand Down Expand Up @@ -613,7 +612,6 @@ i6dOfok=
const result = _preventMalleability(sig, curveParams);

expect(result.s).to.deep.equal('some sub');
expect(mockBN.calledWithNew).to.be.ok; // Believe wrong
expect(mockBN.calledWithNew()).to.be.false;
expect(mockBN.firstCall.args).to.deep.equal(['some string', 16]);
expect(curveParams.n.toString.calledOnce).to.be.true;
Expand Down
7 changes: 0 additions & 7 deletions libraries/fabric-shim/test/unit/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,6 @@ describe('Handler', () => {
handler.chat('starter message example');

expect(handler._client.register.calledOnce).to.be.true;
expect(mockChaincodeMessageHandler.calledWithNew).to.be.ok; // believe wrong
expect(mockChaincodeMessageHandler.calledWithNew()).to.be.false;
expect(handler._stream).to.deep.equal(mockStream);
expect(handler._handler).to.deep.equal(new mockChaincodeMessageHandler(mockStream, mockChaincodeImpl));
Expand Down Expand Up @@ -559,7 +558,6 @@ describe('Handler', () => {
const handler = new Handler.ChaincodeMessageHandler(mockStream, mockChaincodeImpl);
handler.chat('some starter message');

expect(mockMsgQueueHandler.calledWithNew).to.be.ok; // believe wrong
expect(mockMsgQueueHandler.calledWithNew()).to.be.false;
expect(handler._stream).to.deep.equal(mockStream);
expect(handler.msgQueueHandler).to.deep.equal(new mockMsgQueueHandler(handler));
Expand Down Expand Up @@ -1749,7 +1747,6 @@ describe('Handler', () => {
const createStub = Handler.__get__('createStub');
createStub({}, 'channelID', 'txID', 'some input', 'some proposal');

expect(mockStub.calledWithNew).to.be.ok; // believe wrong
expect(mockStub.calledWithNew()).to.be.false;
expect(mockStub.firstCall.args[0]).to.deep.equal({});
expect(mockStub.firstCall.args[1]).to.deep.equal('channelID');
Expand Down Expand Up @@ -1923,7 +1920,6 @@ describe('Handler', () => {

parseResponse(handler, res, 'GetStateByRange');

expect(mockStateQueryIterator.calledWithNew).to.be.ok; // believe wrong
expect(mockStateQueryIterator.calledWithNew()).to.be.false;
expect(mockStateQueryIterator.firstCall.args).to.deep.equal([handler, res.channel_id, res.txid, qrDecodedPayload]);
});
Expand All @@ -1942,7 +1938,6 @@ describe('Handler', () => {

const result = parseResponse(handler, res, 'GetStateByRange');

expect(mockStateQueryIterator.calledWithNew).to.be.ok; // believe wrong
expect(mockStateQueryIterator.calledWithNew()).to.be.false;
expect(mockStateQueryIterator.firstCall.args).to.deep.equal([handler, res.channel_id, res.txid, pagedQrPayload]);

Expand All @@ -1958,7 +1953,6 @@ describe('Handler', () => {

parseResponse(handler, res, 'GetQueryResult');

expect(mockStateQueryIterator.calledWithNew).to.be.ok; // believe wrong
expect(mockStateQueryIterator.calledWithNew()).to.be.false;
expect(mockStateQueryIterator.firstCall.args).to.deep.equal([handler, res.channel_id, res.txid, qrDecodedPayload]);
});
Expand All @@ -1971,7 +1965,6 @@ describe('Handler', () => {

parseResponse(handler, res, 'GetHistoryForKey');

expect(mockHistoryQueryIterator.calledWithNew).to.be.ok; // believe wrong
expect(mockHistoryQueryIterator.calledWithNew()).to.be.false;
expect(mockHistoryQueryIterator.firstCall.args).to.deep.equal([handler, res.channel_id, res.txid, qrDecodedPayload]);
});
Expand Down
18 changes: 9 additions & 9 deletions libraries/fabric-shim/test/unit/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe('ChaincodeServer', () => {
expect(server._serverOpts).to.deep.equal(serverOpts);
expect(server._credentials).to.deep.equal(mockCredentials);

expect(insecureCredentialsStub.calledOnce).to.be.ok;
expect(insecureCredentialsStub.calledOnce).to.be.true;
});
it('should create a gRPC server instance with TLS credentials and call addService in the constructor', () => {
const server = new ChaincodeServer(mockChaincode, serverTLSOpts);
Expand All @@ -89,7 +89,7 @@ describe('ChaincodeServer', () => {
expect(server._serverOpts).to.deep.equal(serverTLSOpts);
expect(server._credentials).to.deep.equal(mockTLSCredentials);

expect(sslCredentialsStub.calledOnce).to.be.ok;
expect(sslCredentialsStub.calledOnce).to.be.true;
expect(sslCredentialsStub.firstCall.args[0]).to.be.null;
expect(sslCredentialsStub.firstCall.args[1]).to.deep.equal([{
private_key: tlsKey,
Expand All @@ -104,7 +104,7 @@ describe('ChaincodeServer', () => {
expect(server._serverOpts).to.deep.equal(serverMutualTLSOpts);
expect(server._credentials).to.deep.equal(mockTLSCredentials);

expect(sslCredentialsStub.calledOnce).to.be.ok;
expect(sslCredentialsStub.calledOnce).to.be.true;
expect(sslCredentialsStub.firstCall.args[0]).to.deep.equal(tlsClientCA);
expect(sslCredentialsStub.firstCall.args[1]).to.deep.equal([{
private_key: tlsKey,
Expand Down Expand Up @@ -155,10 +155,10 @@ describe('ChaincodeServer', () => {
};

expect(await server.start()).not.to.throw;
expect(server._server.bindAsync.calledOnce).to.be.ok;
expect(server._server.bindAsync.calledOnce).to.be.true;
expect(server._server.bindAsync.firstCall.args[0]).to.equal(serverOpts.address);
expect(server._server.bindAsync.firstCall.args[1]).to.equal(mockCredentials);
expect(server._server.start.calledOnce).to.be.ok;
expect(server._server.start.calledOnce).to.be.true;
});

it('should throw if bindAsync fails', async () => {
Expand Down Expand Up @@ -187,8 +187,8 @@ describe('ChaincodeServer', () => {

server.connect(mockStream);

expect(mockHandlerStub.calledOnce).to.be.ok;
expect(mockHandler.chat.calledOnce).to.be.ok;
expect(mockHandlerStub.calledOnce).to.be.true;
expect(mockHandler.chat.calledOnce).to.be.true;
expect(mockHandler.chat.firstCall.args).to.deep.equal([{
type: fabprotos.protos.ChaincodeMessage.Type.REGISTER,
payload: fabprotos.protos.ChaincodeID.encode({
Expand All @@ -208,8 +208,8 @@ describe('ChaincodeServer', () => {
const mockStream = {on: sinon.stub(), write: sinon.stub()};

server.connect(mockStream);
expect(mockHandlerStub.calledOnce).to.be.ok;
expect(mockHandler.chat.calledOnce).to.be.ok;
expect(mockHandlerStub.calledOnce).to.be.true
expect(mockHandler.chat.calledOnce).to.be.true;
});
});
});

0 comments on commit 58387e8

Please sign in to comment.