Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: improve UX of findCheckpointHints #750

Prev Previous commit
Next Next commit
test: fix tests
  • Loading branch information
folkyatina committed Apr 12, 2023
commit 153869dfb7b460b863cc6f01e922d88c6da805ed
15 changes: 9 additions & 6 deletions test/0.8.9/withdrawal-queue.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,7 @@ contract('WithdrawalQueue', ([owner, stranger, daoAgent, user, pauser, resumer,
})

context('findCheckpointHints', () => {
const NOT_FOUND = 0
context('unit tests', () => {
let requestId
const amount = ETH(20)
Expand All @@ -865,11 +866,11 @@ contract('WithdrawalQueue', ([owner, stranger, daoAgent, user, pauser, resumer,
assert.equals(lastCheckpointIndex, 0)
const result = await withdrawalQueue.findCheckpointHints([requestId], 1, lastCheckpointIndex)
assert.isTrue(result.length === 1)
assert.equals(result[0], 0)
assert.equals(result[0], NOT_FOUND)

const claimableEthResult = await withdrawalQueue.getClaimableEther([requestId], result)
assert.isTrue(claimableEthResult.length === 1)
assert.equals(claimableEthResult[0], 0)
assert.equals(claimableEthResult[0], NOT_FOUND)
})

it('reverts if first index is zero', async () => {
Expand Down Expand Up @@ -904,7 +905,7 @@ contract('WithdrawalQueue', ([owner, stranger, daoAgent, user, pauser, resumer,
lastCheckpointIndex
)
assert.equal(hints.length, 1)
assert.equals(hints[0], 0)
assert.equals(hints[0], NOT_FOUND)
})

it('returns hints array with one item for list from single request id', async () => {
Expand Down Expand Up @@ -988,13 +989,15 @@ contract('WithdrawalQueue', ([owner, stranger, daoAgent, user, pauser, resumer,
assert.equals(await withdrawalQueue.getLastCheckpointIndex(), numOfRequests)
})

it('reverts if request is not finalized', async () => {
it('return NOT_FOUND if request is not finalized', async () => {
await withdrawalQueue.requestWithdrawals([ETH(1)], owner, { from: user })
await assert.reverts(withdrawalQueue.findCheckpointHints([11], 1, 10), 'RequestNotFoundOrNotFinalized(11)')
const hints = await withdrawalQueue.findCheckpointHints([11], 1, 10)
assert.equals(hints.length, 1)
assert.equals(hints[0], NOT_FOUND)
})

it('reverts if there is no such a request', async () => {
await assert.reverts(withdrawalQueue.findCheckpointHints([12], 1, 10), 'RequestNotFoundOrNotFinalized(12)')
await assert.reverts(withdrawalQueue.findCheckpointHints([12], 1, 10), 'InvalidRequestId(12)')
})

it('range search (found)', async () => {
Expand Down