mojaloop / project

Repo to track product development issues for the Mojaloop project.
Other
25 stars 15 forks source link

Checking Pending Liquidity #4014

Open PhyuSinMyat8 opened 1 month ago

PhyuSinMyat8 commented 1 month ago

Acceptance Criteria for Clearing Pending/Reserved Amounts

Scenario: Pending/Reserved amount for failed transfers in Account and Balance BC should be cleared after the transaction status is changed to aborted.

Acceptance Criteria:

  1. Transaction Status Change:

    • Given a transfer transaction with a status of "Pending" or "Reserved,"
    • When the transaction status is updated to "Aborted,"
    • Then the system should automatically clear the Pending/Reserved amount associated with that transaction.
  2. Account Balance Update:

    • Given an account with a Pending/Reserved amount due to a failed transfer,
    • When the transaction status is updated to "Aborted,"
    • the available balance should be updated accordingly.
  3. Error Handling:

    • Given a scenario where clearing the Pending/Reserved amount fails,
    • When the transaction status is updated to "Aborted,"
    • Then the system should log the error,
    • And an alert should be sent to the support team for manual intervention.
  4. Consistency Check:

    • Given an account with multiple transactions,
    • When one or more transactions change status to "Aborted,"
    • Then the system should ensure that all Pending/Reserved amounts related to these transactions are accurately cleared,
    • And the account balance remains consistent and accurate.
PhyuSinMyat8 commented 1 month ago

As per testing result ,Pending/Reserved amount for failed transfers in Account and Balance BC still remaining after the transaction status is changed to aborted.

Aborted Transaction (Testing with ILP packet)

image (16).png

Check expired timestamp for short period like 1 hr

image (17).png image (18).png

Check in DB after expiring but remain pending debit balance at payer side

image (19).png
elnyry-sam-k commented 1 month ago

hi @PhyuSinMyat8 , Thanks for catching and documenting this; I'm very eager to see whats happening here.

Are there any equations or specification somewhere in the docs that show how the balances are updated with the terminology used here?

I'm asking because currently - technically there's no pending balance at any given point. The update is clearly made to the position of the Payer FSP account (subject to NDC check and other validations) and then once it is finalized, another change is made to the position - if committed, then to the Payee FSP side (position updated to reflect the incoming amount) and if aborted, then position of the Payer FSP updated again to reflect the amount that wasn't sent.

PhyuSinMyat8 commented 3 weeks ago

Dear @elnyry-sam-k,

Apologies for the delayed response and thank you for your patience. Let me address your question.

The "pending balance" referenced in this ticket refers to the amounts held in the pendingDebitBalance of the payer’s position account and the pendingCreditBalance of the hub reconciliation account before a transaction is finalized. Once the transaction is finalized (committed), these pending debit and credit balances are cleared from their respective accounts. The amounts are then updated in the postedDebitBalance of the payer’s FSP and the postedCreditBalance of the payee in the database.

For aborted transactions, the pending debit in the payer’s position account and the pending credit in the hub reconciliation account should also be cleared after the transaction is aborted. However, at present, the amounts from aborted transactions still remain in the pending debit and pending credit balances of each account.

vNext - Accounts and Balances States.jpg

Credit to @ZweHMyat for the above figure