Finalize test migration: remove legacy dependencies and test helpers (#4797)

This commit is contained in:
Hadrien Croubois
2023-12-26 23:46:06 +01:00
committed by GitHub
parent abcf9dd8b7
commit a72c9561b9
96 changed files with 951 additions and 6503 deletions

View File

@ -48,7 +48,7 @@ describe('ERC20Wrapper', function () {
});
it('has underlying', async function () {
expect(await this.token.underlying()).to.be.equal(this.underlying.target);
expect(await this.token.underlying()).to.be.equal(this.underlying);
});
describe('deposit', function () {
@ -58,9 +58,9 @@ describe('ERC20Wrapper', function () {
const tx = await this.token.connect(this.initialHolder).depositFor(this.initialHolder, initialSupply);
await expect(tx)
.to.emit(this.underlying, 'Transfer')
.withArgs(this.initialHolder.address, this.token.target, initialSupply)
.withArgs(this.initialHolder, this.token, initialSupply)
.to.emit(this.token, 'Transfer')
.withArgs(ethers.ZeroAddress, this.initialHolder.address, initialSupply);
.withArgs(ethers.ZeroAddress, this.initialHolder, initialSupply);
await expect(tx).to.changeTokenBalances(
this.underlying,
[this.initialHolder, this.token],
@ -72,7 +72,7 @@ describe('ERC20Wrapper', function () {
it('reverts when missing approval', async function () {
await expect(this.token.connect(this.initialHolder).depositFor(this.initialHolder, initialSupply))
.to.be.revertedWithCustomError(this.underlying, 'ERC20InsufficientAllowance')
.withArgs(this.token.target, 0, initialSupply);
.withArgs(this.token, 0, initialSupply);
});
it('reverts when inssuficient balance', async function () {
@ -80,7 +80,7 @@ describe('ERC20Wrapper', function () {
await expect(this.token.connect(this.initialHolder).depositFor(this.initialHolder, ethers.MaxUint256))
.to.be.revertedWithCustomError(this.underlying, 'ERC20InsufficientBalance')
.withArgs(this.initialHolder.address, initialSupply, ethers.MaxUint256);
.withArgs(this.initialHolder, initialSupply, ethers.MaxUint256);
});
it('deposits to other account', async function () {
@ -89,9 +89,9 @@ describe('ERC20Wrapper', function () {
const tx = await this.token.connect(this.initialHolder).depositFor(this.recipient, initialSupply);
await expect(tx)
.to.emit(this.underlying, 'Transfer')
.withArgs(this.initialHolder.address, this.token.target, initialSupply)
.withArgs(this.initialHolder, this.token, initialSupply)
.to.emit(this.token, 'Transfer')
.withArgs(ethers.ZeroAddress, this.recipient.address, initialSupply);
.withArgs(ethers.ZeroAddress, this.recipient, initialSupply);
await expect(tx).to.changeTokenBalances(
this.underlying,
[this.initialHolder, this.token],
@ -105,7 +105,7 @@ describe('ERC20Wrapper', function () {
await expect(this.token.connect(this.initialHolder).depositFor(this.token, ethers.MaxUint256))
.to.be.revertedWithCustomError(this.token, 'ERC20InvalidReceiver')
.withArgs(this.token.target);
.withArgs(this.token);
});
});
@ -118,7 +118,7 @@ describe('ERC20Wrapper', function () {
it('reverts when inssuficient balance', async function () {
await expect(this.token.connect(this.initialHolder).withdrawTo(this.initialHolder, ethers.MaxInt256))
.to.be.revertedWithCustomError(this.token, 'ERC20InsufficientBalance')
.withArgs(this.initialHolder.address, initialSupply, ethers.MaxInt256);
.withArgs(this.initialHolder, initialSupply, ethers.MaxInt256);
});
it('executes when operation is valid', async function () {
@ -127,9 +127,9 @@ describe('ERC20Wrapper', function () {
const tx = await this.token.connect(this.initialHolder).withdrawTo(this.initialHolder, value);
await expect(tx)
.to.emit(this.underlying, 'Transfer')
.withArgs(this.token.target, this.initialHolder.address, value)
.withArgs(this.token, this.initialHolder, value)
.to.emit(this.token, 'Transfer')
.withArgs(this.initialHolder.address, ethers.ZeroAddress, value);
.withArgs(this.initialHolder, ethers.ZeroAddress, value);
await expect(tx).to.changeTokenBalances(this.underlying, [this.token, this.initialHolder], [-value, value]);
await expect(tx).to.changeTokenBalance(this.token, this.initialHolder, -value);
});
@ -138,9 +138,9 @@ describe('ERC20Wrapper', function () {
const tx = await this.token.connect(this.initialHolder).withdrawTo(this.initialHolder, initialSupply);
await expect(tx)
.to.emit(this.underlying, 'Transfer')
.withArgs(this.token.target, this.initialHolder.address, initialSupply)
.withArgs(this.token, this.initialHolder, initialSupply)
.to.emit(this.token, 'Transfer')
.withArgs(this.initialHolder.address, ethers.ZeroAddress, initialSupply);
.withArgs(this.initialHolder, ethers.ZeroAddress, initialSupply);
await expect(tx).to.changeTokenBalances(
this.underlying,
[this.token, this.initialHolder],
@ -153,9 +153,9 @@ describe('ERC20Wrapper', function () {
const tx = await this.token.connect(this.initialHolder).withdrawTo(this.recipient, initialSupply);
await expect(tx)
.to.emit(this.underlying, 'Transfer')
.withArgs(this.token.target, this.recipient.address, initialSupply)
.withArgs(this.token, this.recipient, initialSupply)
.to.emit(this.token, 'Transfer')
.withArgs(this.initialHolder.address, ethers.ZeroAddress, initialSupply);
.withArgs(this.initialHolder, ethers.ZeroAddress, initialSupply);
await expect(tx).to.changeTokenBalances(
this.underlying,
[this.token, this.initialHolder, this.recipient],
@ -167,7 +167,7 @@ describe('ERC20Wrapper', function () {
it('reverts withdrawing to the wrapper contract', async function () {
await expect(this.token.connect(this.initialHolder).withdrawTo(this.token, initialSupply))
.to.be.revertedWithCustomError(this.token, 'ERC20InvalidReceiver')
.withArgs(this.token.target);
.withArgs(this.token);
});
});
@ -177,7 +177,7 @@ describe('ERC20Wrapper', function () {
await this.token.connect(this.initialHolder).depositFor(this.initialHolder, initialSupply);
const tx = await this.token.$_recover(this.recipient);
await expect(tx).to.emit(this.token, 'Transfer').withArgs(ethers.ZeroAddress, this.recipient.address, 0n);
await expect(tx).to.emit(this.token, 'Transfer').withArgs(ethers.ZeroAddress, this.recipient, 0n);
await expect(tx).to.changeTokenBalance(this.token, this.recipient, 0);
});
@ -185,9 +185,7 @@ describe('ERC20Wrapper', function () {
await this.underlying.connect(this.initialHolder).transfer(this.token, initialSupply);
const tx = await this.token.$_recover(this.recipient);
await expect(tx)
.to.emit(this.token, 'Transfer')
.withArgs(ethers.ZeroAddress, this.recipient.address, initialSupply);
await expect(tx).to.emit(this.token, 'Transfer').withArgs(ethers.ZeroAddress, this.recipient, initialSupply);
await expect(tx).to.changeTokenBalance(this.token, this.recipient, initialSupply);
});
});