Skip to content

Commit 54e4cad

Browse files
committed
task: patch unit test
1 parent b974d2f commit 54e4cad

File tree

8 files changed

+116
-19
lines changed

8 files changed

+116
-19
lines changed

test/infrastructure/Listener.spec.ts

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ describe('Listener', () => {
285285
);
286286
const transferTransactionDTO = transferTransaction.toJSON();
287287
const hash = 'abc';
288-
transferTransactionDTO.meta = { height: '1', hash: hash };
288+
transferTransactionDTO.meta = { height: '1', hash: hash, timestamp: '0', feeMultiplier: 0 };
289289

290290
const listener = new Listener('http://localhost:3000', namespaceRepo, WebSocketMultisigMock, multisigRepo);
291291
listener.open();
@@ -315,7 +315,7 @@ describe('Listener', () => {
315315
);
316316
const transferTransactionDTO = transferTransaction.toJSON();
317317
const hash = 'abc';
318-
transferTransactionDTO.meta = { height: '1', hash: hash };
318+
transferTransactionDTO.meta = { height: '1', hash: hash, timestamp: '0', feeMultiplier: 0 };
319319

320320
const reportedTransactions: Transaction[] = [];
321321
const listener = new Listener('http://localhost:3000', namespaceRepo, WebSocketMockAlias);
@@ -334,7 +334,10 @@ describe('Listener', () => {
334334
listener.handleMessage(
335335
{
336336
topic: name.toString(),
337-
data: { meta: { height: '2', hash: 'new hash' }, transaction: transferTransactionDTO.transaction },
337+
data: {
338+
meta: { height: '2', hash: 'new hash', timestamp: '2', feeMultiplier: 1 },
339+
transaction: transferTransactionDTO.transaction,
340+
},
338341
},
339342
null,
340343
);
@@ -360,7 +363,7 @@ describe('Listener', () => {
360363
const transferTransactionDTO = transferTransaction.toJSON();
361364
const hash = 'abc';
362365
const hash2 = 'abc2';
363-
transferTransactionDTO.meta = { height: '1', hash: hash };
366+
transferTransactionDTO.meta = { height: '1', hash: hash, timestamp: '0', feeMultiplier: 0 };
364367

365368
const reportedTransactions: Transaction[] = [];
366369
const listener = new Listener('http://localhost:3000', namespaceRepo, WebSocketMock);
@@ -379,7 +382,10 @@ describe('Listener', () => {
379382
listener.handleMessage(
380383
{
381384
topic: name.toString(),
382-
data: { meta: { height: '1', hash: 'new hash' }, transaction: transferTransactionDTO.transaction },
385+
data: {
386+
meta: { height: '1', hash: 'new hash', timestamp: '1', feeMultiplier: 1 },
387+
transaction: transferTransactionDTO.transaction,
388+
},
383389
},
384390
null,
385391
);
@@ -399,7 +405,7 @@ describe('Listener', () => {
399405
);
400406
const transferTransactionDTO = transferTransaction.toJSON();
401407
const hash = 'abc';
402-
transferTransactionDTO.meta = { height: '1', hash: hash };
408+
transferTransactionDTO.meta = { height: '1', hash: hash, timestamp: '0', feeMultiplier: 0 };
403409

404410
const reportedTransactions: Transaction[] = [];
405411
const listener = new Listener('http://localhost:3000', namespaceRepo, WebSocketMockAlias);
@@ -418,7 +424,10 @@ describe('Listener', () => {
418424
listener.handleMessage(
419425
{
420426
topic: name.toString(),
421-
data: { meta: { height: '1', hash: 'new hash' }, transaction: transferTransactionDTO.transaction },
427+
data: {
428+
meta: { height: '1', hash: 'new hash', timestamp: '1', feeMultiplier: 1 },
429+
transaction: transferTransactionDTO.transaction,
430+
},
422431
},
423432
null,
424433
);
@@ -438,7 +447,7 @@ describe('Listener', () => {
438447
);
439448
const transferTransactionDTO = transferTransaction.toJSON();
440449
const hash = 'abc';
441-
transferTransactionDTO.meta = { height: '1', hash: hash };
450+
transferTransactionDTO.meta = { height: '1', hash: hash, timestamp: '0', feeMultiplier: 0 };
442451

443452
const reportedTransactions: Transaction[] = [];
444453

@@ -458,7 +467,10 @@ describe('Listener', () => {
458467
listener.handleMessage(
459468
{
460469
topic: name.toString(),
461-
data: { meta: { height: '1', hash: 'new hash' }, transaction: transferTransactionDTO.transaction },
470+
data: {
471+
meta: { height: '1', hash: 'new hash', timestamp: '1', feeMultiplier: 1 },
472+
transaction: transferTransactionDTO.transaction,
473+
},
462474
},
463475
null,
464476
);
@@ -487,7 +499,7 @@ describe('Listener', () => {
487499
);
488500
const transferTransactionDTO = transferTransaction.toJSON();
489501
const hash = 'abc';
490-
transferTransactionDTO.meta = { height: '1', hash: hash };
502+
transferTransactionDTO.meta = { height: '1', hash: hash, timestamp: '0', feeMultiplier: 0 };
491503

492504
const reportedTransactions: Transaction[] = [];
493505

@@ -507,7 +519,10 @@ describe('Listener', () => {
507519
listener.handleMessage(
508520
{
509521
topic: name.toString(),
510-
data: { meta: { height: '1', hash: 'new hash' }, transaction: transferTransactionDTO.transaction },
522+
data: {
523+
meta: { height: '1', hash: 'new hash', timestamp: '1', feeMultiplier: 1 },
524+
transaction: transferTransactionDTO.transaction,
525+
},
511526
},
512527
null,
513528
);

test/infrastructure/TransactionHttp.spec.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ describe('TransactionHttp', () => {
101101
metaDto.hash = 'hash';
102102
metaDto.height = '1';
103103
metaDto.index = 0;
104+
metaDto.timestamp = '0';
105+
metaDto.feeMultiplier = 0;
104106
metaDto.merkleComponentHash = 'merkleHash';
105107

106108
const transactionDto = {} as TransferTransactionDTO;
@@ -186,6 +188,8 @@ describe('TransactionHttp', () => {
186188
expect(((transactions.data[0] as TransferTransaction).recipientAddress as Address).plain()).to.be.equal(TestAddress.plain());
187189
expect(transactions.data[0].transactionInfo?.id).to.be.equal('id');
188190
expect(transactions.data[0].transactionInfo?.hash).to.be.equal('hash');
191+
expect(transactions.data[0].transactionInfo?.timestamp?.toString()).to.be.equal('0');
192+
expect(transactions.data[0].transactionInfo?.feeMultiplier).to.be.equal(0);
189193

190194
expect(transactions.pageNumber).to.be.equal(1);
191195
expect(transactions.pageSize).to.be.equal(1);
@@ -219,6 +223,8 @@ describe('TransactionHttp', () => {
219223
metaDto.hash = 'hash';
220224
metaDto.height = '1';
221225
metaDto.index = 0;
226+
metaDto.timestamp = '0';
227+
metaDto.feeMultiplier = 0;
222228
metaDto.merkleComponentHash = 'merkleHash';
223229

224230
const transactionDto = {} as TransferTransactionDTO;
@@ -245,14 +251,15 @@ describe('TransactionHttp', () => {
245251
expect(((transaction as TransferTransaction).recipientAddress as Address).plain()).to.be.equal(TestAddress.plain());
246252
expect(transaction.transactionInfo?.id).to.be.equal('id');
247253
expect(transaction.transactionInfo?.hash).to.be.equal('hash');
254+
expect(transaction.transactionInfo?.timestamp?.toString()).to.be.equal('0');
255+
expect(transaction.transactionInfo?.feeMultiplier).to.be.equal(0);
248256

249257
transaction = await firstValueFrom(transactionHttp.getTransaction(generationHash, TransactionGroup.Partial));
250258

251259
expect(transaction.type.valueOf()).to.be.equal(TransactionType.TRANSFER.valueOf());
252260
expect(((transaction as TransferTransaction).recipientAddress as Address).plain()).to.be.equal(TestAddress.plain());
253261
expect(transaction.transactionInfo?.id).to.be.equal('id');
254262
expect(transaction.transactionInfo?.hash).to.be.equal('hash');
255-
256263
transaction = await firstValueFrom(transactionHttp.getTransaction(generationHash, TransactionGroup.Unconfirmed));
257264

258265
expect(transaction.type.valueOf()).to.be.equal(TransactionType.TRANSFER.valueOf());
@@ -267,6 +274,8 @@ describe('TransactionHttp', () => {
267274
metaDto.hash = 'hash';
268275
metaDto.height = '1';
269276
metaDto.index = 0;
277+
metaDto.timestamp = '0';
278+
metaDto.feeMultiplier = 0;
270279
metaDto.merkleComponentHash = 'merkleHash';
271280

272281
const transactionDto = {} as TransferTransactionDTO;
@@ -309,6 +318,8 @@ describe('TransactionHttp', () => {
309318
expect(((transactionConfirmed[0] as TransferTransaction).recipientAddress as Address).plain()).to.be.equal(TestAddress.plain());
310319
expect(transactionConfirmed[0].transactionInfo?.id).to.be.equal('id');
311320
expect(transactionConfirmed[0].transactionInfo?.hash).to.be.equal('hash');
321+
expect(transactionConfirmed[0].transactionInfo?.timestamp?.toString()).to.be.equal('0');
322+
expect(transactionConfirmed[0].transactionInfo?.feeMultiplier).to.be.equal(0);
312323

313324
expect(transactionUnconfirmed.length).to.be.equal(1);
314325
expect(transactionUnconfirmed[0].type.valueOf()).to.be.equal(TransactionType.TRANSFER.valueOf());
@@ -330,6 +341,8 @@ describe('TransactionHttp', () => {
330341
metaDto.height = '1';
331342
metaDto.index = 0;
332343
metaDto.merkleComponentHash = 'merkleHash';
344+
metaDto.timestamp = '0';
345+
metaDto.feeMultiplier = 0;
333346

334347
const transactionDto = {} as TransferTransactionDTO;
335348
transactionDto.deadline = '1';

0 commit comments

Comments
 (0)