Optimize votes lookups for recent checkpoints (#3673)
This commit is contained in:
@ -56,6 +56,19 @@ contract('ERC20Votes', function (accounts) {
|
||||
);
|
||||
});
|
||||
|
||||
it('recent checkpoints', async function () {
|
||||
await this.token.delegate(holder, { from: holder });
|
||||
for (let i = 0; i < 6; i++) {
|
||||
await this.token.mint(holder, 1);
|
||||
}
|
||||
const block = await web3.eth.getBlockNumber();
|
||||
expect(await this.token.numCheckpoints(holder)).to.be.bignumber.equal('6');
|
||||
// recent
|
||||
expect(await this.token.getPastVotes(holder, block - 1)).to.be.bignumber.equal('5');
|
||||
// non-recent
|
||||
expect(await this.token.getPastVotes(holder, block - 6)).to.be.bignumber.equal('0');
|
||||
});
|
||||
|
||||
describe('set delegation', function () {
|
||||
describe('call', function () {
|
||||
it('delegation with balance', async function () {
|
||||
|
||||
Reference in New Issue
Block a user