Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(mojaloop/#2880): simplify liquidity cover check and fix issue with validation (master) #86

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
2daf63c
feat(mojaloop/#2880): simplify liquidity cover check and fix issue wi…
mdebarros Aug 25, 2022
3a7acae
improvements to CGS test cases
mdebarros Aug 25, 2022
5406642
fixes for CGS
mdebarros Aug 25, 2022
8ff2170
several updates and improvements to settlement cgs test-cases
mdebarros Aug 25, 2022
6bdd9f9
removed unnecessary duplicate position check (since we consolidated c…
mdebarros Aug 25, 2022
6b876c4
same as before
mdebarros Aug 25, 2022
62280d9
Merge branch 'master' of github.com:mojaloop/testing-toolkit-test-cas…
mdebarros Aug 25, 2022
bcb7d00
updates for test-cases
mdebarros Aug 26, 2022
eea9005
Revert "Merge branch 'master' of github.com:mojaloop/testing-toolkit-…
mdebarros Aug 31, 2022
49ea150
chore: added "Deposit Funds into Settlement Account (Funds-In)" test-…
mdebarros Aug 31, 2022
272ef06
chore: added balance checks before and after funds-in for CGS test-cases
mdebarros Sep 2, 2022
e3dccdc
chore: maintenance
mdebarros Sep 2, 2022
9304fa9
fixes for settlement cgs ttk tests
mdebarros Sep 6, 2022
c66d5ef
Revert "fixes for settlement cgs ttk tests"
mdebarros Sep 6, 2022
9cf6eb8
Revert "Revert "Merge branch 'master' of github.com:mojaloop/testing-…
mdebarros Sep 6, 2022
8890155
chore: bumped RETRY_MAX_* values to improve stability
mdebarros Sep 7, 2022
a87e552
fix(mojaloop/#2734): failures in daily cron job running GP tests
mdebarros Sep 7, 2022
1c5cf8f
added another POST settlement re-try
mdebarros Sep 7, 2022
7cde52a
fix for scriptEngine
mdebarros Sep 7, 2022
d19ae0d
fixes
mdebarros Sep 7, 2022
a99adbf
Merge branch 'feat/#2880-Simplify-liquidity-cover-check-and-fix-issue…
mdebarros Sep 8, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
280 changes: 151 additions & 129 deletions collections/hub/golden_path/feature_tests/block_transfer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@
"meta": {
"info": "Block Transfer"
},
"fileInfo": {
"path": "hub/golden_path/feature_tests/block_transfer.json"
},
"requests": [
{
"id": 1,
"description": "Get Settlement account balance",
"description": "Get PAYER Settlement account balances for Liquidity and Position",
"meta": {
"info": "Get Settlement account balance"
"info": "Get PAYER Settlement account balances for Liquidity and Position"
},
"apiVersion": {
"minorVersion": 0,
Expand Down Expand Up @@ -42,66 +45,27 @@
]
},
"delay": "500",
"scripts": {
"postRequest": {
"exec": [
"const jsonData = pm.response.body",
"console.log(jsonData)",
"for(var i in jsonData) {",
" if(jsonData[i].ledgerAccountType === 'SETTLEMENT' && jsonData[i].currency === pm.environment.get('currency')) {",
" pm.environment.set(\"payerSettlementAccountBalance\", jsonData[i].value)",
" }",
"}"
]
}
}
},
{
"id": 2,
"meta": {
"info": "GET SIMPAYER position before the transfer"
},
"description": "GET SIMPAYER position before the transfer",
"apiVersion": {
"minorVersion": 0,
"majorVersion": 1,
"type": "central_admin"
},
"operationPath": "/participants/{name}/positions",
"path": "/participants/{$inputs.fromFspId}/positions",
"method": "get",
"params": {
"name": "{$inputs.fromFspId}"
},
"url": "{$inputs.HOST_CENTRAL_LEDGER}",
"tests": {
"assertions": [
{
"id": 1,
"description": "Status code is 200",
"exec": [
"expect(response.status).to.equal(200)"
]
},
{
"id": 2,
"description": "Payer FSP position is not null",
"exec": [
"expect(environment.payerPositionBeforeTransfer).to.not.equal(undefined)"
]
}
]
},
"scriptingEngine": "javascript",
"headers": {
"FSPIOP-Source": "{$inputs.fromFspId}",
"Authorization": "{$inputs.TTK_BEARER_TOKEN}"
},
"scripts": {
"postRequest": {
"exec": [
"const positionItem = response.body.find(item => (item.currency === environment.SIMPAYER_CURRENCY))",
"environment.payerPositionBeforeTransfer = positionItem.value"
"// Find the Settlement account for the set currency to determine the liquidity of the payer",
"const settlementAccount = response.body.find(item => (item.currency === environment.SIMPAYER_CURRENCY && item.ledgerAccountType === 'SETTLEMENT'))",
"environment.payerSettlementAccountBalance = settlementAccount?.value",
"",
"console.log(`environment.payerSettlementAccountBalance=${environment.payerSettlementAccountBalance}`)",
"",
"// Find the Position account for the set currency to determine the position of the payer",
"const positionAccount = response.body.find(item => (item.currency === environment.SIMPAYER_CURRENCY && item.ledgerAccountType === 'POSITION'))",
"environment.payerPositionBeforeTransfer = positionAccount?.value",
"",
"console.log(`environment.payerPositionBeforeTransfer=${environment.payerPositionBeforeTransfer}`)",
"",
"",
"environment.payerReservedPositionBeforeTransfer = positionAccount?.reservedValue",
"",
"console.log(`environment.payerReservedPositionBeforeTransfer=${environment.payerReservedPositionBeforeTransfer}`)",
""
]
}
}
Expand Down Expand Up @@ -367,7 +331,37 @@
"requestVariables.quoteId = '{$function.generic.generateUUID}'",
"requestVariables.transactionId = '{$function.generic.generateUUID}'",
"",
"requestVariables.amount = Number((-Number(environment.payerSettlementAccountBalance).toFixed(2) - Number(environment.payerPositionBeforeTransfer).toFixed(2) + 1000).toFixed(2));",
"console.log(`environment.payerNetDebitCapLimit=${environment.payerNetDebitCapLimit}`)",
"",
"console.log(`environment.payerSettlementAccountBalance=${environment.payerSettlementAccountBalance}`)",
"",
"console.log(`environment.payerPositionBeforeTransfer=${environment.payerPositionBeforeTransfer}`)",
"",
"console.log(`environment.payerReservedPositionBeforeTransfer=${environment.payerReservedPositionBeforeTransfer}`)",
"",
"const payerLiquidityCover = -Number(environment.payerSettlementAccountBalance);",
"",
"console.log(`payerLiquidityCover=${payerLiquidityCover}`)",
"",
"const payerPositionBeforeTransfer = Number(environment.payerPositionBeforeTransfer);",
"",
"console.log(`payerPositionBeforeTransfer=${payerPositionBeforeTransfer}`)",
"",
"const payerReservedPositionBeforeTransfer = Number(environment.payerReservedPositionBeforeTransfer);",
"",
"console.log(`payerReservedPositionBeforeTransfer=${payerReservedPositionBeforeTransfer}`)",
"",
"const effectivePosition = payerPositionBeforeTransfer + payerReservedPositionBeforeTransfer;",
"",
"console.log(`effectivePosition=${effectivePosition}`)",
"",
" const liquidityAndPositionDifference = (payerLiquidityCover - effectivePosition);",
" ",
" console.log(`liquidityAndPositionDifference=${liquidityAndPositionDifference}`);",
"",
"requestVariables.amount = Number((liquidityAndPositionDifference + 1000).toFixed(2));",
"",
"console.log(`requestVariables.amount=${requestVariables.amount}`)",
"",
"if(environment.ENABLE_JWS_SIGNING) {",
" custom.jws.signRequest(environment.TTKFSP_JWS_KEY)",
Expand Down Expand Up @@ -512,6 +506,7 @@
}
]
},
"disabled": false,
"scripts": {
"preRequest": {
"exec": [
Expand Down Expand Up @@ -630,6 +625,9 @@
"meta": {
"info": "Block Transfer due to NDC limit"
},
"fileInfo": {
"path": "hub/golden_path/feature_tests/block_transfer.json"
},
"requests": [
{
"id": 1,
Expand Down Expand Up @@ -740,9 +738,9 @@
},
{
"id": 3,
"description": "Get Settlement account balance",
"description": "Get PAYER Settlement account balances for Liquidity and Position",
"meta": {
"info": "Get Settlement account balance"
"info": "Get PAYER Settlement account balances for Liquidity and Position"
},
"apiVersion": {
"minorVersion": 0,
Expand Down Expand Up @@ -772,20 +770,30 @@
]
},
"delay": "500",
"scriptingEngine": "javascript",
"scripts": {
"postRequest": {
"exec": [
"const jsonData = response.body",
"for(var i in jsonData) {",
" if(jsonData[i].ledgerAccountType === 'SETTLEMENT' && jsonData[i].currency === environment.currency) {",
" environment.payerSettlementAccountBalance = jsonData[i].value",
" }",
"}",
"// Find the Settlement account for the set currency to determine the liquidity of the payer",
"const settlementAccount = response.body.find(item => (item.currency === environment.SIMPAYER_CURRENCY && item.ledgerAccountType === 'SETTLEMENT'))",
"environment.payerSettlementAccountBalance = settlementAccount?.value",
"",
"console.log(`environment.payerSettlementAccountBalance=${environment.payerSettlementAccountBalance}`)",
"",
"// Find the Position account for the set currency to determine the position of the payer",
"const positionAccount = response.body.find(item => (item.currency === environment.SIMPAYER_CURRENCY && item.ledgerAccountType === 'POSITION'))",
"environment.payerPositionBeforeTransfer = positionAccount?.value",
"",
"console.log(`environment.payerPositionBeforeTransfer=${environment.payerPositionBeforeTransfer}`)",
"",
"",
"environment.payerReservedPositionBeforeTransfer = positionAccount?.reservedValue",
"",
"console.log(`environment.payerReservedPositionBeforeTransfer=${environment.payerReservedPositionBeforeTransfer}`)",
""
]
}
},
"scriptingEngine": "javascript"
}
},
{
"id": 4,
Expand All @@ -811,43 +819,6 @@
}
},
"scriptingEngine": "javascript",
"scripts": {
"preRequest": {
"exec": [
"environment.tempNDCLimit = -Number(environment.payerSettlementAccountBalance) - 1000"
]
}
},
"tests": {
"assertions": [
{
"id": 1,
"description": "Status code is 200",
"exec": [
"expect(response.status).to.equal(200)"
]
}
]
}
},
{
"id": 5,
"meta": {
"info": "GET SIMPAYER position before the transfer"
},
"description": "GET SIMPAYER position before the transfer",
"apiVersion": {
"minorVersion": 0,
"majorVersion": 1,
"type": "central_admin"
},
"operationPath": "/participants/{name}/positions",
"path": "/participants/{$inputs.fromFspId}/positions",
"method": "get",
"params": {
"name": "{$inputs.fromFspId}"
},
"url": "{$inputs.HOST_CENTRAL_LEDGER}",
"tests": {
"assertions": [
{
Expand All @@ -856,26 +827,49 @@
"exec": [
"expect(response.status).to.equal(200)"
]
},
{
"id": 2,
"description": "Payer FSP position correctly set",
"exec": [
"expect(environment.payerPositionBeforeTransfer).to.not.equal(undefined)"
]
}
]
},
"scriptingEngine": "javascript",
"headers": {
"FSPIOP-Source": "{$inputs.fromFspId}",
"Authorization": "{$inputs.TTK_BEARER_TOKEN}"
},
"scripts": {
"postRequest": {
"preRequest": {
"exec": [
"const positionItem = response.body.find(item => (item.currency === environment.SIMPAYER_CURRENCY))",
"environment.payerPositionBeforeTransfer = positionItem.value"
"// environment.tempNDCLimit = -Number(environment.payerSettlementAccountBalance) - 1000",
"",
"",
"console.log(`environment.payerNetDebitCapLimit=${environment.payerNetDebitCapLimit}`)",
"",
"console.log(`environment.payerSettlementAccountBalance=${environment.payerSettlementAccountBalance}`)",
"",
"console.log(`environment.payerPositionBeforeTransfer=${environment.payerPositionBeforeTransfer}`)",
"",
"console.log(`environment.payerReservedPositionBeforeTransfer=${environment.payerReservedPositionBeforeTransfer}`)",
"",
"const payerLiquidityCover = -Number(environment.payerSettlementAccountBalance);",
"",
"console.log(`payerLiquidityCover=${payerLiquidityCover}`)",
"",
"const payerPositionBeforeTransfer = Number(environment.payerPositionBeforeTransfer);",
"",
"console.log(`payerPositionBeforeTransfer=${payerPositionBeforeTransfer}`)",
"",
"const payerReservedPositionBeforeTransfer = Number(environment.payerReservedPositionBeforeTransfer);",
"",
"console.log(`payerReservedPositionBeforeTransfer=${payerReservedPositionBeforeTransfer}`)",
"",
"// const effectivePosition = payerPositionBeforeTransfer + payerReservedPositionBeforeTransfer;",
"",
"// console.log(`effectivePosition=${effectivePosition}`)",
"",
"// const liquidityAndPositionDifference = (payerLiquidityCover - effectivePosition);",
" ",
"// console.log(`liquidityAndPositionDifference=${liquidityAndPositionDifference}`);",
"",
"// environment.tempNDCLimit = (liquidityAndPositionDifference - 1000).toFixed(2);",
"",
"// console.log(`environment.tempNDCLimitt=${environment.tempNDCLimit}`)",
"",
"environment.tempNDCLimit = (Math.abs(payerLiquidityCover) - 1000).toFixed(2)",
""
]
}
}
Expand Down Expand Up @@ -1141,7 +1135,35 @@
"requestVariables.quoteId = '{$function.generic.generateUUID}'",
"requestVariables.transactionId = '{$function.generic.generateUUID}'",
"",
"requestVariables.amount = Number((-Number(environment.payerSettlementAccountBalance).toFixed(2) - Number(environment.payerPositionBeforeTransfer).toFixed(2) - 500).toFixed(2));",
"console.log(`environment.payerNetDebitCapLimit=${environment.payerNetDebitCapLimit}`)",
"",
"console.log(`environment.payerPositionBeforeTransfer=${environment.payerPositionBeforeTransfer}`)",
"",
"console.log(`environment.payerReservedPositionBeforeTransfer=${environment.payerReservedPositionBeforeTransfer}`)",
"",
"console.log(`environment.tempNDCLimit=${environment.tempNDCLimit}`)",
"",
"const currentNDCLimit = environment.tempNDCLimit",
"",
"const payerPositionBeforeTransfer = Number(environment.payerPositionBeforeTransfer);",
"",
"console.log(`payerPositionBeforeTransfer=${payerPositionBeforeTransfer}`)",
"",
"const payerReservedPositionBeforeTransfer = Number(environment.payerReservedPositionBeforeTransfer);",
"",
"console.log(`payerReservedPositionBeforeTransfer=${payerReservedPositionBeforeTransfer}`)",
"",
"const effectivePosition = payerPositionBeforeTransfer + payerReservedPositionBeforeTransfer;",
"",
"console.log(`effectivePosition=${effectivePosition}`)",
"",
"const positionLimitDifference = Math.abs(currentNDCLimit - effectivePosition)",
" ",
"console.log(`positionLimitDifference=${positionLimitDifference}`);",
"",
"requestVariables.amount = Number((positionLimitDifference + 1).toFixed(2));",
"",
"console.log(`requestVariables.amount=${requestVariables.amount}`)",
"",
"if(environment.ENABLE_JWS_SIGNING) {",
" custom.jws.signRequest(environment.TTKFSP_JWS_KEY)",
Expand Down Expand Up @@ -1420,13 +1442,6 @@
}
},
"scriptingEngine": "javascript",
"scripts": {
"preRequest": {
"exec": [
"environment.tempNDCLimit = -environment.payerSettlementAccountBalance + 200"
]
}
},
"tests": {
"assertions": [
{
Expand All @@ -1437,6 +1452,13 @@
]
}
]
},
"scripts": {
"preRequest": {
"exec": [
"environment.tempNDCLimit = -environment.payerSettlementAccountBalance + 200"
]
}
}
}
]
Expand Down
Loading