@@ -20,19 +20,23 @@ import { Listener } from '../../src/infrastructure/Listener';
2020import { NamespaceHttp } from '../../src/infrastructure/NamespaceHttp' ;
2121import { TransactionHttp } from '../../src/infrastructure/TransactionHttp' ;
2222import { Account } from '../../src/model/account/Account' ;
23+ import { Address } from '../../src/model/account/Address' ;
2324import { NetworkType } from '../../src/model/blockchain/NetworkType' ;
2425import { PlainMessage } from '../../src/model/message/PlainMessage' ;
25- import { Address , Mosaic , MosaicSupplyChangeAction , MosaicSupplyChangeTransaction } from '../../src/model/model ' ;
26+ import { Mosaic } from '../../src/model/mosaic/Mosaic ' ;
2627import { MosaicFlags } from '../../src/model/mosaic/MosaicFlags' ;
2728import { MosaicId } from '../../src/model/mosaic/MosaicId' ;
2829import { MosaicNonce } from '../../src/model/mosaic/MosaicNonce' ;
30+ import { MosaicSupplyChangeAction } from '../../src/model/mosaic/MosaicSupplyChangeAction' ;
2931import { NetworkCurrencyMosaic } from '../../src/model/mosaic/NetworkCurrencyMosaic' ;
3032import { AliasAction } from '../../src/model/namespace/AliasAction' ;
3133import { NamespaceId } from '../../src/model/namespace/NamespaceId' ;
3234import { AddressAliasTransaction } from '../../src/model/transaction/AddressAliasTransaction' ;
35+ import { AggregateTransaction } from '../../src/model/transaction/AggregateTransaction' ;
3336import { Deadline } from '../../src/model/transaction/Deadline' ;
3437import { MosaicAliasTransaction } from '../../src/model/transaction/MosaicAliasTransaction' ;
3538import { MosaicDefinitionTransaction } from '../../src/model/transaction/MosaicDefinitionTransaction' ;
39+ import { MosaicSupplyChangeTransaction } from '../../src/model/transaction/MosaicSupplyChangeTransaction' ;
3640import { NamespaceRegistrationTransaction } from '../../src/model/transaction/NamespaceRegistrationTransaction' ;
3741import { TransferTransaction } from '../../src/model/transaction/TransferTransaction' ;
3842import { UInt64 } from '../../src/model/UInt64' ;
@@ -94,7 +98,7 @@ describe('TransactionService', () => {
9498 ) ;
9599 addressAlias = new NamespaceId ( namespaceName ) ;
96100 const signedTransaction = registerNamespaceTransaction . signWith ( account , generationHash ) ;
97-
101+ transactionHashes . push ( signedTransaction . hash ) ;
98102 listener . confirmed ( account . address ) . subscribe ( ( ) => {
99103 done ( ) ;
100104 } ) ;
@@ -126,7 +130,7 @@ describe('TransactionService', () => {
126130 ) ;
127131 mosaicAlias = new NamespaceId ( namespaceName ) ;
128132 const signedTransaction = registerNamespaceTransaction . signWith ( account , generationHash ) ;
129-
133+ transactionHashes . push ( signedTransaction . hash ) ;
130134 listener . confirmed ( account . address ) . subscribe ( ( ) => {
131135 done ( ) ;
132136 } ) ;
@@ -158,7 +162,7 @@ describe('TransactionService', () => {
158162 NetworkType . MIJIN_TEST ,
159163 ) ;
160164 const signedTransaction = addressAliasTransaction . signWith ( account , generationHash ) ;
161-
165+ transactionHashes . push ( signedTransaction . hash ) ;
162166 listener . confirmed ( account . address ) . subscribe ( ( ) => {
163167 done ( ) ;
164168 } ) ;
@@ -193,7 +197,7 @@ describe('TransactionService', () => {
193197 NetworkType . MIJIN_TEST ,
194198 ) ;
195199 const signedTransaction = mosaicDefinitionTransaction . signWith ( account , generationHash ) ;
196-
200+ transactionHashes . push ( signedTransaction . hash ) ;
197201 listener . confirmed ( account . address ) . subscribe ( ( ) => {
198202 done ( ) ;
199203 } ) ;
@@ -219,6 +223,7 @@ describe('TransactionService', () => {
219223 NetworkType . MIJIN_TEST ,
220224 ) ;
221225 const signedTransaction = mosaicSupplyChangeTransaction . signWith ( account , generationHash ) ;
226+ transactionHashes . push ( signedTransaction . hash ) ;
222227 listener . confirmed ( account . address ) . subscribe ( ( ) => {
223228 done ( ) ;
224229 } ) ;
@@ -250,7 +255,7 @@ describe('TransactionService', () => {
250255 NetworkType . MIJIN_TEST ,
251256 ) ;
252257 const signedTransaction = mosaicAliasTransaction . signWith ( account , generationHash ) ;
253-
258+ transactionHashes . push ( signedTransaction . hash ) ;
254259 listener . confirmed ( account . address ) . subscribe ( ( ) => {
255260 done ( ) ;
256261 } ) ;
@@ -277,7 +282,7 @@ describe('TransactionService', () => {
277282 Deadline . create ( ) ,
278283 addressAlias ,
279284 [
280- // NetworkCurrencyMosaic.createAbsolute(1), //Seems get banned on rest if passing multiple mosaic alias in
285+ NetworkCurrencyMosaic . createAbsolute ( 1 ) ,
281286 new Mosaic ( mosaicAlias , UInt64 . fromUint ( 1 ) ) ,
282287 ] ,
283288 PlainMessage . create ( 'test-message' ) ,
@@ -298,13 +303,60 @@ describe('TransactionService', () => {
298303 transactionHttp . announce ( signedTransaction ) ;
299304 } ) ;
300305 } ) ;
306+
307+ describe ( 'Create Aggreate TransferTransaction' , ( ) => {
308+ let listener : Listener ;
309+ before ( ( ) => {
310+ listener = new Listener ( config . apiUrl ) ;
311+ return listener . open ( ) ;
312+ } ) ;
313+ after ( ( ) => {
314+ return listener . close ( ) ;
315+ } ) ;
316+ it ( 'aggregate' , ( done ) => {
317+ const transferTransaction = TransferTransaction . create (
318+ Deadline . create ( ) ,
319+ addressAlias ,
320+ [
321+ NetworkCurrencyMosaic . createAbsolute ( 1 ) ,
322+ new Mosaic ( mosaicAlias , UInt64 . fromUint ( 1 ) ) ,
323+ ] ,
324+ PlainMessage . create ( 'test-message' ) ,
325+ NetworkType . MIJIN_TEST ,
326+ ) ;
327+ const aggregateTransaction = AggregateTransaction . createComplete ( Deadline . create ( ) ,
328+ [ transferTransaction . toAggregate ( account . publicAccount ) ] ,
329+ NetworkType . MIJIN_TEST ,
330+ [ ] ,
331+ ) ;
332+ const signedTransaction = aggregateTransaction . signWith ( account , generationHash ) ;
333+ transactionHashes . push ( signedTransaction . hash ) ;
334+ listener . confirmed ( account . address ) . subscribe ( ( ) => {
335+ done ( ) ;
336+ } ) ;
337+ listener . status ( account . address ) . subscribe ( ( error ) => {
338+ console . log ( 'Error:' , error ) ;
339+ assert ( false ) ;
340+ done ( ) ;
341+ } ) ;
342+ transactionHttp . announce ( signedTransaction ) ;
343+ } ) ;
344+ } ) ;
301345 describe ( 'should return resolved transaction' , ( ) => {
302346 it ( 'call transaction service' , ( done ) => {
303347 const transactionService = new TransactionService ( url ) ;
304348 return transactionService . resolveAliases ( transactionHashes ) . subscribe ( ( transactions ) => {
305- transactions . map ( ( tx : TransferTransaction ) => {
306- expect ( ( tx . recipientAddress as Address ) . plain ( ) ) . to . be . equal ( account . address . plain ( ) ) ;
307- expect ( tx . mosaics . find ( ( m ) => m . id . toHex ( ) === mosaicId . toHex ( ) ) ) . not . to . equal ( undefined ) ;
349+ expect ( transactions . length ) . to . be . equal ( 8 ) ;
350+ transactions . map ( ( tx ) => {
351+ if ( tx instanceof TransferTransaction ) {
352+ expect ( ( tx . recipientAddress as Address ) . plain ( ) ) . to . be . equal ( account . address . plain ( ) ) ;
353+ expect ( tx . mosaics . find ( ( m ) => m . id . toHex ( ) === mosaicId . toHex ( ) ) ) . not . to . equal ( undefined ) ;
354+ } else if ( tx instanceof AggregateTransaction ) {
355+ expect ( ( ( tx . innerTransactions [ 0 ] as TransferTransaction ) . recipientAddress as Address )
356+ . plain ( ) ) . to . be . equal ( account . address . plain ( ) ) ;
357+ expect ( ( tx . innerTransactions [ 0 ] as TransferTransaction ) . mosaics
358+ . find ( ( m ) => m . id . toHex ( ) === mosaicId . toHex ( ) ) ) . not . to . equal ( undefined ) ;
359+ }
308360 } ) ;
309361 done ( ) ;
310362 } ) ;
0 commit comments