Added fallback function

This commit is contained in:
David Racero 2020-11-03 13:51:10 +01:00
parent f70754263d
commit 5f37f317e9
2 changed files with 13 additions and 6 deletions

View File

@ -117,7 +117,7 @@ contract WETHGateway is IWETHGateway {
/**
* @dev Revert fallback calls
*/
fallback() external {
revert('Fallback not allowed');
fallback() external payable {
require(false, 'Fallback not allowed');
}
}

View File

@ -5,6 +5,7 @@ import {parseEther} from 'ethers/lib/utils';
import {BRE, waitForTx} from '../helpers/misc-utils';
import {BigNumber} from 'ethers';
import {getStableDebtToken, getVariableDebtToken} from '../helpers/contracts-getters';
import {WethGateway} from '../types/WethGateway';
const {expect} = require('chai');
@ -182,7 +183,7 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
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 user = users[0];
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})
).to.be.revertedWith('Receive not allowed');
await expect(user.signer.sendTransaction({to: wethGateway.address})).to.be.revertedWith(
'Fallback not allowed'
);
const fakeABI = ['function wantToCallFallback()'];
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;
});
});