ERC6372.behavior.js 1.0 KB

12345678910111213141516171819202122232425262728
  1. const { expect } = require('chai');
  2. const time = require('../../helpers/time');
  3. function shouldBehaveLikeERC6372(mode = 'blocknumber') {
  4. describe(`ERC-6372 behavior in ${mode} mode`, function () {
  5. beforeEach(async function () {
  6. this.mock = this.mock ?? this.token ?? this.votes;
  7. });
  8. it('should have a correct clock value', async function () {
  9. const currentClock = await this.mock.clock();
  10. const expectedClock = await time.clock[mode]();
  11. expect(currentClock).to.equal(expectedClock, `Clock mismatch in ${mode} mode`);
  12. });
  13. it('should have the correct CLOCK_MODE parameters', async function () {
  14. const clockModeParams = new URLSearchParams(await this.mock.CLOCK_MODE());
  15. const expectedFromValue = mode === 'blocknumber' ? 'default' : null;
  16. expect(clockModeParams.get('mode')).to.equal(mode, `Expected mode to be ${mode}`);
  17. expect(clockModeParams.get('from')).to.equal(expectedFromValue, `Expected 'from' to be ${expectedFromValue}`);
  18. });
  19. });
  20. }
  21. module.exports = {
  22. shouldBehaveLikeERC6372,
  23. };