Skip to content

Commit

Permalink
fix(#2557): error notification to payer fsp, header for source having…
Browse files Browse the repository at this point in the history
… wrong value

- fix for mojaloop/project#2557
- Updated fulfil-handler logic to produce an action type "ABORT_VALIDATION" when a validation error occurs (i.e. invalid fulfilment)
- updated util/scripts/populateTestData.sh script to create a default settlement model for local dev testing
  • Loading branch information
mdebarros committed Nov 8, 2021
1 parent f0268fe commit 2241331
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/handlers/positions/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ const positions = async (error, messages) => {
histTimerEnd({ success: true, fspId: Config.INSTRUMENTATION_METRICS_LABELS.fspId, action })
return true
}
} else if (eventType === Enum.Events.Event.Type.POSITION && [Enum.Events.Event.Action.REJECT, Enum.Events.Event.Action.ABORT, Enum.Events.Event.Action.BULK_ABORT].includes(action)) {
} else if (eventType === Enum.Events.Event.Type.POSITION && [Enum.Events.Event.Action.REJECT, Enum.Events.Event.Action.ABORT, Enum.Events.Event.Action.ABORT_VALIDATION, Enum.Events.Event.Action.BULK_ABORT].includes(action)) {
Logger.isInfoEnabled && Logger.info(Utility.breadcrumb(location, { path: action }))
const transferInfo = await TransferService.getTransferInfoToChangePosition(transferId, Enum.Accounts.TransferParticipantRoleType.PAYER_DFSP, Enum.Accounts.LedgerEntryType.PRINCIPLE_VALUE)
let transferStateId
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/transfers/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ const fulfil = async (error, messages) => {
const fspiopError = ErrorHandler.Factory.createFSPIOPError(ErrorHandler.Enums.FSPIOPErrorCodes.VALIDATION_ERROR, 'invalid fulfilment')
const apiFspiopError = fspiopError.toApiErrorObject(Config.ERROR_HANDLING)
await TransferService.handlePayeeResponse(transferId, payload, action, apiFspiopError)
const eventDetail = { functionality: TransferEventType.POSITION, action: TransferEventAction.ABORT }
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
20 changes: 20 additions & 0 deletions test/util/scripts/populateTestData.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,26 @@ curl -X POST \
"type": "HUB_MULTILATERAL_SETTLEMENT"
}'

echo "---------------------------------------------------------------------"
echo "Creating Default Settlement Model"
echo "---------------------------------------------------------------------"
curl -X POST \
${CENTRAL_LEDGER_ADMIN_URI_PREFIX}://${CENTRAL_LEDGER_ADMIN_HOST}:${CENTRAL_LEDGER_ADMIN_PORT}${CENTRAL_LEDGER_ADMIN_BASE}settlementModels \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-H 'cache-control: no-cache' \
-d '{
"name": "DEFERREDNETUSD",
"settlementGranularity": "NET",
"settlementInterchange": "MULTILATERAL",
"settlementDelay": "DEFERRED",
"requireLiquidityCheck": true,
"ledgerAccountType": "POSITION",
"autoPositionReset": true,
"currency": "USD",
"settlementAccountType": "SETTLEMENT"
}'

echo
echo "---------------------------------------------------------------------"
echo " Creating TestData for $FSPList"
Expand Down

0 comments on commit 2241331

Please sign in to comment.