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

@ -2,15 +2,16 @@
const { BN, constants, expectEvent, expectRevert, time } = require('@openzeppelin/test-helpers');
const { expect } = require('chai');
const { MAX_UINT256, ZERO_ADDRESS, ZERO_BYTES32 } = constants;
const { MAX_UINT256, ZERO_ADDRESS } = constants;
const { batchInBlock } = require('../../../helpers/txpool');
const { shouldBehaveLikeVotes } = require('../../../governance/utils/Votes.behavior');
const { fromRpcSig } = require('ethereumjs-util');
const ethSigUtil = require('eth-sig-util');
const Wallet = require('ethereumjs-wallet').default;
const ERC20VotesCompMock = artifacts.require('ERC20VotesCompMock');
const { batchInBlock } = require('../../../helpers/txpool');
const { EIP712Domain, domainSeparator } = require('../../../helpers/eip712');
const Delegation = [
@ -52,7 +53,7 @@ contract('ERC20VotesComp', function (accounts) {
const amount = new BN('2').pow(new BN('96'));
await expectRevert(
this.token.mint(holder, amount),
'ERC20Votes: total supply risks overflowing votes',
"ERC20Votes: total supply risks overflowing votes",
);
});
@ -159,7 +160,7 @@ contract('ERC20VotesComp', function (accounts) {
await expectRevert(
this.token.delegateBySig(delegatorAddress, nonce, MAX_UINT256, v, r, s),
'ERC20Votes: invalid nonce',
'Votes: invalid nonce',
);
});
@ -191,7 +192,7 @@ contract('ERC20VotesComp', function (accounts) {
));
await expectRevert(
this.token.delegateBySig(delegatorAddress, nonce + 1, MAX_UINT256, v, r, s),
'ERC20Votes: invalid nonce',
'Votes: invalid nonce',
);
});
@ -208,7 +209,7 @@ contract('ERC20VotesComp', function (accounts) {
await expectRevert(
this.token.delegateBySig(delegatorAddress, nonce, expiry, v, r, s),
'ERC20Votes: signature expired',
'Votes: signature expired',
);
});
});
@ -373,12 +374,12 @@ contract('ERC20VotesComp', function (accounts) {
expect(await this.token.checkpoints(other1, 1)).to.be.deep.equal([ t4.receipt.blockNumber.toString(), '100' ]);
});
});
describe('getPriorVotes', function () {
it('reverts if block number >= current block', async function () {
await expectRevert(
this.token.getPriorVotes(other1, 5e10),
'ERC20Votes: block not yet mined',
'Checkpoints: block not yet mined',
);
});
@ -440,7 +441,7 @@ contract('ERC20VotesComp', function (accounts) {
it('reverts if block number >= current block', async function () {
await expectRevert(
this.token.getPastTotalSupply(5e10),
'ERC20Votes: block not yet mined',
'Votes: block not yet mined',
);
});
@ -493,4 +494,20 @@ contract('ERC20VotesComp', function (accounts) {
expect(await this.token.getPastTotalSupply(t4.receipt.blockNumber + 1)).to.be.bignumber.equal('10000000000000000000000000');
});
});
describe('Voting workflow', function () {
beforeEach(async function () {
this.account1 = holder;
this.account1Delegatee = holderDelegatee;
this.account2 = recipient;
this.name = 'My Token';
this.votes = this.token
this.token0 = 1;
this.token1 = 1;
this.token2 = 1;
this.token3 = 1;
});
shouldBehaveLikeVotes();
});
});