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/3018): [SDK-Scheme-Adapter] TransactionId is being used instead of TransferId #422

Merged
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
0c27bbb
feat(mojaloop/3018): [SDK-Scheme-Adapter] TransactionId is being used…
mdebarros Nov 11, 2022
1bf3617
chore(snapshot): 21.4.0-snapshot.0
mdebarros Nov 11, 2022
f32ae2b
docs: cleanup on readme
mdebarros Nov 11, 2022
5f3c2ef
fix: for outbound-command-handler integration tests
mdebarros Nov 11, 2022
ab3698c
chore(snapshot): 21.4.0-snapshot.1
mdebarros Nov 11, 2022
3c1bbcd
updated api-snippets
mdebarros Nov 11, 2022
741a224
chore(snapshot): 21.4.0-snapshot.2
mdebarros Nov 11, 2022
a90f262
chore: made updates for api-snippets 17.0.0-snapshot.2 changes
mdebarros Nov 11, 2022
5023dda
updates to main readme about redis-insights and added todo on docker-…
mdebarros Nov 11, 2022
517e18d
chore(snapshot): 21.4.0-snapshot.3
mdebarros Nov 11, 2022
c273ef7
updated api-snippets to final v17.0.0 version
mdebarros Nov 11, 2022
558abe4
chore(snapshot): 21.4.0-snapshot.4
mdebarros Nov 11, 2022
cb6c53d
test: updated bulk_happy_path_dynamic to align to api-snippets v17.0.…
mdebarros Nov 11, 2022
2a36def
removed bulkHomeTransactionId from PUT ACCEPT /bulkTransaction callba…
mdebarros Nov 11, 2022
288e66c
fix for integration tests
mdebarros Nov 11, 2022
1ac2f3e
chore(snapshot): 21.4.0-snapshot.5
mdebarros Nov 11, 2022
a9f96f1
Merge remote-tracking branch 'origin/master' into feat/#3018-Transact…
kleyow Nov 11, 2022
b2e20a8
chore: yarn and merge
kleyow Nov 11, 2022
cc01fc3
chore: remove ncu
kleyow Nov 11, 2022
4974ccd
chore: id
kleyow Nov 11, 2022
c7422b8
chore(snapshot): 21.4.0-snapshot.0
kleyow Nov 11, 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
1 change: 0 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ defaults_license_scanner: &defaults_license_scanner
git clone https://github.com/mojaloop/license-scanner /tmp/license-scanner
cd /tmp/license-scanner && make build default-files set-up


defaults_export_version_from_package: &defaults_export_version_from_package
name: Format the changelog into the github release body and get release tag
command: |
Expand Down
5 changes: 1 addition & 4 deletions .ncurc.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
## Add a TODO comment indicating the reason for each rejected dependency upgrade added to this list, and what should be done to resolve it (i.e. handle it through a story, etc).
reject: [
## To be removed when https://github.com/mojaloop/sdk-scheme-adapter/pull/422 is checked in
'@mojaloop/api-snippets'
]
reject: []
27 changes: 19 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ _Note that these instructions are for Linux based systems. For Mac and/or Window

You can now examine the code of the Mock DFSP backend to understand how it implements the scheme-adapter simplified inbound API.


## Testing

### Unit Tests
Expand Down Expand Up @@ -161,13 +160,23 @@ docker-compose -f docker-compose.yml down
src/junit.xml
```

If you want to use Redis Insights, you can start it as follows:
<!-- TODO: Add this as part of the Docker Compose -->
```bash
docker run -itd -p 8001:8001 --network="mojaloop-net" redislabs/redisinsight
```

And open http://localhost:8001 in your browser.

### Get status of quote request

The status of a previously sent quotation request can be get by executing `GET /quotes/{ID}`.
When the response to the original quote request is sent, the response is cached in the redis store. When a `GET /quotes/{ID}` is received,
the cached response is retrieved from the redis store and returned to the caller as a body with `PUT /quotes/{ID}` request.
When the redis is setup as a persistent store then it will return the response for all the quote requests sent with `POST /quotes`. If the the redis is setup as cache with expiry time then it will not return response for the expired quotes when the cache expires. Also only the payer dfsp is supposed to make the `GET /quotes/{ID}` request.
If the quote response is not found in the redis store `PUT /quotes/{ID}` will be made with the following body
```

```json
{
"errorInformation":{
"errorCode":"3205",
Expand All @@ -177,6 +186,7 @@ If the quote response is not found in the redis store `PUT /quotes/{ID}` will be
```

### Dev Tools

This project uses @redocly/openapi-cli and @mojaloop/api-snippets to build interfaces.

