Skip to content

Commit

Permalink
feature/904 Request Duplicate Check update (#96)
Browse files Browse the repository at this point in the history
* Settlement transfer fulfilment insert update

* Fix standard and other issues

* Preparing snapshot release
  • Loading branch information
ggrg authored Aug 26, 2019
1 parent 82dfe0e commit 4ece497
Show file tree
Hide file tree
Showing 10 changed files with 3,247 additions and 2,037 deletions.
5,089 changes: 3,146 additions & 1,943 deletions package-lock.json

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "central-settlement",
"description": "Central settlements hosted by a scheme to record and make settlements",
"version": "7.3.0",
"version": "7.4.0-snapshot",
"license": "Apache-2.0",
"private": true,
"author": "ModusBox",
Expand All @@ -20,26 +20,26 @@
"registry": "https://registry.npmjs.org"
},
"dependencies": {
"@hapi/catbox-memory": "4.1.0",
"@hapi/hapi": "18.3.1",
"@mojaloop/central-ledger": "5.2.1",
"@hapi/catbox-memory": "4.1.1",
"@hapi/hapi": "18.3.2",
"@mojaloop/central-ledger": "7.4.0",
"@mojaloop/central-services-auth": "5.2.1",
"@mojaloop/central-services-database": "5.2.1",
"@mojaloop/central-services-database": "7.4.0",
"@mojaloop/central-services-error-handling": "7.3.0",
"@mojaloop/central-services-health": "7.0.0",
"@mojaloop/central-services-shared": "7.2.0",
"@mojaloop/central-services-shared": "7.4.3",
"@mojaloop/central-services-stream": "6.2.2",
"@mojaloop/forensic-logging-client": "5.2.0",
"hapi-openapi": "1.2.2",
"hapi-pagination": "3.0.0",
"mustache": "3.0.1",
"mustache": "3.0.2",
"rc": "1.2.8",
"uuid4": "1.1.4"
},
"devDependencies": {
"@hapi/joi": "15.1.0",
"@hapi/joi": "15.1.1",
"bluebird": "3.5.5",
"eslint": "6.1.0",
"eslint": "6.2.1",
"faucet": "0.0.1",
"nyc": "14.1.1",
"npm-audit-resolver": "1.5.0",
Expand All @@ -49,7 +49,7 @@
"proxyquire": "2.1.3",
"rewire": "4.0.1",
"sinon": "7.4.1",
"standard": "13.1.0",
"standard": "14.0.2",
"swagmock": "1.0.0",
"tap-xunit": "2.4.1",
"tape": "4.11.0",
Expand Down
21 changes: 12 additions & 9 deletions src/models/settlement/facade.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,10 @@ const settlementTransfersReserve = async function (settlementId, transactionTime

const trxFunction = async (trx, doCommit = true) => {
try {
for (const { transferId, ledgerEntryTypeId, dfspAccountId, dfspAmount, hubAccountId, hubAmount,
dfspName, currencyId } of settlementTransferList) {
for (const {
transferId, ledgerEntryTypeId, dfspAccountId, dfspAmount, hubAccountId, hubAmount,
dfspName, currencyId
} of settlementTransferList) {
// Persist transfer state change
transferStateChangeId = await knex('transferStateChange')
.insert({
Expand Down Expand Up @@ -409,8 +411,10 @@ const settlementTransfersAbort = async function (settlementId, transactionTimest

const trxFunction = async (trx, doCommit = true) => {
try {
for (const { transferId, ledgerEntryTypeId, dfspAccountId, dfspAmount, hubAccountId, hubAmount, isReserved,
dfspName, currencyId } of settlementTransferList) {
for (const {
transferId, ledgerEntryTypeId, dfspAccountId, dfspAmount, hubAccountId, hubAmount, isReserved,
dfspName, currencyId
} of settlementTransferList) {
// Persist transfer state change
await knex('transferStateChange')
.insert({
Expand Down Expand Up @@ -561,20 +565,19 @@ const settlementTransfersCommit = async function (settlementId, transactionTimes

const trxFunction = async (trx, doCommit = true) => {
try {
for (const { transferId, ledgerEntryTypeId, dfspAccountId, dfspAmount, hubAccountId, hubAmount,
dfspName, currencyId } of settlementTransferList) {
for (const {
transferId, ledgerEntryTypeId, dfspAccountId, dfspAmount, hubAccountId, hubAmount,
dfspName, currencyId
} of settlementTransferList) {
// Persist transfer fulfilment and transfer state change
const transferFulfilmentId = Uuid()
await knex('transferFulfilmentDuplicateCheck')
.insert({
transferFulfilmentId,
transferId
})
.transacting(trx)

await knex('transferFulfilment')
.insert({
transferFulfilmentId,
transferId,
ilpFulfilment: 0,
completedDate: transactionTimestamp,
Expand Down
4 changes: 4 additions & 0 deletions test/integration-config-centralledger.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"PORT": 3001,
"HOSTNAME": "http://central-ledger",
"MIGRATIONS": {
"DISABLED": false,
"RUN_DATA_MIGRATIONS": true
},
"ENABLE_TOKEN_AUTH": false,
"ENABLE_BASIC_AUTH": false,
"LEDGER_ACCOUNT_NAME": "LedgerName",
Expand Down
2 changes: 1 addition & 1 deletion test/integration-runner.env
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ SIMULATOR_REMOTE_PORT=${SIMULATOR_REMOTE_PORT:-"8444"}
CENTRAL_LEDGER_HOST=${CENTRAL_LEDGER_HOST:-"central-ledger-int"}
CENTRAL_LEDGER_PORT=${CENTRAL_LEDGER_PORT:-"3001"}
CENTRAL_LEDGER_IMAGE=${CENTRAL_LEDGER_IMAGE:-'mojaloop/central-ledger'}
CENTRAL_LEDGER_TAG=${CENTRAL_LEDGER_TAG:-'latest'}
CENTRAL_LEDGER_TAG=${CENTRAL_LEDGER_TAG:-'v7.4.1-snapshot'}
ML_API_ADAPTER_HOST=${ML_API_ADAPTER_HOST:-"ml-api-adapter-int"}
ML_API_ADAPTER_PORT=${ML_API_ADAPTER_PORT:-"3000"}
ML_API_ADAPTER_IMAGE=${ML_API_ADAPTER_IMAGE:-'mojaloop/ml-api-adapter'}
Expand Down
2 changes: 1 addition & 1 deletion test/integration/handlers/health.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const healthHandler = require('../../../src/handlers/health')

Test('Health Handler', async handlersTest => {
await handlersTest.test('registerAllHandlers should', async registerAllHandlers => {
await registerAllHandlers.test(`setup handlers`, async (test) => {
await registerAllHandlers.test('setup handlers', async (test) => {
await Db.connect(Config.DATABASE_URI)

test.pass('done')
Expand Down
2 changes: 1 addition & 1 deletion test/integration/helpers/transferData.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ module.exports = () => {

try {
const res = await fetch(url, opts)
test.equal(res.status, 202, `transfer PREPARE request returned 202 Accepted`)
test.equal(res.status, 202, 'transfer PREPARE request returned 202 Accepted')

let transferCommitted = false
for (let i = 0; i < 10; i++) {
Expand Down
6 changes: 3 additions & 3 deletions test/integration/settlementTransfer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ Test('SettlementTransfer should', async settlementTransferTest => {
test.ok(settlement, `create settlement with id ${settlementData.id}`)

const settlementState = await SettlementStateChangeModel.getBySettlementId(settlementData.id)
test.equal(settlementState.settlementStateId, enums.settlementStates.PENDING_SETTLEMENT, `settlement state is PENDING_SETTLEMENT`)
test.equal(settlementState.settlementStateId, enums.settlementStates.PENDING_SETTLEMENT, 'settlement state is PENDING_SETTLEMENT')
test.end()
} catch (err) {
Logger.error(`settlementTransferTest failed with error - ${err}`)
Expand Down Expand Up @@ -246,7 +246,7 @@ Test('SettlementTransfer should', async settlementTransferTest => {
test.ok(payeeTransferParticipant.amount > 0, `CR settlement transfer for SETTLEMENT_NET_RECIPIENT is positive for payer ${payeeTransferParticipant.amount}`)

const settlementState = await SettlementStateChangeModel.getBySettlementId(settlementData.id)
test.equal(settlementState.settlementStateId, enums.settlementStates.PS_TRANSFERS_RECORDED, `settlement state is PS_TRANSFERS_RECORDED`)
test.equal(settlementState.settlementStateId, enums.settlementStates.PS_TRANSFERS_RECORDED, 'settlement state is PS_TRANSFERS_RECORDED')

test.end()
} catch (err) {
Expand Down Expand Up @@ -295,7 +295,7 @@ Test('SettlementTransfer should', async settlementTransferTest => {
test.equal(payeeSettlementParticipantCurrencyRecord.settlementStateId, enums.settlementStates.PS_TRANSFERS_RESERVED, 'record for payee changed to PS_TRANSFERS_RESERVED')

const settlementState = await SettlementStateChangeModel.getBySettlementId(settlementData.id)
test.equal(settlementState.settlementStateId, enums.settlementStates.PS_TRANSFERS_RESERVED, `settlement state is PS_TRANSFERS_RESERVED`)
test.equal(settlementState.settlementStateId, enums.settlementStates.PS_TRANSFERS_RESERVED, 'settlement state is PS_TRANSFERS_RESERVED')

const payerTransferStateChangeRecord = await TransferStateChangeModel.getByTransferId(netSenderSettlementTransferId)
test.equal(payerTransferStateChangeRecord.transferStateId, enums.transferStates.RESERVED, 'settlement transfer for payer is RESERVED')
Expand Down
2 changes: 1 addition & 1 deletion test/unit/handlers/health.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
const Test = require('tapes')(require('tape'))
const Sinon = require('sinon')

const src = `../../../src`
const src = '../../../src'
const getHealth = require(`${src}/handlers/health`).get
const MigrationLockModel = require(`${src}/models/misc/migrationLock`)

Expand Down
Loading

0 comments on commit 4ece497

Please sign in to comment.