@@ -27,8 +27,8 @@ import { NetworkCurrencyMosaic } from '../../src/model/mosaic/NetworkCurrencyMos
27
27
import { Deadline } from '../../src/model/transaction/Deadline' ;
28
28
import { TransactionInfo } from '../../src/model/transaction/TransactionInfo' ;
29
29
import { TransferTransaction } from '../../src/model/transaction/TransferTransaction' ;
30
- import { IntegrationTestHelper } from './IntegrationTestHelper' ;
31
30
import { UInt64 } from '../../src/model/UInt64' ;
31
+ import { IntegrationTestHelper } from './IntegrationTestHelper' ;
32
32
33
33
describe ( 'BlockHttp' , ( ) => {
34
34
const helper = new IntegrationTestHelper ( ) ;
@@ -69,7 +69,7 @@ describe('BlockHttp', () => {
69
69
70
70
describe ( 'Setup Test Data' , ( ) => {
71
71
72
- it ( 'Announce TransferTransaction' , ( done ) => {
72
+ it ( 'Announce TransferTransaction' , ( ) => {
73
73
const transferTransaction = TransferTransaction . create (
74
74
Deadline . create ( ) ,
75
75
account2 . address ,
@@ -79,99 +79,79 @@ describe('BlockHttp', () => {
79
79
helper . maxFee ,
80
80
) ;
81
81
const signedTransaction = transferTransaction . signWith ( account , generationHash ) ;
82
- helper . announce ( signedTransaction ) . then ( ( transaction ) => {
82
+ return helper . announce ( signedTransaction ) . then ( ( transaction ) => {
83
83
chainHeight = transaction . transactionInfo ! . height . toString ( ) ;
84
- done ( ) ;
84
+ return chainHeight ;
85
85
} ) ;
86
86
} ) ;
87
87
} ) ;
88
88
89
89
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
+
101
99
} ) ;
102
100
} ) ;
103
101
104
102
describe ( 'getBlockTransactions' , ( ) => {
105
103
let nextId : string ;
106
104
let firstId : string ;
107
105
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 ) ;
116
111
} ) ;
117
112
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 ) ;
125
117
} ) ;
126
118
} ) ;
127
119
128
120
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 ) ;
135
124
} ) ;
136
125
} ) ;
137
126
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 (
140
129
mergeMap ( ( _ ) => {
141
130
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 ;
147
133
} ) ;
148
134
} ) ;
149
135
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 (
152
138
mergeMap ( ( _ ) => {
153
139
const hash = ( _ [ 0 ] . transactionInfo as TransactionInfo ) . hash ;
154
140
if ( hash ) {
155
141
return blockRepository . getMerkleTransaction ( chainHeight , hash ) ;
156
142
}
157
143
// If reaching this line, something is not right
158
144
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 ;
164
147
} ) ;
165
148
} ) ;
166
149
167
150
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 ) ;
175
155
} ) ;
176
156
} ) ;
177
157
} ) ;
0 commit comments