Skip to content

Commit

Permalink
fix: inconsistent completedTimestamp (#1141)
Browse files Browse the repository at this point in the history
  • Loading branch information
kalinkrustev authored Jan 10, 2025
1 parent 7a78241 commit f9720ef
Show file tree
Hide file tree
Showing 17 changed files with 104 additions and 164 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,5 @@ devspace*
*IGNORE*
*ignore*
!.npmignore

.rush
220 changes: 76 additions & 144 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"test:int:spec": "npm run test:int | npx tap-spec",
"test:xint": "npm run test:int | tee /dev/tty | tap-xunit > ./test/results/xunit-integration.xml",
"test:xint-override": "npm run test:int-override | tee /dev/tty | tap-xunit > ./test/results/xunit-integration-override.xml",
"test:integration": "./test/scripts/test-integration.sh",
"test:integration": "CSL_LOG_LEVEL=debug ./test/scripts/test-integration.sh",
"test:functional": "./test/scripts/test-functional.sh",
"migrate": "npm run migrate:latest && npm run seed:run",
"migrate:latest": "npx knex $npm_package_config_knex migrate:latest",
Expand Down Expand Up @@ -86,7 +86,6 @@
"@hapi/good": "9.0.1",
"@hapi/hapi": "21.3.12",
"@hapi/inert": "7.1.0",
"@hapi/joi": "17.1.1",
"@hapi/vision": "7.0.3",
"@mojaloop/central-services-error-handling": "13.0.3",
"@mojaloop/central-services-health": "15.0.0",
Expand All @@ -95,7 +94,7 @@
"@mojaloop/central-services-shared": "18.15.1",
"@mojaloop/central-services-stream": "11.4.2",
"@mojaloop/database-lib": "11.1.1",
"@mojaloop/event-sdk": "14.1.1",
"@mojaloop/event-sdk": "14.1.2",
"@mojaloop/inter-scheme-proxy-cache-lib": "2.3.1",
"@mojaloop/ml-number": "11.2.5",
"@mojaloop/object-store-lib": "12.0.4",
Expand All @@ -105,7 +104,7 @@
"base64url": "3.0.1",
"blipp": "4.0.2",
"commander": "13.0.0",
"cron": "3.3.2",
"cron": "3.4.0",
"decimal.js": "10.4.3",
"docdash": "2.0.2",
"event-stream": "4.0.1",
Expand All @@ -115,6 +114,7 @@
"hapi-auth-bearer-token": "8.0.0",
"hapi-swagger": "17.3.2",
"ilp-packet": "2.2.0",
"joi": "17.13.3",
"knex": "3.1.0",
"lodash": "4.17.21",
"moment": "2.30.1",
Expand Down
2 changes: 1 addition & 1 deletion src/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const MetricsPlugin = require('@mojaloop/central-services-metrics').plugin
module.exports = Setup.initialize({
service: 'api',
port: Config.PORT,
modules: [Routes, MetricsPlugin],
modules: [Routes, !Config.INSTRUMENTATION_METRICS_DISABLED && MetricsPlugin].filter(Boolean),
runMigrations: Config.RUN_MIGRATIONS,
runHandlers: !Config.HANDLERS_DISABLED
})
2 changes: 1 addition & 1 deletion src/api/ledgerAccountTypes/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
'use strict'

const Handler = require('./handler')
const Joi = require('@hapi/joi')
const Joi = require('joi')
const tags = ['api', 'ledgerAccountTypes']

module.exports = [
Expand Down
6 changes: 5 additions & 1 deletion src/handlers/transfers/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,11 @@ const processFulfilMessage = async (message, functionality, span) => {
Logger.isInfoEnabled && Logger.info(Util.breadcrumb(location, `callbackErrorInvalidFulfilment--${actionLetter}9`))
const fspiopError = ErrorHandler.Factory.createFSPIOPError(ErrorHandler.Enums.FSPIOPErrorCodes.VALIDATION_ERROR, 'invalid fulfilment')
const apiFSPIOPError = fspiopError.toApiErrorObject(Config.ERROR_HANDLING)
await TransferService.handlePayeeResponse(transferId, payload, TransferEventAction.ABORT_VALIDATION, apiFSPIOPError)
const updatedTransfer = await TransferService.handlePayeeResponse(transferId, payload, TransferEventAction.ABORT_VALIDATION, apiFSPIOPError)
params.message.value.payload = {
...params.message.value.payload,
completedTimestamp: updatedTransfer.completedTimestamp
}
const eventDetail = { functionality: TransferEventType.POSITION, action: TransferEventAction.ABORT_VALIDATION }
/**
* TODO: BulkProcessingHandler (not in scope of #967) The individual transfer is ABORTED by notification is never sent.
Expand Down
3 changes: 2 additions & 1 deletion src/lib/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@
******/
'use strict'

module.exports = require('@mojaloop/database-lib').Db
const Database = require('@mojaloop/database-lib/src/database')
module.exports = new Database()
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const { randomUUID } = require('crypto')
const Logger = require('@mojaloop/central-services-logger')
const Config = require('#src/lib/config')
const ProxyCache = require('#src/lib/proxyCache')
const Db = require('@mojaloop/database-lib').Db
const Db = require('../../../../src/lib/db')
const Cache = require('#src/lib/cache')
const { Producer, Consumer } = require('@mojaloop/central-services-stream').Util
const Utility = require('@mojaloop/central-services-shared').Util.Kafka
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const Test = require('tape')
const { randomUUID } = require('crypto')
const Logger = require('@mojaloop/central-services-logger')
const Config = require('#src/lib/config')
const Db = require('@mojaloop/database-lib').Db
const Db = require('../../../../src/lib/db')
const Cache = require('#src/lib/cache')
const ProxyCache = require('#src/lib/proxyCache')
const Producer = require('@mojaloop/central-services-stream').Util.Producer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
**********/

const Test = require('tape')
const { Db } = require('@mojaloop/database-lib')
const Db = require('../../../../src/lib/db')
const { Enum, Util } = require('@mojaloop/central-services-shared')
const { Producer } = require('@mojaloop/central-services-stream').Kafka

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const Test = require('tape')
const { randomUUID } = require('crypto')
const Logger = require('@mojaloop/central-services-logger')
const Config = require('#src/lib/config')
const Db = require('@mojaloop/database-lib').Db
const Db = require('../../../../src/lib/db')
const Cache = require('#src/lib/cache')
const ProxyCache = require('#src/lib/proxyCache')
const Producer = require('@mojaloop/central-services-stream').Util.Producer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const Test = require('tape')
const { randomUUID } = require('crypto')
const Logger = require('@mojaloop/central-services-logger')
const Config = require('#src/lib/config')
const Db = require('@mojaloop/database-lib').Db
const Db = require('../../../../src/lib/db')
const Cache = require('#src/lib/cache')
const ProxyCache = require('#src/lib/proxyCache')
const Producer = require('@mojaloop/central-services-stream').Util.Producer
Expand Down
2 changes: 1 addition & 1 deletion test/integration/handlers/root.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
const Test = require('tape')
const Joi = require('joi')
const Logger = require('@mojaloop/central-services-logger')
const Db = require('@mojaloop/database-lib').Db
const Db = require('../../../src/lib/db')

const Config = require('../../../src/lib/config')
const ProxyCache = require('../../../src/lib/proxyCache')
Expand Down
8 changes: 4 additions & 4 deletions test/integration/handlers/transfers/handlers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const Logger = require('@mojaloop/central-services-logger')
const Config = require('#src/lib/config')
const ProxyCache = require('#src/lib/proxyCache')
const Time = require('@mojaloop/central-services-shared').Util.Time
const Db = require('@mojaloop/database-lib').Db
const Db = require('../../../../src/lib/db')
const Cache = require('#src/lib/cache')
const Producer = require('@mojaloop/central-services-stream').Util.Producer
const Utility = require('@mojaloop/central-services-shared').Util.Kafka
Expand Down Expand Up @@ -817,16 +817,16 @@ Test('Handlers test', async handlersTest => {
test.ok(payeeAbortNotificationEvent, 'Payee Abort notification sent')

// grab kafka message
const payerAbortNotificationPayload = getMessagePayloadOrThrow(payeeAbortNotificationEvent)
const payeeAbortNotificationPayload = getMessagePayloadOrThrow(payeeAbortNotificationEvent)

test.equal(
payerAbortNotificationPayload.transferState,
payeeAbortNotificationPayload.transferState,
expectedAbortNotificationPayload.transferState,
'Abort notification should be sent with the correct transferState'
)

test.equal(
payerAbortNotificationPayload.completedTimestamp,
payeeAbortNotificationPayload.completedTimestamp,
expectedAbortNotificationPayload.completedTimestamp,
'Abort notification should be sent with the correct completedTimestamp'
)
Expand Down
2 changes: 1 addition & 1 deletion test/integration/helpers/settlementModels.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
const Model = require('../../../src/domain/settlement')
const Enums = require('../../../src/lib/enumCached')
const ErrorHandler = require('@mojaloop/central-services-error-handling')
const Db = require('@mojaloop/database-lib').Db
const Db = require('../../../src/lib/db')
const Cache = require('../../../src/lib/cache')
const ProxyCache = require('../../../src/lib/proxyCache')
const ParticipantCached = require('../../../src/models/participant/participantCached')
Expand Down
2 changes: 1 addition & 1 deletion test/unit/handlers/transfers/FxFulfilService.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
/* eslint-disable object-property-newline */
const Sinon = require('sinon')
const Test = require('tapes')(require('tape'))
const { Db } = require('@mojaloop/database-lib')
const Db = require('../../../../src/lib/db')
const { Enum, Util } = require('@mojaloop/central-services-shared')
const { Consumer, Producer } = require('@mojaloop/central-services-stream').Util

Expand Down
1 change: 1 addition & 0 deletions test/unit/handlers/transfers/handler.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ Test('Transfer handler', transferHandlerTest => {
sandbox.stub(Comparators)
sandbox.stub(Validator)
sandbox.stub(TransferService)
TransferService.handlePayeeResponse.returns(Promise.resolve({}))
sandbox.stub(Cyril)
Cyril.processFulfilMessage.returns({
isFx: false
Expand Down

0 comments on commit f9720ef

Please sign in to comment.