1515 */
1616
1717import { assert , expect } from 'chai' ;
18+ import { mergeMap } from 'rxjs/operators' ;
1819import { BlockHttp } from '../../src/infrastructure/BlockHttp' ;
1920import { Listener , ReceiptHttp , TransactionHttp } from '../../src/infrastructure/infrastructure' ;
2021import { QueryParams } from '../../src/infrastructure/QueryParams' ;
@@ -24,6 +25,7 @@ import { PlainMessage } from '../../src/model/message/PlainMessage';
2425import { NetworkCurrencyMosaic } from '../../src/model/mosaic/NetworkCurrencyMosaic' ;
2526import { Deadline } from '../../src/model/transaction/Deadline' ;
2627import { Transaction } from '../../src/model/transaction/Transaction' ;
28+ import { TransactionInfo } from '../../src/model/transaction/TransactionInfo' ;
2729import { TransferTransaction } from '../../src/model/transaction/TransferTransaction' ;
2830
2931describe ( 'BlockHttp' , ( ) => {
@@ -144,17 +146,28 @@ describe('BlockHttp', () => {
144146 } ) ;
145147 describe ( 'getMerkleReceipts' , ( ) => {
146148 it ( 'should return Merkle Receipts' , ( done ) => {
147- receiptHttp . getMerkleReceipts ( chainHeight , blockReceiptHash )
148- . subscribe ( ( merkleReceipts ) => {
149- expect ( merkleReceipts . merklePath ) . not . to . be . null ;
150- done ( ) ;
151- } ) ;
149+ receiptHttp . getBlockReceipts ( chainHeight ) . pipe (
150+ mergeMap ( ( _ ) => {
151+ return receiptHttp . getMerkleReceipts ( chainHeight , _ . transactionStatements [ 0 ] . generateHash ( ) ) ;
152+ } ) )
153+ . subscribe ( ( merkleReceipts ) => {
154+ expect ( merkleReceipts . merklePath ) . not . to . be . null ;
155+ done ( ) ;
156+ } ) ;
152157 } ) ;
153158 } ) ;
154159 describe ( 'getMerkleTransaction' , ( ) => {
155160 it ( 'should return Merkle Transaction' , ( done ) => {
156- blockHttp . getMerkleTransaction ( chainHeight , blockTransactionHash )
157- . subscribe ( ( merkleTransactionss ) => {
161+ blockHttp . getBlockTransactions ( chainHeight ) . pipe (
162+ mergeMap ( ( _ ) => {
163+ const hash = ( _ [ 0 ] . transactionInfo as TransactionInfo ) . hash ;
164+ if ( hash ) {
165+ return blockHttp . getMerkleTransaction ( chainHeight , hash ) ;
166+ }
167+ // If reaching this line, something is not right
168+ throw new Error ( 'Tansacation hash is undefined' ) ;
169+ } ) )
170+ . subscribe ( ( merkleTransactionss ) => {
158171 expect ( merkleTransactionss . merklePath ) . not . to . be . null ;
159172 done ( ) ;
160173 } ) ;
0 commit comments