@@ -27,6 +27,11 @@ import { Deadline } from '../../../src/model/transaction/Deadline';
2727import { TransferTransaction } from '../../../src/model/transaction/TransferTransaction' ;
2828import { UInt64 } from '../../../src/model/UInt64' ;
2929import { TestingAccount } from '../../conf/conf.spec' ;
30+ import { Mosaic } from '../../../src/model/mosaic/Mosaic' ;
31+ import { MosaicId } from '../../../src/model/model' ;
32+ import { CreateStatementFromDTO } from '../../../src/infrastructure/receipt/CreateReceiptFromDTO' ;
33+ import { CreateTransactionFromDTO } from '../../../src/infrastructure/transaction/CreateTransactionFromDTO' ;
34+ import { CreateTransactionFromPayload } from '../../../src/infrastructure/transaction/CreateTransactionFromPayload' ;
3035
3136describe ( 'TransferTransaction' , ( ) => {
3237 let account : Account ;
@@ -295,4 +300,34 @@ describe('TransferTransaction', () => {
295300 ) ;
296301 } ) . to . throw ( ) ;
297302 } ) ;
303+
304+ it ( 'should sort the Mosaic array' , ( ) => {
305+ const mosaics = [
306+ new Mosaic ( new MosaicId ( UInt64 . fromUint ( 200 ) . toDTO ( ) ) , UInt64 . fromUint ( 0 ) ) ,
307+ new Mosaic ( new MosaicId ( UInt64 . fromUint ( 100 ) . toDTO ( ) ) , UInt64 . fromUint ( 0 ) ) ,
308+ ] ;
309+
310+ const transferTransaction = TransferTransaction . create (
311+ Deadline . create ( ) ,
312+ Address . createFromRawAddress ( 'SBILTA367K2LX2FEXG5TFWAS7GEFYAGY7QLFBYKC' ) ,
313+ mosaics ,
314+ PlainMessage . create ( 'NEM' ) ,
315+ NetworkType . MIJIN_TEST ,
316+ ) ;
317+
318+ expect ( transferTransaction . mosaics [ 0 ] . id . id . compact ( ) ) . to . be . equal ( 200 ) ;
319+ expect ( transferTransaction . mosaics [ 1 ] . id . id . compact ( ) ) . to . be . equal ( 100 ) ;
320+
321+ const signedTransaction = transferTransaction . signWith ( account , generationHash ) ;
322+
323+ expect ( signedTransaction . payload . substring (
324+ 304 ,
325+ signedTransaction . payload . length ,
326+ ) ) . to . be . equal (
327+ '64000000000000000000000000000000C8000000000000000000000000000000' ) ;
328+
329+ const sorted = CreateTransactionFromPayload ( signedTransaction . payload ) as TransferTransaction ;
330+ expect ( sorted . mosaics [ 0 ] . id . id . compact ( ) ) . to . be . equal ( 100 ) ;
331+ expect ( sorted . mosaics [ 1 ] . id . id . compact ( ) ) . to . be . equal ( 200 ) ;
332+ } ) ;
298333} ) ;
0 commit comments