-
Notifications
You must be signed in to change notification settings - Fork 465
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me, just a minor nit and q
// (i) Set `epochDurationInSeconds` to a constant value of 1, and | ||
// (ii) Rearrange the eqn above to get: | ||
// `currentEpochStartTimeInSeconds = epochEndTimeDelta + block.timestamp - epochDurationInSeconds` | ||
epochDurationInSeconds = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we set this to 1? can we use a more realistic value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The value just needs to be non-zero. Allows us to verify that the endTime
is accounting for both currentEpochStartTimeInSeconds
and epochDurationInSeconds
.
// Mine the block that this tx would've been in. | ||
await env.web3Wrapper.mineBlockAsync(); | ||
const blockNumber = await env.web3Wrapper.getBlockNumberAsync(); | ||
const blockTimestampAsNumber = await env.web3Wrapper.getBlockTimestampAsync(blockNumber); | ||
const blockTimestamp = new BigNumber(blockTimestampAsNumber); | ||
const epochEndTime = blockTimestamp.plus(epochEndTimeDelta); | ||
return expect(tx).to.revertWith( | ||
new StakingRevertErrors.BlockTimestampTooLowError(epochEndTime, blockTimestamp), | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
expect(currentEpoch).to.bignumber.equal(testLog.oldEpoch.plus(1)); | ||
expect(currentEpochStartTimeInSeconds).to.bignumber.equal(testLog.blockTimestamp); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optional nit: use verifyEventsFromLogs
for these events
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice coverage! Just a few cleanup related nits, and then this looks g2g.
} catch (e) {} | ||
|
||
// Mine the block that this tx would've been in. | ||
await env.web3Wrapper.mineBlockAsync(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a pretty cool pattern. Might make sense to make a function and put in test-utils, but optional for this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙏 - although it's such an edge case idk if it would be worth abstracting as-is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough lol
expect(currentEpochStartTimeInSeconds).to.bignumber.equal(testLog.blockTimestamp); | ||
}); | ||
|
||
it('Should succeed if epoch end time is equal to block timestamp', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rigor lvl 💯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved (modulo "static-tests")
87b8cc8
to
9b2231e
Compare
Description
This PR includes unit tests for
MixinScheduler
in the Staking Contracts.Testing instructions
Types of changes
Checklist:
[WIP]
if necessary.