@mojaloop/sdk-scheme-adapter 12.0.1 → 12.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.circleci/config.yml +619 -0
- package/.env.example +13 -0
- package/CHANGELOG.md +29 -0
- package/CODEOWNERS +2 -0
- package/Dockerfile +35 -0
- package/LICENSE.md +10 -0
- package/PROXY.md +84 -0
- package/README.md +228 -0
- package/SECURITY.md +18 -0
- package/audit-resolve.json +20 -0
- package/docker/ml-testing-toolkit/secrets/keygen.sh +5 -0
- package/docker/ml-testing-toolkit/secrets/privatekey.pem +27 -0
- package/docker/ml-testing-toolkit/secrets/publickey.cer +21 -0
- package/docker/ml-testing-toolkit/secrets/tls/createSecrets.sh +29 -0
- package/docker/ml-testing-toolkit/secrets/tls/hub_client.csr +28 -0
- package/docker/ml-testing-toolkit/secrets/tls/hub_client_cacert.pem +32 -0
- package/docker/ml-testing-toolkit/secrets/tls/hub_client_cakey.key +51 -0
- package/docker/ml-testing-toolkit/secrets/tls/hub_client_key.key +51 -0
- package/docker/ml-testing-toolkit/secrets/tls/hub_server.csr +28 -0
- package/docker/ml-testing-toolkit/secrets/tls/hub_server_cacert.pem +32 -0
- package/docker/ml-testing-toolkit/secrets/tls/hub_server_cacert.srl +1 -0
- package/docker/ml-testing-toolkit/secrets/tls/hub_server_cakey.key +51 -0
- package/docker/ml-testing-toolkit/secrets/tls/hub_server_cert.pem +33 -0
- package/docker/ml-testing-toolkit/secrets/tls/hub_server_key.key +51 -0
- package/docker/ml-testing-toolkit/secrets/tls/openssl.conf +17 -0
- package/docker/ml-testing-toolkit/spec_files/api_definitions/central_admin_9.3/api_spec.yaml +2450 -0
- package/docker/ml-testing-toolkit/spec_files/api_definitions/central_admin_9.3/response_map.json +96 -0
- package/docker/ml-testing-toolkit/spec_files/api_definitions/fspiop_1.0/api_spec.yaml +4187 -0
- package/docker/ml-testing-toolkit/spec_files/api_definitions/fspiop_1.0/callback_map.json +542 -0
- package/docker/ml-testing-toolkit/spec_files/api_definitions/fspiop_1.0/mockRef.json +83 -0
- package/docker/ml-testing-toolkit/spec_files/api_definitions/fspiop_1.0/trigger_templates/transaction_request_followup.json +125 -0
- package/docker/ml-testing-toolkit/spec_files/api_definitions/fspiop_1.1/api_spec.yaml +3703 -0
- package/docker/ml-testing-toolkit/spec_files/api_definitions/fspiop_1.1/callback_map.json +568 -0
- package/docker/ml-testing-toolkit/spec_files/api_definitions/fspiop_1.1/mockRef.json +83 -0
- package/docker/ml-testing-toolkit/spec_files/api_definitions/fspiop_1.1/trigger_templates/transaction_request_followup.json +125 -0
- package/docker/ml-testing-toolkit/spec_files/api_definitions/settlements_1.0/api_spec.yaml +983 -0
- package/docker/ml-testing-toolkit/spec_files/api_definitions/settlements_1.0/mockRef.json +38 -0
- package/docker/ml-testing-toolkit/spec_files/api_definitions/settlements_1.0/response_map.json +34 -0
- package/docker/ml-testing-toolkit/spec_files/reports/templates/newman/html_template.html +1074 -0
- package/docker/ml-testing-toolkit/spec_files/reports/templates/newman/pdf_template.html +765 -0
- package/docker/ml-testing-toolkit/spec_files/reports/templates/newman/script.js +98 -0
- package/docker/ml-testing-toolkit/spec_files/rules_callback/config.json +3 -0
- package/docker/ml-testing-toolkit/spec_files/rules_callback/default.json +426 -0
- package/docker/ml-testing-toolkit/spec_files/rules_response/config.json +3 -0
- package/docker/ml-testing-toolkit/spec_files/rules_response/default.json +1623 -0
- package/docker/ml-testing-toolkit/spec_files/rules_response/default_pisp_rules.json +161 -0
- package/docker/ml-testing-toolkit/spec_files/rules_validation/config.json +3 -0
- package/docker/ml-testing-toolkit/spec_files/rules_validation/default.json +672 -0
- package/docker/ml-testing-toolkit/spec_files/system_config.json +62 -0
- package/docker/ml-testing-toolkit/spec_files/user_config.json +45 -0
- package/docker/wait4/setup_hosts_file.sh +25 -0
- package/docker/wait4/wait4.config.js +71 -0
- package/docker/wait4/wait4.js +204 -0
- package/docker-compose.yml +67 -0
- package/docs/Mojaloop - Modusbox Onboarding functionality.pdf +0 -0
- package/docs/dfspInboundApi.yaml +1091 -0
- package/jest.config.js +4 -1
- package/package.json +13 -8
- package/secrets/jwsSigningKey.key +27 -0
- package/secrets/jwsVerificationKeys/mojaloop-sdk.pem +9 -0
- package/secrets/jwsVerificationKeys/switch.pem +9 -0
- package/sequences.puml +99 -0
- package/src/ControlAgent/index.js +221 -0
- package/{TestServer → src/ControlServer}/handlers.js +0 -0
- package/src/ControlServer/index.js +294 -0
- package/{InboundServer → src/InboundServer}/api.yaml +0 -0
- package/src/InboundServer/api_template.yaml +69 -0
- package/{InboundServer → src/InboundServer}/handlers.js +0 -0
- package/{InboundServer → src/InboundServer}/index.js +33 -1
- package/{InboundServer → src/InboundServer}/middlewares.js +0 -0
- package/{OAuthTestServer → src/OAuthTestServer}/index.js +0 -0
- package/{OAuthTestServer → src/OAuthTestServer}/model.js +0 -0
- package/{OutboundServer → src/OutboundServer}/api.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_interfaces/index.d.ts +0 -0
- package/{OutboundServer → src/OutboundServer}/api_interfaces/openapi.d.ts +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/parameters/bulkQuoteId.yaml +1 -1
- package/{OutboundServer → src/OutboundServer}/api_template/components/parameters/bulkTransferId.yaml +1 -1
- package/{OutboundServer → src/OutboundServer}/api_template/components/parameters/requestToPayTransactionId.yaml +1 -1
- package/{OutboundServer → src/OutboundServer}/api_template/components/parameters/transferId.yaml +1 -1
- package/{OutboundServer → src/OutboundServer}/api_template/components/responses/accountsCreationCompleted.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/responses/accountsCreationError.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/responses/accountsCreationTimeout.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/responses/bulkQuoteBadRequest.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/responses/bulkQuoteServerError.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/responses/bulkQuoteSuccess.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/responses/bulkQuoteTimeout.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/responses/bulkTransferBadRequest.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/responses/bulkTransferServerError.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/responses/bulkTransferSuccess.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/responses/bulkTransferTimeout.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/responses/partiesByIdError404.yaml +1 -1
- package/{OutboundServer → src/OutboundServer}/api_template/components/responses/partiesByIdSuccess.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/responses/quotesPostSuccess.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/responses/quotesServerError.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/responses/requestToPaySuccess.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/responses/requestToPayTransferBadRequest.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/responses/requestToPayTransferSuccess.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/responses/simpleTransfersPostSuccess.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/responses/simpleTransfersServerError.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/responses/transferBadRequest.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/responses/transferServerError.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/responses/transferSuccess.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/responses/transferTimeout.yaml +0 -0
- package/src/OutboundServer/api_template/components/schemas/accountCreationStatus.yaml +18 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/accountsCreationState.yaml +0 -0
- package/src/OutboundServer/api_template/components/schemas/accountsRequest.yaml +20 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/accountsResponse.yaml +1 -1
- package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/async2SyncCurrentState.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/bulkQuoteErrorResponse.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/bulkQuoteRequest.yaml +2 -2
- package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/bulkQuoteResponse.yaml +1 -1
- package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/bulkQuoteStatus.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/bulkQuoteStatusResponse.yaml +1 -1
- package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/bulkTransferErrorResponse.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/bulkTransferRequest.yaml +2 -2
- package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/bulkTransferResponse.yaml +1 -1
- package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/bulkTransferStatus.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/bulkTransferStatusResponse.yaml +1 -1
- package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/errorAccountsResponse.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/errorQuotesResponse.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/errorResponse.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/errorSimpleTransfersResponse.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/errorTransferResponse.yaml +0 -0
- package/src/OutboundServer/api_template/components/schemas/extensionListEmptiable.yaml +6 -0
- package/src/OutboundServer/api_template/components/schemas/individualQuote.yaml +32 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/individualQuoteResult.yaml +5 -5
- package/src/OutboundServer/api_template/components/schemas/individualTransfer.yaml +32 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/individualTransferFulfilment.yaml +2 -2
- package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/individualTransferResult.yaml +6 -6
- package/src/OutboundServer/api_template/components/schemas/mojaloopError.yaml +5 -0
- package/src/OutboundServer/api_template/components/schemas/mojaloopTransactionRequestState.yaml +2 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/partiesByIdResponse.yaml +1 -1
- package/src/OutboundServer/api_template/components/schemas/quote.yaml +3 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/quoteError.yaml +0 -0
- package/src/OutboundServer/api_template/components/schemas/quotesPostRequest.yaml +13 -0
- package/src/OutboundServer/api_template/components/schemas/quotesPostResponse.yaml +48 -0
- package/src/OutboundServer/api_template/components/schemas/requestToPayRequest.yaml +39 -0
- package/src/OutboundServer/api_template/components/schemas/requestToPayResponse.yaml +41 -0
- package/src/OutboundServer/api_template/components/schemas/requestToPayTransferRequest.yaml +42 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/requestToPayTransferResponse.yaml +6 -6
- package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/simpleTransferServerError.yaml +0 -0
- package/src/OutboundServer/api_template/components/schemas/simpleTransfersPostRequest.yaml +12 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/simpleTransfersPostResponse.yaml +1 -1
- package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/transactionType.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/transferContinuationAcceptOTP.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/transferContinuationAcceptParty.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/transferContinuationAcceptQuote.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/transferError.yaml +0 -0
- package/src/OutboundServer/api_template/components/schemas/transferFulfilment.yaml +3 -0
- package/src/OutboundServer/api_template/components/schemas/transferParty.yaml +40 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/transferRequest.yaml +4 -4
- package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/transferResponse.yaml +6 -6
- package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/transferStatus.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/components/schemas/transferStatusResponse.yaml +1 -1
- package/{OutboundServer → src/OutboundServer}/api_template/health.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/openapi.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/paths/accounts.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/paths/bulkQuotes.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/paths/bulkQuotes_bulkQuoteId.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/paths/bulkTransfers.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/paths/bulkTransfers_bulkTransferId.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/paths/parties_Type_ID.yaml +2 -2
- package/{OutboundServer → src/OutboundServer}/api_template/paths/parties_Type_ID_SubId.yaml +3 -3
- package/{OutboundServer → src/OutboundServer}/api_template/paths/quotes.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/paths/requestToPay.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/paths/requestToPayTransfer.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/paths/requestToPayTransfer_requestToPayTransactionId.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/paths/simpleTransfers.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/paths/transfers.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/api_template/paths/transfers_transferId.yaml +0 -0
- package/{OutboundServer → src/OutboundServer}/handlers.js +0 -0
- package/{OutboundServer → src/OutboundServer}/index.js +15 -0
- package/{OutboundServer → src/OutboundServer}/middlewares.js +0 -0
- package/{TestServer → src/TestServer}/api.yaml +0 -0
- package/src/TestServer/handlers.js +63 -0
- package/{TestServer → src/TestServer}/index.js +31 -0
- package/{config.js → src/config.js} +6 -0
- package/{index.d.ts → src/index.d.ts} +0 -0
- package/{index.js → src/index.js} +0 -0
- package/{lib → src/lib}/api/index.js +0 -0
- package/{lib → src/lib}/cache.js +0 -0
- package/{lib → src/lib}/check.js +0 -0
- package/{lib → src/lib}/model/AccountsModel.js +0 -0
- package/{lib → src/lib}/model/Async2SyncModel.js +0 -0
- package/{lib → src/lib}/model/InboundTransfersModel.js +0 -0
- package/{lib → src/lib}/model/OutboundBulkQuotesModel.js +3 -3
- package/{lib → src/lib}/model/OutboundBulkTransfersModel.js +1 -1
- package/{lib → src/lib}/model/OutboundRequestToPayModel.js +1 -1
- package/{lib → src/lib}/model/OutboundRequestToPayTransferModel.js +9 -9
- package/{lib → src/lib}/model/OutboundTransfersModel.js +1 -1
- package/{lib → src/lib}/model/PartiesModel.js +0 -0
- package/{lib → src/lib}/model/ProxyModel/MatchRules/Expression.js +0 -0
- package/{lib → src/lib}/model/ProxyModel/MatchRules/Headers.js +0 -0
- package/{lib → src/lib}/model/ProxyModel/MatchRules/MatchRule.js +0 -0
- package/{lib → src/lib}/model/ProxyModel/MatchRules/Path.js +0 -0
- package/{lib → src/lib}/model/ProxyModel/MatchRules/Query.js +0 -0
- package/{lib → src/lib}/model/ProxyModel/MatchRules/index.js +0 -0
- package/{lib → src/lib}/model/ProxyModel/Route.js +0 -0
- package/{lib → src/lib}/model/ProxyModel/configSchema.json +0 -0
- package/{lib → src/lib}/model/ProxyModel/index.js +0 -0
- package/{lib → src/lib}/model/QuotesModel.js +0 -0
- package/{lib → src/lib}/model/TransfersModel.js +0 -0
- package/{lib → src/lib}/model/common/BackendError.js +0 -0
- package/{lib → src/lib}/model/common/PersistentStateMachine.js +0 -0
- package/{lib → src/lib}/model/common/index.js +0 -0
- package/{lib → src/lib}/model/index.js +0 -0
- package/{lib → src/lib}/model/lib/deferredJob.js +0 -0
- package/{lib → src/lib}/model/lib/index.js +0 -0
- package/{lib → src/lib}/model/lib/requests/backendRequests.js +0 -0
- package/{lib → src/lib}/model/lib/requests/common.js +0 -0
- package/{lib → src/lib}/model/lib/requests/index.js +0 -0
- package/{lib → src/lib}/model/lib/shared.js +6 -5
- package/{lib → src/lib}/randomphrase/index.js +0 -0
- package/{lib → src/lib}/randomphrase/words.json +0 -0
- package/{lib → src/lib}/router.js +0 -0
- package/{lib → src/lib}/validate.js +0 -0
- package/test/config/integration.env +9 -0
- package/test/integration/lib/cache.test.js +3 -3
- package/test/unit/ControlClient.test.js +113 -0
- package/test/unit/ControlServer/events.js +41 -0
- package/test/unit/ControlServer/index.js +231 -0
- package/test/unit/ControlServer.test.js +126 -0
- package/test/unit/InboundServer.test.js +4 -4
- package/test/unit/TestServer.test.js +5 -5
- package/test/unit/api/utils.js +5 -5
- package/test/unit/config.test.js +10 -9
- package/test/unit/inboundApi/handlers.test.js +6 -6
- package/test/unit/index.test.js +2 -1
- package/test/unit/lib/cache.test.js +1 -1
- package/test/unit/lib/model/AccountsModel.test.js +2 -2
- package/test/unit/lib/model/InboundTransfersModel.test.js +5 -5
- package/test/unit/lib/model/OutboundBulkQuotesModel.test.js +2 -2
- package/test/unit/lib/model/OutboundBulkTransfersModel.test.js +2 -2
- package/test/unit/lib/model/OutboundRequestToPayModel.test.js +3 -3
- package/test/unit/lib/model/OutboundRequestToPayTransferModel.test.js +2 -2
- package/test/unit/lib/model/OutboundTransfersModel.test.js +36 -3
- package/test/unit/lib/model/PartiesModel.test.js +28 -28
- package/test/unit/lib/model/QuotesModel.test.js +31 -31
- package/test/unit/lib/model/TransfersModel.test.js +3 -3
- package/test/unit/lib/model/common/PersistentStateMachine.test.js +13 -13
- package/test/unit/lib/model/mockedLibRequests.js +1 -1
- package/test/unit/outboundApi/handlers.test.js +3 -3
- package/.eslintignore +0 -2
- package/InboundServer/api_template.yaml +0 -69
- package/OutboundServer/api_template/components/schemas/accountCreationStatus.yaml +0 -18
- package/OutboundServer/api_template/components/schemas/accountsRequest.yaml +0 -20
- package/OutboundServer/api_template/components/schemas/extensionListEmptiable.yaml +0 -6
- package/OutboundServer/api_template/components/schemas/individualQuote.yaml +0 -32
- package/OutboundServer/api_template/components/schemas/individualTransfer.yaml +0 -32
- package/OutboundServer/api_template/components/schemas/mojaloopError.yaml +0 -5
- package/OutboundServer/api_template/components/schemas/mojaloopTransactionRequestState.yaml +0 -2
- package/OutboundServer/api_template/components/schemas/quote.yaml +0 -3
- package/OutboundServer/api_template/components/schemas/quotesPostRequest.yaml +0 -13
- package/OutboundServer/api_template/components/schemas/quotesPostResponse.yaml +0 -48
- package/OutboundServer/api_template/components/schemas/requestToPayRequest.yaml +0 -39
- package/OutboundServer/api_template/components/schemas/requestToPayResponse.yaml +0 -41
- package/OutboundServer/api_template/components/schemas/requestToPayTransferRequest.yaml +0 -42
- package/OutboundServer/api_template/components/schemas/simpleTransfersPostRequest.yaml +0 -12
- package/OutboundServer/api_template/components/schemas/transferFulfilment.yaml +0 -3
- package/OutboundServer/api_template/components/schemas/transferParty.yaml +0 -40
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
jest.mock('@mojaloop/sdk-standard-components');
|
|
15
15
|
jest.mock('redis');
|
|
16
16
|
|
|
17
|
-
const Cache = require('
|
|
18
|
-
const Model = require('
|
|
17
|
+
const Cache = require('~/lib/cache');
|
|
18
|
+
const Model = require('~/lib/model').OutboundRequestToPayTransferModel;
|
|
19
19
|
|
|
20
20
|
const { MojaloopRequests, Logger } = require('@mojaloop/sdk-standard-components');
|
|
21
21
|
const StateMachine = require('javascript-state-machine');
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
jest.mock('@mojaloop/sdk-standard-components');
|
|
15
15
|
jest.mock('redis');
|
|
16
16
|
|
|
17
|
-
const Cache = require('
|
|
18
|
-
const Model = require('
|
|
19
|
-
const PartiesModel = require('
|
|
17
|
+
const Cache = require('~/lib/cache');
|
|
18
|
+
const Model = require('~/lib/model').OutboundTransfersModel;
|
|
19
|
+
const PartiesModel = require('~/lib/model').PartiesModel;
|
|
20
20
|
|
|
21
21
|
const { MojaloopRequests, Logger } = require('@mojaloop/sdk-standard-components');
|
|
22
22
|
const StateMachine = require('javascript-state-machine');
|
|
@@ -354,6 +354,39 @@ describe('outboundModel', () => {
|
|
|
354
354
|
expect(StateMachine.__instance.state).toBe('payeeResolved');
|
|
355
355
|
});
|
|
356
356
|
|
|
357
|
+
test('uses payee party fspid as source header when supplied - resolving payee', async () => {
|
|
358
|
+
config.autoAcceptParty = false;
|
|
359
|
+
|
|
360
|
+
const model = new Model({
|
|
361
|
+
cache,
|
|
362
|
+
logger,
|
|
363
|
+
...config,
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
let req = JSON.parse(JSON.stringify(transferRequest));
|
|
367
|
+
const testFspId = 'TESTDESTFSPID';
|
|
368
|
+
req.to.fspId = testFspId;
|
|
369
|
+
|
|
370
|
+
await model.initialize(req);
|
|
371
|
+
|
|
372
|
+
expect(StateMachine.__instance.state).toBe('start');
|
|
373
|
+
|
|
374
|
+
// start the model running
|
|
375
|
+
const resultPromise = model.run();
|
|
376
|
+
|
|
377
|
+
// now we started the model running we simulate a callback with the resolved party
|
|
378
|
+
emitPartyCacheMessage(cache, payeeParty);
|
|
379
|
+
|
|
380
|
+
// wait for the model to reach a terminal state
|
|
381
|
+
const result = await resultPromise;
|
|
382
|
+
|
|
383
|
+
// check we stopped at payeeResolved state
|
|
384
|
+
expect(result.currentState).toBe('WAITING_FOR_PARTY_ACCEPTANCE');
|
|
385
|
+
expect(StateMachine.__instance.state).toBe('payeeResolved');
|
|
386
|
+
|
|
387
|
+
// check getParties mojaloop requests method was called with the correct arguments
|
|
388
|
+
expect(MojaloopRequests.__getParties).toHaveBeenCalledWith(req.to.idType, req.to.idValue, req.to.idSubValue, testFspId);
|
|
389
|
+
});
|
|
357
390
|
|
|
358
391
|
test('halts after resolving payee, resumes and then halts after receiving quote response when AUTO_ACCEPT_PARTY is false and AUTO_ACCEPT_QUOTES is false', async () => {
|
|
359
392
|
config.autoAcceptParty = false;
|
|
@@ -14,19 +14,19 @@
|
|
|
14
14
|
jest.mock('@mojaloop/sdk-standard-components');
|
|
15
15
|
|
|
16
16
|
const { uuid } = require('uuidv4');
|
|
17
|
-
const Model = require('
|
|
18
|
-
const PSM = require('
|
|
17
|
+
const Model = require('~/lib/model').PartiesModel;
|
|
18
|
+
const PSM = require('~/lib/model/common').PersistentStateMachine;
|
|
19
19
|
const { MojaloopRequests } = require('@mojaloop/sdk-standard-components');
|
|
20
20
|
const defaultConfig = require('./data/defaultConfig');
|
|
21
21
|
const mockLogger = require('../../mockLogger');
|
|
22
|
-
const deferredJob = require('
|
|
22
|
+
const deferredJob = require('~/lib/model/lib').deferredJob;
|
|
23
23
|
const pt = require('promise-timeout');
|
|
24
24
|
|
|
25
25
|
describe('PartiesModel', () => {
|
|
26
26
|
let cacheKey;
|
|
27
27
|
let data;
|
|
28
28
|
let modelConfig;
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
const subId = 123;
|
|
31
31
|
let handler = null;
|
|
32
32
|
beforeEach(async () => {
|
|
@@ -44,7 +44,7 @@ describe('PartiesModel', () => {
|
|
|
44
44
|
handler = jest.fn(h);
|
|
45
45
|
return subId;
|
|
46
46
|
}),
|
|
47
|
-
|
|
47
|
+
|
|
48
48
|
// mock publish and call stored handler
|
|
49
49
|
publish: jest.fn(async (channel, message) => await handler(channel, message, subId)),
|
|
50
50
|
|
|
@@ -53,7 +53,7 @@ describe('PartiesModel', () => {
|
|
|
53
53
|
...defaultConfig
|
|
54
54
|
};
|
|
55
55
|
data = { the: 'mocked data' };
|
|
56
|
-
|
|
56
|
+
|
|
57
57
|
cacheKey = 'cache-key';
|
|
58
58
|
});
|
|
59
59
|
|
|
@@ -62,7 +62,7 @@ describe('PartiesModel', () => {
|
|
|
62
62
|
const model = await Model.create(data, cacheKey, modelConfig);
|
|
63
63
|
|
|
64
64
|
expect(model.state).toBe('start');
|
|
65
|
-
|
|
65
|
+
|
|
66
66
|
// model's methods layout
|
|
67
67
|
const methods = [
|
|
68
68
|
'run',
|
|
@@ -75,7 +75,7 @@ describe('PartiesModel', () => {
|
|
|
75
75
|
});
|
|
76
76
|
|
|
77
77
|
describe('getResponse', () => {
|
|
78
|
-
|
|
78
|
+
|
|
79
79
|
it('should remap currentState', async () => {
|
|
80
80
|
const model = await Model.create(data, cacheKey, modelConfig);
|
|
81
81
|
const states = model.allStates();
|
|
@@ -85,12 +85,12 @@ describe('PartiesModel', () => {
|
|
|
85
85
|
const result = model.getResponse();
|
|
86
86
|
expect(result.currentState).toEqual(Model.mapCurrentState[state]);
|
|
87
87
|
});
|
|
88
|
-
|
|
88
|
+
|
|
89
89
|
});
|
|
90
90
|
|
|
91
91
|
it('should handle unexpected state', async() => {
|
|
92
92
|
const model = await Model.create(data, cacheKey, modelConfig);
|
|
93
|
-
|
|
93
|
+
|
|
94
94
|
// simulate lack of state by undefined property
|
|
95
95
|
delete model.context.data.currentState;
|
|
96
96
|
|
|
@@ -176,9 +176,9 @@ describe('PartiesModel', () => {
|
|
|
176
176
|
// check that this.context.data is updated
|
|
177
177
|
expect(model.context.data).toEqual({
|
|
178
178
|
...message,
|
|
179
|
-
// current state will be updated by onAfterTransition which isn't called
|
|
179
|
+
// current state will be updated by onAfterTransition which isn't called
|
|
180
180
|
// when manual invocation of transition handler happens
|
|
181
|
-
currentState: 'start'
|
|
181
|
+
currentState: 'start'
|
|
182
182
|
});
|
|
183
183
|
// handler should be called only once
|
|
184
184
|
expect(handler).toBeCalledTimes(1);
|
|
@@ -195,7 +195,7 @@ describe('PartiesModel', () => {
|
|
|
195
195
|
|
|
196
196
|
// ensure that cache.unsubscribe does not happened before fire the message
|
|
197
197
|
expect(cache.unsubscribe).not.toBeCalled();
|
|
198
|
-
|
|
198
|
+
|
|
199
199
|
// fire publication with given message
|
|
200
200
|
const df = deferredJob(cache, channel);
|
|
201
201
|
setImmediate(() => df.trigger(message));
|
|
@@ -250,10 +250,10 @@ describe('PartiesModel', () => {
|
|
|
250
250
|
|
|
251
251
|
// ensure that cache.unsubscribe does not happened before fire the message
|
|
252
252
|
expect(cache.unsubscribe).not.toBeCalled();
|
|
253
|
-
|
|
253
|
+
|
|
254
254
|
// fire publication with given message
|
|
255
255
|
const df = deferredJob(cache, channel);
|
|
256
|
-
|
|
256
|
+
|
|
257
257
|
setTimeout(
|
|
258
258
|
() => { df.trigger(message); },
|
|
259
259
|
// ensure that publication will be far long after timeout should be auto triggered
|
|
@@ -285,7 +285,7 @@ describe('PartiesModel', () => {
|
|
|
285
285
|
});
|
|
286
286
|
});
|
|
287
287
|
|
|
288
|
-
// fire publication to channel with invalid message
|
|
288
|
+
// fire publication to channel with invalid message
|
|
289
289
|
// should throw the exception from JSON.parse
|
|
290
290
|
const df = deferredJob(cache, channel);
|
|
291
291
|
setImmediate(() => df.trigger(undefined));
|
|
@@ -328,7 +328,7 @@ describe('PartiesModel', () => {
|
|
|
328
328
|
const subIdValue = uuid();
|
|
329
329
|
|
|
330
330
|
const model = await Model.create(data, cacheKey, modelConfig);
|
|
331
|
-
|
|
331
|
+
|
|
332
332
|
model.requestAction = jest.fn();
|
|
333
333
|
model.getResponse = jest.fn(() => Promise.resolve({the: 'response'}));
|
|
334
334
|
|
|
@@ -349,12 +349,12 @@ describe('PartiesModel', () => {
|
|
|
349
349
|
const subIdValue = uuid();
|
|
350
350
|
|
|
351
351
|
const model = await Model.create(data, cacheKey, modelConfig);
|
|
352
|
-
|
|
352
|
+
|
|
353
353
|
model.getResponse = jest.fn(() => Promise.resolve({the: 'response'}));
|
|
354
|
-
|
|
354
|
+
|
|
355
355
|
model.context.data.currentState = 'succeeded';
|
|
356
356
|
const result = await model.run({ type, id, subId: subIdValue });
|
|
357
|
-
|
|
357
|
+
|
|
358
358
|
expect(result).toEqual({the: 'response'});
|
|
359
359
|
expect(model.getResponse).toBeCalledTimes(1);
|
|
360
360
|
expect(model.context.logger.log).toBeCalledWith('Action called successfully');
|
|
@@ -366,12 +366,12 @@ describe('PartiesModel', () => {
|
|
|
366
366
|
const subIdValue = uuid();
|
|
367
367
|
|
|
368
368
|
const model = await Model.create(data, cacheKey, modelConfig);
|
|
369
|
-
|
|
369
|
+
|
|
370
370
|
model.getResponse = jest.fn(() => Promise.resolve({the: 'response'}));
|
|
371
|
-
|
|
371
|
+
|
|
372
372
|
model.context.data.currentState = 'errored';
|
|
373
373
|
const result = await model.run({ type, id, subId: subIdValue });
|
|
374
|
-
|
|
374
|
+
|
|
375
375
|
expect(result).toBeFalsy();
|
|
376
376
|
expect(model.getResponse).not.toBeCalled();
|
|
377
377
|
expect(model.context.logger.log).toBeCalledWith('State machine in errored state');
|
|
@@ -383,7 +383,7 @@ describe('PartiesModel', () => {
|
|
|
383
383
|
const subIdValue = uuid();
|
|
384
384
|
|
|
385
385
|
const model = await Model.create(data, cacheKey, modelConfig);
|
|
386
|
-
|
|
386
|
+
|
|
387
387
|
model.requestAction = jest.fn(() => { throw new Error('mocked error'); });
|
|
388
388
|
|
|
389
389
|
model.context.data.currentState = 'start';
|
|
@@ -405,7 +405,7 @@ describe('PartiesModel', () => {
|
|
|
405
405
|
const subIdValue = uuid();
|
|
406
406
|
|
|
407
407
|
const model = await Model.create(data, cacheKey, modelConfig);
|
|
408
|
-
|
|
408
|
+
|
|
409
409
|
model.requestAction = jest.fn(() => {
|
|
410
410
|
const err = new Error('requestAction failed');
|
|
411
411
|
err.requestActionState = 'some';
|
|
@@ -413,7 +413,7 @@ describe('PartiesModel', () => {
|
|
|
413
413
|
});
|
|
414
414
|
model.error = jest.fn();
|
|
415
415
|
model.context.data.currentState = 'start';
|
|
416
|
-
|
|
416
|
+
|
|
417
417
|
let theError = null;
|
|
418
418
|
try {
|
|
419
419
|
await model.run({ type, id, subId: subIdValue });
|
|
@@ -431,7 +431,7 @@ describe('PartiesModel', () => {
|
|
|
431
431
|
it('should handle input validation for id/subId params', async () => {
|
|
432
432
|
const type = uuid();
|
|
433
433
|
const model = await Model.create(data, cacheKey, modelConfig);
|
|
434
|
-
|
|
434
|
+
|
|
435
435
|
expect(() => model.run(type))
|
|
436
436
|
.rejects.toEqual(
|
|
437
437
|
new Error('PartiesModel args required at least two string arguments: \'type\' and \'id\'')
|
|
@@ -465,4 +465,4 @@ describe('PartiesModel', () => {
|
|
|
465
465
|
);
|
|
466
466
|
});
|
|
467
467
|
});
|
|
468
|
-
});
|
|
468
|
+
});
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
jest.mock('@mojaloop/sdk-standard-components');
|
|
15
15
|
|
|
16
16
|
const { uuid } = require('uuidv4');
|
|
17
|
-
const Model = require('
|
|
18
|
-
const PSM = require('
|
|
17
|
+
const Model = require('~/lib/model').QuotesModel;
|
|
18
|
+
const PSM = require('~/lib/model/common').PersistentStateMachine;
|
|
19
19
|
const { MojaloopRequests } = require('@mojaloop/sdk-standard-components');
|
|
20
20
|
const defaultConfig = require('./data/defaultConfig');
|
|
21
21
|
const mockLogger = require('../../mockLogger');
|
|
22
|
-
const deferredJob = require('
|
|
22
|
+
const deferredJob = require('~/lib/model/lib').deferredJob;
|
|
23
23
|
const pt = require('promise-timeout');
|
|
24
24
|
const putQuotesResponse = require('./data/putQuotesResponse.json');
|
|
25
25
|
|
|
@@ -27,7 +27,7 @@ describe('QuotesModel', () => {
|
|
|
27
27
|
let cacheKey;
|
|
28
28
|
let data;
|
|
29
29
|
let modelConfig;
|
|
30
|
-
|
|
30
|
+
|
|
31
31
|
const subId = uuid();
|
|
32
32
|
let handler = null;
|
|
33
33
|
beforeEach(async () => {
|
|
@@ -45,7 +45,7 @@ describe('QuotesModel', () => {
|
|
|
45
45
|
handler = jest.fn(h);
|
|
46
46
|
return subId;
|
|
47
47
|
}),
|
|
48
|
-
|
|
48
|
+
|
|
49
49
|
// mock publish and call stored handler
|
|
50
50
|
publish: jest.fn(async (channel, message) => await handler(channel, message, subId)),
|
|
51
51
|
|
|
@@ -56,7 +56,7 @@ describe('QuotesModel', () => {
|
|
|
56
56
|
data = {
|
|
57
57
|
the: 'mocked data'
|
|
58
58
|
};
|
|
59
|
-
|
|
59
|
+
|
|
60
60
|
cacheKey = `key-quotes-${uuid()}`;
|
|
61
61
|
});
|
|
62
62
|
|
|
@@ -65,7 +65,7 @@ describe('QuotesModel', () => {
|
|
|
65
65
|
const model = await Model.create(data, cacheKey, modelConfig);
|
|
66
66
|
|
|
67
67
|
expect(model.state).toBe('start');
|
|
68
|
-
|
|
68
|
+
|
|
69
69
|
// model's methods layout
|
|
70
70
|
const methods = [
|
|
71
71
|
'run',
|
|
@@ -78,7 +78,7 @@ describe('QuotesModel', () => {
|
|
|
78
78
|
});
|
|
79
79
|
|
|
80
80
|
describe('getResponse', () => {
|
|
81
|
-
|
|
81
|
+
|
|
82
82
|
it('should remap currentState', async () => {
|
|
83
83
|
const model = await Model.create(data, cacheKey, modelConfig);
|
|
84
84
|
const states = model.allStates();
|
|
@@ -88,12 +88,12 @@ describe('QuotesModel', () => {
|
|
|
88
88
|
const result = model.getResponse();
|
|
89
89
|
expect(result.currentState).toEqual(Model.mapCurrentState[state]);
|
|
90
90
|
});
|
|
91
|
-
|
|
91
|
+
|
|
92
92
|
});
|
|
93
93
|
|
|
94
94
|
it('should handle unexpected state', async() => {
|
|
95
95
|
const model = await Model.create(data, cacheKey, modelConfig);
|
|
96
|
-
|
|
96
|
+
|
|
97
97
|
// simulate lack of state by undefined property
|
|
98
98
|
delete model.context.data.currentState;
|
|
99
99
|
|
|
@@ -160,9 +160,9 @@ describe('QuotesModel', () => {
|
|
|
160
160
|
// check that this.context.data is updated
|
|
161
161
|
expect(model.context.data).toEqual({
|
|
162
162
|
quotes: { ...message },
|
|
163
|
-
// current state will be updated by onAfterTransition which isn't called
|
|
163
|
+
// current state will be updated by onAfterTransition which isn't called
|
|
164
164
|
// when manual invocation of transition handler happens
|
|
165
|
-
currentState: 'start'
|
|
165
|
+
currentState: 'start'
|
|
166
166
|
});
|
|
167
167
|
// handler should be called only once
|
|
168
168
|
expect(handler).toBeCalledTimes(1);
|
|
@@ -179,7 +179,7 @@ describe('QuotesModel', () => {
|
|
|
179
179
|
|
|
180
180
|
// ensure that cache.unsubscribe does not happened before fire the message
|
|
181
181
|
expect(cache.unsubscribe).not.toBeCalled();
|
|
182
|
-
|
|
182
|
+
|
|
183
183
|
// fire publication with given message
|
|
184
184
|
const df = deferredJob(cache, channel);
|
|
185
185
|
setImmediate(() => df.trigger(message));
|
|
@@ -205,7 +205,7 @@ describe('QuotesModel', () => {
|
|
|
205
205
|
const onRequestActionPromise = new Promise((resolve, reject) => {
|
|
206
206
|
// manually invoke transition handler
|
|
207
207
|
model.onRequestAction(model.fsm, { quoteId, fspId, quote })
|
|
208
|
-
.then(() => reject())
|
|
208
|
+
.then(() => reject())
|
|
209
209
|
.catch((err) => {
|
|
210
210
|
// subscribe should be called only once
|
|
211
211
|
expect(err instanceof pt.TimeoutError).toBeTruthy();
|
|
@@ -231,10 +231,10 @@ describe('QuotesModel', () => {
|
|
|
231
231
|
|
|
232
232
|
// ensure that cache.unsubscribe does not happened before fire the message
|
|
233
233
|
expect(cache.unsubscribe).not.toBeCalled();
|
|
234
|
-
|
|
234
|
+
|
|
235
235
|
// fire publication with given message
|
|
236
236
|
const df = deferredJob(cache, channel);
|
|
237
|
-
|
|
237
|
+
|
|
238
238
|
setTimeout(
|
|
239
239
|
() => { df.trigger(message); },
|
|
240
240
|
// ensure that publication will be far long after timeout should be auto triggered
|
|
@@ -254,7 +254,7 @@ describe('QuotesModel', () => {
|
|
|
254
254
|
const model = await Model.create(data, cacheKey, modelConfig);
|
|
255
255
|
const { cache } = model.context;
|
|
256
256
|
|
|
257
|
-
// fire publication to channel with invalid message
|
|
257
|
+
// fire publication to channel with invalid message
|
|
258
258
|
// should throw the exception from JSON.parse
|
|
259
259
|
const df = deferredJob(cache, channel);
|
|
260
260
|
setImmediate(() => df.trigger(undefined));
|
|
@@ -305,7 +305,7 @@ describe('QuotesModel', () => {
|
|
|
305
305
|
const quote = { quoteId };
|
|
306
306
|
|
|
307
307
|
const model = await Model.create(data, cacheKey, modelConfig);
|
|
308
|
-
|
|
308
|
+
|
|
309
309
|
model.requestAction = jest.fn();
|
|
310
310
|
model.getResponse = jest.fn(() => Promise.resolve({the: 'response'}));
|
|
311
311
|
|
|
@@ -327,12 +327,12 @@ describe('QuotesModel', () => {
|
|
|
327
327
|
const quote = { quoteId };
|
|
328
328
|
|
|
329
329
|
const model = await Model.create(data, cacheKey, modelConfig);
|
|
330
|
-
|
|
330
|
+
|
|
331
331
|
model.getResponse = jest.fn(() => Promise.resolve({the: 'response'}));
|
|
332
|
-
|
|
332
|
+
|
|
333
333
|
model.context.data.currentState = 'succeeded';
|
|
334
334
|
const result = await model.run({ quoteId, fspId, quote });
|
|
335
|
-
|
|
335
|
+
|
|
336
336
|
expect(result).toEqual({the: 'response'});
|
|
337
337
|
expect(model.getResponse).toBeCalledTimes(1);
|
|
338
338
|
expect(model.context.logger.log).toBeCalledWith('Action called successfully');
|
|
@@ -345,12 +345,12 @@ describe('QuotesModel', () => {
|
|
|
345
345
|
const quote = { quoteId };
|
|
346
346
|
|
|
347
347
|
const model = await Model.create(data, cacheKey, modelConfig);
|
|
348
|
-
|
|
348
|
+
|
|
349
349
|
model.getResponse = jest.fn(() => Promise.resolve({the: 'response'}));
|
|
350
|
-
|
|
350
|
+
|
|
351
351
|
model.context.data.currentState = 'errored';
|
|
352
352
|
const result = await model.run({ quoteId, fspId, quote});
|
|
353
|
-
|
|
353
|
+
|
|
354
354
|
expect(result).toBeFalsy();
|
|
355
355
|
expect(model.getResponse).not.toBeCalled();
|
|
356
356
|
expect(model.context.logger.log).toBeCalledWith('State machine in errored state');
|
|
@@ -363,7 +363,7 @@ describe('QuotesModel', () => {
|
|
|
363
363
|
const quote = { quoteId };
|
|
364
364
|
|
|
365
365
|
const model = await Model.create(data, cacheKey, modelConfig);
|
|
366
|
-
|
|
366
|
+
|
|
367
367
|
model.requestAction = jest.fn(() => { throw new Error('mocked error'); });
|
|
368
368
|
|
|
369
369
|
model.context.data.currentState = 'start';
|
|
@@ -387,7 +387,7 @@ describe('QuotesModel', () => {
|
|
|
387
387
|
const quote = { quoteId };
|
|
388
388
|
|
|
389
389
|
const model = await Model.create(data, cacheKey, modelConfig);
|
|
390
|
-
|
|
390
|
+
|
|
391
391
|
model.requestAction = jest.fn(() => {
|
|
392
392
|
const err = new Error('requestAction failed');
|
|
393
393
|
err.requestActionState = 'some';
|
|
@@ -395,7 +395,7 @@ describe('QuotesModel', () => {
|
|
|
395
395
|
});
|
|
396
396
|
model.error = jest.fn();
|
|
397
397
|
model.context.data.currentState = 'start';
|
|
398
|
-
|
|
398
|
+
|
|
399
399
|
let theError = null;
|
|
400
400
|
try {
|
|
401
401
|
await model.run({ quoteId, fspId, quote });
|
|
@@ -412,7 +412,7 @@ describe('QuotesModel', () => {
|
|
|
412
412
|
|
|
413
413
|
it('should handle input validation for lack of quoteId param', async () => {
|
|
414
414
|
const model = await Model.create(data, cacheKey, modelConfig);
|
|
415
|
-
|
|
415
|
+
|
|
416
416
|
expect(() => model.run({}))
|
|
417
417
|
.rejects.toEqual(
|
|
418
418
|
new Error('QuotesModel args requires \'quoteId\' is nonempty string and mandatory property')
|
|
@@ -422,7 +422,7 @@ describe('QuotesModel', () => {
|
|
|
422
422
|
it('should handle input validation for not quoteId & quote.quoteId be in sync', async () => {
|
|
423
423
|
const quoteId = uuid();
|
|
424
424
|
const model = await Model.create(data, cacheKey, modelConfig);
|
|
425
|
-
|
|
425
|
+
|
|
426
426
|
expect(() => model.run({quoteId, quote: { quoteId: uuid()}}))
|
|
427
427
|
.rejects.toEqual(
|
|
428
428
|
new Error('QuotesModel args requires properties \'quote.quoteId\' and \'quoteId\' to be the equal in value')
|
|
@@ -432,7 +432,7 @@ describe('QuotesModel', () => {
|
|
|
432
432
|
it('should handle input validation for fspId param', async () => {
|
|
433
433
|
const quoteId = uuid();
|
|
434
434
|
const model = await Model.create(data, cacheKey, modelConfig);
|
|
435
|
-
|
|
435
|
+
|
|
436
436
|
expect(() => model.run({quoteId, fspId:'' }))
|
|
437
437
|
.rejects.toEqual(
|
|
438
438
|
new Error('QuotesModel args requires \'fspId\' to be nonempty string')
|
|
@@ -467,4 +467,4 @@ describe('QuotesModel', () => {
|
|
|
467
467
|
);
|
|
468
468
|
});
|
|
469
469
|
});
|
|
470
|
-
});
|
|
470
|
+
});
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
jest.mock('@mojaloop/sdk-standard-components');
|
|
15
15
|
|
|
16
16
|
const { uuid } = require('uuidv4');
|
|
17
|
-
const Model = require('
|
|
18
|
-
const PSM = require('
|
|
17
|
+
const Model = require('~/lib/model').TransfersModel;
|
|
18
|
+
const PSM = require('~/lib/model/common').PersistentStateMachine;
|
|
19
19
|
const { MojaloopRequests } = require('@mojaloop/sdk-standard-components');
|
|
20
20
|
const defaultConfig = require('./data/defaultConfig');
|
|
21
21
|
const mockLogger = require('../../mockLogger');
|
|
22
|
-
const deferredJob = require('
|
|
22
|
+
const deferredJob = require('~/lib/model/lib').deferredJob;
|
|
23
23
|
const pt = require('promise-timeout');
|
|
24
24
|
const putTransfersResponse = require('./data/putTransfersResponse.json');
|
|
25
25
|
|
|
@@ -10,21 +10,21 @@
|
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
const Cache = jest.createMockFromModule('
|
|
13
|
+
const Cache = jest.createMockFromModule('~/lib/cache');
|
|
14
14
|
|
|
15
|
-
const PSM = require('
|
|
15
|
+
const PSM = require('~/lib/model').PersistentStateMachine;
|
|
16
16
|
const mockLogger = require('../../../mockLogger');
|
|
17
17
|
describe('PersistentStateMachine', () => {
|
|
18
18
|
let cache;
|
|
19
19
|
let data;
|
|
20
20
|
let smSpec;
|
|
21
21
|
const key = 'cache-key';
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
const logger = mockLogger({app: 'persistent-state-machine-test'});
|
|
24
24
|
|
|
25
25
|
function checkPSMLayout(psm, optData) {
|
|
26
26
|
expect(psm).toBeTruthy();
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
expect(psm.state).toEqual((optData && optData.currentState) || smSpec.init || 'none');
|
|
29
29
|
|
|
30
30
|
expect(psm.context).toEqual({
|
|
@@ -54,7 +54,7 @@ describe('PersistentStateMachine', () => {
|
|
|
54
54
|
{ name: 'init', from: 'none', to: 'start'},
|
|
55
55
|
{ name: 'gogo', from: 'start', to: 'end' },
|
|
56
56
|
{ name: 'error', from: '*', to: 'errored' }
|
|
57
|
-
],
|
|
57
|
+
],
|
|
58
58
|
methods: {
|
|
59
59
|
onGogo: async () => {
|
|
60
60
|
return new Promise( (resolved) => {
|
|
@@ -70,7 +70,7 @@ describe('PersistentStateMachine', () => {
|
|
|
70
70
|
|
|
71
71
|
// test data
|
|
72
72
|
data = { the: 'data' };
|
|
73
|
-
|
|
73
|
+
|
|
74
74
|
cache = new Cache({
|
|
75
75
|
host: 'dummycachehost',
|
|
76
76
|
port: 1234,
|
|
@@ -100,20 +100,20 @@ describe('PersistentStateMachine', () => {
|
|
|
100
100
|
expect(psm.state).toEqual('start');
|
|
101
101
|
});
|
|
102
102
|
|
|
103
|
-
describe('onPendingTransition', () => {
|
|
103
|
+
describe('onPendingTransition', () => {
|
|
104
104
|
it('should throw error if not `error` transition', async () => {
|
|
105
105
|
const psm = await PSM.create(data, cache, key, logger, smSpec);
|
|
106
106
|
checkPSMLayout(psm);
|
|
107
107
|
|
|
108
108
|
psm.init();
|
|
109
109
|
expect(() => psm.gogo()).toThrowError('Transition \'gogo\' requested while another transition is in progress');
|
|
110
|
-
|
|
110
|
+
|
|
111
111
|
});
|
|
112
112
|
|
|
113
113
|
it('should not throw error if `error` transition called when `gogo` is pending', (done) => {
|
|
114
114
|
PSM.create(data, cache, key, logger, smSpec).then((psm) => {
|
|
115
115
|
checkPSMLayout(psm);
|
|
116
|
-
|
|
116
|
+
|
|
117
117
|
psm.init()
|
|
118
118
|
.then(() => {
|
|
119
119
|
expect(psm.state).toEqual('start');
|
|
@@ -125,7 +125,7 @@ describe('PersistentStateMachine', () => {
|
|
|
125
125
|
.then(done)
|
|
126
126
|
.catch(shouldNotBeExecuted);
|
|
127
127
|
});
|
|
128
|
-
});
|
|
128
|
+
});
|
|
129
129
|
});
|
|
130
130
|
|
|
131
131
|
describe('loadFromCache', () => {
|
|
@@ -163,10 +163,10 @@ describe('PersistentStateMachine', () => {
|
|
|
163
163
|
describe('saveToCache', () => {
|
|
164
164
|
|
|
165
165
|
it('should rethrow error from cache.set', async () => {
|
|
166
|
-
|
|
166
|
+
|
|
167
167
|
// mock to simulate throwing error
|
|
168
168
|
cache.set = jest.fn(() => { throw new Error('error from cache.set'); });
|
|
169
|
-
|
|
169
|
+
|
|
170
170
|
const psm = await PSM.create(data, cache, key, logger, smSpec);
|
|
171
171
|
checkPSMLayout(psm);
|
|
172
172
|
await psm.init();
|
|
@@ -176,4 +176,4 @@ describe('PersistentStateMachine', () => {
|
|
|
176
176
|
});
|
|
177
177
|
});
|
|
178
178
|
|
|
179
|
-
});
|
|
179
|
+
});
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
13
|
const util = require('util');
|
|
14
|
-
const { BackendRequests } = jest.requireActual('
|
|
14
|
+
const { BackendRequests } = jest.requireActual('~/lib/model/lib/requests');
|
|
15
15
|
|
|
16
16
|
const respErrSym = Symbol('ResponseErrorDataSym');
|
|
17
17
|
|
|
@@ -24,9 +24,9 @@ const requestToPayTransferRequest = require('./data/requestToPayTransferRequest'
|
|
|
24
24
|
const mockLogger = require('../mockLogger');
|
|
25
25
|
const { uuid } = require('uuidv4');
|
|
26
26
|
|
|
27
|
-
jest.mock('
|
|
27
|
+
jest.mock('~/lib/model');
|
|
28
28
|
|
|
29
|
-
const handlers = require('
|
|
29
|
+
const handlers = require('~/OutboundServer/handlers');
|
|
30
30
|
const {
|
|
31
31
|
OutboundTransfersModel,
|
|
32
32
|
OutboundBulkTransfersModel,
|
|
@@ -36,7 +36,7 @@ const {
|
|
|
36
36
|
PartiesModel,
|
|
37
37
|
QuotesModel,
|
|
38
38
|
TransfersModel
|
|
39
|
-
} = require('
|
|
39
|
+
} = require('~/lib/model');
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* Mock the outbound transfer model to simulate throwing errors
|
package/.eslintignore
DELETED