diff --git a/src/domain/participant/index.js b/src/domain/participant/index.js index bbeb0cd39..394508c63 100644 --- a/src/domain/participant/index.js +++ b/src/domain/participant/index.js @@ -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) } diff --git a/test/integration/domain/participant/index.test.js b/test/integration/domain/participant/index.test.js index bf957c748..e74e3c938 100644 --- a/test/integration/domain/participant/index.test.js +++ b/test/integration/domain/participant/index.test.js @@ -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') @@ -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) { diff --git a/test/integration/helpers/participant.js b/test/integration/helpers/participant.js index 004985684..9ba247e5d 100644 --- a/test/integration/helpers/participant.js +++ b/test/integration/helpers/participant.js @@ -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) diff --git a/test/unit/domain/participant/index.test.js b/test/unit/domain/participant/index.test.js index 66be4818a..003590965 100644 --- a/test/unit/domain/participant/index.test.js +++ b/test/unit/domain/participant/index.test.js @@ -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)) @@ -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)