account-lookup-service 17.8.0-snapshot.11 → 17.8.0-snapshot.12
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.
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "account-lookup-service",
|
3
3
|
"description": "Account Lookup Service is used to validate Party and Participant lookups.",
|
4
|
-
"version": "17.8.0-snapshot.
|
4
|
+
"version": "17.8.0-snapshot.12",
|
5
5
|
"license": "Apache-2.0",
|
6
6
|
"author": "ModusBox",
|
7
7
|
"contributors": [
|
@@ -92,9 +92,9 @@
|
|
92
92
|
"@hapi/vision": "7.0.3",
|
93
93
|
"@mojaloop/central-services-error-handling": "13.0.7",
|
94
94
|
"@mojaloop/central-services-health": "15.0.4",
|
95
|
-
"@mojaloop/central-services-logger": "11.8.
|
95
|
+
"@mojaloop/central-services-logger": "11.8.1",
|
96
96
|
"@mojaloop/central-services-metrics": "12.5.0",
|
97
|
-
"@mojaloop/central-services-shared": "18.23.
|
97
|
+
"@mojaloop/central-services-shared": "18.23.2",
|
98
98
|
"@mojaloop/central-services-stream": "11.5.2",
|
99
99
|
"@mojaloop/database-lib": "11.1.4",
|
100
100
|
"@mojaloop/event-sdk": "14.4.0",
|
@@ -100,16 +100,17 @@ class BasePartiesService {
|
|
100
100
|
get state () { return this.#state }
|
101
101
|
|
102
102
|
async handleError (error) {
|
103
|
-
const {
|
103
|
+
const { params } = this.inputs
|
104
104
|
const log = this.log.child({ method: 'handleError' })
|
105
105
|
try {
|
106
106
|
log.error('error in processing parties request: ', error)
|
107
107
|
const fspiopError = ErrorHandler.Factory.reformatFSPIOPError(error)
|
108
|
-
const
|
108
|
+
const callbackHeaders = BasePartiesService.createErrorCallbackHeaders(this.inputs.headers, params)
|
109
|
+
const errorInfo = await this.deps.partiesUtils.makePutPartiesErrorPayload(this.deps.config, fspiopError, callbackHeaders, params)
|
109
110
|
|
110
111
|
await this.sendErrorCallback({
|
111
112
|
errorInfo,
|
112
|
-
headers:
|
113
|
+
headers: callbackHeaders,
|
113
114
|
params
|
114
115
|
})
|
115
116
|
log.info('handleError in done')
|
@@ -54,7 +54,8 @@ describe('BasePartiesService Tests -->', () => {
|
|
54
54
|
expect(sentTo).toBe(source)
|
55
55
|
expect(payload.Rpt.Rsn.Cd).toBe('2001')
|
56
56
|
expect(payload.Rpt.OrgnlId).toBe(`${params.Type}/${params.ID}`)
|
57
|
-
expect(payload.Assgnmt.
|
57
|
+
expect(payload.Assgnmt.Assgne.Agt.FinInstnId.Othr.Id).toBe(source)
|
58
|
+
expect(payload.Assgnmt.Assgnr.Agt.FinInstnId.Othr.Id).toBe(config.HUB_NAME)
|
58
59
|
})
|
59
60
|
|
60
61
|
test('should remove proxy getParties timeout cache key', async () => {
|
@@ -199,15 +199,18 @@ describe('GetPartiesService Tests -->', () => {
|
|
199
199
|
expect(participantMock.sendRequest.mock.lastCall[1]).toBe(proxyOk)
|
200
200
|
})
|
201
201
|
|
202
|
-
|
203
|
-
expect.assertions(1)
|
202
|
+
const throwDelayedErrorOnNthCall = (N, delay = 1000, error = new Error('Nth call Delayed Error')) => {
|
204
203
|
let count = 0
|
205
|
-
|
204
|
+
return async () => {
|
206
205
|
count++
|
207
|
-
if (count !==
|
208
|
-
await sleep(1000)
|
209
|
-
throw
|
210
|
-
}
|
206
|
+
if (count !== N) return {}
|
207
|
+
await sleep(1000)
|
208
|
+
throw error
|
209
|
+
}
|
210
|
+
}
|
211
|
+
|
212
|
+
const prepareGetPartiesServiceForDelayedProxyError = () => {
|
213
|
+
participantMock.sendRequest = jest.fn(throwDelayedErrorOnNthCall(2)) // throw error on 2nd proxy call
|
211
214
|
const proxies = createProxiesUtilMock({
|
212
215
|
getAllProxiesNames: jest.fn().mockResolvedValue(['proxy1', 'proxy2'])
|
213
216
|
})
|
@@ -215,14 +218,31 @@ describe('GetPartiesService Tests -->', () => {
|
|
215
218
|
receivedErrorResponse: jest.fn().mockResolvedValue(true) // failed proxy request is last in inter-scheme discovery flow
|
216
219
|
})
|
217
220
|
const deps = createMockDeps({ proxies, proxyCache })
|
218
|
-
|
219
221
|
const headers = fixtures.partiesCallHeadersDto({ destination: '' })
|
220
222
|
const params = fixtures.partiesParamsDto()
|
221
|
-
|
223
|
+
|
224
|
+
return new GetPartiesService(deps, { headers, params })
|
225
|
+
}
|
226
|
+
|
227
|
+
test('should throw an error if proxyRequest failed after delay, and other proxies have already replied', async () => {
|
228
|
+
expect.assertions(1)
|
229
|
+
const service = prepareGetPartiesServiceForDelayedProxyError()
|
230
|
+
const { headers } = service.inputs
|
222
231
|
|
223
232
|
await expect(service.triggerInterSchemeDiscoveryFlow(headers))
|
224
233
|
.rejects.toThrow(ERROR_MESSAGES.noSuccessfulProxyDiscoveryResponses)
|
225
234
|
})
|
235
|
+
|
236
|
+
test('should send error callback in ISO format if proxyRequest failed after delay, and other proxies have already replied', async () => {
|
237
|
+
const service = prepareGetPartiesServiceForDelayedProxyError()
|
238
|
+
const { headers } = service.inputs
|
239
|
+
service.deps.config.API_TYPE = API_TYPES.iso20022
|
240
|
+
|
241
|
+
await service.triggerInterSchemeDiscoveryFlow(headers)
|
242
|
+
.catch(err => service.handleError(err))
|
243
|
+
expect(participantMock.sendErrorToParticipant).toHaveBeenCalledTimes(1)
|
244
|
+
expect(participantMock.sendErrorToParticipant.mock.lastCall[2].Rpt.Rsn.Cd).toBe('3200')
|
245
|
+
})
|
226
246
|
})
|
227
247
|
|
228
248
|
describe('setProxyGetPartiesTimeout Tests', () => {
|