@@ -27,8 +27,8 @@ import { NetworkCurrencyMosaic } from '../../src/model/mosaic/NetworkCurrencyMos
2727import { Deadline } from '../../src/model/transaction/Deadline' ;
2828import { TransactionInfo } from '../../src/model/transaction/TransactionInfo' ;
2929import { TransferTransaction } from '../../src/model/transaction/TransferTransaction' ;
30- import { IntegrationTestHelper } from './IntegrationTestHelper' ;
3130import { UInt64 } from '../../src/model/UInt64' ;
31+ import { IntegrationTestHelper } from './IntegrationTestHelper' ;
3232
3333describe ( 'BlockHttp' , ( ) => {
3434 const helper = new IntegrationTestHelper ( ) ;
@@ -69,7 +69,7 @@ describe('BlockHttp', () => {
6969
7070 describe ( 'Setup Test Data' , ( ) => {
7171
72- it ( 'Announce TransferTransaction' , ( done ) => {
72+ it ( 'Announce TransferTransaction' , ( ) => {
7373 const transferTransaction = TransferTransaction . create (
7474 Deadline . create ( ) ,
7575 account2 . address ,
@@ -79,99 +79,79 @@ describe('BlockHttp', () => {
7979 helper . maxFee ,
8080 ) ;
8181 const signedTransaction = transferTransaction . signWith ( account , generationHash ) ;
82- helper . announce ( signedTransaction ) . then ( ( transaction ) => {
82+ return helper . announce ( signedTransaction ) . then ( ( transaction ) => {
8383 chainHeight = transaction . transactionInfo ! . height . toString ( ) ;
84- done ( ) ;
84+ return chainHeight ;
8585 } ) ;
8686 } ) ;
8787 } ) ;
8888
8989 describe ( 'getBlockByHeight' , ( ) => {
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- } ) ;
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+
10199 } ) ;
102100 } ) ;
103101
104102 describe ( 'getBlockTransactions' , ( ) => {
105103 let nextId : string ;
106104 let firstId : string ;
107105
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- } ) ;
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 ) ;
116111 } ) ;
117112
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- } ) ;
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 ) ;
125117 } ) ;
126118 } ) ;
127119
128120 describe ( 'getBlocksByHeightWithLimit' , ( ) => {
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- } ) ;
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 ) ;
135124 } ) ;
136125 } ) ;
137126 describe ( 'getMerkleReceipts' , ( ) => {
138- it ( 'should return Merkle Receipts' , ( done ) => {
139- receiptRepository . getBlockReceipts ( chainHeight ) . pipe (
127+ it ( 'should return Merkle Receipts' , async ( ) => {
128+ const merkleReceipts = await receiptRepository . getBlockReceipts ( chainHeight ) . pipe (
140129 mergeMap ( ( _ ) => {
141130 return receiptRepository . getMerkleReceipts ( chainHeight , _ . transactionStatements [ 0 ] . generateHash ( ) ) ;
142- } ) )
143- . subscribe ( ( merkleReceipts ) => {
144- expect ( merkleReceipts . merklePath ) . not . to . be . null ;
145- done ( ) ;
146- } ) ;
131+ } ) ) . toPromise ( ) ;
132+ expect ( merkleReceipts . merklePath ) . not . to . be . null ;
147133 } ) ;
148134 } ) ;
149135 describe ( 'getMerkleTransaction' , ( ) => {
150- it ( 'should return Merkle Transaction' , ( done ) => {
151- blockRepository . getBlockTransactions ( chainHeight ) . pipe (
136+ it ( 'should return Merkle Transaction' , async ( ) => {
137+ const merkleTransactionss = await blockRepository . getBlockTransactions ( chainHeight ) . pipe (
152138 mergeMap ( ( _ ) => {
153139 const hash = ( _ [ 0 ] . transactionInfo as TransactionInfo ) . hash ;
154140 if ( hash ) {
155141 return blockRepository . getMerkleTransaction ( chainHeight , hash ) ;
156142 }
157143 // If reaching this line, something is not right
158144 throw new Error ( 'Tansacation hash is undefined' ) ;
159- } ) )
160- . subscribe ( ( merkleTransactionss ) => {
161- expect ( merkleTransactionss . merklePath ) . not . to . be . null ;
162- done ( ) ;
163- } ) ;
145+ } ) ) . toPromise ( ) ;
146+ expect ( merkleTransactionss . merklePath ) . not . to . be . null ;
164147 } ) ;
165148 } ) ;
166149
167150 describe ( 'getBlockReceipts' , ( ) => {
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- } ) ;
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 ) ;
175155 } ) ;
176156 } ) ;
177157} ) ;
0 commit comments