From 9c4d0d04660a67b10296e0aebaf8928ac553871d Mon Sep 17 00:00:00 2001 From: Steven Liu Date: Tue, 3 Mar 2020 08:45:27 +0000 Subject: [PATCH] Fixed #472 - Updated nodetime model using UInt64 --- src/infrastructure/NodeHttp.ts | 4 ++-- src/model/node/NodeTime.ts | 6 ++---- test/infrastructure/NodeHttp.spec.ts | 8 +++++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/infrastructure/NodeHttp.ts b/src/infrastructure/NodeHttp.ts index 3806079ebb..ead8c00555 100644 --- a/src/infrastructure/NodeHttp.ts +++ b/src/infrastructure/NodeHttp.ts @@ -72,8 +72,8 @@ export class NodeHttp extends Http implements NodeRepository { (body) => { const nodeTimeDTO = body; if (nodeTimeDTO.communicationTimestamps.sendTimestamp && nodeTimeDTO.communicationTimestamps.receiveTimestamp) { - return new NodeTime(UInt64.fromNumericString(nodeTimeDTO.communicationTimestamps.sendTimestamp).toDTO(), - UInt64.fromNumericString(nodeTimeDTO.communicationTimestamps.receiveTimestamp).toDTO()); + return new NodeTime(UInt64.fromNumericString(nodeTimeDTO.communicationTimestamps.sendTimestamp), + UInt64.fromNumericString(nodeTimeDTO.communicationTimestamps.receiveTimestamp)); } throw Error('Node time not available'); }, diff --git a/src/model/node/NodeTime.ts b/src/model/node/NodeTime.ts index ccacf4c363..6e8a26e5e7 100644 --- a/src/model/node/NodeTime.ts +++ b/src/model/node/NodeTime.ts @@ -13,9 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { NetworkType } from '../blockchain/NetworkType'; import { UInt64 } from '../UInt64'; -import { RoleType } from './RoleType'; /** * The node info structure describes basic information of a node. */ @@ -28,9 +26,9 @@ export class NodeTime { constructor(/** * The request send timestamp */ - public readonly sendTimeStamp?: number[], + public readonly sendTimeStamp?: UInt64, /** * The request received timestamp */ - public readonly receiveTimeStamp?: number[] ) {} + public readonly receiveTimeStamp?: UInt64 ) {} } diff --git a/test/infrastructure/NodeHttp.spec.ts b/test/infrastructure/NodeHttp.spec.ts index 80239ab33f..c17e51ab6d 100644 --- a/test/infrastructure/NodeHttp.spec.ts +++ b/test/infrastructure/NodeHttp.spec.ts @@ -26,7 +26,7 @@ import { RolesTypeEnum, ServerDTO, ServerInfoDTO, - StorageInfoDTO + StorageInfoDTO, } from 'symbol-openapi-typescript-node-client'; import { instance, mock, reset, when } from 'ts-mockito'; import { DtoMapping } from '../../src/core/utils/DtoMapping'; @@ -125,8 +125,10 @@ describe('NodeHttp', () => { const nodeTime = await nodeRepository.getNodeTime().toPromise(); expect(nodeTime).to.be.not.null; - expect(nodeTime.receiveTimeStamp).to.deep.equals([1111, 0]); - expect(nodeTime.sendTimeStamp).to.deep.equals([2222, 0]); + if (nodeTime.receiveTimeStamp && nodeTime.sendTimeStamp) { + expect(nodeTime.receiveTimeStamp.toDTO()).to.deep.equals([1111, 0]); + expect(nodeTime.sendTimeStamp.toDTO()).to.deep.equals([2222, 0]); + } }); it('getNodeTim When No Timestamp', async () => {