Skip to content
Permalink
Browse files

fix: add draws separately

  • Loading branch information...
satello committed Jun 22, 2018
1 parent 7db78c8 commit 9371397bfcabe5b6717e24bd1ddbfd58e8a2b9e1
@@ -37,22 +37,31 @@ class Arbitrator extends AbstractContract {
// update user profile for each dispute
await Promise.all(
myDisputes.map(async dispute => {
const disputeCreationLog = await this._contractImplementation.getDisputeCreationEvent(
dispute.disputeId
)
if (dispute.appealDraws[dispute.numberOfAppeals].length > 0) {
const disputeCreationLog = await this._contractImplementation.getDisputeCreationEvent(
dispute.disputeId
)

if (!disputeCreationLog)
throw new Error('Could not fetch dispute creation event log')
// update profile for account
await this._StoreProvider.updateDisputeProfile(
account,
dispute.arbitratorAddress,
dispute.disputeId,
{
appealDraws: dispute.appealDraws,
blockNumber: disputeCreationLog.blockNumber
}
)
if (!disputeCreationLog)
throw new Error('Could not fetch dispute creation event log')
// update profile for account
await this._StoreProvider.updateDisputeProfile(
account,
dispute.arbitratorAddress,
dispute.disputeId,
{
blockNumber: disputeCreationLog.blockNumber
}
)
// add draws separately for appeals
await this._StoreProvider.addNewDrawsDisputeProfile(
account,
dispute.arbitratorAddress,
dispute.disputeId,
dispute.appealDraws[dispute.numberOfAppeals],
dispute.numberOfAppeals
)
}
})
)

@@ -442,7 +442,11 @@ class KlerosPOC extends ContractImplementation {

const currentSession = await this.getSession()
const period = await this.getPeriod()
return validDraws && lastRuling !== currentSession && period < arbitratorConstants.PERIOD.APPEAL
return (
validDraws &&
lastRuling !== currentSession &&
period < arbitratorConstants.PERIOD.APPEAL
)
}

/**
@@ -118,10 +118,12 @@ describe('Arbitrator', () => {
const mockGetDisputesForJuror = jest.fn()
const mockUpdateDisputeProfile = jest.fn()
const mockUpdateSession = jest.fn()
const mockAddNewDrawsDisputeProfile = jest.fn()
const mockDispute = {
arbitratorAddress: arbitratorAddress,
disputeId: '1',
appealDraws: [1]
appealDraws: [[1]],
numberOfAppeals: 0
}
const mockStoreProvider = {
getDisputes: mockGetDisputesForUser.mockReturnValue(
@@ -133,7 +135,8 @@ describe('Arbitrator', () => {
})
),
updateDisputeProfile: mockUpdateDisputeProfile,
updateUserSession: mockUpdateSession
updateUserSession: mockUpdateSession,
addNewDrawsDisputeProfile: mockAddNewDrawsDisputeProfile
}

arbitratorInstance.setStoreProviderInstance(mockStoreProvider)
@@ -169,9 +172,9 @@ describe('Arbitrator', () => {
mockDispute.disputeId
)
expect(mockUpdateDisputeProfile.mock.calls[0][3]).toEqual({
appealDraws: mockDispute.appealDraws,
blockNumber: 1
})
expect(mockAddNewDrawsDisputeProfile.mock.calls.length).toBe(1)
expect(mockUpdateSession.mock.calls.length).toBe(1)
})
})

0 comments on commit 9371397

Please sign in to comment.
You can’t perform that action at this time.