Skip to content

Commit

Permalink
test: AccountingOracle.submitReportData exited validarors count bound…
Browse files Browse the repository at this point in the history
…aries scenarios
  • Loading branch information
manneredboor committed Feb 13, 2023
1 parent bde7cd3 commit 12baa27
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions test/0.8.9/oracle/accounting-oracle-submit-report-data.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,47 @@ contract('AccountingOracle', ([admin, account1, account2, member1, member2, stra
'InvalidExitedValidatorsData()'
)
})

it('reverts with NumExitedValidatorsCannotDecrease if total count of exited validators less then previous exited number', async () => {
const totalExitedValidators = reportFields.numExitedValidatorsByStakingModule.reduce(
(sum, curr) => sum + curr,
0
)
await mockStakingRouter.setExitedKeysCountAcrossAllModules(totalExitedValidators + 1)
await assert.reverts(
oracle.submitReportData(reportItems, oracleVersion, { from: member1 }),
'NumExitedValidatorsCannotDecrease()'
)
})

it('does not reverts with NumExitedValidatorsCannotDecrease if total count of exited validators equals to previous exited number', async () => {
const totalExitedValidators = reportFields.numExitedValidatorsByStakingModule.reduce(
(sum, curr) => sum + curr,
0
)
await mockStakingRouter.setExitedKeysCountAcrossAllModules(totalExitedValidators)
await oracle.submitReportData(reportItems, oracleVersion, { from: member1 })
})

it('reverts with ExitedValidatorsLimitExceeded if exited validators rate limit will be reached', async () => {
// Really simple test here for now
// TODO: Come up with more tests for better coverage of edge-case scenarios that can be accrued
// during calculation `exitedValidatorsPerDay` rate in AccountingOracle:612
const totalExitedValidators = reportFields.numExitedValidatorsByStakingModule.reduce(
(sum, curr) => sum + curr,
0
)
const exitingRateLimit = totalExitedValidators - 1
await oracleReportSanityChecker.setChurnValidatorsPerDayLimit(exitingRateLimit)
assert.equals(
(await oracleReportSanityChecker.getOracleReportLimits()).churnValidatorsPerDayLimit,
exitingRateLimit
)
await assert.reverts(
oracle.submitReportData(reportItems, oracleVersion, { from: member1 }),
`ExitedValidatorsLimitExceeded(${exitingRateLimit}, ${totalExitedValidators})`
)
})
})

context('delivers the data to corresponded contracts', () => {
Expand Down

0 comments on commit 12baa27

Please sign in to comment.