From 278878aa8cae4709bc3b20f4e2b12334b48b4f26 Mon Sep 17 00:00:00 2001 From: Anthony Law Yong Chuan Date: Tue, 4 May 2021 21:23:41 +0800 Subject: [PATCH] update test case to pass travis --- catapult-sdk/src/plugins/catapultModelSystem.js | 2 +- catapult-sdk/src/plugins/cmc.js | 4 ++++ .../test/plugins/catapultModelSystem_spec.js | 3 ++- rest/test/plugins/cmc/cmcRoutes_spec.js | 17 ++++++++++++----- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/catapult-sdk/src/plugins/catapultModelSystem.js b/catapult-sdk/src/plugins/catapultModelSystem.js index be43cbe9d..2de6c2c90 100644 --- a/catapult-sdk/src/plugins/catapultModelSystem.js +++ b/catapult-sdk/src/plugins/catapultModelSystem.js @@ -22,6 +22,7 @@ /** @module plugins/catapultModelSystem */ const accountLink = require('./accountLink'); const aggregate = require('./aggregate'); +const cmc = require('./cmc'); const lockHash = require('./lockHash'); const lockSecret = require('./lockSecret'); const metadata = require('./metadata'); @@ -31,7 +32,6 @@ const namespace = require('./namespace'); const receipts = require('./receipts'); const restrictions = require('./restrictions'); const transfer = require('./transfer'); -const cmc = require('./cmc'); const ModelFormatterBuilder = require('../model/ModelFormatterBuilder'); const ModelSchemaBuilder = require('../model/ModelSchemaBuilder'); const ModelCodecBuilder = require('../modelBinary/ModelCodecBuilder'); diff --git a/catapult-sdk/src/plugins/cmc.js b/catapult-sdk/src/plugins/cmc.js index b546c2154..4cea11557 100644 --- a/catapult-sdk/src/plugins/cmc.js +++ b/catapult-sdk/src/plugins/cmc.js @@ -21,6 +21,10 @@ /** @module plugins/cmc */ +// To ensure cmc able to load from the config, created empty plugins + +/* eslint-disable no-unused-vars */ + /** * Creates a cmc plugin use for CoinMarketCap. * @type {module:plugins/CatapultPlugin} diff --git a/catapult-sdk/test/plugins/catapultModelSystem_spec.js b/catapult-sdk/test/plugins/catapultModelSystem_spec.js index 93ecdaa6d..9e69c719d 100644 --- a/catapult-sdk/test/plugins/catapultModelSystem_spec.js +++ b/catapult-sdk/test/plugins/catapultModelSystem_spec.js @@ -56,7 +56,8 @@ describe('catapult model system', () => { 'namespace', 'receipts', 'restrictions', - 'transfer' + 'transfer', + 'cmc' ]); }); }); diff --git a/rest/test/plugins/cmc/cmcRoutes_spec.js b/rest/test/plugins/cmc/cmcRoutes_spec.js index faa7d1ce0..89105f1e3 100644 --- a/rest/test/plugins/cmc/cmcRoutes_spec.js +++ b/rest/test/plugins/cmc/cmcRoutes_spec.js @@ -34,11 +34,6 @@ describe('cmc routes', () => { const maxSupply = 9000000000000000; const XYMSupply = 8998999998000000; - sinon.stub(fs, 'readFile').callsFake((path, data, callback) => - callback(null, `${'[chain]\n' - + 'maxMosaicAtomicUnits = '}${maxSupply}\n` - + 'currencyMosaicId = 1234567890ABCDEF')); - const mosaicsSample = [{ id: '', mosaic: { @@ -94,6 +89,9 @@ describe('cmc routes', () => { describe('GET', () => { it('network currency supply circulating', () => { + const readFileStub = sinon.stub(fs, 'readFile').callsFake((path, data, callback) => + callback(null, `[chain]\nmaxMosaicAtomicUnits = ${maxSupply}\ncurrencyMosaicId = "0x1234567890ABCDEF"`)); + const route = mockServer.getRoute('/network/currency/supply/circulating').get(); // Arrange: @@ -105,10 +103,14 @@ describe('cmc routes', () => { // Assert expect(mockServer.next.calledOnce).to.equal(true); expect(mockServer.send.firstCall.args[0]).to.equal(cmcUtils.convertToRelative(circulatingSupply)); + readFileStub.restore(); }); }); it('network currency supply total', () => { + const readFileStub = sinon.stub(fs, 'readFile').callsFake((path, data, callback) => + callback(null, '[chain]\ncurrencyMosaicId = 0x1234567890ABCDEF')); + const route = mockServer.getRoute('/network/currency/supply/total').get(); // Arrange: @@ -119,10 +121,14 @@ describe('cmc routes', () => { // Assert expect(mockServer.next.calledOnce).to.equal(true); expect(mockServer.send.firstCall.args[0]).to.equal(xymSupply); + readFileStub.restore(); }); }); it('network currency supply max', () => { + const readFileStub = sinon.stub(fs, 'readFile').callsFake((path, data, callback) => + callback(null, `[chain]\nmaxMosaicAtomicUnits = ${maxSupply}`)); + const route = mockServer.getRoute('/network/currency/supply/max').get(); // Arrange: @@ -133,6 +139,7 @@ describe('cmc routes', () => { // Assert expect(mockServer.next.calledOnce).to.equal(true); expect(mockServer.send.firstCall.args[0]).to.equal(mosaicMaxSupply); + readFileStub.restore(); }); }); });