Skip to content

Commit d682aac

Browse files
authored
Merge pull request #476 from NEMStudios/task/g472_node_time_in_uint64
Updated nodetime model using UInt64
2 parents 0aae295 + 9c4d0d0 commit d682aac

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/infrastructure/NodeHttp.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ export class NodeHttp extends Http implements NodeRepository {
7272
(body) => {
7373
const nodeTimeDTO = body;
7474
if (nodeTimeDTO.communicationTimestamps.sendTimestamp && nodeTimeDTO.communicationTimestamps.receiveTimestamp) {
75-
return new NodeTime(UInt64.fromNumericString(nodeTimeDTO.communicationTimestamps.sendTimestamp).toDTO(),
76-
UInt64.fromNumericString(nodeTimeDTO.communicationTimestamps.receiveTimestamp).toDTO());
75+
return new NodeTime(UInt64.fromNumericString(nodeTimeDTO.communicationTimestamps.sendTimestamp),
76+
UInt64.fromNumericString(nodeTimeDTO.communicationTimestamps.receiveTimestamp));
7777
}
7878
throw Error('Node time not available');
7979
},

src/model/node/NodeTime.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
import { NetworkType } from '../blockchain/NetworkType';
1716
import { UInt64 } from '../UInt64';
18-
import { RoleType } from './RoleType';
1917
/**
2018
* The node info structure describes basic information of a node.
2119
*/
@@ -28,9 +26,9 @@ export class NodeTime {
2826
constructor(/**
2927
* The request send timestamp
3028
*/
31-
public readonly sendTimeStamp?: number[],
29+
public readonly sendTimeStamp?: UInt64,
3230
/**
3331
* The request received timestamp
3432
*/
35-
public readonly receiveTimeStamp?: number[] ) {}
33+
public readonly receiveTimeStamp?: UInt64 ) {}
3634
}

test/infrastructure/NodeHttp.spec.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {
2626
RolesTypeEnum,
2727
ServerDTO,
2828
ServerInfoDTO,
29-
StorageInfoDTO
29+
StorageInfoDTO,
3030
} from 'symbol-openapi-typescript-node-client';
3131
import { instance, mock, reset, when } from 'ts-mockito';
3232
import { DtoMapping } from '../../src/core/utils/DtoMapping';
@@ -125,8 +125,10 @@ describe('NodeHttp', () => {
125125

126126
const nodeTime = await nodeRepository.getNodeTime().toPromise();
127127
expect(nodeTime).to.be.not.null;
128-
expect(nodeTime.receiveTimeStamp).to.deep.equals([1111, 0]);
129-
expect(nodeTime.sendTimeStamp).to.deep.equals([2222, 0]);
128+
if (nodeTime.receiveTimeStamp && nodeTime.sendTimeStamp) {
129+
expect(nodeTime.receiveTimeStamp.toDTO()).to.deep.equals([1111, 0]);
130+
expect(nodeTime.sendTimeStamp.toDTO()).to.deep.equals([2222, 0]);
131+
}
130132
});
131133

132134
it('getNodeTim When No Timestamp', async () => {

0 commit comments

Comments
 (0)