Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kleyow committed May 31, 2024
1 parent e143de0 commit 09856d1
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/domain/participant/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const { destroyParticipantEndpointByParticipantId } = require('../../models/part

const create = async (payload) => {
try {
return ParticipantModel.create({ name: payload.name })
return ParticipantModel.create({ name: payload.name, isProxy: !!payload.isProxy })
} catch (err) {
throw ErrorHandler.Factory.reformatFSPIOPError(err)
}
Expand Down
4 changes: 1 addition & 3 deletions test/integration/domain/participant/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ const ParticipantService = require('../../../../src/domain/participant')
const ParticipantCached = require('../../../../src/models/participant/participantCached')
const ParticipantCurrencyCached = require('../../../../src/models/participant/participantCurrencyCached')
const ParticipantLimitCached = require('../../../../src/models/participant/participantLimitCached')
const ParticipantProxy = require('../../../../src/models/participant/participantProxy')
const ParticipantHelper = require('../../helpers/participant')
const ParticipantEndpointHelper = require('../../helpers/participantEndpoint')
const ParticipantLimitHelper = require('../../helpers/participantLimit')
Expand Down Expand Up @@ -418,8 +417,7 @@ Test('Participant service', async (participantTest) => {
await participantTest.test('create participant with proxy', async (assert) => {
try {
const getByNameResult = await ParticipantService.getByName(testData.proxyParticipant)
const result = await ParticipantHelper.prepareData(testData.proxyParticipant, testData.currency, undefined, !!getByNameResult)
await ParticipantProxy.create(result.participant.participantId, true)
const result = await ParticipantHelper.prepareData(testData.proxyParticipant, testData.currency, undefined, !!getByNameResult, true)
participantProxyFixtures.push(result.participant)

for (const participant of participantProxyFixtures) {
Expand Down
5 changes: 3 additions & 2 deletions test/integration/helpers/participant.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@ const testParticipant = {
createdDate: new Date()
}

exports.prepareData = async (name, currencyId = 'USD', secondaryCurrencyId = 'XXX', isUnique = true) => {
exports.prepareData = async (name, currencyId = 'USD', secondaryCurrencyId = 'XXX', isUnique = true, isProxy = false) => {
try {
const participantId = await Model.create(Object.assign(
{},
testParticipant,
{
name: (name || testParticipant.name) + (isUnique ? time.msToday().toString() : '')
name: (name || testParticipant.name) + (isUnique ? time.msToday().toString() : ''),
isProxy
}
))
const participantCurrencyId = await ParticipantCurrencyModel.create(participantId, currencyId, Enum.Accounts.LedgerAccountType.POSITION, false)
Expand Down
4 changes: 2 additions & 2 deletions test/unit/domain/participant/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ Test('Participant service', async (participantTest) => {
participantFixtures.forEach((participant, index) => {
participantMap.set(index + 1, participantResult[index])
Db.participant.insert.withArgs({ participant }).returns(index)
ParticipantModelCached.create.withArgs({ name: participant.name }).returns((index + 1))
ParticipantModelCached.create.withArgs({ name: participant.name, isProxy: !!participant.isProxy }).returns((index + 1))
ParticipantModelCached.getByName.withArgs(participant.name).returns(participantResult[index])
ParticipantModelCached.getById.withArgs(index).returns(participantResult[index])
ParticipantModelCached.update.withArgs(participant, 1).returns((index + 1))
Expand Down Expand Up @@ -254,7 +254,7 @@ Test('Participant service', async (participantTest) => {
})

await participantTest.test('create false participant', async (assert) => {
const falseParticipant = { name: 'fsp3' }
const falseParticipant = { name: 'fsp3', isProxy: false }
ParticipantModelCached.create.withArgs(falseParticipant).throws(new Error())
try {
await Service.create(falseParticipant)
Expand Down

0 comments on commit 09856d1

Please sign in to comment.