Skip to content

Commit

Permalink
BE-834 Add unit test for the fix of memory leak issue
Browse files Browse the repository at this point in the history
Signed-off-by: Atsushi Neki <nekiaiken@gmail.com>
  • Loading branch information
nekia committed Dec 10, 2020
1 parent 4201d71 commit affddef
Show file tree
Hide file tree
Showing 63 changed files with 2,259 additions and 7,417 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ first-network/channel-artifacts/*
tmp/wallet/*
wallet/*
*.swp
package-lock.json
# package-lock.json
ssl-certs/*.pem
ssl-certs/*.csr
0
Expand Down
8 changes: 8 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"require": "./node_modules/ts-node/register",
"watch-extensions": "ts",
"recursive": true,
"spec": ["./app/test/**/*.test.ts"],
"timeout": 5000,
"extension": ["ts"]
}
10 changes: 10 additions & 0 deletions .nycrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "@istanbuljs/nyc-config-typescript",
"require": ["ts-node/register"],
"extension": [".ts"],
"reporter": ["lcov", "text-summary"],
"sourceMap": true,
"instrument": true,
"temp-dir": "app/test/.nyc_output",
"report-dir": "app/test/coverage"
}
55 changes: 55 additions & 0 deletions app/test/FabricGateway.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
*SPDX-License-Identifier: Apache-2.0
*/

/* tslint:disable:no-unused-expression */
import { expect, use } from 'chai';
import chaiAsPromised from 'chai-as-promised';
import sinonChai from 'sinon-chai';
import { FabricConfig } from '../platform/fabric/FabricConfig';

use(chaiAsPromised);
use(sinonChai);

// export const expect = chai.expect
import proxyquire from 'proxyquire';
import sinon from 'sinon';
import { assert } from 'console';
// import { expect } from './expect'

describe('setupDiscoveryRequest', () => {
it('should return without error', async () => {
const stubSign = sinon.stub();
const { FabricGateway } = proxyquire
.noCallThru()
.load('../platform/fabric/gateway/FabricGateway', {
'fabric-common': {
DiscoveryService: function() {
return {
build: sinon.stub(),
sign: stubSign
};
}
},
'../../../common/helper': {
helper: {
getLogger: function() {}
}
}
});

const config = new FabricConfig();
config.initialize('first-network', {
name: 'My first network',
profile: './connection-profile/first-network.json'
});

const gw = new FabricGateway(config);
const stubGetNetwork = sinon.stub(gw.gateway, 'getNetwork');
const stubGetChannel = sinon.stub();
stubGetChannel.returns({});
stubGetNetwork.returns(Promise.resolve({ getChannel: stubGetChannel }));
await gw.setupDiscoveryRequest('testChannel');
expect(stubSign.calledOnce).to.be.equal(true);
});
});
Binary file removed app/test/artifacts/hellochannel.tx
Binary file not shown.
84 changes: 0 additions & 84 deletions app/test/artifacts/help/Test-ubuntu-install-cello.md

This file was deleted.

208 changes: 0 additions & 208 deletions app/test/artifacts/help/Test-ubuntu-install-composer.md

This file was deleted.

Loading

0 comments on commit affddef

Please sign in to comment.