@@ -69,7 +69,7 @@ describe('BlockHttp', () => {
6969
7070 describe ( 'Setup Test Data' , ( ) => {
7171
72- it ( 'Announce TransferTransaction' , ( ) => {
72+ it ( 'Announce TransferTransaction' , ( done ) => {
7373 const transferTransaction = TransferTransaction . create (
7474 Deadline . create ( ) ,
7575 account2 . address ,
@@ -79,79 +79,99 @@ describe('BlockHttp', () => {
7979 helper . maxFee ,
8080 ) ;
8181 const signedTransaction = transferTransaction . signWith ( account , generationHash ) ;
82- return helper . announce ( signedTransaction ) . then ( ( transaction ) => {
82+ helper . announce ( signedTransaction ) . then ( ( transaction ) => {
8383 chainHeight = transaction . transactionInfo ! . height . toString ( ) ;
84- return chainHeight ;
84+ done ( ) ;
8585 } ) ;
8686 } ) ;
8787 } ) ;
8888
8989 describe ( 'getBlockByHeight' , ( ) => {
90- it ( 'should return block info given height' , async ( ) => {
91- const blockInfo = await blockRepository . getBlockByHeight ( UInt64 . fromUint ( 1 ) ) . toPromise ( ) ;
92- blockReceiptHash = blockInfo . blockReceiptsHash ;
93- blockTransactionHash = blockInfo . blockTransactionsHash ;
94- expect ( blockInfo . height . lower ) . to . be . equal ( 1 ) ;
95- expect ( blockInfo . height . higher ) . to . be . equal ( 0 ) ;
96- expect ( blockInfo . timestamp . lower ) . to . be . equal ( 0 ) ;
97- expect ( blockInfo . timestamp . higher ) . to . be . equal ( 0 ) ;
98-
90+ it ( 'should return block info given height' , ( done ) => {
91+ blockRepository . getBlockByHeight ( UInt64 . fromUint ( 1 ) )
92+ . subscribe ( ( blockInfo ) => {
93+ blockReceiptHash = blockInfo . blockReceiptsHash ;
94+ blockTransactionHash = blockInfo . blockTransactionsHash ;
95+ expect ( blockInfo . height . lower ) . to . be . equal ( 1 ) ;
96+ expect ( blockInfo . height . higher ) . to . be . equal ( 0 ) ;
97+ expect ( blockInfo . timestamp . lower ) . to . be . equal ( 0 ) ;
98+ expect ( blockInfo . timestamp . higher ) . to . be . equal ( 0 ) ;
99+ done ( ) ;
100+ } ) ;
99101 } ) ;
100102 } ) ;
101103
102104 describe ( 'getBlockTransactions' , ( ) => {
103105 let nextId : string ;
104106 let firstId : string ;
105107
106- it ( 'should return block transactions data given height' , async ( ) => {
107- const transactions = await blockRepository . getBlockTransactions ( UInt64 . fromUint ( 1 ) ) . toPromise ( ) ;
108- nextId = transactions [ 0 ] . transactionInfo ! . id ;
109- firstId = transactions [ 1 ] . transactionInfo ! . id ;
110- expect ( transactions . length ) . to . be . greaterThan ( 0 ) ;
108+ it ( 'should return block transactions data given height' , ( done ) => {
109+ blockRepository . getBlockTransactions ( UInt64 . fromUint ( 1 ) )
110+ . subscribe ( ( transactions ) => {
111+ nextId = transactions [ 0 ] . transactionInfo ! . id ;
112+ firstId = transactions [ 1 ] . transactionInfo ! . id ;
113+ expect ( transactions . length ) . to . be . greaterThan ( 0 ) ;
114+ done ( ) ;
115+ } ) ;
111116 } ) ;
112117
113- it ( 'should return block transactions data given height with paginated transactionId' , async ( ) => {
114- const transactions = await blockRepository . getBlockTransactions ( UInt64 . fromUint ( 1 ) , new QueryParams ( 10 , nextId ) ) . toPromise ( ) ;
115- expect ( transactions [ 0 ] . transactionInfo ! . id ) . to . be . equal ( firstId ) ;
116- expect ( transactions . length ) . to . be . greaterThan ( 0 ) ;
118+ it ( 'should return block transactions data given height with paginated transactionId' , ( done ) => {
119+ blockRepository . getBlockTransactions ( UInt64 . fromUint ( 1 ) , new QueryParams ( 10 , nextId ) )
120+ . subscribe ( ( transactions ) => {
121+ expect ( transactions [ 0 ] . transactionInfo ! . id ) . to . be . equal ( firstId ) ;
122+ expect ( transactions . length ) . to . be . greaterThan ( 0 ) ;
123+ done ( ) ;
124+ } ) ;
117125 } ) ;
118126 } ) ;
119127
120128 describe ( 'getBlocksByHeightWithLimit' , ( ) => {
121- it ( 'should return block info given height and limit' , async ( ) => {
122- const blocksInfo = await blockRepository . getBlocksByHeightWithLimit ( chainHeight , 50 ) . toPromise ( ) ;
123- expect ( blocksInfo . length ) . to . be . greaterThan ( 0 ) ;
129+ it ( 'should return block info given height and limit' , ( done ) => {
130+ blockRepository . getBlocksByHeightWithLimit ( chainHeight , 50 )
131+ . subscribe ( ( blocksInfo ) => {
132+ expect ( blocksInfo . length ) . to . be . greaterThan ( 0 ) ;
133+ done ( ) ;
134+ } ) ;
124135 } ) ;
125136 } ) ;
126137 describe ( 'getMerkleReceipts' , ( ) => {
127- it ( 'should return Merkle Receipts' , async ( ) => {
128- const merkleReceipts = await receiptRepository . getBlockReceipts ( chainHeight ) . pipe (
138+ it ( 'should return Merkle Receipts' , ( done ) => {
139+ receiptRepository . getBlockReceipts ( chainHeight ) . pipe (
129140 mergeMap ( ( _ ) => {
130141 return receiptRepository . getMerkleReceipts ( chainHeight , _ . transactionStatements [ 0 ] . generateHash ( ) ) ;
131- } ) ) . toPromise ( ) ;
132- expect ( merkleReceipts . merklePath ) . not . to . be . null ;
142+ } ) )
143+ . subscribe ( ( merkleReceipts ) => {
144+ expect ( merkleReceipts . merklePath ) . not . to . be . null ;
145+ done ( ) ;
146+ } ) ;
133147 } ) ;
134148 } ) ;
135149 describe ( 'getMerkleTransaction' , ( ) => {
136- it ( 'should return Merkle Transaction' , async ( ) => {
137- const merkleTransactionss = await blockRepository . getBlockTransactions ( chainHeight ) . pipe (
150+ it ( 'should return Merkle Transaction' , ( done ) => {
151+ blockRepository . getBlockTransactions ( chainHeight ) . pipe (
138152 mergeMap ( ( _ ) => {
139153 const hash = ( _ [ 0 ] . transactionInfo as TransactionInfo ) . hash ;
140154 if ( hash ) {
141155 return blockRepository . getMerkleTransaction ( chainHeight , hash ) ;
142156 }
143157 // If reaching this line, something is not right
144158 throw new Error ( 'Tansacation hash is undefined' ) ;
145- } ) ) . toPromise ( ) ;
146- expect ( merkleTransactionss . merklePath ) . not . to . be . null ;
159+ } ) )
160+ . subscribe ( ( merkleTransactionss ) => {
161+ expect ( merkleTransactionss . merklePath ) . not . to . be . null ;
162+ done ( ) ;
163+ } ) ;
147164 } ) ;
148165 } ) ;
149166
150167 describe ( 'getBlockReceipts' , ( ) => {
151- it ( 'should return block receipts' , async ( ) => {
152- const statement = await receiptRepository . getBlockReceipts ( chainHeight ) . toPromise ( ) ;
153- expect ( statement . transactionStatements ) . not . to . be . null ;
154- expect ( statement . transactionStatements . length ) . to . be . greaterThan ( 0 ) ;
168+ it ( 'should return block receipts' , ( done ) => {
169+ receiptRepository . getBlockReceipts ( chainHeight )
170+ . subscribe ( ( statement ) => {
171+ expect ( statement . transactionStatements ) . not . to . be . null ;
172+ expect ( statement . transactionStatements . length ) . to . be . greaterThan ( 0 ) ;
173+ done ( ) ;
174+ } ) ;
155175 } ) ;
156176 } ) ;
157177} ) ;
0 commit comments