Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/#248 merge all the changes #73

Merged
merged 34 commits into from
Jun 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
f2ef7e0
Added Unhappy line test to improve code coverage
May 31, 2018
c751aa8
transfer model integration done, fixed bug in the model, fixed the un…
vgenev May 31, 2018
5bf1796
extension coverage 100%
vgenev May 31, 2018
82ffcb0
Fulfil handler commit implementation
ggrg May 31, 2018
ec683e6
TODO: FiveBellsCondition.fulfillmentToCondition comment changed
ggrg May 31, 2018
44f3620
Added destroyByName method's happy and Unhappy line Unit tests, Code …
May 31, 2018
51dc581
Unit tests for fulfil success
ggrg May 31, 2018
974eed8
Merge vgenev feature/#248
ggrg May 31, 2018
473fc63
Starting to add unhappy lines on transferstatechange read-model-test.…
Jun 1, 2018
84538c6
Repair new Error and run /integration tests
ggrg Jun 1, 2018
ab0fd63
Added more unhappy line integration tests
Jun 1, 2018
75c761c
Restore sidecar-enabled and keychain-admin_secret
ggrg Jun 1, 2018
71f233b
Ja and some more still
Jun 1, 2018
d2d6e9f
added final unhappy lines , code coverage 100% for read-model.test.js
Jun 1, 2018
dad408d
improvement of the coverage for ilp
nikolayanastasovsg Jun 1, 2018
f125b07
Integration tests for Fulfil Commit Success
ggrg Jun 1, 2018
1a1a661
Merge remote-tracking branch 'nikolay/develop-PI2' into feature/#248
vgenev Jun 1, 2018
fc1b67c
improvement of the coverage for transferState
nikolayanastasovsg Jun 1, 2018
5c25e16
Added unhappy line integration test (get All method) on participant/i…
Jun 1, 2018
6f7bcf3
Final chnages code coverage 100% on integration tests for participant…
Jun 1, 2018
56e8398
remove unnecessary ilp
vgenev Jun 1, 2018
2c2e54e
Merge remote-tracking branch 'deon/feature/248CodeCoverageTests' into…
vgenev Jun 1, 2018
bf26e38
Merge remote-tracking branch 'nikolay/develop-PI2' into feature/#248M…
vgenev Jun 1, 2018
6af0373
resolve conflicts
vgenev Jun 1, 2018
3d81801
ilp cleaned and tested
vgenev Jun 3, 2018
6d65863
all test coverage 100%
vgenev Jun 3, 2018
aa4f0e5
added license info
vgenev Jun 4, 2018
be493e3
removed some commented code and added license to the transfer-read-mo…
vgenev Jun 4, 2018
79ed62e
removed some commented code and added license to the transfer-read-mo…
vgenev Jun 4, 2018
83f667f
merged with develop-PI2
vgenev Jun 4, 2018
656f40a
removed commented out code and fixed some merge issues
vgenev Jun 5, 2018
8753963
Merge remote-tracking branch 'mojaloop/develop-PI2' into feature/#248…
vgenev Jun 5, 2018
eaa987e
merged
vgenev Jun 5, 2018
55c81f1
worked on Georgi remarks
vgenev Jun 5, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/domain/participant/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ module.exports = {
getAll,
getById,
getByName,
participantExists,
update
// verify,
// updatePartyCredentials,
Expand Down
69 changes: 0 additions & 69 deletions src/domain/transfer/models/ilp-model.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,16 +1,35 @@
/*****
License
--------------
Copyright © 2017 Bill & Melinda Gates Foundation
The Mojaloop files are made available by the Bill & Melinda Gates Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Contributors
--------------
This is the official list of the Mojaloop project contributors for this file.
Names of the original copyright holders (individuals or organizations)
should be listed with a '*' in the first column. People who have
contributed from an organization can be listed under the organization
that actually holds the copyright for their contributions (see the
Gates Foundation organization for an example). Those individuals should have
their names indented and be marked with a '-'. Email address can be added
optionally within square brackets <email>.
* Gates Foundation
- Name Surname <name.surname@gatesfoundation.com>
* Valentin Genev <valentin.genev@modusbox.com>
* Rajiv Mothilal <rajiv.mothilal@modusbox.com>
* Miguel de Barros <miguel.debarros@modusbox.com>
* Georgi Georgiev <georgi.georgiev@modusbox.com>e
--------------
******/

'use strict'

const Moment = require('moment')
const Db = require('../../../db')
const TransferState = require('../state')
const extensionModel = require('../../../models/extensions')
const Logger = require('@mojaloop/central-services-shared').Logger

const findExpired = (expiresAt) => {
const expirationDate = (expiresAt || Moment.utc()).toISOString()
return Db.transfer.find({ state: TransferState.PREPARED, 'expirationDate <': expirationDate })
}

const saveTransfer = async (record) => {
Logger.debug('save transfer' + record.toString())
try {
Expand Down Expand Up @@ -113,7 +132,6 @@ const getById = async (id) => {
}

module.exports = {
findExpired,
saveTransfer,
getAll,
updateTransfer,
Expand Down
11 changes: 5 additions & 6 deletions src/domain/transfer/models/transferStateChanges.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@

'use strict'

// const Moment = require('moment')
const Db = require('../../../db')
// const TransferState = require('../state')
const Logger = require('@mojaloop/central-services-shared').Logger

const saveTransferStateChange = async (stateChange) => {
Expand All @@ -41,11 +39,12 @@ const saveTransferStateChange = async (stateChange) => {

const getByTransferId = async (id) => {
try {
// let transferStateChanges = await Db.transferStateChange.find({ transferId: id }, { order: 'changedDate desc' })
// return transferStateChanges[0]
return await Db.transferStateChange.query(async (builder) => {
let result = builder.where({'transferStateChange.transferId': id}).select('transferStateChange.*').orderBy('transferStateChangeId', 'desc').first()
if (!result) throw new Error('no such transfer')
let result = builder
.where({'transferStateChange.transferId': id})
.select('transferStateChange.*')
.orderBy('changedDate', 'desc')
.first()
return result
})
} catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion src/domain/transfer/projection.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const _ = require('lodash')
const ParticipantService = require('../../domain/participant')
const TransferState = require('./state')
const TransfersModel = require('./models/transfers-read-model')
const TransfersModel = require('./models/transfer-read-model')
const ilpModel = require('../../models/ilp')
const extensionModel = require('../../models/extensions')
const transferStateChangeModel = require('./models/transferStateChanges')
Expand Down
2 changes: 1 addition & 1 deletion src/domain/transfer/queries.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const TransfersReadModel = require('./models/transfers-read-model')
const TransfersReadModel = require('./models/transfer-read-model')
// const TransferStateChange = require('./models/transferStateChanges')

const getAll = () => {
Expand Down
90 changes: 38 additions & 52 deletions src/models/ilp.js
Original file line number Diff line number Diff line change
@@ -1,71 +1,49 @@
/*****
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is the license agreement removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a totally non-intentional mistake. Or it wasn't there the file I started with. there were 2 ILP models, in the end we tested one of them and the handlers were using the other one. I will put it in right away.

License
--------------
Copyright © 2017 Bill & Melinda Gates Foundation
The Mojaloop files are made available by the Bill & Melinda Gates Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Contributors
--------------
This is the official list of the Mojaloop project contributors for this file.
Names of the original copyright holders (individuals or organizations)
should be listed with a '*' in the first column. People who have
contributed from an organization can be listed under the organization
that actually holds the copyright for their contributions (see the
Gates Foundation organization for an example). Those individuals should have
their names indented and be marked with a '-'. Email address can be added
optionally within square brackets <email>.
* Gates Foundation
- Name Surname <name.surname@gatesfoundation.com>
* Valentin Genev <valentin.genev@modusbox.com>
* Rajiv Mothilal <rajiv.mothilal@modusbox.com>
* Miguel de Barros <miguel.debarros@modusbox.com>
--------------
******/
/*
- License
- --------------
- Copyright © 2017 Bill & Melinda Gates Foundation
- The Mojaloop files are made available by the Bill & Melinda Gates Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
- Contributors
- --------------
- This is the official list of the Mojaloop project contributors for this file.
- Names of the original copyright holders (individuals or organizations)
- should be listed with a '*' in the first column. People who have
- contributed from an organization can be listed under the organization
- that actually holds the copyright for their contributions (see the
- Gates Foundation organization for an example). Those individuals should have
- their names indented and be marked with a '-'. Email address can be added
- optionally within square brackets <email>.
- * Gates Foundation
- - Name Surname <name.surname@gatesfoundation.com>
- * Valentin Genev <valentin.genev@modusbox.com>
- * Rajiv Mothilal <rajiv.mothilal@modusbox.com>
- * Miguel de Barros <miguel.debarros@modusbox.com>
- --------------
- ******/

'use strict'

const Db = require('../db/index')
// const Moment = require('moment')
const Db = require('../db')
const Util = require('../lib/util')
// const Time = require('../lib/time')

exports.saveIlp = async (ilp) => {
exports.saveIlp = async (transfer) => {
try {
return await Db.ilp.insert({
transferId: ilp.transferId,
packet: ilp.packet,
condition: ilp.condition,
fulfilment: ilp.fulfilment
transferId: transfer.transferId,
packet: transfer.packet,
condition: transfer.condition,
fulfilment: transfer.fulfilment
})
} catch (err) {
throw new Error(err.message)
}
}

// exports.getById = async (id) => {
// try {
// return await Db.ilp.findOne({ ilpId: id })
// } catch (err) {
// throw new Error(err.message)
// }
// }

exports.getByTransferId = async (transferId) => {
try {
return await Db.ilp.findOne({ transferId: transferId })
// .innerJoin('transfer', 'transfer.transferId', 'ilp.transferId')
// .where('expirationDate', '>', `${Time.getCurrentUTCTimeInMilliseconds()}`) // or maybe ${Moment.utc().toISOString()}
} catch (err) {
throw new Error(err.message)
}
}

exports.getByIlpId = async (ilpId) => {
try {
return await Db.ilp.findOne({ ilpId: ilpId })
// .innerJoin('transfer', 'transfer.transferId', 'ilp.transferId')
// .where('expirationDate', '>', `${Time.getCurrentUTCTimeInMilliseconds()}`) // or maybe ${Moment.utc().toISOString()}
} catch (err) {
throw new Error(err.message)
}
Expand All @@ -84,3 +62,11 @@ exports.update = async (ilp) => {
throw new Error(err.message)
}
}

exports.destroyByTransferId = async (ilp) => {
try {
return await Db.ilp.destroy({transferId: ilp.transferId})
} catch (err) {
throw new Error(err.message)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const Test = require('tape')
const Moment = require('moment')
const Db = require(`${src}/db`)
const Participant = require(`${src}/domain/participant`)
const ReadModel = require(`${src}/domain/transfer/models/transfers-read-model`)
const ReadModel = require(`${src}/domain/transfer/models/transfer-read-model`)
const Fixtures = require('../../../../fixtures')
const TransferState = require('../../../../../src/domain/transfer/state')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const Uuid = require('uuid4')
const ExecutedTransfersModel = require(`${src}/models/executed-transfers`)
const SettledTransfersModel = require(`${src}/models/settled-transfers`)
const Participant = require(`${src}/domain/participant`)
const TransfersReadModel = require(`${src}/domain/transfer/models/transfers-read-model`)
const TransfersReadModel = require(`${src}/domain/transfer/models/transfer-read-model`)
const ReadModel = require(`${src}/models/settleable-transfers-read-model`)
const Fixtures = require('../../fixtures')
const TransferState = require(`${src}/domain/transfer/state`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const Moment = require('moment')
const Uuid = require('uuid4')
const Db = require(`${src}/db`)
const UrlParser = require(`${src}/lib/urlparser`)
const TransfersReadModel = require(`${src}/domain/transfer/models/transfers-read-model`)
const TransfersReadModel = require(`${src}/domain/transfer/models/transfer-read-model`)
const TransferState = require(`${src}/domain/transfer/state`)

Test('transfer model', modelTest => {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/domain/transfer/projection.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const UrlParser = require('../../../../src/lib/urlparser')
const ParticipantService = require('../../../../src/domain/participant')
const TransferState = require('../../../../src/domain/transfer/state')
const TransferRejectionType = require('../../../../src/domain/transfer/rejection-type')
const TransfersReadModel = require('../../../../src/domain/transfer/models/transfers-read-model')
const TransfersReadModel = require('../../../../src/domain/transfer/models/transfer-read-model')
const TransfersProjection = require('../../../../src/domain/transfer/projection')

const hostname = 'http://some-host'
Expand Down
2 changes: 1 addition & 1 deletion test/unit/domain/transfer/queries.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const Test = require('tapes')(require('tape'))
const Sinon = require('sinon')
const P = require('bluebird')
const Uuid = require('uuid4')
const TransferReadModel = require('../../../../src/domain/transfer/models/transfers-read-model')
const TransferReadModel = require('../../../../src/domain/transfer/models/transfer-read-model')
const TransferQueries = require('../../../../src/domain/transfer/queries')

Test('Transfer Queries tests', queriesTest => {
Expand Down
9 changes: 2 additions & 7 deletions testPI2/integration/domain/transfer/ilp.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,14 @@
--------------
******/

/*
'use strict'

const Test = require('tape')
const Sinon = require('sinon')
const Db = require('../../../../src/db/index')
const Logger = require('@mojaloop/central-services-shared').Logger
const Config = require('../../../../src/lib/config')
// const Model = require('../../../../src/domain/transfer/models/ilp-model')
const Service = require('../../../../src/domain/transfer/ilp')
// const TransferModel = require('../../../../src/domain/transfer/index')
const Service = require('../../../../src/models/ilp')
const HelperModule = require('../../helpers/index')

Test('Ilp service tests', async (ilpTest) => {
Expand Down Expand Up @@ -101,7 +98,6 @@ Test('Ilp service tests', async (ilpTest) => {
assert.end()
}
})
// assert.end()
} catch (err) {
Logger.error(`create all ilp objects failed with error - ${err}`)
assert.fail(`Create all ilp objects failed - ${err}`)
Expand Down Expand Up @@ -187,7 +183,7 @@ Test('Ilp service tests', async (ilpTest) => {
await ilpTest.test('update', async (assert) => {
try {
for (let ilp of ilpMap.values()) {
let result = await Service.update(ilp.transferId, {packet: 'new test packet'})
let result = await Service.update({ ilpId: ilp.ilpId, packet: 'new test packet' })
let ilpDb = await Service.getByTransferId(ilp.transferId)
assert.equal(result, 1, ' ilp is updated')
assert.equal(ilp.ilpId, ilpDb.ilpId, ' ids match')
Expand Down Expand Up @@ -221,4 +217,3 @@ Test('Ilp service tests', async (ilpTest) => {
}
})
})
*/
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ Test('Extension model test', async (extensionTest) => {
assert.end()
}
})
// assert.end()
} catch (err) {
Logger.error(`create all extension objects failed with error - ${err}`)
assert.fail(`Create all extension objects failed - ${err}`)
Expand Down
Loading