@@ -15,7 +15,9 @@ jest.mock('@tezos-x/octez.connect-utils', () => {
1515 this . _resolve = res
1616 this . _reject = rej
1717 } )
18- // Prevent unhandled rejection when promise is rejected without a concurrent awaiter
18+ // Prevent Node.js from throwing unhandled promise rejection errors during tests
19+ // when the ExposedPromise is rejected before any caller awaits it,
20+ // which can occur in error recovery paths
1921 this . promise . catch ( ( ) => { } )
2022 }
2123 resolve ( value : T ) {
@@ -144,7 +146,8 @@ describe('P2PCommunicationClient', () => {
144146
145147 describe ( 'getBeaconInfo' , ( ) => {
146148 it ( 'fetches /_synapse/client/beacon/info and maps the response' , async ( ) => {
147- ; ( axios . get as jest . Mock ) . mockResolvedValue ( {
149+ const axiosGetMock = axios . get as jest . Mock
150+ axiosGetMock . mockResolvedValue ( {
148151 data : {
149152 region : 'eu' ,
150153 known_servers : [ 'a' , 'b' ] ,
@@ -178,7 +181,8 @@ describe('P2PCommunicationClient', () => {
178181 mockStorage . set . mockResolvedValue ( undefined )
179182
180183 // First call (stored node) rejects, second call (discovery probe) succeeds
181- ; ( axios . get as jest . Mock )
184+ const axiosGetMock = axios . get as jest . Mock
185+ axiosGetMock
182186 . mockRejectedValueOnce ( new Error ( 'ECONNREFUSED' ) )
183187 . mockResolvedValue ( {
184188 data : { region : 'eu' , known_servers : [ 'a' ] , timestamp : 5000 }
@@ -197,7 +201,8 @@ describe('P2PCommunicationClient', () => {
197201 it ( 'uses stored node when it is reachable' , async ( ) => {
198202 mockStorage . get . mockResolvedValue ( 'healthy-node.papers.tech' )
199203
200- ; ( axios . get as jest . Mock ) . mockResolvedValue ( {
204+ const axiosGetMock = axios . get as jest . Mock
205+ axiosGetMock . mockResolvedValue ( {
201206 data : { region : 'eu' , known_servers : [ 'a' ] , timestamp : 7777 }
202207 } )
203208
@@ -214,7 +219,8 @@ describe('P2PCommunicationClient', () => {
214219 mockStorage . delete . mockResolvedValue ( undefined )
215220
216221 // All discovery probes fail
217- ; ( axios . get as jest . Mock ) . mockRejectedValue ( new Error ( 'ECONNREFUSED' ) )
222+ const axiosGetMock = axios . get as jest . Mock
223+ axiosGetMock . mockRejectedValue ( new Error ( 'ECONNREFUSED' ) )
218224
219225 await expect ( freshClient . getRelayServer ( ) ) . rejects . toThrow ( )
220226
@@ -228,7 +234,8 @@ describe('P2PCommunicationClient', () => {
228234 mockStorage . delete . mockResolvedValue ( undefined )
229235
230236 // First getRelayServer call: no stored node, discovery finds a server
231- ; ( axios . get as jest . Mock ) . mockResolvedValue ( {
237+ const axiosGetMock = axios . get as jest . Mock
238+ axiosGetMock . mockResolvedValue ( {
232239 data : { region : 'eu' , known_servers : [ 'a' ] , timestamp : 1000 }
233240 } )
234241
@@ -246,7 +253,7 @@ describe('P2PCommunicationClient', () => {
246253 // The recovery path resets state and retries via findBestRegionAndGetServer(),
247254 // which probes all servers. Set up the mock so the first call rejects,
248255 // then all subsequent calls (discovery probes) succeed with a new timestamp.
249- ; ( axios . get as jest . Mock )
256+ axiosGetMock
250257 . mockReset ( )
251258 . mockRejectedValueOnce ( new Error ( 'ETIMEDOUT' ) )
252259 . mockResolvedValue ( {
0 commit comments