File tree Expand file tree Collapse file tree 3 files changed +13
-8
lines changed Expand file tree Collapse file tree 3 files changed +13
-8
lines changed Original file line number Diff line number Diff line change 1
- [ ![ npm] ( https://img.shields.io/npm/v/@defichain/testcontainer )] ( https://www.npmjs.com/package/@defichain/testcontainer /v/latest )
2
- [ ![ npm@next] ( https://img.shields.io/npm/v/@defichain/testcontainer /next )] ( https://www.npmjs.com/package/@defichain/testcontainer /v/next )
1
+ [ ![ npm] ( https://img.shields.io/npm/v/@defichain/testcontainers )] ( https://www.npmjs.com/package/@defichain/testcontainers /v/latest )
2
+ [ ![ npm@next] ( https://img.shields.io/npm/v/@defichain/testcontainers /next )] ( https://www.npmjs.com/package/@defichain/testcontainers /v/next )
3
3
4
4
# @defichain/testcontainers
5
5
Original file line number Diff line number Diff line change @@ -269,8 +269,9 @@ export abstract class DeFiDContainer {
269
269
/**
270
270
* @param {() => Promise<boolean> } condition to wait for true
271
271
* @param {number } timeout duration when condition is not met
272
+ * @param {number } [interval=200] duration in ms
272
273
*/
273
- async waitForCondition ( condition : ( ) => Promise < boolean > , timeout : number ) : Promise < void > {
274
+ async waitForCondition ( condition : ( ) => Promise < boolean > , timeout : number , interval : number = 200 ) : Promise < void > {
274
275
const expiredAt = Date . now ( ) + timeout
275
276
276
277
return await new Promise ( ( resolve , reject ) => {
@@ -281,7 +282,7 @@ export abstract class DeFiDContainer {
281
282
} else if ( expiredAt < Date . now ( ) ) {
282
283
reject ( new Error ( `waitForCondition is not ready within given timeout of ${ timeout } ms.` ) )
283
284
} else {
284
- setTimeout ( ( ) => void checkCondition ( ) , 200 )
285
+ setTimeout ( ( ) => void checkCondition ( ) , interval )
285
286
}
286
287
}
287
288
Original file line number Diff line number Diff line change @@ -89,11 +89,15 @@ export class MasterNodeRegTestContainer extends RegTestContainer {
89
89
*
90
90
* A coinbase transaction must be 100 blocks deep before you can spend its outputs.
91
91
* This is a safeguard to prevent outputs that originate
92
- * from the coinbase transaction from becoming unspendable
93
- * (in the event the mined block moves out of the active chaindue to a fork).
92
+ * from the coinbase transaction from becoming un-spendable
93
+ * (in the event the mined block moves out of the active chain due to a fork).
94
94
*/
95
- async waitForWalletCoinbaseMaturity ( ) : Promise < void > {
96
- await this . generate ( 100 )
95
+ async waitForWalletCoinbaseMaturity ( timeout = 90000 ) : Promise < void > {
96
+ return await this . waitForCondition ( async ( ) => {
97
+ await this . generate ( 1 )
98
+ const count = await this . getBlockCount ( )
99
+ return count > 100
100
+ } , timeout , 100 )
97
101
}
98
102
99
103
/**
You can’t perform that action at this time.
0 commit comments