-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(mojaloop/#3844): added integration tests for fxFulfil flow (#1011)
* feat(mojaloop/#3844): added corner cases impl. for FX; added unit-tests * feat(mojaloop/#3844): added corner cases impl. for FX; added unit-tests * feat(mojaloop/#3844): added fxTransferErrorDuplicateCheck table; moved fxFulfilt tests in a separare file * feat(mojaloop/#3844): run tests with output * feat(mojaloop/#3844): fixed unit-test on ci env * feat(mojaloop/#3844): added unit-tests for FxFulfilService; moved duplicateCheckComparator logic to service * feat(mojaloop/#3844): reverted ci test-coverage * feat(mojaloop/#3844): added license * feat(mojaloop/#3844): moved checkErrorPayload to helpers * feat(mojaloop/#3844): moved checkErrorPayload to helpers * feat(mojaloop/#3844): updated from feat/fx-impl * feat(mojaloop/#3844): added integration tests for fxFulfil flow * feat(mojaloop/#3844): fixed producer.disconnect() in int-tests * feat(mojaloop/#3844): added test:int:transfers script * feat(mojaloop/#3844): added duplicateCheck int test * feat(mojaloop/#3844): small cleanup * feat(mojaloop/#3844): added duplicate and fulfilment check int-tests * feat(mojaloop/#3844): removed unneeded code * feat(mojaloop/#3844): added testConsumer.clearEvents() for int-tests * feat(mojaloop/#3844): skipped newly added int-test * feat(mojaloop/#3844): updated validateFulfilCondition * feat: unskip int-test feat: unskip int-test * feat(mojaloop/#3844): removed unneeded npm script --------- Co-authored-by: Kevin Leyow <[email protected]>
- Loading branch information
Showing
15 changed files
with
528 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
* Gates Foundation | ||
- Name Surname <[email protected]> | ||
* Eugen Klymniuk <[email protected] | ||
* Eugen Klymniuk <[email protected]> | ||
-------------- | ||
**********/ | ||
|
||
|
@@ -111,13 +111,14 @@ class FxFulfilService { | |
|
||
async getDuplicateCheckResult({ commitRequestId, payload, action }) { | ||
const { duplicateCheck } = this.FxTransferModel | ||
const isFxTransferError = action === Action.FX_ABORT | ||
|
||
const getDuplicateFn = action === Action.FX_ABORT | ||
const getDuplicateFn = isFxTransferError | ||
? duplicateCheck.getFxTransferErrorDuplicateCheck | ||
: duplicateCheck.getFxTransferDuplicateCheck | ||
const saveHashFn = action === Action.FX_ABORT | ||
: duplicateCheck.getFxTransferFulfilmentDuplicateCheck | ||
const saveHashFn = isFxTransferError | ||
? duplicateCheck.saveFxTransferErrorDuplicateCheck | ||
: duplicateCheck.saveFxTransferDuplicateCheck | ||
: duplicateCheck.saveFxTransferFulfilmentDuplicateCheck | ||
|
||
return this.Comparators.duplicateCheckComparator( | ||
commitRequestId, | ||
|
@@ -212,17 +213,20 @@ class FxFulfilService { | |
}) | ||
throw fspiopError | ||
} | ||
this.log.debug('validateEventType is passed', { type, functionality }) | ||
} | ||
|
||
async validateFulfilment(transfer, payload) { | ||
if (payload.fulfilment && !this.Validator.validateFulfilCondition(payload.fulfilment, transfer.condition)) { | ||
const isValid = this.validateFulfilCondition(payload.fulfilment, transfer.ilpCondition) | ||
|
||
if (!isValid) { | ||
const fspiopError = fspiopErrorFactory.fxInvalidFulfilment() | ||
const apiFSPIOPError = fspiopError.toApiErrorObject(this.Config.ERROR_HANDLING) | ||
const eventDetail = { | ||
functionality: Type.POSITION, | ||
action: Action.FX_ABORT_VALIDATION | ||
} | ||
this.log.warn('callbackErrorInvalidFulfilment', { eventDetail, apiFSPIOPError }) | ||
this.log.warn('callbackErrorInvalidFulfilment', { eventDetail, apiFSPIOPError, transfer, payload }) | ||
await this.FxTransferModel.fxTransfer.saveFxFulfilResponse(transfer.commitRequestId, payload, eventDetail.action, apiFSPIOPError) | ||
|
||
await this.kafkaProceed({ | ||
|
@@ -233,9 +237,9 @@ class FxFulfilService { | |
}) | ||
throw fspiopError | ||
} | ||
this.log.info('fulfilmentCheck passed successfully') | ||
|
||
return true | ||
this.log.info('fulfilmentCheck passed successfully', { isValid }) | ||
return isValid | ||
} | ||
|
||
async validateTransferState(transfer, functionality) { | ||
|
@@ -246,7 +250,7 @@ class FxFulfilService { | |
functionality, | ||
action: Action.FX_RESERVE | ||
} | ||
this.log.warn('callbackErrorNonReservedState', { eventDetail, apiFSPIOPError }) | ||
this.log.warn('callbackErrorNonReservedState', { eventDetail, apiFSPIOPError, transfer }) | ||
|
||
await this.kafkaProceed({ | ||
consumerCommit, | ||
|
@@ -256,6 +260,8 @@ class FxFulfilService { | |
}) | ||
throw fspiopError | ||
} | ||
this.log.debug('validateTransferState is passed') | ||
return true | ||
} | ||
|
||
async validateExpirationDate(transfer, functionality) { | ||
|
@@ -320,6 +326,17 @@ class FxFulfilService { | |
return this.Kafka.proceed(this.Config.KAFKA_CONFIG, this.params, kafkaOpts) | ||
} | ||
|
||
validateFulfilCondition(fulfilment, condition) { | ||
try { | ||
const isValid = fulfilment && this.Validator.validateFulfilCondition(fulfilment, condition) | ||
this.log.debug('validateFulfilCondition result:', { isValid, fulfilment, condition }) | ||
return isValid | ||
} catch (err) { | ||
this.log.warn(`validateFulfilCondition error: ${err?.message}`, { fulfilment, condition }) | ||
return false | ||
} | ||
} | ||
|
||
static decodeKafkaMessage(message) { | ||
if (!message?.value) { | ||
throw TypeError('Invalid message format!') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
* Gates Foundation | ||
- Name Surname <[email protected]> | ||
* Eugen Klymniuk <[email protected] | ||
* Eugen Klymniuk <[email protected]> | ||
-------------- | ||
**********/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ | |
* Gates Foundation | ||
- Name Surname <[email protected]> | ||
* Eugen Klymniuk <[email protected] | ||
* Eugen Klymniuk <[email protected]> | ||
-------------- | ||
**********/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ | |
* Gates Foundation | ||
- Name Surname <[email protected]> | ||
* Eugen Klymniuk <[email protected] | ||
* Eugen Klymniuk <[email protected]> | ||
-------------- | ||
**********/ | ||
|
||
|
Oops, something went wrong.