2020-08-10 18:20:08 +00:00
|
|
|
import {expect} from 'chai';
|
|
|
|
import {makeSuite, TestEnv} from './helpers/make-suite';
|
|
|
|
import {ProtocolErrors, eContractid} from '../helpers/types';
|
2020-09-02 15:54:34 +00:00
|
|
|
import {
|
|
|
|
deployGenericAToken,
|
|
|
|
getAToken,
|
|
|
|
deployContract,
|
|
|
|
getContract,
|
|
|
|
} from '../helpers/contracts-helpers';
|
2020-08-10 18:20:08 +00:00
|
|
|
import {MockAToken} from '../types/MockAToken';
|
2020-09-02 15:54:34 +00:00
|
|
|
import {MockStableDebtToken} from '../types/MockStableDebtToken';
|
|
|
|
import {MockVariableDebtToken} from '../types/MockVariableDebtToken';
|
2020-06-08 12:03:40 +00:00
|
|
|
|
2020-08-10 18:20:08 +00:00
|
|
|
makeSuite('Upgradeability', (testEnv: TestEnv) => {
|
2020-09-02 15:54:34 +00:00
|
|
|
const {CALLER_NOT_LENDING_POOL_MANAGER} = ProtocolErrors;
|
2020-08-10 18:20:08 +00:00
|
|
|
let newATokenAddress: string;
|
2020-08-18 10:16:48 +00:00
|
|
|
let newStableTokenAddress: string;
|
|
|
|
let newVariableTokenAddress: string;
|
|
|
|
|
2020-08-10 18:20:08 +00:00
|
|
|
before('deploying instances', async () => {
|
|
|
|
const {dai, pool} = testEnv;
|
|
|
|
const aTokenInstance = await deployContract<MockAToken>(eContractid.MockAToken, [
|
|
|
|
pool.address,
|
|
|
|
dai.address,
|
|
|
|
'Aave Interest bearing DAI updated',
|
|
|
|
'aDAI',
|
|
|
|
]);
|
2020-06-08 12:03:40 +00:00
|
|
|
|
2020-09-02 15:54:34 +00:00
|
|
|
const stableDebtTokenInstance = await deployContract<MockStableDebtToken>(
|
|
|
|
eContractid.MockStableDebtToken,
|
|
|
|
[pool.address, dai.address, 'Aave stable debt bearing DAI updated', 'stableDebtDAI']
|
|
|
|
);
|
2020-08-18 10:16:48 +00:00
|
|
|
|
2020-09-02 15:54:34 +00:00
|
|
|
const variableDebtTokenInstance = await deployContract<MockVariableDebtToken>(
|
|
|
|
eContractid.MockVariableDebtToken,
|
|
|
|
[pool.address, dai.address, 'Aave variable debt bearing DAI updated', 'variableDebtDAI']
|
|
|
|
);
|
2020-08-18 10:16:48 +00:00
|
|
|
|
2020-08-10 18:20:08 +00:00
|
|
|
newATokenAddress = aTokenInstance.address;
|
2020-08-18 10:16:48 +00:00
|
|
|
newVariableTokenAddress = variableDebtTokenInstance.address;
|
|
|
|
newStableTokenAddress = stableDebtTokenInstance.address;
|
2020-08-10 18:20:08 +00:00
|
|
|
});
|
2020-06-08 12:03:40 +00:00
|
|
|
|
2020-08-10 18:20:08 +00:00
|
|
|
it('Tries to update the DAI Atoken implementation with a different address than the lendingPoolManager', async () => {
|
|
|
|
const {dai, configurator, users} = testEnv;
|
2020-06-08 12:03:40 +00:00
|
|
|
|
2020-08-10 18:20:08 +00:00
|
|
|
await expect(
|
|
|
|
configurator.connect(users[1].signer).updateAToken(dai.address, newATokenAddress)
|
2020-09-02 15:54:34 +00:00
|
|
|
).to.be.revertedWith(CALLER_NOT_LENDING_POOL_MANAGER);
|
2020-08-10 18:20:08 +00:00
|
|
|
});
|
2020-06-08 12:03:40 +00:00
|
|
|
|
2020-08-10 18:20:08 +00:00
|
|
|
it('Upgrades the DAI Atoken implementation ', async () => {
|
|
|
|
const {dai, configurator, aDai} = testEnv;
|
2020-06-08 12:03:40 +00:00
|
|
|
|
2020-08-10 18:20:08 +00:00
|
|
|
const name = await (await getAToken(newATokenAddress)).name();
|
2020-06-08 12:03:40 +00:00
|
|
|
|
2020-08-10 18:20:08 +00:00
|
|
|
await configurator.updateAToken(dai.address, newATokenAddress);
|
2020-06-08 12:03:40 +00:00
|
|
|
|
2020-08-10 18:20:08 +00:00
|
|
|
const tokenName = await aDai.name();
|
2020-06-08 12:03:40 +00:00
|
|
|
|
2020-08-10 18:20:08 +00:00
|
|
|
expect(tokenName).to.be.eq('Aave Interest bearing DAI updated', 'Invalid token name');
|
|
|
|
});
|
2020-08-18 10:16:48 +00:00
|
|
|
|
|
|
|
it('Tries to update the DAI Stable debt token implementation with a different address than the lendingPoolManager', async () => {
|
|
|
|
const {dai, configurator, users} = testEnv;
|
|
|
|
|
|
|
|
await expect(
|
2020-09-02 15:54:34 +00:00
|
|
|
configurator
|
|
|
|
.connect(users[1].signer)
|
|
|
|
.updateStableDebtToken(dai.address, newStableTokenAddress)
|
|
|
|
).to.be.revertedWith(CALLER_NOT_LENDING_POOL_MANAGER);
|
2020-08-18 10:16:48 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('Upgrades the DAI stable debt token implementation ', async () => {
|
|
|
|
const {dai, configurator, pool} = testEnv;
|
|
|
|
|
|
|
|
const name = await (await getAToken(newATokenAddress)).name();
|
|
|
|
|
|
|
|
await configurator.updateStableDebtToken(dai.address, newStableTokenAddress);
|
|
|
|
|
|
|
|
const {stableDebtTokenAddress} = await pool.getReserveTokensAddresses(dai.address);
|
|
|
|
|
2020-09-02 15:54:34 +00:00
|
|
|
const debtToken = await getContract<MockStableDebtToken>(
|
|
|
|
eContractid.MockStableDebtToken,
|
|
|
|
stableDebtTokenAddress
|
|
|
|
);
|
2020-08-18 10:16:48 +00:00
|
|
|
|
|
|
|
const tokenName = await debtToken.name();
|
|
|
|
|
|
|
|
expect(tokenName).to.be.eq('Aave stable debt bearing DAI updated', 'Invalid token name');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Tries to update the DAI variable debt token implementation with a different address than the lendingPoolManager', async () => {
|
|
|
|
const {dai, configurator, users} = testEnv;
|
|
|
|
|
|
|
|
await expect(
|
2020-09-02 15:54:34 +00:00
|
|
|
configurator
|
|
|
|
.connect(users[1].signer)
|
|
|
|
.updateVariableDebtToken(dai.address, newVariableTokenAddress)
|
|
|
|
).to.be.revertedWith(CALLER_NOT_LENDING_POOL_MANAGER);
|
2020-08-18 10:16:48 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('Upgrades the DAI variable debt token implementation ', async () => {
|
|
|
|
const {dai, configurator, pool} = testEnv;
|
|
|
|
|
|
|
|
const name = await (await getAToken(newATokenAddress)).name();
|
|
|
|
|
|
|
|
await configurator.updateVariableDebtToken(dai.address, newVariableTokenAddress);
|
|
|
|
|
|
|
|
const {variableDebtTokenAddress} = await pool.getReserveTokensAddresses(dai.address);
|
|
|
|
|
2020-09-02 15:54:34 +00:00
|
|
|
const debtToken = await getContract<MockStableDebtToken>(
|
|
|
|
eContractid.MockStableDebtToken,
|
|
|
|
variableDebtTokenAddress
|
|
|
|
);
|
2020-08-18 10:16:48 +00:00
|
|
|
|
|
|
|
const tokenName = await debtToken.name();
|
|
|
|
|
|
|
|
expect(tokenName).to.be.eq('Aave variable debt bearing DAI updated', 'Invalid token name');
|
|
|
|
});
|
2020-08-10 18:20:08 +00:00
|
|
|
});
|