Make ERC20Votes independent from ERC20Permit (#3816)

Co-authored-by: Francisco <frangio.1@gmail.com>
This commit is contained in:
JulissaDantes
2022-11-29 10:25:52 -04:00
committed by GitHub
parent bc8f442d00
commit e2d2ebc8fc
18 changed files with 231 additions and 343 deletions

View File

@ -7,6 +7,7 @@ const ethSigUtil = require('eth-sig-util');
const Wallet = require('ethereumjs-wallet').default;
const { EIP712Domain, domainSeparator } = require('../../helpers/eip712');
const { web3 } = require('hardhat');
const Delegation = [
{ name: 'delegatee', type: 'address' },
@ -45,7 +46,7 @@ function shouldBehaveLikeVotes () {
});
beforeEach(async function () {
await this.votes.mint(delegatorAddress, this.NFT0);
await this.votes.mint(delegatorAddress, this.token0);
});
it('accept signed delegation', async function () {
@ -151,7 +152,7 @@ function shouldBehaveLikeVotes () {
describe('set delegation', function () {
describe('call', function () {
it('delegation with tokens', async function () {
await this.votes.mint(this.account1, this.NFT0);
await this.votes.mint(this.account1, this.token0);
expect(await this.votes.delegates(this.account1)).to.be.equal(ZERO_ADDRESS);
const { receipt } = await this.votes.delegate(this.account1, { from: this.account1 });
@ -192,7 +193,7 @@ function shouldBehaveLikeVotes () {
describe('change delegation', function () {
beforeEach(async function () {
await this.votes.mint(this.account1, this.NFT0);
await this.votes.mint(this.account1, this.token0);
await this.votes.delegate(this.account1, { from: this.account1 });
});
@ -245,7 +246,7 @@ function shouldBehaveLikeVotes () {
});
it('returns the latest block if >= last checkpoint block', async function () {
const t1 = await this.votes.mint(this.account1, this.NFT0);
const t1 = await this.votes.mint(this.account1, this.token0);
await time.advanceBlock();
await time.advanceBlock();
@ -255,7 +256,7 @@ function shouldBehaveLikeVotes () {
it('returns zero if < first checkpoint block', async function () {
await time.advanceBlock();
const t2 = await this.votes.mint(this.account1, this.NFT1);
const t2 = await this.votes.mint(this.account1, this.token1);
await time.advanceBlock();
await time.advanceBlock();
@ -264,19 +265,19 @@ function shouldBehaveLikeVotes () {
});
it('generally returns the voting balance at the appropriate checkpoint', async function () {
const t1 = await this.votes.mint(this.account1, this.NFT1);
const t1 = await this.votes.mint(this.account1, this.token1);
await time.advanceBlock();
await time.advanceBlock();
const t2 = await this.votes.burn(this.NFT1);
const t2 = await this.votes.burn(this.account1, this.token1);
await time.advanceBlock();
await time.advanceBlock();
const t3 = await this.votes.mint(this.account1, this.NFT2);
const t3 = await this.votes.mint(this.account1, this.token2);
await time.advanceBlock();
await time.advanceBlock();
const t4 = await this.votes.burn(this.NFT2);
const t4 = await this.votes.burn(this.account1, this.token2);
await time.advanceBlock();
await time.advanceBlock();
const t5 = await this.votes.mint(this.account1, this.NFT3);
const t5 = await this.votes.mint(this.account1, this.token3);
await time.advanceBlock();
await time.advanceBlock();
@ -298,10 +299,10 @@ function shouldBehaveLikeVotes () {
// https://github.com/compound-finance/compound-protocol/blob/master/tests/Governance/CompTest.js.
describe('Compound test suite', function () {
beforeEach(async function () {
await this.votes.mint(this.account1, this.NFT0);
await this.votes.mint(this.account1, this.NFT1);
await this.votes.mint(this.account1, this.NFT2);
await this.votes.mint(this.account1, this.NFT3);
await this.votes.mint(this.account1, this.token0);
await this.votes.mint(this.account1, this.token1);
await this.votes.mint(this.account1, this.token2);
await this.votes.mint(this.account1, this.token3);
});
describe('getPastVotes', function () {