Skip to content

Commit 963db2d

Browse files
committed
fixed unit test
1 parent d6251ee commit 963db2d

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

e2e/infrastructure/MosaicHttp.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ describe('MosaicHttp', () => {
6666
describe('Setup test MosaicId', () => {
6767

6868
it('Announce MosaicDefinitionTransaction', async () => {
69-
const nonce = MosaicNonce.createFromUint8Array(new Uint8Array([200, 255, 255, 255]));
69+
const nonce = MosaicNonce.createFromNumber(-1501238750);
70+
expect(nonce.toDTO()).to.be.equals(2793728546);
71+
expect(nonce.toHex()).to.be.equals('22EA84A6');
7072
mosaicId = MosaicId.createFromNonce(nonce, account.publicAccount);
7173
const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create(
7274
Deadline.create(),

test/core/format/Convert.spec.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ describe('convert', () => {
403403
});
404404
});
405405

406-
describe('uint8ToNumber', () => {
406+
describe('numberToUint8Array', () => {
407407
it('should convert to number and back', () => {
408408
const input = 123456789;
409409
const array = convert.numberToUint8Array(input, 4);
@@ -413,18 +413,16 @@ describe('convert', () => {
413413
// Assert:
414414
expect(result).to.be.equal(input);
415415
});
416-
});
417416

418-
describe('uint8ToNumber', () => {
419417
it('should convert to number and back when negative', () => {
420-
const input = 123456789 >> (Number.MAX_SAFE_INTEGER);
418+
const input = -123456789;
421419
const array = convert.numberToUint8Array(input, 4);
422420
// Act:
423421
const result = convert.uintArray8ToNumber(array);
424422

425423
// Assert:
426-
expect(result).to.be.equal(123456789);
427-
expect(input).to.be.equal(123456789);
424+
expect(result).to.be.equal(4171510507);
425+
expect(input).to.be.equal(-123456789);
428426
});
429427
});
430428

test/model/mosaic/MosaicNonce.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ describe('MosaicNonce', () => {
5959
}).to.throw(Error, 'Invalid byte size for nonce, should be 4 bytes but received 6');
6060
});
6161

62+
it('should createFromHex from nonce', () => {
63+
const nonce = MosaicNonce.createFromHex('FFFFFFC8');
64+
deepEqual(nonce.toHex().toUpperCase(), 'FFFFFFC8');
65+
deepEqual(nonce.toDTO(), 3372220415);
66+
67+
const nonce2 = MosaicNonce.createFromNumber(nonce.toDTO());
68+
deepEqual(nonce2.toHex().toUpperCase(), 'FFFFFFC8');
69+
});
70+
6271
it('should create nonce from hexadecimal notation with uint32 input - 0 value', () => {
6372
const nonce = MosaicNonce.createFromHex((0).toString(16).padStart(8, '0'));
6473
expect(nonce.nonce).to.not.be.null;

0 commit comments

Comments
 (0)