@@ -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 ;
@@ -299,4 +304,34 @@ describe('TransferTransaction', () => {
299304 ) ;
300305 } ) . to . throw ( ) ;
301306 } ) ;
307+
308+ it ( 'should sort the Mosaic array' , ( ) => {
309+ const mosaics = [
310+ new Mosaic ( new MosaicId ( UInt64 . fromUint ( 200 ) . toDTO ( ) ) , UInt64 . fromUint ( 0 ) ) ,
311+ new Mosaic ( new MosaicId ( UInt64 . fromUint ( 100 ) . toDTO ( ) ) , UInt64 . fromUint ( 0 ) ) ,
312+ ] ;
313+
314+ const transferTransaction = TransferTransaction . create (
315+ Deadline . create ( ) ,
316+ Address . createFromRawAddress ( 'SBILTA367K2LX2FEXG5TFWAS7GEFYAGY7QLFBYKC' ) ,
317+ mosaics ,
318+ PlainMessage . create ( 'NEM' ) ,
319+ NetworkType . MIJIN_TEST ,
320+ ) ;
321+
322+ expect ( transferTransaction . mosaics [ 0 ] . id . id . compact ( ) ) . to . be . equal ( 200 ) ;
323+ expect ( transferTransaction . mosaics [ 1 ] . id . id . compact ( ) ) . to . be . equal ( 100 ) ;
324+
325+ const signedTransaction = transferTransaction . signWith ( account , generationHash ) ;
326+
327+ expect ( signedTransaction . payload . substring (
328+ 304 ,
329+ signedTransaction . payload . length ,
330+ ) ) . to . be . equal (
331+ '64000000000000000000000000000000C8000000000000000000000000000000' ) ;
332+
333+ const sorted = CreateTransactionFromPayload ( signedTransaction . payload ) as TransferTransaction ;
334+ expect ( sorted . mosaics [ 0 ] . id . id . compact ( ) ) . to . be . equal ( 100 ) ;
335+ expect ( sorted . mosaics [ 1 ] . id . id . compact ( ) ) . to . be . equal ( 200 ) ;
336+ } ) ;
302337} ) ;
0 commit comments