@mojaloop/sdk-scheme-adapter 16.0.0 → 17.0.2-snapshot.6

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.
Files changed (41) hide show
  1. package/.circleci/config.yml +463 -178
  2. package/CHANGELOG.md +24 -0
  3. package/Dockerfile +4 -0
  4. package/audit-resolve.json +27 -93
  5. package/package.json +20 -19
  6. package/src/InboundServer/index.js +4 -2
  7. package/src/InboundServer/middlewares.js +12 -4
  8. package/src/OutboundServer/index.js +3 -2
  9. package/src/OutboundServer/middlewares.js +6 -2
  10. package/src/TestServer/index.js +4 -2
  11. package/src/index.js +0 -2
  12. package/src/lib/metrics.js +0 -2
  13. package/src/lib/model/AccountsModel.js +4 -7
  14. package/src/lib/model/Async2SyncModel.js +4 -3
  15. package/src/lib/model/InboundTransfersModel.js +16 -14
  16. package/src/lib/model/OutboundBulkQuotesModel.js +4 -7
  17. package/src/lib/model/OutboundBulkTransfersModel.js +4 -7
  18. package/src/lib/model/OutboundRequestToPayModel.js +5 -10
  19. package/src/lib/model/OutboundRequestToPayTransferModel.js +6 -12
  20. package/src/lib/model/OutboundTransfersModel.js +10 -9
  21. package/src/lib/model/common/BackendError.js +1 -13
  22. package/src/lib/model/common/Enums.js +30 -0
  23. package/src/lib/model/common/index.js +3 -2
  24. package/src/lib/router.js +3 -1
  25. package/src/lib/validate.js +10 -1
  26. package/test/integration/lib/Outbound/parties.test.js +2 -1
  27. package/test/integration/lib/Outbound/quotes.test.js +3 -1
  28. package/test/integration/lib/Outbound/simpleTransfers.test.js +2 -1
  29. package/test/unit/inboundApi/handlers.test.js +3 -1
  30. package/test/unit/lib/model/AccountsModel.test.js +2 -1
  31. package/test/unit/lib/model/InboundTransfersModel.test.js +10 -6
  32. package/test/unit/lib/model/OutboundBulkQuotesModel.test.js +5 -3
  33. package/test/unit/lib/model/OutboundBulkTransfersModel.test.js +4 -3
  34. package/test/unit/lib/model/OutboundRequestToPayModel.test.js +3 -2
  35. package/test/unit/lib/model/OutboundRequestToPayTransferModel.test.js +4 -3
  36. package/test/unit/lib/model/OutboundTransfersModel.test.js +37 -34
  37. package/test/unit/lib/model/PartiesModel.test.js +2 -1
  38. package/test/unit/lib/model/QuotesModel.test.js +2 -1
  39. package/test/unit/lib/model/TransfersModel.test.js +2 -1
  40. package/test/unit/lib/model/data/getBulkTransfersBackendResponse.json +1 -1
  41. package/test/unit/lib/model/data/getBulkTransfersMojaloopResponse.json +1 -1
@@ -16,10 +16,7 @@ const StateMachine = require('javascript-state-machine');
16
16
  const { MojaloopRequests } = require('@mojaloop/sdk-standard-components');
17
17
  const { BackendError } = require('./common');
18
18
 
19
- const stateEnum = {
20
- 'ERROR_OCCURRED': 'ERROR_OCCURRED',
21
- 'COMPLETED': 'COMPLETED',
22
- };
19
+ const { SDKStateEnum } = require('./common');
23
20
 
