1515 */
1616import { assert , expect } from 'chai' ;
1717import { ChronoUnit } from 'js-joda' ;
18- import { filter } from 'rxjs/operators' ;
18+ import { filter , mergeMap } from 'rxjs/operators' ;
1919import { TransactionRepository } from '../../src/infrastructure/TransactionRepository' ;
2020import { Account } from '../../src/model/account/Account' ;
2121import { PlainMessage } from '../../src/model/message/PlainMessage' ;
22- import { Address , CosignatureTransaction , LockFundsTransaction , Mosaic , SignedTransaction , UInt64 } from '../../src/model/model' ;
23- import { MosaicId } from '../../src/model/mosaic/MosaicId' ;
24- import { NamespaceId } from '../../src/model/namespace/NamespaceId' ;
2522import { NetworkType } from '../../src/model/network/NetworkType' ;
2623import { AggregateTransaction } from '../../src/model/transaction/AggregateTransaction' ;
2724import { Deadline } from '../../src/model/transaction/Deadline' ;
2825import { MultisigAccountModificationTransaction } from '../../src/model/transaction/MultisigAccountModificationTransaction' ;
2926import { TransferTransaction } from '../../src/model/transaction/TransferTransaction' ;
3027import { IntegrationTestHelper } from './IntegrationTestHelper' ;
3128import { TransactionSearchCriteria } from '../../src/infrastructure/searchCriteria/TransactionSearchCriteria' ;
32- import { TransactionGroupSubsetEnum } from 'symbol-openapi-typescript-node-client' ;
29+ import { Address } from '../../src/model/account/Address' ;
30+ import { SignedTransaction } from '../../src/model/transaction/SignedTransaction' ;
31+ import { LockFundsTransaction } from '../../src/model/transaction/LockFundsTransaction' ;
32+ import { UInt64 } from '../../src/model/UInt64' ;
33+ import { Mosaic } from '../../src/model/mosaic/Mosaic' ;
34+ import { CosignatureTransaction } from '../../src/model/transaction/CosignatureTransaction' ;
35+ import { UnresolvedMosaicId } from '../../src/model/mosaic/UnresolvedMosaicId' ;
36+ import { TransactionGroup } from '../../src/infrastructure/TransactionGroup' ;
3337
3438describe ( 'Listener' , ( ) => {
3539 const helper = new IntegrationTestHelper ( ) ;
@@ -41,7 +45,6 @@ describe('Listener', () => {
4145 let cosignAccount3 : Account ;
4246 let generationHash : string ;
4347 let networkType : NetworkType ;
44- const NetworkCurrencyLocalId : NamespaceId = helper . networkCurrencyNamespaceId ;
4548 let transactionRepository : TransactionRepository ;
4649
4750 before ( ( ) => {
@@ -92,7 +95,7 @@ describe('Listener', () => {
9295 const createHashLockTransactionAndAnnounce = (
9396 signedAggregatedTransaction : SignedTransaction ,
9497 signer : Account ,
95- mosaicId : MosaicId | NamespaceId ,
98+ mosaicId : UnresolvedMosaicId ,
9699 ) : void => {
97100 const lockFundsTransaction = LockFundsTransaction . create (
98101 Deadline . create ( ) ,
@@ -182,7 +185,7 @@ describe('Listener', () => {
182185 const transferTransaction = TransferTransaction . create (
183186 Deadline . create ( ) ,
184187 cosignAccount1 . address ,
185- [ new Mosaic ( NetworkCurrencyLocalId , UInt64 . fromUint ( 10 * Math . pow ( 10 , helper . networkCurrencyDivisibility ) ) ) ] ,
188+ [ helper . createNetworkCurrency ( 10 , true ) ] ,
186189 PlainMessage . create ( 'test-message' ) ,
187190 networkType ,
188191 helper . maxFee ,
@@ -199,7 +202,7 @@ describe('Listener', () => {
199202 Deadline . create ( ) ,
200203 2 ,
201204 1 ,
202- [ cosignAccount1 . publicAccount , cosignAccount2 . publicAccount , cosignAccount3 . publicAccount ] ,
205+ [ cosignAccount1 . address , cosignAccount2 . address , cosignAccount3 . address ] ,
203206 [ ] ,
204207 networkType ,
205208 helper . maxFee ,
@@ -225,7 +228,7 @@ describe('Listener', () => {
225228 describe ( 'Aggregate Bonded Transactions' , ( ) => {
226229 it ( 'aggregateBondedTransactionsAdded' , ( done ) => {
227230 const signedAggregatedTx = createSignedAggregatedBondTransaction ( multisigAccount , account , account2 . address ) ;
228- createHashLockTransactionAndAnnounce ( signedAggregatedTx , account , NetworkCurrencyLocalId ) ;
231+ createHashLockTransactionAndAnnounce ( signedAggregatedTx , account , helper . networkCurrencyNamespaceId ) ;
229232 helper . listener . aggregateBondedAdded ( account . address ) . subscribe ( ( ) => {
230233 done ( ) ;
231234 } ) ;
@@ -239,26 +242,34 @@ describe('Listener', () => {
239242 } ) ;
240243 } ) ;
241244 } ) ;
245+
242246 describe ( 'Aggregate Bonded Transactions' , ( ) => {
243247 it ( 'aggregateBondedTransactionsRemoved' , ( done ) => {
244248 const signedAggregatedTx = createSignedAggregatedBondTransaction ( multisigAccount , cosignAccount1 , account2 . address ) ;
245-
246- createHashLockTransactionAndAnnounce ( signedAggregatedTx , cosignAccount1 , NetworkCurrencyLocalId ) ;
249+ createHashLockTransactionAndAnnounce ( signedAggregatedTx , cosignAccount1 , helper . networkCurrencyNamespaceId ) ;
250+ helper . listener . aggregateBondedRemoved ( cosignAccount1 . address , signedAggregatedTx . hash ) . subscribe ( ( ) => {
251+ done ( ) ;
252+ } ) ;
247253 helper . listener . confirmed ( cosignAccount1 . address ) . subscribe ( ( ) => {
248- helper . listener . aggregateBondedRemoved ( cosignAccount1 . address ) . subscribe ( ( ) => {
249- done ( ) ;
250- } ) ;
251254 helper . listener . aggregateBondedAdded ( cosignAccount1 . address ) . subscribe ( ( ) => {
252255 const criteria : TransactionSearchCriteria = {
253- address : cosignAccount1 . publicAccount . address ,
254- group : TransactionGroupSubsetEnum . Partial ,
256+ address : cosignAccount1 . address ,
257+ group : TransactionGroup . Partial ,
258+ embedded : true ,
255259 } ;
256- transactionRepository . search ( criteria ) . subscribe ( ( transactions ) => {
257- const transactionToCosign = transactions [ 0 ] ;
258- const cosignatureTransaction = CosignatureTransaction . create ( transactionToCosign ) ;
259- const cosignatureSignedTransaction = cosignAccount2 . signCosignatureTransaction ( cosignatureTransaction ) ;
260- transactionRepository . announceAggregateBondedCosignature ( cosignatureSignedTransaction ) ;
261- } ) ;
260+ transactionRepository
261+ . search ( criteria )
262+ . pipe (
263+ mergeMap ( ( page ) => {
264+ return transactionRepository . getTransaction ( page . data [ 0 ] . transactionInfo ?. hash ! , TransactionGroup . Partial ) ;
265+ } ) ,
266+ )
267+ . subscribe ( ( transactions ) => {
268+ const transactionToCosign = transactions as AggregateTransaction ;
269+ const cosignatureTransaction = CosignatureTransaction . create ( transactionToCosign ) ;
270+ const cosignatureSignedTransaction = cosignAccount2 . signCosignatureTransaction ( cosignatureTransaction ) ;
271+ transactionRepository . announceAggregateBondedCosignature ( cosignatureSignedTransaction ) ;
272+ } ) ;
262273 } ) ;
263274 helper . listener . status ( cosignAccount1 . address ) . subscribe ( ( error ) => {
264275 console . log ( 'Error:' , error ) ;
@@ -279,17 +290,17 @@ describe('Listener', () => {
279290 it ( 'cosignatureAdded' , ( done ) => {
280291 const signedAggregatedTx = createSignedAggregatedBondTransaction ( multisigAccount , cosignAccount1 , account2 . address ) ;
281292
282- createHashLockTransactionAndAnnounce ( signedAggregatedTx , cosignAccount1 , NetworkCurrencyLocalId ) ;
293+ createHashLockTransactionAndAnnounce ( signedAggregatedTx , cosignAccount1 , helper . networkCurrencyNamespaceId ) ;
283294 helper . listener . cosignatureAdded ( cosignAccount1 . address ) . subscribe ( ( ) => {
284295 done ( ) ;
285296 } ) ;
286297 helper . listener . aggregateBondedAdded ( cosignAccount1 . address ) . subscribe ( ( ) => {
287298 const criteria : TransactionSearchCriteria = {
288299 address : cosignAccount1 . publicAccount . address ,
289- group : TransactionGroupSubsetEnum . Partial ,
300+ group : TransactionGroup . Partial ,
290301 } ;
291302 transactionRepository . search ( criteria ) . subscribe ( ( transactions ) => {
292- const transactionToCosign = transactions [ 0 ] ;
303+ const transactionToCosign = transactions . data [ 0 ] as AggregateTransaction ;
293304 const cosignatureTransaction = CosignatureTransaction . create ( transactionToCosign ) ;
294305 const cosignatureSignedTransaction = cosignAccount2 . signCosignatureTransaction ( cosignatureTransaction ) ;
295306 transactionRepository . announceAggregateBondedCosignature ( cosignatureSignedTransaction ) ;
@@ -313,15 +324,15 @@ describe('Listener', () => {
313324 - 1 ,
314325 0 ,
315326 [ ] ,
316- [ cosignAccount1 . publicAccount ] ,
327+ [ cosignAccount1 . address ] ,
317328 networkType ,
318329 ) ;
319330 const removeCosigner2 = MultisigAccountModificationTransaction . create (
320331 Deadline . create ( ) ,
321332 0 ,
322333 0 ,
323334 [ ] ,
324- [ cosignAccount2 . publicAccount ] ,
335+ [ cosignAccount2 . address ] ,
325336 networkType ,
326337 ) ;
327338
@@ -330,7 +341,7 @@ describe('Listener', () => {
330341 - 1 ,
331342 - 1 ,
332343 [ ] ,
333- [ cosignAccount3 . publicAccount ] ,
344+ [ cosignAccount3 . address ] ,
334345 networkType ,
335346 ) ;
336347
@@ -343,6 +354,7 @@ describe('Listener', () => {
343354 ] ,
344355 networkType ,
345356 [ ] ,
357+ helper . maxFee ,
346358 ) ;
347359 const signedTransaction = aggregateTransaction . signTransactionWithCosignatories (
348360 cosignAccount1 ,
0 commit comments