Skip to content

Commit

Permalink
feat: position zero messages (#1079)
Browse files Browse the repository at this point in the history
* feat: initial commit

* fix: int tests

* fix: int tests

* chore: skip coverage check for snapshots

* chore(snapshot): 17.8.0-snapshot.8

* fix: proxy cluster

* chore: dep update

* chore(snapshot): 17.8.0-snapshot.9

* test: add unit tests for zero position change (#1081)

---------

Co-authored-by: Steven Oderayi <oderayi@gmail.com>
  • Loading branch information
vijayg10 and oderayi authored Aug 22, 2024
1 parent 348f12a commit 06e08bc
Show file tree
Hide file tree
Showing 32 changed files with 1,028 additions and 710 deletions.
3 changes: 2 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,8 @@ workflows:
# - test-dependencies
- test-lint
- test-unit
- test-coverage
## To be able to release a snapshot without code coverage
# - test-coverage
- test-integration
- test-functional
- vulnerability-check
Expand Down
3 changes: 2 additions & 1 deletion audit-ci.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"GHSA-c429-5p7v-vgjp", // https://github.com/advisories/GHSA-c429-5p7v-vgjp
"GHSA-g64q-3vg8-8f93", // https://github.com/advisories/GHSA-g64q-3vg8-8f93
"GHSA-mg85-8mv5-ffjr", // https://github.com/advisories/GHSA-mg85-8mv5-ffjr
"GHSA-8hc4-vh64-cxmj" // https://github.com/advisories/GHSA-8hc4-vh64-cxmj
"GHSA-8hc4-vh64-cxmj", // https://github.com/advisories/GHSA-8hc4-vh64-cxmj
"GHSA-952p-6rrq-rcjv" // https://github.com/advisories/GHSA-952p-6rrq-rcjv
]
}
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mojaloop/central-ledger",
"version": "17.8.0-snapshot.7",
"version": "17.8.0-snapshot.9",
"description": "Central ledger hosted by a scheme to record and settle transfers",
"license": "Apache-2.0",
"author": "ModusBox",
Expand Down Expand Up @@ -133,7 +133,7 @@
"jsdoc": "4.0.3",
"jsonpath": "1.1.1",
"nodemon": "3.1.4",
"npm-check-updates": "17.0.6",
"npm-check-updates": "17.1.0",
"nyc": "17.0.0",
"pre-commit": "1.2.2",
"proxyquire": "2.1.3",
Expand Down
2 changes: 1 addition & 1 deletion src/domain/fx/cyril.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ const processFulfilMessage = async (transferId, payload, transfer) => {
let sendingFxpRecord = null
let receivingFxpRecord = null
for (const watchListRecord of watchListRecords) {
const fxTransferRecord = await fxTransfer.getAllDetailsByCommitRequestId(watchListRecord.commitRequestId)
const fxTransferRecord = await fxTransfer.getAllDetailsByCommitRequestIdForProxiedFxTransfer(watchListRecord.commitRequestId)
// Original Plan: If the reservation is against the FXP, then this is a conversion at the creditor. Mark FXP as receiving FXP
// The above condition is not required as we are setting the fxTransferType in the watchList beforehand
if (watchListRecord.fxTransferTypeId === Enum.Fx.FxTransferType.PAYEE_CONVERSION) {
Expand Down
27 changes: 16 additions & 11 deletions src/domain/position/abort.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,24 @@ const Logger = require('@mojaloop/central-services-logger')
* @description This is the domain function to process a bin of abort / fx-abort messages of a single participant account.
*
* @param {array} abortBins - an array containing abort / fx-abort action bins
* @param {number} accumulatedPositionValue - value of position accumulated so far from previous bin processing
* @param {number} accumulatedPositionReservedValue - value of position reserved accumulated so far, not used but kept for consistency
* @param {object} accumulatedTransferStates - object with transfer id keys and transfer state id values. Used to check if transfer is in correct state for processing. Clone and update states for output.
* @param {object} transferInfoList - object with transfer id keys and transfer info values. Used to pass transfer info to domain function.
* @param {object} options
* @param {number} accumulatedPositionValue - value of position accumulated so far from previous bin processing
* @param {number} accumulatedPositionReservedValue - value of position reserved accumulated so far, not used but kept for consistency
* @param {object} accumulatedTransferStates - object with transfer id keys and transfer state id values. Used to check if transfer is in correct state for processing. Clone and update states for output.
* @param {object} transferInfoList - object with transfer id keys and transfer info values. Used to pass transfer info to domain function.
* @param {boolean} changePositions - whether to change positions or not
* @returns {object} - Returns an object containing accumulatedPositionValue, accumulatedPositionReservedValue, accumulatedTransferStateChanges, accumulatedTransferStates, resultMessages, limitAlarms or throws an error if failed
*/
const processPositionAbortBin = async (
abortBins,
accumulatedPositionValue,
accumulatedPositionReservedValue,
accumulatedTransferStates,
accumulatedFxTransferStates,
isFx
{
accumulatedPositionValue,
accumulatedPositionReservedValue,
accumulatedTransferStates,
accumulatedFxTransferStates,
isFx,
changePositions = true
}
) => {
const transferStateChanges = []
const participantPositionChanges = []
Expand Down Expand Up @@ -108,13 +113,13 @@ const processPositionAbortBin = async (
}

return {
accumulatedPositionValue: runningPosition.toNumber(),
accumulatedPositionValue: changePositions ? runningPosition.toNumber() : accumulatedPositionValue,
accumulatedTransferStates: accumulatedTransferStatesCopy, // finalized transfer state after fulfil processing
accumulatedPositionReservedValue, // not used but kept for consistency
accumulatedTransferStateChanges: transferStateChanges, // transfer state changes to be persisted in order
accumulatedFxTransferStates: accumulatedFxTransferStatesCopy, // finalized fx transfer state after fulfil processing
accumulatedFxTransferStateChanges: fxTransferStateChanges, // fx transfer state changes to be persisted in order
accumulatedPositionChanges: participantPositionChanges, // participant position changes to be persisted in order
accumulatedPositionChanges: changePositions ? participantPositionChanges : [], // participant position changes to be persisted in order
notifyMessages: resultMessages, // array of objects containing bin item and result message. {binItem, message}
followupMessages // array of objects containing bin item, message key and followup message. {binItem, messageKey, message}
}
Expand Down
Loading

0 comments on commit 06e08bc

Please sign in to comment.