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

@ -2,34 +2,28 @@ const { time } = require('@nomicfoundation/hardhat-network-helpers');
const { expectEvent } = require('@openzeppelin/test-helpers');
const { expect } = require('chai');
function releasedEvent (token, amount) {
return token
? [ 'ERC20Released', { token: token.address, amount } ]
: [ 'EtherReleased', { amount } ];
function releasedEvent(token, amount) {
return token ? ['ERC20Released', { token: token.address, amount }] : ['EtherReleased', { amount }];
}
function shouldBehaveLikeVesting (beneficiary) {
function shouldBehaveLikeVesting(beneficiary) {
it('check vesting schedule', async function () {
const [ vestedAmount, releasable, ...args ] = this.token
? [ 'vestedAmount(address,uint64)', 'releasable(address)', this.token.address ]
: [ 'vestedAmount(uint64)', 'releasable()' ];
const [vestedAmount, releasable, ...args] = this.token
? ['vestedAmount(address,uint64)', 'releasable(address)', this.token.address]
: ['vestedAmount(uint64)', 'releasable()'];
for (const timestamp of this.schedule) {
await time.increaseTo(timestamp);
const vesting = this.vestingFn(timestamp);
expect(await this.mock.methods[vestedAmount](...args, timestamp))
.to.be.bignumber.equal(vesting);
expect(await this.mock.methods[vestedAmount](...args, timestamp)).to.be.bignumber.equal(vesting);
expect(await this.mock.methods[releasable](...args))
.to.be.bignumber.equal(vesting);
expect(await this.mock.methods[releasable](...args)).to.be.bignumber.equal(vesting);
}
});
it('execute vesting schedule', async function () {
const [ release, ...args ] = this.token
? [ 'release(address)', this.token.address ]
: [ 'release()' ];
const [release, ...args] = this.token ? ['release(address)', this.token.address] : ['release()'];
let released = web3.utils.toBN(0);
const before = await this.getBalance(beneficiary);
@ -37,11 +31,7 @@ function shouldBehaveLikeVesting (beneficiary) {
{
const receipt = await this.mock.methods[release](...args);
await expectEvent.inTransaction(
receipt.tx,
this.mock,
...releasedEvent(this.token, '0'),
);
await expectEvent.inTransaction(receipt.tx, this.mock, ...releasedEvent(this.token, '0'));
await this.checkRelease(receipt, beneficiary, '0');
@ -53,16 +43,11 @@ function shouldBehaveLikeVesting (beneficiary) {
const vested = this.vestingFn(timestamp);
const receipt = await this.mock.methods[release](...args);
await expectEvent.inTransaction(
receipt.tx,
this.mock,
...releasedEvent(this.token, vested.sub(released)),
);
await expectEvent.inTransaction(receipt.tx, this.mock, ...releasedEvent(this.token, vested.sub(released)));
await this.checkRelease(receipt, beneficiary, vested.sub(released));
expect(await this.getBalance(beneficiary))
.to.be.bignumber.equal(before.add(vested));
expect(await this.getBalance(beneficiary)).to.be.bignumber.equal(before.add(vested));
released = vested;
}