#59422 [SC-Low] periodattimestamp ignores the supplied timestamp
Previous#59445 [SC-Low] periodattimestamp does not work as expectedNext#59385 [SC-Low] timestamp ignored current block time used
Was this helpful?
Was this helpful?
Was this helpful?
const { loadFixture, time } = require('@nomicfoundation/hardhat-network-helpers')
const { expect } = require('chai')
const { deployVault } = require('./setup/fixtures')
describe('periodAtTimestamp behavior', function () {
before(async () => {
({ firelight_vault, period_configuration_updater, config } = await loadFixture(deployVault.bind(null, {})))
})
it('returns the current period even for historical timestamps', async () => {
const initialTimestamp = await time.latest()
const initialPeriod = await firelight_vault.currentPeriod()
expect(initialPeriod).to.equal(0n)
await time.increase(BigInt(config.period_configuration_duration) * 3n)
const currentPeriod = await firelight_vault.currentPeriod()
expect(currentPeriod).to.be.gt(initialPeriod)
const lookup = await firelight_vault.periodAtTimestamp(initialTimestamp)
expect(lookup).to.equal(currentPeriod)
expect(lookup).to.not.equal(initialPeriod)
})
it('reverts for timestamps scheduled in future period configurations', async () => {
const currentEnd = await firelight_vault.currentPeriodEnd()
const duration = config.period_configuration_duration
const newEpoch = Number(currentEnd) + Number(duration)
await firelight_vault.connect(period_configuration_updater).addPeriodConfiguration(newEpoch, duration)
await expect(firelight_vault.periodAtTimestamp(newEpoch)).to.be.reverted
})
})
npx hardhat test test/period_at_timestamp.js
periodAtTimestamp behavior
✔ returns the current period even for historical timestamps
✔ reverts for timestamps scheduled in future period configurations (280ms)
2 passing (5s)