24
21
  /**
25
22
  * Models the state machine and operations required for performing an outbound bulk transfer
@@ -373,16 +370,16 @@ class OutboundBulkTransfersModel {
373
370
 
374
371
  switch(this.data.currentState) {
375
372
  case 'succeeded':
376
- resp.currentState = stateEnum.COMPLETED;
373
+ resp.currentState = SDKStateEnum.COMPLETED;
377
374
  break;
378
375
 
379
376
  case 'errored':
380
- resp.currentState = stateEnum.ERROR_OCCURRED;
377
+ resp.currentState = SDKStateEnum.ERROR_OCCURRED;
381
378
  break;
382
379
 
383
380
  default:
384
381
  this._logger.log(`Bulk transfer model response being returned from an unexpected state: ${this.data.currentState}. Returning ERROR_OCCURRED state`);
385
- resp.currentState = stateEnum.ERROR_OCCURRED;
382
+ resp.currentState = SDKStateEnum.ERROR_OCCURRED;
386
383
  break;
387
384
  }
388
385
 
@@ -17,12 +17,7 @@ const { MojaloopRequests } = require('@mojaloop/sdk-standard-components');
17
17
  const { BackendError } = require('./common');
18
18
  const PartiesModel = require('./PartiesModel');
19
19
 
20
- const transferStateEnum = {
21
- 'WAITING_FOR_PARTY_ACCEPTANCE': 'WAITING_FOR_PARTY_ACCEPTANCE',
22
- 'WAITING_FOR_QUOTE_ACCEPTANCE': 'WAITING_FOR_QUOTE_ACCEPTANCE',
23
- 'ERROR_OCCURRED': 'ERROR_OCCURRED',
24
- 'COMPLETED': 'COMPLETED',
25
- };
20
+ const { SDKStateEnum } = require('./common');
26
21
 
27
22
  class OutboundRequestToPayModel {
28
23
 
@@ -480,20 +475,20 @@ class OutboundRequestToPayModel {
480
475
 
481
476
  switch(this.data.currentState) {
482
477
  case 'payeeResolved':
483
- resp.currentState = transferStateEnum.WAITING_FOR_PARTY_ACCEPTANCE;
478
+ resp.currentState = SDKStateEnum.WAITING_FOR_PARTY_ACCEPTANCE;
484
479
  break;
485
480
 
486
481
  case 'succeeded':
487
- resp.currentState = transferStateEnum.COMPLETED;
482
+ resp.currentState = SDKStateEnum.COMPLETED;
488
483
  break;
489
484
 
490
485
  case 'errored':
491
- resp.currentState = transferStateEnum.ERROR_OCCURRED;
486
+ resp.currentState = SDKStateEnum.ERROR_OCCURRED;
492
487
  break;
493
488
 
494
489
  default:
495
490
  this._logger.log(`Transaction Request model response being returned from an unexpected state: ${this.data.currentState}. Returning ERROR_OCCURRED state`);
496
- resp.currentState = transferStateEnum.ERROR_OCCURRED;
491
+ resp.currentState = SDKStateEnum.ERROR_OCCURRED;
497
492
  break;
498
493
  }
499
494
 
@@ -18,13 +18,7 @@ const shared = require('./lib/shared');
18
18
  const { BackendError } = require('./common');
19
19
  const PartiesModel = require('./PartiesModel');
20
20
 
21
- const requestToPayTransferStateEnum = {
22
- 'WAITING_FOR_QUOTE_ACCEPTANCE': 'WAITING_FOR_QUOTE_ACCEPTANCE',
23
- 'WAITING_FOR_OTP_ACCEPTANCE': 'WAITING_FOR_OTP_ACCEPTANCE',
24
- 'ERROR_OCCURRED': 'ERROR_OCCURRED',
25
- 'COMPLETED': 'COMPLETED',
26
- };
27
-
21
+ const { SDKStateEnum } = require('./common');
28
22
 
29
23
  /**
30
24
  * Models the state machine and operations required for performing an outbound transfer
@@ -826,24 +820,24 @@ class OutboundRequestToPayTransferModel {
826
820
 
827
821
  switch(this.data.currentState) {
828
822
  case 'quoteReceived':
829
- resp.currentState = requestToPayTransferStateEnum.WAITING_FOR_QUOTE_ACCEPTANCE;
823
+ resp.currentState = SDKStateEnum.WAITING_FOR_QUOTE_ACCEPTANCE;
830
824
  break;
831
825
 
832
826
  case 'otpReceived':
833
- resp.currentState = requestToPayTransferStateEnum.WAITING_FOR_OTP_ACCEPTANCE;
827
+ resp.currentState = SDKStateEnum.WAITING_FOR_OTP_ACCEPTANCE;
834
828
  break;
835
829
 
836
830
  case 'succeeded':
837
- resp.currentState = requestToPayTransferStateEnum.COMPLETED;
831
+ resp.currentState = SDKStateEnum.COMPLETED;
838
832
  break;
839
833
 
840
834
  case 'errored':
841
- resp.currentState = requestToPayTransferStateEnum.ERROR_OCCURRED;
835
+ resp.currentState = SDKStateEnum.ERROR_OCCURRED;
842
836
  break;
843
837
 
844
838
  default:
845
839
  this._logger.log(`Transfer model response being returned from an unexpected state: ${this.data.currentState}. Returning ERROR_OCCURRED state`);
846
- resp.currentState = requestToPayTransferStateEnum.ERROR_OCCURRED;
840
+ resp.currentState = SDKStateEnum.ERROR_OCCURRED;
847
841
  break;
848
842
  }
849
843
 
@@ -15,7 +15,8 @@ const { uuid } = require('uuidv4');
15
15
  const StateMachine = require('javascript-state-machine');
16
16
  const { Ilp, MojaloopRequests } = require('@mojaloop/sdk-standard-components');
17
17
  const shared = require('./lib/shared');
18
- const { BackendError, TransferStateEnum } = require('./common');
18
+ const { BackendError, SDKStateEnum } = require('./common');
19
+ const FSPIOPTransferStateEnum = require('@mojaloop/central-services-shared').Enum.Transfers.TransferState;
19
20
  const PartiesModel = require('./PartiesModel');
20
21
 
21
22
  /**
@@ -685,7 +686,7 @@ class OutboundTransfersModel {
685
686
  if(this._checkIlp && !this._ilp.validateFulfil(fulfil.body.fulfilment, this.data.quoteResponse.body.condition)) {
686
687
  throw new Error('Invalid fulfilment received from peer DFSP.');
687
688
  }
688
- if(this._sendFinalNotificationIfRequested && fulfil.body.transferState === 'RESERVED') {
689
+ if(this._sendFinalNotificationIfRequested && fulfil.body.transferState === FSPIOPTransferStateEnum.RESERVED) {
689
690
  // we need to send a PATCH notification back to say we have committed the transfer.
690
691
  // Note that this is normally a switch only responsibility but the capability is
691
692
  // implemented here to support testing use cases where the mojaloop-connector is
@@ -695,7 +696,7 @@ class OutboundTransfersModel {
695
696
  // we will use the current server time as committed timestamp.
696
697
  const patchNotification = {
697
698
  completedTimestamp: (new Date()).toISOString(),
698
- transferState: 'COMMITTED',
699
+ transferState: FSPIOPTransferStateEnum.COMMITTED,
699
700
  };
700
701
  const res = this._requests.patchTransfers(this.data.transferId,
701
702
  patchNotification, this.data.quoteResponseSource);
@@ -885,28 +886,28 @@ class OutboundTransfersModel {
885
886
 
886
887
  switch(this.data.currentState) {
887
888
  case 'payeeResolved':
888
- resp.currentState = TransferStateEnum.WAITING_FOR_PARTY_ACCEPTANCE;
889
+ resp.currentState = SDKStateEnum.WAITING_FOR_PARTY_ACCEPTANCE;
889
890
  break;
890
891
 
891
892
  case 'quoteReceived':
892
- resp.currentState = TransferStateEnum.WAITING_FOR_QUOTE_ACCEPTANCE;
893
+ resp.currentState = SDKStateEnum.WAITING_FOR_QUOTE_ACCEPTANCE;
893
894
  break;
894
895
 
895
896
  case 'succeeded':
896
- resp.currentState = TransferStateEnum.COMPLETED;
897
+ resp.currentState = SDKStateEnum.COMPLETED;
897
898
  break;
898
899
 
899
900
  case 'aborted':
900
- resp.currentState = TransferStateEnum.ABORTED;
901
+ resp.currentState = SDKStateEnum.ABORTED;
901
902
  break;
902
903
 
903
904
  case 'errored':
904
- resp.currentState = TransferStateEnum.ERROR_OCCURRED;
905
+ resp.currentState = SDKStateEnum.ERROR_OCCURRED;
905
906
  break;
906
907
 
907
908
  default:
908
909
  this._logger.log(`Transfer model response being returned from an unexpected state: ${this.data.currentState}. Returning ERROR_OCCURRED state`);
909
- resp.currentState = TransferStateEnum.ERROR_OCCURRED;
910
+ resp.currentState = SDKStateEnum.ERROR_OCCURRED;
910
911
  break;
911
912
  }
912
913
 
@@ -10,17 +10,6 @@
10
10
 
11
11
  'use strict';
12
12
 
13
- const TransferStateEnum = {
14
- 'WAITING_FOR_PARTY_ACCEPTANCE': 'WAITING_FOR_PARTY_ACCEPTANCE',
15
- 'QUOTE_REQUEST_RECEIVED': 'QUOTE_REQUEST_RECEIVED',
16
- 'WAITING_FOR_QUOTE_ACCEPTANCE': 'WAITING_FOR_QUOTE_ACCEPTANCE',
17
- 'PREPARE_RECEIVED': 'PREPARE_RECEIVED',
18
- 'ERROR_OCCURRED': 'ERROR_OCCURRED',
19
- 'COMPLETED': 'COMPLETED',
20
- 'ABORTED': 'ABORTED',
21
- 'RESERVED': 'RESERVED',
22
- };
23
-
24
13
  class BackendError extends Error {
25
14
  constructor(msg, httpStatusCode) {
26
15
  super(msg);
@@ -45,6 +34,5 @@ class BackendError extends Error {
45
34
 
46
35
 
47
36
  module.exports = {
48
- BackendError,
49
- TransferStateEnum,
37
+ BackendError
50
38
  };
@@ -0,0 +1,30 @@
1
+
2
+ /**************************************************************************
3
+ * (C) Copyright ModusBox Inc. 2019 - All rights reserved. *
4
+ * *
5
+ * This file is made available under the terms of the license agreement *
6
+ * specified in the corresponding source code repository. *
7
+ * *
8
+ * ORIGINAL AUTHOR: *
9
+ * Yevhen Kyriukha - yevhen.kyriukha@modusbox.com *
10
+ **************************************************************************/
11
+
12
+ 'use strict';
13
+
14
+ // NOTE: Stick all common SDK ENUMS here. SDKStateEnum is the first attempt at consolidating and cleaning up ENUMS in the SDK.
15
+
16
+ const SDKStateEnum = {
17
+ WAITING_FOR_ACTION: 'WAITING_FOR_ACTION',
18
+ WAITING_FOR_PARTY_ACCEPTANCE: 'WAITING_FOR_PARTY_ACCEPTANCE',
19
+ QUOTE_REQUEST_RECEIVED: 'QUOTE_REQUEST_RECEIVED',
20
+ WAITING_FOR_QUOTE_ACCEPTANCE: 'WAITING_FOR_QUOTE_ACCEPTANCE',
21
+ PREPARE_RECEIVED: 'PREPARE_RECEIVED',
22
+ ERROR_OCCURRED: 'ERROR_OCCURRED',
23
+ COMPLETED: 'COMPLETED',
24
+ ABORTED: 'ABORTED',
25
+ RESERVED: 'RESERVED',
26
+ };
27
+
28
+ module.exports = {
29
+ SDKStateEnum,
30
+ };
@@ -9,11 +9,12 @@
9
9
  **************************************************************************/
