@@ -614,6 +614,54 @@ test('args: timeout', async () => {
614614 ) . rejects . toThrowError ( WaitForTransactionReceiptTimeoutError )
615615} )
616616
617+ test ( 'args: requestOptions.signal (already aborted)' , async ( ) => {
618+ setup ( )
619+
620+ const hash = await sendTransaction ( client , {
621+ account : sourceAccount . address ,
622+ to : targetAccount . address ,
623+ value : parseEther ( '1' ) ,
624+ } )
625+
626+ const controller = new AbortController ( )
627+ controller . abort ( )
628+
629+ await expect ( ( ) =>
630+ waitForTransactionReceipt ( client , {
631+ hash,
632+ requestOptions : { signal : controller . signal } ,
633+ } ) ,
634+ ) . rejects . toThrow ( 'This operation was aborted' )
635+ } )
636+
637+ test ( 'args: requestOptions.signal (aborted during wait)' , async ( ) => {
638+ setup ( )
639+
640+ const hash = await sendTransaction ( client , {
641+ account : sourceAccount . address ,
642+ to : targetAccount . address ,
643+ value : parseEther ( '1' ) ,
644+ } )
645+
646+ const controller = new AbortController ( )
647+
648+ const receiptPromise = waitForTransactionReceipt ( client , {
649+ hash,
650+ pollingInterval : 50 ,
651+ timeout : 10_000 ,
652+ requestOptions : { signal : controller . signal } ,
653+ } )
654+
655+ await wait ( 100 )
656+ controller . abort ( )
657+
658+ const start = Date . now ( )
659+ await expect ( ( ) => receiptPromise ) . rejects . toThrow ( )
660+ const elapsed = Date . now ( ) - start
661+
662+ expect ( elapsed ) . toBeLessThan ( 2000 )
663+ } )
664+
617665describe ( 'errors' , ( ) => {
618666 test ( 'throws when transaction replaced and getBlock fails' , async ( ) => {
619667 setup ( )
0 commit comments