@ledgerhq/coin-evm 16.4.0 → 16.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -121,6 +121,7 @@ describe('composeInternalTxsFetcher', () => {
121
121
 
122
122
  await expect(fetch(height)).rejects.toMatchObject({
123
123
  errors: [explorerError, traceError],
124
+ message: 'internal tx sources failed: [explorer] explorer down; [trace_block] trace down',
124
125
  })
125
126
  })
126
127
 
@@ -137,9 +138,48 @@ describe('composeInternalTxsFetcher', () => {
137
138
 
138
139
  await expect(fetch(height)).rejects.toMatchObject({
139
140
  errors: [explorerError, traceError],
141
+ message: 'internal tx sources failed: [explorer] explorer down; [trace_block] trace down',
140
142
  })
141
143
  })
142
144
 
145
+ it('reports the cause of an unavailable source next to the real errors', async () => {
146
+ const explorerUnavailable = new SourceUnavailableError('explorer internal txs failed', {
147
+ cause: new Error('rate limited'),
148
+ })
149
+ const traceError = new Error('trace down')
150
+ const fetch = composeInternalTxsFetcher(
151
+ ['explorer', 'trace_block'],
152
+ makeFetchers({
153
+ explorer: jest.fn().mockRejectedValue(explorerUnavailable),
154
+ trace_block: jest.fn().mockRejectedValue(traceError),
155
+ })
156
+ )
157
+
158
+ await expect(fetch(height)).rejects.toMatchObject({
159
+ errors: [explorerUnavailable, traceError],
160
+ message:
161
+ 'internal tx sources failed: [explorer] explorer internal txs failed (cause: rate limited); [trace_block] trace down',
162
+ })
163
+ })
164
+
165
+ it('reports the cause of unavailable sources when all sources are unavailable', async () => {
166
+ const fetch = composeInternalTxsFetcher(
167
+ ['explorer', 'trace_block'],
168
+ makeFetchers({
169
+ explorer: jest.fn().mockRejectedValue(
170
+ new SourceUnavailableError('explorer internal txs failed', {
171
+ cause: new Error('rate limited'),
172
+ })
173
+ ),
174
+ trace_block: jest.fn().mockRejectedValue(new SourceUnavailableError('trace not supported')),
175
+ })
176
+ )
177
+
178
+ await expect(fetch(height)).rejects.toThrow(
179
+ 'all internal tx sources unavailable: [explorer] explorer internal txs failed (cause: rate limited)'
180
+ )
181
+ })
182
+
143
183
  it('falls back from trace_block to debug_traceBlockByNumber', async () => {
144
184
  const gethResult = new Map<string, BlockOperation[]>([['0x3', []]])
145
185
  const fetch = composeInternalTxsFetcher(
@@ -203,7 +243,10 @@ describe('makeSourceFetchers', () => {
203
243
  mockGetInternalTransactionsByBlock.mockRejectedValueOnce(new Error('explorer error'))
204
244
 
205
245
  const fetchers = makeSourceFetchers(config, mockNodeApi(), testLogger)
206
- await expect(fetchers.explorer(99)).rejects.toBeInstanceOf(SourceUnavailableError)
246
+ await expect(fetchers.explorer(99)).rejects.toMatchObject({
247
+ name: 'SourceUnavailableError',
248
+ cause: new Error('explorer error'),
249
+ })
207
250
  })
208
251
 
209
252
  it('calls getInternalTransactionsByBlock for explorer when configured', async () => {
@@ -266,7 +309,10 @@ describe('makeSourceFetchers', () => {
266
309
  .mockRejectedValueOnce(new Error('explorer error'))
267
310
 
268
311
  const fetchers = makeSourceFetchers(config, mockNodeApi(), testLogger)
269
- await expect(fetchers.explorer(99)).rejects.toBeInstanceOf(SourceUnavailableError)
312
+ await expect(fetchers.explorer(99)).rejects.toMatchObject({
313
+ name: 'SourceUnavailableError',
314
+ cause: new Error('explorer error'),
315
+ })
270
316
  })
271
317
 
272
318
  it('empty always resolves to an empty map', async () => {