Any interface changes should be done in the corresponding `api-template.yaml`
Expand Down Expand Up @@ -222,16 +232,17 @@ push a release triggering another subsequent build that also publishes a docker
* It is unknown if a race condition might occur with multiple merges with master in
quick succession, but this is a suspected edge case.


### Running monorepo

- Start the dependencies
```

```bash
docker-compose up
```

- Run application
```

```bash
nvm use
yarn install
yarn run build
Expand All @@ -244,20 +255,20 @@ Note: api-svc is failing to start at the moment.

- Produce a domain event with the following test code

```
```bash
yarn workspace @mojaloop/sdk-scheme-adapter-outbound-domain-event-handler run test:integration
```

- Observe the bulk transaction state using test API
Go to `http://localhost:8000/docs/` and execute the `GET /bulkTransactionsState` request and see response


- Redis commands to observe

```
```redis
KEYS *
HKEYS outboundBulkTransaction_b51ec534-ee48-4575-b6a9-ead2955b8069
HGET outboundBulkTransaction_b51ec534-ee48-4575-b6a9-ead2955b8069 bulkTransactionEntityState
HGET outboundBulkTransaction_b51ec534-ee48-4575-b6a9-ead2955b8069 individualItem_<individualTransferIDHere>
```

Note: If you run test code multiple times, you may observe duplicate individual transfer added to the same bulk transaction. Duplicate check should be implemented somewhere to handle this.
4 changes: 4 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## TODOs
# - Add Redis Insights

version: '3.7'
networks:
mojaloop-net:
Expand All @@ -18,6 +21,7 @@ services:
- "4000:4000"
- "4001:4001"
- "4002:4002"
- "9229:9229"
depends_on:
- redis
- ml-testing-toolkit
Expand Down
5 changes: 3 additions & 2 deletions modules/api-svc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mojaloop/sdk-scheme-adapter-api-svc",
"version": "20.3.5",
"version": "20.4.0-snapshot.0",
"description": "An adapter for connecting to Mojaloop API enabled switches.",
"main": "src/index.js",
"types": "src/index.d.ts",
Expand All @@ -18,6 +18,7 @@
},
"scripts": {
"start": "node src/index.js",
"start:debug": "node --inspect=0.0.0.0:9229 src/index.js",
"build": "yarn run build:openapi",
"build:openapi": "yarn run build:openapi:inbound",
"build:openapi:inbound": "openapi bundle --output ./src/InboundServer/api.yaml --ext yaml ./src/InboundServer/api_template.yaml",
Expand Down Expand Up @@ -60,7 +61,7 @@
},
"dependencies": {
"@koa/cors": "^4.0.0",
"@mojaloop/api-snippets": "^16.0.6",
"@mojaloop/api-snippets": "17.0.0",
"@mojaloop/central-services-error-handling": "^12.0.5",
"@mojaloop/central-services-logger": "^11.0.1",
"@mojaloop/central-services-metrics": "^12.0.5",
Expand Down
6 changes: 4 additions & 2 deletions modules/outbound-command-event-handler/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mojaloop/sdk-scheme-adapter-outbound-command-event-handler",
"version": "0.2.10",
"version": "0.2.11-snapshot.0",
"description": "mojaloop sdk scheme adapter command event handler",
"license": "Apache-2.0",
"homepage": "https://github.com/mojaloop/sdk-scheme-adapter/",
Expand All @@ -18,8 +18,10 @@
],
"scripts": {
"start": "yarn run service",
"start:debug": "yarn run service:debug",
"start:dev": "ts-node src/application/index.ts",
"service": "node dist/application/index.js",
"service:debug": "node --inspect=0.0.0.0:9229 dist/application/index.js",
"build": "tsc && yarn run copy-files",
"watch": "tsc -w",
"dev": "nodemon",
Expand All @@ -39,7 +41,7 @@
"snapshot": "standard-version --no-verify --skip.changelog --prerelease snapshot --releaseCommitMessageFormat 'chore(snapshot): {{currentTag}}'"
},
"dependencies": {
"@mojaloop/api-snippets": "^16.0.6",
"@mojaloop/api-snippets": "17.0.0",
"@mojaloop/central-services-shared": "^17.3.1",
"@mojaloop/logging-bc-client-lib": "^0.1.16",
"@mojaloop/logging-bc-public-types-lib": "^0.1.13",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ export async function handleProcessBulkQuotesCallbackCmdEvt(
if(individualTransfer.quoteResponse) {
individualTransferResults.push({
homeTransactionId: individualTransfer.request.homeTransactionId,
transferId: individualTransfer.id,
transactionId: individualTransfer.transactionId,
quoteResponse: individualTransfer.quoteResponse,
lastError: individualTransfer.lastError && {
Expand All @@ -193,6 +194,7 @@ export async function handleProcessBulkQuotesCallbackCmdEvt(
} else if(!individualTransfer.quoteResponse && individualTransfer.lastError) {
individualTransferResults.push({
homeTransactionId: individualTransfer.request.homeTransactionId,
transferId: individualTransfer.id,
transactionId: individualTransfer.transactionId,
lastError: {
httpStatusCode: individualTransfer.lastError.httpStatusCode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import { ILogger } from '@mojaloop/logging-bc-public-types-lib';
import {
CommandEvent,
IndividualTransferEntity,
IndividualTransferInternalState,
ProcessPartyInfoCallbackCmdEvt,
PartyInfoCallbackProcessedDmEvt,
Expand Down Expand Up @@ -150,7 +149,8 @@ export async function handleProcessPartyInfoCallbackCmdEvt(
// set. `transactionId` and `homeTransaction` still need to be set.
individualTransferResults.push({
homeTransactionId: individualTransferData.request.homeTransactionId,
transactionId: individualTransferData.id,
transferId: individualTransferData.id,
transactionId: individualTransferData.transactionId, // NOTE: This is not available at this time as batches have not been generated yet.
to: individualTransferData.partyResponse?.party,
lastError,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ export async function handleProcessSDKOutboundBulkAcceptPartyInfoCmdEvt(
try {
// TODO: Confirm the field name transactionId in the individualTransfer from the message
individualTransfer =
await bulkTransactionAgg.getIndividualTransferById(individualTransferFromMessage.transactionId);
await bulkTransactionAgg.getIndividualTransferById(individualTransferFromMessage.transferId);
} catch {
logger.warn(`Can not find the individual transfer with id ${individualTransferFromMessage.transactionId} in bulk transaction`);
logger.warn(`Can not find the individual transfer with id ${individualTransferFromMessage.transferId} in bulk transaction`);
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ export async function handleProcessSDKOutboundBulkAcceptQuoteCmdEvt(
try {
// TODO: Confirm the field name transactionId in the individualTransfer from the message
individualTransfer =
await bulkTransactionAgg.getIndividualTransferById(individualTransferFromMessage.transactionId);
await bulkTransactionAgg.getIndividualTransferById(individualTransferFromMessage.transferId);
} catch {
logger.warn(`Can not find the individual transfer with id ${individualTransferFromMessage.transactionId} in bulk transaction`);
logger.warn(`Can not find the individual transfer with id ${individualTransferFromMessage.transferId} in bulk transaction`);
continue;
}

Expand All @@ -79,7 +79,7 @@ export async function handleProcessSDKOutboundBulkAcceptQuoteCmdEvt(
) {
individualTransfer.setTransferState(IndividualTransferInternalState.AGREEMENT_REJECTED);
} else { // handle other cases
logger.warn(`individualTransfer.transactionId[${individualTransferFromMessage.transactionId}] is already in a non-processing state: ${individualTransfer.transferState}`);
logger.warn(`individualTransfer.transferId[${individualTransfer.transferId}] is already in a non-processing state: ${individualTransfer.transferState}`);
}

await bulkTransactionAgg.setIndividualTransferById(individualTransfer.id, individualTransfer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,26 +328,21 @@ import { Timer } from "../../../util/timer";
const processSDKOutboundBulkAcceptPartyInfoCommandEventData : IProcessSDKOutboundBulkAcceptPartyInfoCmdEvtData = {
bulkId: bulkTransactionId,
bulkTransactionContinuationAcceptParty: {
bulkHomeTransactionID: 'string',
individualTransfers: [
{
homeTransactionId: 'string',
transactionId: randomGeneratedTransferIds[amountList.indexOf('1')],
transferId: randomGeneratedTransferIds[amountList.indexOf('1')],
acceptParty: true
},
{
homeTransactionId: 'string',
transactionId: randomGeneratedTransferIds[amountList.indexOf('2')],
transferId: randomGeneratedTransferIds[amountList.indexOf('2')],
acceptParty: true
},
{
homeTransactionId: 'string',
transactionId: randomGeneratedTransferIds[amountList.indexOf('3')],
transferId: randomGeneratedTransferIds[amountList.indexOf('3')],
acceptParty: true
},
{
homeTransactionId: 'string',
transactionId: randomGeneratedTransferIds[amountList.indexOf('4')],
transferId: randomGeneratedTransferIds[amountList.indexOf('4')],
acceptParty: true
}
]
Expand Down Expand Up @@ -746,26 +741,21 @@ import { Timer } from "../../../util/timer";
const processSDKOutboundBulkAcceptPartyInfoCommandEventData : IProcessSDKOutboundBulkAcceptPartyInfoCmdEvtData = {
bulkId: bulkTransactionId,
bulkTransactionContinuationAcceptParty: {
bulkHomeTransactionID: 'string',
individualTransfers: [
{
homeTransactionId: 'string',
transactionId: randomGeneratedTransferIds[amountList.indexOf('1')],
transferId: randomGeneratedTransferIds[amountList.indexOf('1')],
acceptParty: true
},
{
homeTransactionId: 'string',
transactionId: randomGeneratedTransferIds[amountList.indexOf('2')],
transferId: randomGeneratedTransferIds[amountList.indexOf('2')],
acceptParty: true
},
{
homeTransactionId: 'string',
transactionId: randomGeneratedTransferIds[amountList.indexOf('3')],
transferId: randomGeneratedTransferIds[amountList.indexOf('3')],
acceptParty: true
},
{
homeTransactionId: 'string',
transactionId: randomGeneratedTransferIds[amountList.indexOf('4')],
transferId: randomGeneratedTransferIds[amountList.indexOf('4')],
acceptParty: true
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,21 +275,17 @@ describe("Tests for ProcessSDKOutboundBulkQuotesRequest Event Handler", () => {
const processSDKOutboundBulkAcceptPartyInfoCommandEventData : IProcessSDKOutboundBulkAcceptPartyInfoCmdEvtData = {
bulkId: bulkTransactionId,
bulkTransactionContinuationAcceptParty: {
bulkHomeTransactionID: 'string',
individualTransfers: [
{
homeTransactionId: 'string',
transactionId: randomGeneratedTransferIds[amountList.indexOf('1')],
transferId: randomGeneratedTransferIds[amountList.indexOf('1')],
acceptParty: true
},
{
homeTransactionId: 'string',
transactionId: randomGeneratedTransferIds[amountList.indexOf('2')],
transferId: randomGeneratedTransferIds[amountList.indexOf('2')],
acceptParty: false
},
{
homeTransactionId: 'string',
transactionId: randomGeneratedTransferIds[amountList.indexOf('3')],
transferId: randomGeneratedTransferIds[amountList.indexOf('3')],
acceptParty: true
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,16 +240,13 @@ describe("Tests for ProcessSDKOutboundBulkAcceptPartyInfo Event Handler", () =>
const processSDKOutboundBulkAcceptPartyInfoCommandEventData : IProcessSDKOutboundBulkAcceptPartyInfoCmdEvtData = {
bulkId: bulkTransactionId,
bulkTransactionContinuationAcceptParty: {
bulkHomeTransactionID: 'string',
individualTransfers: [
{
homeTransactionId: 'string',
transactionId: randomGeneratedTransferIds[amountList.indexOf('1')],
transferId: randomGeneratedTransferIds[amountList.indexOf('1')],
acceptParty: true
},
{
homeTransactionId: 'string',
transactionId: randomGeneratedTransferIds[amountList.indexOf('2')],
transferId: randomGeneratedTransferIds[amountList.indexOf('2')],
acceptParty: false
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,16 +236,13 @@ describe("Tests for PrepareSDKOutboundBulkResponseCmdEvt Command Event", () => {
const processSDKOutboundBulkAcceptPartyInfoCommandEventData : IProcessSDKOutboundBulkAcceptPartyInfoCmdEvtData = {
bulkId: bulkTransactionId,
bulkTransactionContinuationAcceptParty: {
bulkHomeTransactionID: 'string',
individualTransfers: [
{
homeTransactionId: 'string',
transactionId: randomGeneratedTransferIds[amountList.indexOf('1')],
transferId: randomGeneratedTransferIds[amountList.indexOf('1')],
acceptParty: true
},
{
homeTransactionId: 'string',
transactionId: randomGeneratedTransferIds[amountList.indexOf('2')],
transferId: randomGeneratedTransferIds[amountList.indexOf('2')],
acceptParty: false
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,9 @@ describe.skip('SDKOutboundBulkAcceptPartyInfoRequested', () => {
const sampleSDKOutboundBulkAcceptPartyInfoReceivedDmEvtData: ISDKOutboundBulkAcceptPartyInfoReceivedDmEvtData = {
bulkId: bulkTransactionId,
bulkTransactionContinuationAcceptParty: {
bulkHomeTransactionID: "abc123",
individualTransfers: [
{
homeTransactionId: homeTransactionId1,
transactionId: allIndividualTransferIds[0],
transferId: allIndividualTransferIds[0],
acceptParty: true
}
]
Expand Down
Loading