Skip to content

Commit

Permalink
chore: fix adjudicatorsNullifier len
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanycw committed Aug 30, 2024
1 parent 6cb75f3 commit cf87209
Showing 1 changed file with 51 additions and 46 deletions.
97 changes: 51 additions & 46 deletions packages/relay/test/report.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,20 +472,21 @@ describe('POST /api/report', function () {

it('should fetch report whose adjudication result is tie', async function () {
// update mock value into report
const adjudicatorsNullifier = [
{ adjudicateValue: AdjudicateValue.AGREE },
{ adjudicateValue: AdjudicateValue.AGREE },
{ adjudicateValue: AdjudicateValue.AGREE },
{ adjudicateValue: AdjudicateValue.DISAGREE },
{ adjudicateValue: AdjudicateValue.DISAGREE },
{ adjudicateValue: AdjudicateValue.DISAGREE },
]
await db.update('ReportHistory', {
where: {
AND: [{ objectId: '0' }, { type: ReportType.POST }],
},
update: {
adjudicatorsNullifier: [
{ adjudicateValue: 1 },
{ adjudicateValue: 1 },
{ adjudicateValue: 1 },
{ adjudicateValue: 0 },
{ adjudicateValue: 0 },
{ adjudicateValue: 0 },
],
adjudicateCount: 6,
adjudicatorsNullifier,
adjudicateCount: adjudicatorsNullifier.length,
},
})

Expand Down Expand Up @@ -538,21 +539,22 @@ describe('POST /api/report', function () {

it('should fetch report whose status is waiting for transaction', async function () {
// insert mock value into report
const adjudicatorsNullifier = [
{ adjudicateValue: AdjudicateValue.AGREE },
{ adjudicateValue: AdjudicateValue.AGREE },
{ adjudicateValue: AdjudicateValue.AGREE },
{ adjudicateValue: AdjudicateValue.AGREE },
{ adjudicateValue: AdjudicateValue.DISAGREE },
{ adjudicateValue: AdjudicateValue.DISAGREE },
{ adjudicateValue: AdjudicateValue.DISAGREE },
]
await db.update('ReportHistory', {
where: {
AND: [{ objectId: '0' }, { type: ReportType.POST }],
},
update: {
adjudicatorsNullifier: [
{ adjudicateValue: 1 },
{ adjudicateValue: 1 },
{ adjudicateValue: 1 },
{ adjudicateValue: 1 },
{ adjudicateValue: 0 },
{ adjudicateValue: 0 },
{ adjudicateValue: 0 },
],
adjudicateCount: 7,
adjudicatorsNullifier,
adjudicateCount: adjudicatorsNullifier.length,
status: ReportStatus.WAITING_FOR_TRANSACTION,
},
})
Expand Down Expand Up @@ -930,24 +932,25 @@ describe('POST /api/report', function () {

it('should settle report and update object status', async function () {
// insert mock value into report
const adjudicatorsNullifier = [
{ adjudicateValue: AdjudicateValue.AGREE },
{ adjudicateValue: AdjudicateValue.AGREE },
{ adjudicateValue: AdjudicateValue.AGREE },
{ adjudicateValue: AdjudicateValue.AGREE },
{ adjudicateValue: AdjudicateValue.AGREE },
{ adjudicateValue: AdjudicateValue.DISAGREE },
{ adjudicateValue: AdjudicateValue.DISAGREE },
{ adjudicateValue: AdjudicateValue.DISAGREE },
{ adjudicateValue: AdjudicateValue.DISAGREE },
]
const prevEpoch = await sync.loadCurrentEpoch()
await db.update('ReportHistory', {
where: {
AND: [{ objectId: '0' }, { type: ReportType.POST }],
},
update: {
adjudicatorsNullifier: [
{ adjudicateValue: AdjudicateValue.AGREE },
{ adjudicateValue: AdjudicateValue.AGREE },
{ adjudicateValue: AdjudicateValue.AGREE },
{ adjudicateValue: AdjudicateValue.AGREE },
{ adjudicateValue: AdjudicateValue.AGREE },
{ adjudicateValue: AdjudicateValue.DISAGREE },
{ adjudicateValue: AdjudicateValue.DISAGREE },
{ adjudicateValue: AdjudicateValue.DISAGREE },
{ adjudicateValue: AdjudicateValue.DISAGREE },
],
adjudicateCount: 7,
adjudicatorsNullifier,
adjudicateCount: adjudicatorsNullifier.length,
status: ReportStatus.VOTING,
reportEpoch: prevEpoch,
},
Expand Down Expand Up @@ -983,18 +986,19 @@ describe('POST /api/report', function () {

it('should not settle report if the vote count is less than five', async function () {
// insert mock value into report
const adjudicatorsNullifier = [
{ adjudicateValue: AdjudicateValue.AGREE },
{ adjudicateValue: AdjudicateValue.DISAGREE },
{ adjudicateValue: AdjudicateValue.DISAGREE },
]
const prevEpoch = await sync.loadCurrentEpoch()
await db.update('ReportHistory', {
where: {
AND: [{ objectId: '0' }, { type: ReportType.POST }],
},
update: {
adjudicatorsNullifier: [
{ adjudicateValue: AdjudicateValue.AGREE },
{ adjudicateValue: AdjudicateValue.DISAGREE },
{ adjudicateValue: AdjudicateValue.DISAGREE },
],
adjudicateCount: 3,
adjudicatorsNullifier,
adjudicateCount: adjudicatorsNullifier.length,
status: ReportStatus.VOTING,
reportEpoch: prevEpoch,
},
Expand Down Expand Up @@ -1035,21 +1039,22 @@ describe('POST /api/report', function () {

it('should not settle report if the vote is tie', async function () {
// insert mock value into report
const adjudicatorsNullifier = [
{ adjudicateValue: AdjudicateValue.AGREE },
{ adjudicateValue: AdjudicateValue.AGREE },
{ adjudicateValue: AdjudicateValue.AGREE },
{ adjudicateValue: AdjudicateValue.DISAGREE },
{ adjudicateValue: AdjudicateValue.DISAGREE },
{ adjudicateValue: AdjudicateValue.DISAGREE },
]
const prevEpoch = await sync.loadCurrentEpoch()
await db.update('ReportHistory', {
where: {
AND: [{ objectId: '0' }, { type: ReportType.POST }],
},
update: {
adjudicatorsNullifier: [
{ adjudicateValue: AdjudicateValue.AGREE },
{ adjudicateValue: AdjudicateValue.AGREE },
{ adjudicateValue: AdjudicateValue.AGREE },
{ adjudicateValue: AdjudicateValue.DISAGREE },
{ adjudicateValue: AdjudicateValue.DISAGREE },
{ adjudicateValue: AdjudicateValue.DISAGREE },
],
adjudicateCount: 6,
adjudicatorsNullifier,
adjudicateCount: adjudicatorsNullifier.length,
status: ReportStatus.VOTING,
reportEpoch: prevEpoch,
},
Expand Down

0 comments on commit cf87209

Please sign in to comment.