Use Prettier for JS files (#3913)

Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
This commit is contained in:
Francisco
2023-01-04 11:03:40 -03:00
committed by GitHub
parent 88754d0b36
commit a28aafdc85
135 changed files with 2737 additions and 3121 deletions

View File

@ -16,16 +16,14 @@ const Delegation = [
const version = '1';
function shouldBehaveLikeVotes () {
function shouldBehaveLikeVotes() {
describe('run votes workflow', function () {
it('initial nonce is 0', async function () {
expect(await this.votes.nonces(this.account1)).to.be.bignumber.equal('0');
});
it('domain separator', async function () {
expect(
await this.votes.DOMAIN_SEPARATOR(),
).to.equal(
expect(await this.votes.DOMAIN_SEPARATOR()).to.equal(
await domainSeparator({
name: this.name,
version,
@ -54,14 +52,16 @@ function shouldBehaveLikeVotes () {
});
it('accept signed delegation', async function () {
const { v, r, s } = fromRpcSig(ethSigUtil.signTypedMessage(
delegator.getPrivateKey(),
buildData(this.chainId, this.votes.address, this.name, {
delegatee: delegatorAddress,
nonce,
expiry: MAX_UINT256,
}),
));
const { v, r, s } = fromRpcSig(
ethSigUtil.signTypedMessage(
delegator.getPrivateKey(),
buildData(this.chainId, this.votes.address, this.name, {
delegatee: delegatorAddress,
nonce,
expiry: MAX_UINT256,
}),
),
);
expect(await this.votes.delegates(delegatorAddress)).to.be.equal(ZERO_ADDRESS);
@ -86,14 +86,16 @@ function shouldBehaveLikeVotes () {
});
it('rejects reused signature', async function () {
const { v, r, s } = fromRpcSig(ethSigUtil.signTypedMessage(
delegator.getPrivateKey(),
buildData(this.chainId, this.votes.address, this.name, {
delegatee: delegatorAddress,
nonce,
expiry: MAX_UINT256,
}),
));
const { v, r, s } = fromRpcSig(
ethSigUtil.signTypedMessage(
delegator.getPrivateKey(),
buildData(this.chainId, this.votes.address, this.name, {
delegatee: delegatorAddress,
nonce,
expiry: MAX_UINT256,
}),
),
);
await this.votes.delegateBySig(delegatorAddress, nonce, MAX_UINT256, v, r, s);
@ -104,14 +106,16 @@ function shouldBehaveLikeVotes () {
});
it('rejects bad delegatee', async function () {
const { v, r, s } = fromRpcSig(ethSigUtil.signTypedMessage(
delegator.getPrivateKey(),
buildData(this.chainId, this.votes.address, this.name, {
delegatee: delegatorAddress,
nonce,
expiry: MAX_UINT256,
}),
));
const { v, r, s } = fromRpcSig(
ethSigUtil.signTypedMessage(
delegator.getPrivateKey(),
buildData(this.chainId, this.votes.address, this.name, {
delegatee: delegatorAddress,
nonce,
expiry: MAX_UINT256,
}),
),
);
const receipt = await this.votes.delegateBySig(this.account1Delegatee, nonce, MAX_UINT256, v, r, s);
const { args } = receipt.logs.find(({ event }) => event === 'DelegateChanged');
@ -121,14 +125,16 @@ function shouldBehaveLikeVotes () {
});
it('rejects bad nonce', async function () {
const { v, r, s } = fromRpcSig(ethSigUtil.signTypedMessage(
delegator.getPrivateKey(),
buildData(this.chainId, this.votes.address, this.name, {
delegatee: delegatorAddress,
nonce,
expiry: MAX_UINT256,
}),
));
const { v, r, s } = fromRpcSig(
ethSigUtil.signTypedMessage(
delegator.getPrivateKey(),
buildData(this.chainId, this.votes.address, this.name, {
delegatee: delegatorAddress,
nonce,
expiry: MAX_UINT256,
}),
),
);
await expectRevert(
this.votes.delegateBySig(delegatorAddress, nonce + 1, MAX_UINT256, v, r, s),
'Votes: invalid nonce',
@ -137,14 +143,16 @@ function shouldBehaveLikeVotes () {
it('rejects expired permit', async function () {
const expiry = (await time.latest()) - time.duration.weeks(1);
const { v, r, s } = fromRpcSig(ethSigUtil.signTypedMessage(
delegator.getPrivateKey(),
buildData(this.chainId, this.votes.address, this.name, {
delegatee: delegatorAddress,
nonce,
expiry,
}),
));
const { v, r, s } = fromRpcSig(
ethSigUtil.signTypedMessage(
delegator.getPrivateKey(),
buildData(this.chainId, this.votes.address, this.name, {
delegatee: delegatorAddress,
nonce,
expiry,
}),
),
);
await expectRevert(
this.votes.delegateBySig(delegatorAddress, nonce, expiry, v, r, s),
@ -239,10 +247,7 @@ function shouldBehaveLikeVotes () {
});
it('reverts if block number >= current block', async function () {
await expectRevert(
this.votes.getPastTotalSupply(5e10),
'block not yet mined',
);
await expectRevert(this.votes.getPastTotalSupply(5e10), 'block not yet mined');
});
it('returns 0 if there are no checkpoints', async function () {
@ -311,10 +316,7 @@ function shouldBehaveLikeVotes () {
describe('getPastVotes', function () {
it('reverts if block number >= current block', async function () {
await expectRevert(
this.votes.getPastVotes(this.account2, 5e10),
'block not yet mined',
);
await expectRevert(this.votes.getPastVotes(this.account2, 5e10), 'block not yet mined');
});
it('returns 0 if there are no checkpoints', async function () {