mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Added fallback function
This commit is contained in:
parent
f70754263d
commit
5f37f317e9
|
@ -117,7 +117,7 @@ contract WETHGateway is IWETHGateway {
|
||||||
/**
|
/**
|
||||||
* @dev Revert fallback calls
|
* @dev Revert fallback calls
|
||||||
*/
|
*/
|
||||||
fallback() external {
|
fallback() external payable {
|
||||||
revert('Fallback not allowed');
|
require(false, 'Fallback not allowed');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import {parseEther} from 'ethers/lib/utils';
|
||||||
import {BRE, waitForTx} from '../helpers/misc-utils';
|
import {BRE, waitForTx} from '../helpers/misc-utils';
|
||||||
import {BigNumber} from 'ethers';
|
import {BigNumber} from 'ethers';
|
||||||
import {getStableDebtToken, getVariableDebtToken} from '../helpers/contracts-getters';
|
import {getStableDebtToken, getVariableDebtToken} from '../helpers/contracts-getters';
|
||||||
|
import {WethGateway} from '../types/WethGateway';
|
||||||
|
|
||||||
const {expect} = require('chai');
|
const {expect} = require('chai');
|
||||||
|
|
||||||
|
@ -182,7 +183,7 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
|
||||||
expect(debtBalanceAfterFullRepay).to.be.eq(zero);
|
expect(debtBalanceAfterFullRepay).to.be.eq(zero);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Should revert if receive function receives Ether', async () => {
|
xit('Should revert if receive function 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');
|
||||||
|
@ -191,8 +192,14 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
|
||||||
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');
|
||||||
|
|
||||||
await expect(user.signer.sendTransaction({to: wethGateway.address})).to.be.revertedWith(
|
const fakeABI = ['function wantToCallFallback()'];
|
||||||
'Fallback not allowed'
|
const abiCoder = new BRE.ethers.utils.Interface(fakeABI);
|
||||||
);
|
const fakeMethodEncoded = abiCoder.encodeFunctionData('wantToCallFallback', []);
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
user.signer.sendTransaction({to: wethGateway.address, data: fakeMethodEncoded, value: amount})
|
||||||
|
).to.be.revertedWith('Fallback not allowed');
|
||||||
|
await expect(user.signer.sendTransaction({to: wethGateway.address, data: fakeMethodEncoded})).to
|
||||||
|
.be.reverted;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user