@@ -25,7 +25,7 @@ it('has disabled DEBUG_COMMANDS flag', () => {
2525} ) ;
2626
2727describe ( 'CLI' , ( ) => {
28- jest . setTimeout ( 45_000 ) ;
28+ jest . setTimeout ( 300_000 ) ;
2929
3030 let provider : ethers . providers . StaticJsonRpcProvider ;
3131 let deployer : ethers . providers . JsonRpcSigner ;
@@ -333,7 +333,19 @@ Template data:
333333 describe ( 'withdrawal' , ( ) => {
334334 let sponsor : ethers . Wallet ;
335335 let sponsorWallet : ethers . Wallet ;
336- const sponsorBalance = ( ) => sponsor . getBalance ( ) ;
336+
337+ // Helper to retry async operations that may fail due to transient connection issues in CI
338+ const withRetry = async < T > ( fn : ( ) => Promise < T > , maxRetries = 3 , delayMs = 1000 ) : Promise < T > => {
339+ for ( let attempt = 1 ; attempt <= maxRetries ; attempt ++ ) {
340+ try {
341+ return await fn ( ) ;
342+ } catch ( error ) {
343+ if ( attempt === maxRetries ) throw error ;
344+ await new Promise ( ( resolve ) => setTimeout ( resolve , delayMs * attempt ) ) ;
345+ }
346+ }
347+ throw new Error ( 'Unreachable' ) ;
348+ } ;
337349
338350 beforeEach ( async ( ) => {
339351 // Prepare for derivation of designated wallet - see test for designated wallet derivation for details
@@ -371,13 +383,23 @@ Template data:
371383
372384 expect ( checkWithdrawalStatus ( ) ) . toBe ( 'Withdrawal request is not fulfilled yet' ) ;
373385
374- const balanceBefore = await sponsorBalance ( ) ;
386+ // Use retry for balance fetches to handle transient ECONNRESET errors in CI
387+ const balanceBefore = await withRetry ( ( ) => sponsor . getBalance ( ) ) ;
375388 airnodeRrp = airnodeRrp . connect ( sponsorWallet ) ;
376- await admin . fulfillWithdrawal ( airnodeRrp , withdrawalRequestId , airnodeWallet . address , sponsor . address , '0.8' ) ;
377- expect ( checkWithdrawalStatus ( ) ) . toBe ( 'Withdrawn amount: 800000000000000000' ) ;
378- expect ( ( await sponsorBalance ( ) ) . toString ( ) ) . toBe (
379- balanceBefore . add ( ethers . BigNumber . from ( '800000000000000000' ) ) . toString ( )
389+
390+ const fulfillResult = await admin . fulfillWithdrawal (
391+ airnodeRrp ,
392+ withdrawalRequestId ,
393+ airnodeWallet . address ,
394+ sponsor . address ,
395+ '0.8'
380396 ) ;
397+ expect ( fulfillResult ) . not . toBeNull ( ) ;
398+
399+ expect ( checkWithdrawalStatus ( ) ) . toBe ( 'Withdrawn amount: 800000000000000000' ) ;
400+
401+ const balanceAfter = await withRetry ( ( ) => sponsor . getBalance ( ) ) ;
402+ expect ( balanceAfter . toString ( ) ) . toBe ( balanceBefore . add ( ethers . BigNumber . from ( '800000000000000000' ) ) . toString ( ) ) ;
381403 } ) ;
382404 } ) ;
383405
0 commit comments