mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Added fallback/receive test
This commit is contained in:
parent
ad5fa1b9a0
commit
4893548d36
|
@ -183,11 +183,12 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
|
||||||
expect(debtBalanceAfterFullRepay).to.be.eq(zero);
|
expect(debtBalanceAfterFullRepay).to.be.eq(zero);
|
||||||
});
|
});
|
||||||
|
|
||||||
xit('Should revert if receive function receives Ether', async () => {
|
it('Should revert if receive or fallback functions receives Ether', async () => {
|
||||||
const {users, wethGateway} = testEnv;
|
const {users, wethGateway} = testEnv;
|
||||||
const user = users[0];
|
const user = users[0];
|
||||||
const amount = parseEther('1');
|
const amount = parseEther('1');
|
||||||
|
|
||||||
|
// Call receiver function (empty data + value)
|
||||||
await expect(
|
await expect(
|
||||||
user.signer.sendTransaction({to: wethGateway.address, value: amount})
|
user.signer.sendTransaction({to: wethGateway.address, value: amount})
|
||||||
).to.be.revertedWith('Receive not allowed');
|
).to.be.revertedWith('Receive not allowed');
|
||||||
|
@ -196,9 +197,12 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
|
||||||
const abiCoder = new BRE.ethers.utils.Interface(fakeABI);
|
const abiCoder = new BRE.ethers.utils.Interface(fakeABI);
|
||||||
const fakeMethodEncoded = abiCoder.encodeFunctionData('wantToCallFallback', []);
|
const fakeMethodEncoded = abiCoder.encodeFunctionData('wantToCallFallback', []);
|
||||||
|
|
||||||
|
// Call fallback function with value
|
||||||
await expect(
|
await expect(
|
||||||
user.signer.sendTransaction({to: wethGateway.address, data: fakeMethodEncoded, value: amount})
|
user.signer.sendTransaction({to: wethGateway.address, data: fakeMethodEncoded, value: amount})
|
||||||
).to.be.revertedWith('Fallback not allowed');
|
).to.be.reverted;
|
||||||
|
|
||||||
|
// Call fallback function without value
|
||||||
await expect(user.signer.sendTransaction({to: wethGateway.address, data: fakeMethodEncoded})).to
|
await expect(user.signer.sendTransaction({to: wethGateway.address, data: fakeMethodEncoded})).to
|
||||||
.be.reverted;
|
.be.reverted;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user