@@ -31,6 +31,9 @@ import { Deadline } from '../../src/model/transaction/Deadline';
3131import { MultisigAccountModificationTransaction } from '../../src/model/transaction/MultisigAccountModificationTransaction' ;
3232import { TransferTransaction } from '../../src/model/transaction/TransferTransaction' ;
3333import { AggregateTransactionService } from '../../src/service/AggregateTransactionService' ;
34+ import { RepositoryFactory } from '../../src/infrastructure/RepositoryFactory' ;
35+ import { NetworkRepository } from '../../src/infrastructure/NetworkRepository' ;
36+ import { NetworkConfigurationDTO , PluginsPropertiesDTO , AggregateNetworkPropertiesDTO } from 'symbol-openapi-typescript-node-client' ;
3437
3538/**
3639 * For multi level multisig scenario visit: https://github.com/nemtech/symbol-docs/issues/10
@@ -131,8 +134,20 @@ describe('AggregateTransactionService', () => {
131134 return new MultisigAccountGraphInfo ( map ) ;
132135 }
133136
137+ function getNetworkProperties ( input : string ) : NetworkConfigurationDTO {
138+ const body = new NetworkConfigurationDTO ( ) ;
139+ const plugin = new PluginsPropertiesDTO ( ) ;
140+ plugin . aggregate = new AggregateNetworkPropertiesDTO ( ) ;
141+ plugin . aggregate . maxCosignaturesPerAggregate = input ;
142+ body . plugins = plugin ;
143+ return body ;
144+ }
145+
146+ let mockNetworkRepository : NetworkRepository ;
134147 before ( ( ) => {
135- const mockedAccountRepository : MultisigRepository = mock ( ) ;
148+ mockNetworkRepository = mock < NetworkRepository > ( ) ;
149+ const mockRepoFactory = mock < RepositoryFactory > ( ) ;
150+ const mockedAccountRepository : MultisigRepository = mock < MultisigRepository > ( ) ;
136151
137152 when ( mockedAccountRepository . getMultisigAccountInfo ( deepEqual ( account1 . address ) ) ) . thenReturn ( observableOf ( givenAccount1Info ( ) ) ) ;
138153 when ( mockedAccountRepository . getMultisigAccountInfo ( deepEqual ( account4 . address ) ) ) . thenReturn ( observableOf ( givenAccount4Info ( ) ) ) ;
@@ -152,7 +167,11 @@ describe('AggregateTransactionService', () => {
152167 when ( mockedAccountRepository . getMultisigAccountInfo ( deepEqual ( account3 . address ) ) ) . thenReturn ( observableOf ( givenAccount3Info ( ) ) ) ;
153168
154169 const accountRepository = instance ( mockedAccountRepository ) ;
155- aggregateTransactionService = new AggregateTransactionService ( accountRepository ) ;
170+ const networkRespository = instance ( mockNetworkRepository ) ;
171+ const repoFactory = instance ( mockRepoFactory ) ;
172+ when ( mockRepoFactory . createMultisigRepository ( ) ) . thenReturn ( accountRepository ) ;
173+ when ( mockRepoFactory . createNetworkRepository ( ) ) . thenReturn ( networkRespository ) ;
174+ aggregateTransactionService = new AggregateTransactionService ( repoFactory ) ;
156175 } ) ;
157176
158177 it ( 'should return isComplete: true for aggregated complete transaction - 2 levels Multisig' , ( ) => {
@@ -580,4 +599,31 @@ describe('AggregateTransactionService', () => {
580599 expect ( isComplete ) . to . be . false ;
581600 } ) ;
582601 } ) ;
602+
603+ it ( 'should call getNetworkMaxCosignaturesPerAggregate and returns' , async ( ) => {
604+ when ( mockNetworkRepository . getNetworkProperties ( ) ) . thenReturn ( observableOf ( getNetworkProperties ( '15' ) ) ) ;
605+ const max = await aggregateTransactionService . getNetworkMaxCosignaturesPerAggregate ( ) . toPromise ( ) ;
606+ expect ( max ) . to . be . equal ( 15 ) ;
607+ } ) ;
608+
609+ it ( 'should call getNetworkMaxCosignaturesPerAggregate and returns with single quote' , async ( ) => {
610+ when ( mockNetworkRepository . getNetworkProperties ( ) ) . thenReturn ( observableOf ( getNetworkProperties ( `1'000` ) ) ) ;
611+ const max = await aggregateTransactionService . getNetworkMaxCosignaturesPerAggregate ( ) . toPromise ( ) ;
612+ expect ( max ) . to . be . equal ( 1000 ) ;
613+ } ) ;
614+
615+ it ( 'should call getNetworkMaxCosignaturesPerAggregate and throw' , ( ) => {
616+ when ( mockNetworkRepository . getNetworkProperties ( ) ) . thenReturn ( observableOf ( getNetworkProperties ( '' ) ) ) ;
617+ aggregateTransactionService
618+ . getNetworkMaxCosignaturesPerAggregate ( )
619+ . toPromise ( )
620+ . catch ( ( error ) => {
621+ expect ( error ) . not . to . be . undefined ;
622+ } ) ;
623+ } ) ;
624+
625+ it ( 'should call getMaxCosignatures and returns' , async ( ) => {
626+ const max = await aggregateTransactionService . getMaxCosignatures ( multisig2 . address ) . toPromise ( ) ;
627+ expect ( max ) . to . be . equal ( 4 ) ;
628+ } ) ;
583629} ) ;
0 commit comments