10
10
 
11
11
  'use strict';
12
- const { BackendError, TransferStateEnum } = require('./BackendError');
12
+ const { SDKStateEnum } = require('./Enums');
13
+ const { BackendError } = require('./BackendError');
13
14
  const PersistentStateMachine = require('./PersistentStateMachine');
14
15
 
15
16
  module.exports = {
16
17
  BackendError,
17
- TransferStateEnum,
18
+ SDKStateEnum,
18
19
  PersistentStateMachine
19
20
  };
package/src/lib/router.js CHANGED
@@ -21,7 +21,9 @@ module.exports = (handlerMap) => async (ctx, next) => {
21
21
  ctx.response.body = { statusCode: 404, message: 'Not found' };
22
22
  }
23
23
  else {
24
- ctx.state.logger.push({ handler }).log('Found handler');
24
+ if (!ctx.state.logExcludePaths.includes(ctx.path)) {
25
+ ctx.state.logger.push({handler}).log('Found handler');
26
+ }
25
27
  await handler(ctx);
26
28
  }
27
29
  await next();
@@ -125,6 +125,13 @@ const transformApiDoc = apiDoc => ({
125
125
  });
126
126
 
127
127
  class Validator {
128
+ /**
129
+ * @param {{logExcludePaths: string[]}} [opts]
130
+ */
131
+
132
+ constructor(opts) {
133
+ this.logExcludePaths = opts?.logExcludePaths || [];
134
+ }
128
135
  // apiDoc
129
136
  // POJO representing apiDoc API spec. Example:
130
137
  // const v = new Validator(require('./apiDoc.json'));
@@ -163,7 +170,9 @@ class Validator {
163
170
  }
164
171
  result.params = Object.assign({}, ...path.match(result.matcher.regex).slice(1).map((m, i) => ({ [result.matcher.params[i]]: m})));
165
172
 
166
- logger.push({ path, result }).log('Matched path');
173
+ if (!this.logExcludePaths.includes(path)) {
174
+ logger.push({path, result}).log('Matched path');
175
+ }
167
176
  return result;
168
177
  }
