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