169
178
 
@@ -2,6 +2,7 @@
2
2
 
3
3
  const axios = require('axios');
4
4
  const env = require('../../testEnv');
5
+ const { SDKStateEnum } = require('../../../../src/lib/model/common');
5
6
 
6
7
  jest.dontMock('redis');
7
8
 
@@ -12,7 +13,7 @@ describe('/parties', () => {
12
13
  const res = await axios.get(getPartiesURI);
13
14
 
14
15
  expect(res.status).toEqual(200);
15
- expect(res.data.currentState).toEqual('COMPLETED');
16
+ expect(res.data.currentState).toEqual(SDKStateEnum.COMPLETED);
16
17
  expect(typeof res.data.party).toEqual('object');
17
18
  expect(typeof res.data.party.body).toEqual('object');
18
19
  expect(typeof res.data.party.headers).toEqual('object');
@@ -4,6 +4,8 @@ const axios = require('axios');
4
4
  const { uuid } = require('uuidv4');
5
5
  const env = require('../../testEnv');
6
6
  const quotesPostRequest = require('./data/quotesPostRequest.json');
7
+ const { SDKStateEnum } = require('../../../../src/lib/model/common');
8
+
7
9
 
8
10
  jest.dontMock('redis');
9
11
 
@@ -28,7 +30,7 @@ describe('/quotes', () => {
28
30
  });
29
31
 
30
32
  expect(res.status).toEqual(200);
31
- expect(res.data.currentState).toEqual('COMPLETED');
33
+ expect(res.data.currentState).toEqual(SDKStateEnum.COMPLETED);
32
34
  expect(typeof res.data.quotes).toEqual('object');
33
35
  expect(typeof res.data.quotes.body).toEqual('object');
34
36
  expect(typeof res.data.quotes.headers).toEqual('object');
@@ -4,6 +4,7 @@ const axios = require('axios');
4
4
  const { uuid } = require('uuidv4');
5
5
  const env = require('../../testEnv');
6
6
  const transfersPostRequest = require('./data/transfersPostRequest.json');
7
+ const { SDKStateEnum } = require('../../../../src/lib/model/common');
7
8
 
8
9
  jest.dontMock('redis');
9
10
 
@@ -37,7 +38,7 @@ describe('/simpleTransfers', () => {
37
38
  });
38
39
 
39
40
  expect(res.status).toEqual(200);
40
- expect(res.data.currentState).toEqual('COMPLETED');
41
+ expect(res.data.currentState).toEqual(SDKStateEnum.COMPLETED);
41
42
  expect(typeof res.data.transfer).toEqual('object');
42
43
  expect(typeof res.data.transfer.body).toEqual('object');
43
44
  expect(typeof res.data.transfer.headers).toEqual('object');
@@ -22,6 +22,8 @@ const mockArguments = require('./data/mockArguments');
22
22
  const mockTransactionRequestData = require('./data/mockTransactionRequest');
23
23
  const { Logger } = require('@mojaloop/sdk-standard-components');
24
24
 
25
+ const FSPIOPTransferStateEnum = require('@mojaloop/central-services-shared').Enum.Transfers.TransferState;
26
+
25
27
  describe('Inbound API handlers:', () => {
26
28
  let mockArgs;
27
29
  let mockTransactionRequest;
@@ -549,7 +551,7 @@ describe('Inbound API handlers:', () => {
549
551
 
550
552
  },
551
553
  body: {
552
- transferState: 'COMMITTED',
554
+ transferState: FSPIOPTransferStateEnum.COMMITTED,
553
555
  completedTimestamp: '2020-08-18T09:39:33.552Z'
554
556
  }
555
557
  },
@@ -19,6 +19,7 @@ const { AccountsModel } = require('~/lib/model');
19
19
 
20
20
  const StateMachine = require('javascript-state-machine');
21
21
  const { MojaloopRequests, Logger } = require('@mojaloop/sdk-standard-components');
22
+ const { SDKStateEnum } = require('../../../../src/lib/model/common');
22
23
 
23
24
  const defaultConfig = require('./data/defaultConfig');
24
25
  const transferRequest = require('./data/transferRequest');
@@ -83,7 +84,7 @@ describe('AccountsModel', () => {
83
84
  (Math.floor(count / MAX_ITEMS_PER_REQUEST) + ((count % MAX_ITEMS_PER_REQUEST) ? 1 : 0));
84
85
  expect(MojaloopRequests.__postParticipants).toHaveBeenCalledTimes(expectedRequestsCount);
85
86
 
86
- expect(result.currentState).toBe('COMPLETED');
87
+ expect(result.currentState).toBe(SDKStateEnum.COMPLETED);
87
88
  expect(StateMachine.__instance.state).toBe('succeeded');
88
89
  }
89
90
 
@@ -31,6 +31,10 @@ const notificationToPayee = require('./data/notificationToPayee');
31
31
  const notificationAbortedToPayee = require('./data/notificationAbortedToPayee');
32
32
  const notificationReservedToPayee = require('./data/notificationReservedToPayee');
33
33
 
34
+ const { SDKStateEnum } = require('../../../../src/lib/model/common');
35
+ const FSPIOPTransferStateEnum = require('@mojaloop/central-services-shared').Enum.Transfers.TransferState;
36
+ const FSPIOPBulkTransferStateEnum = require('@mojaloop/central-services-shared').Enum.Transfers.BulkTransferState;
37
+
34
38
  describe('inboundModel', () => {
35
39
  let config;
36
40
  let mockArgs;
@@ -324,7 +328,7 @@ describe('inboundModel', () => {
324
328
  const call = MojaloopRequests.__putTransfers.mock.calls[0];
325
329
  expect(call[0]).toEqual(TRANSFER_ID);
326
330
  expect(call[1]).toEqual(getTransfersMojaloopResponse);
327
- expect(call[1].transferState).toEqual('COMMITTED');
331
+ expect(call[1].transferState).toEqual(FSPIOPTransferStateEnum.COMMITTED);
328
332
  });
329
333
 
330
334
  test('getTransfer should not return fulfillment from payer', async () => {
@@ -345,7 +349,7 @@ describe('inboundModel', () => {
345
349
  const call = MojaloopRequests.__putTransfers.mock.calls[0];
346
350
  expect(call[0]).toEqual(TRANSFER_ID);
347
351
  expect(call[1]).toEqual({...getTransfersMojaloopResponse, fulfilment: undefined});
348
- expect(call[1].transferState).toEqual('COMMITTED');
352
+ expect(call[1].transferState).toEqual(FSPIOPTransferStateEnum.COMMITTED);
349
353
  });
350
354
 
351
355
  test('getTransfer should return not found error', async () => {
@@ -601,7 +605,7 @@ describe('inboundModel', () => {
601
605
  const call = MojaloopRequests.__putBulkTransfers.mock.calls[0];
602
606
  expect(call[0]).toEqual(BULK_TRANSFER_ID);
603
607
  expect(call[1]).toEqual(getBulkTransfersMojaloopResponse);
604
- expect(call[1].bulkTransferState).toEqual('COMMITTED');
608
+ expect(call[1].bulkTransferState).toEqual(FSPIOPBulkTransferStateEnum.COMPLETED);
605
609
  });
606
610
 
607
611
  test('getBulkTransfer should not return fulfillment from payer', async () => {
@@ -621,7 +625,7 @@ describe('inboundModel', () => {
621
625
 
622
626
  const call = MojaloopRequests.__putBulkTransfers.mock.calls[0];
623
627
  expect(call[0]).toEqual(BULK_TRANSFER_ID);
624
- expect(call[1].bulkTransferState).toEqual('COMMITTED');
628
+ expect(call[1].bulkTransferState).toEqual(FSPIOPBulkTransferStateEnum.COMPLETED);
625
629
  const expectedResponse = {...getBulkTransfersMojaloopResponse};
626
630
  expectedResponse.individualTransferResults[0].fulfilment = undefined;
627
631
  expect(call[1]).toMatchObject(expectedResponse);
@@ -738,7 +742,7 @@ describe('inboundModel', () => {
738
742
  const notif = JSON.parse(JSON.stringify(notificationToPayee));
739
743
 
740
744
  const expectedRequest = {
741
- currentState: 'COMPLETED',
745
+ currentState: SDKStateEnum.COMPLETED,
742
746
  finalNotification: notif.data,
743
747
  };
744
748
 
@@ -760,7 +764,7 @@ describe('inboundModel', () => {
760
764
  const notif = JSON.parse(JSON.stringify(notificationAbortedToPayee));
761
765
 
762
766
  const expectedRequest = {
763
- currentState: 'ABORTED',
767
+ currentState: SDKStateEnum.ABORTED,
764
768
  finalNotification: notif.data,
765
769
  };
766
770
 
@@ -20,6 +20,8 @@ const Model = require('~/lib/model').OutboundBulkQuotesModel;
20
20
  const { MojaloopRequests, Logger } = require('@mojaloop/sdk-standard-components');
21
21
  const StateMachine = require('javascript-state-machine');
22
22
 
23
+ const { SDKStateEnum } = require('../../../../src/lib/model/common');
24
+
23
25
  const defaultConfig = require('./data/defaultConfig');
24
26
  const bulkQuoteRequest = require('./data/bulkQuoteRequest');
25
27
  const bulkQuoteResponseTemplate = require('./data/bulkQuoteResponse');
@@ -74,7 +76,7 @@ describe('OutboundBulkQuotesModel', () => {
74
76
  await expect(model.run()).rejects.toThrowError(expectError);
75
77
  } else {
76
78
  const result = await model.run();
77
- await expect(result.currentState).toBe('COMPLETED');
79
+ await expect(result.currentState).toBe(SDKStateEnum.COMPLETED);
78
80
  }
79
81
  }
80
82
 
@@ -139,7 +141,7 @@ describe('OutboundBulkQuotesModel', () => {
139
141
  expect(MojaloopRequests.__getBulkQuotes).toHaveBeenCalledTimes(1);
140
142
 
141
143
  // check we stopped at succeeded state
142
- expect(result.currentState).toBe('COMPLETED');
144
+ expect(result.currentState).toBe(SDKStateEnum.COMPLETED);
143
145
  expect(StateMachine.__instance.state).toBe('succeeded');
144
146
  });
145
147
 
@@ -174,7 +176,7 @@ describe('OutboundBulkQuotesModel', () => {
174
176
  expect(MojaloopRequests.__postBulkQuotes).toHaveBeenCalledTimes(1);
175
177
 
176
178
  // check we stopped at 'succeeded' state
177
- expect(result.currentState).toBe('COMPLETED');
179
+ expect(result.currentState).toBe(SDKStateEnum.COMPLETED);
178
180
  expect(StateMachine.__instance.state).toBe('succeeded');
179
181
  });
180
182
 
@@ -19,6 +19,7 @@ const Model = require('~/lib/model').OutboundBulkTransfersModel;
19
19
 
20
20
  const { MojaloopRequests, Logger } = require('@mojaloop/sdk-standard-components');
21
21
  const StateMachine = require('javascript-state-machine');
22
+ const { SDKStateEnum } = require('../../../../src/lib/model/common');
22
23
 
23
24
  const defaultConfig = require('./data/defaultConfig');
24
25
  const bulkTransferRequest = require('./data/bulkTransferRequest');
@@ -70,7 +71,7 @@ describe('outboundBulkTransferModel', () => {
70
71
  await expect(model.run()).rejects.toThrowError(expectError);
71
72
  } else {
72
73
  const result = await model.run();
73
- await expect(result.currentState).toBe('COMPLETED');
74
+ await expect(result.currentState).toBe(SDKStateEnum.COMPLETED);
74
75
  }
75
76
  }
76
77
 
@@ -136,7 +137,7 @@ describe('outboundBulkTransferModel', () => {
136
137
  expect(MojaloopRequests.__postBulkTransfers).toHaveBeenCalledTimes(1);
137
138
 
138
139
  // check we stopped at succeeded state
139
- expect(result.currentState).toBe('COMPLETED');
140
+ expect(result.currentState).toBe(SDKStateEnum.COMPLETED);
140
141
  expect(StateMachine.__instance.state).toBe('succeeded');
141
142
  });
142
143
 
@@ -168,7 +169,7 @@ describe('outboundBulkTransferModel', () => {
168
169
  expect(MojaloopRequests.__getBulkTransfers).toHaveBeenCalledTimes(1);
169
170
 
170
171
  // check we stopped at succeeded state
171
- expect(result.currentState).toBe('COMPLETED');
172
+ expect(result.currentState).toBe(SDKStateEnum.COMPLETED);
172
173
  expect(StateMachine.__instance.state).toBe('succeeded');
173
174
  });
174
175
 
@@ -20,6 +20,7 @@ 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');
23
+ const { SDKStateEnum } = require('../../../../src/lib/model/common');
23
24
 
24
25
  const defaultConfig = require('./data/defaultConfig');
25
26
  const requestToPayRequest = require('./data/requestToPayRequest');
@@ -124,7 +125,7 @@ describe('outboundModel', () => {
124
125
  expect(MojaloopRequests.__postTransactionRequests).toHaveBeenCalledTimes(1);
125
126
 
126
127
  // check we stopped at payeeResolved state
127
- expect(result.currentState).toBe('COMPLETED');
128
+ expect(result.currentState).toBe(SDKStateEnum.COMPLETED);
128
129
  expect(result.requestToPayState).toBe('RECEIVED');
129
130
  expect(StateMachine.__instance.state).toBe('succeeded');
130
131
  });
@@ -157,7 +158,7 @@ describe('outboundModel', () => {
157
158
  const result = await resultPromise;
158
159
 
159
160
  // check we stopped at payeeResolved state
160
- expect(result.currentState).toBe('WAITING_FOR_PARTY_ACCEPTANCE');
161
+ expect(result.currentState).toBe(SDKStateEnum.WAITING_FOR_PARTY_ACCEPTANCE);
161
162
  expect(StateMachine.__instance.state).toBe('payeeResolved');
162
163
  });
163
164
 
@@ -19,6 +19,7 @@ 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');
22
+ const { SDKStateEnum } = require('../../../../src/lib/model/common');
22
23
 
23
24
  const defaultConfig = require('./data/defaultConfig');
24
25
  const requestToPayTransferRequest = require('./data/requestToPayTransferRequest');
@@ -154,7 +155,7 @@ describe('outboundRequestToPayTransferModel', () => {
154
155
  expect(MojaloopRequests.__postTransfers).toHaveBeenCalledTimes(1);
155
156
 
156
157
  // check we stopped at payeeResolved state
157
- expect(result.currentState).toBe('COMPLETED');
158
+ expect(result.currentState).toBe(SDKStateEnum.COMPLETED);
158
159
  expect(StateMachine.__instance.state).toBe('succeeded');
159
160
  });
160
161
 
@@ -183,7 +184,7 @@ describe('outboundRequestToPayTransferModel', () => {
183
184
  // let result = await resultPromise;
184
185
 
185
186
  // // check we stopped at quoteReceived state
186
- // expect(result.currentState).toBe('WAITING_FOR_QUOTE_ACCEPTANCE');
187
+ // expect(result.currentState).toBe(SDKStateEnum.WAITING_FOR_QUOTE_ACCEPTANCE);
187
188
  // expect(StateMachine.__instance.state).toBe('quoteReceived');
188
189
 
189
190
  // const requestToPayTransactionId = requestToPayTransferRequest.requestToPayTransactionId;
@@ -235,7 +236,7 @@ describe('outboundRequestToPayTransferModel', () => {
235
236
  // result = await resultPromise;
236
237
 
237
238
  // // check we stopped at quoteReceived state
238
- // expect(result.currentState).toBe('COMPLETED');
239
+ // expect(result.currentState).toBe(SDKStateEnum.COMPLETED);
239
240
  // expect(StateMachine.__instance.state).toBe('succeeded');
240
241
 
241
242
  // });