aave-protocol-v2/test/delegation-aware-atoken.spec.ts

59 lines
2.1 KiB
TypeScript
Raw Normal View History

import { MAX_UINT_AMOUNT, ZERO_ADDRESS } from '../helpers/constants';
import { BUIDLEREVM_CHAINID } from '../helpers/buidler-constants';
import { buildPermitParams, getSignatureFromTypedData } from '../helpers/contracts-helpers';
import { expect } from 'chai';
import { ethers } from 'ethers';
import { eEthereumNetwork, ProtocolErrors } from '../helpers/types';
import { makeSuite, TestEnv } from './helpers/make-suite';
import { DRE } from '../helpers/misc-utils';
2020-11-02 13:44:11 +00:00
import {
ConfigNames,
getATokenDomainSeparatorPerNetwork,
loadPoolConfig,
} from '../helpers/configuration';
import { waitForTx } from '../helpers/misc-utils';
2020-11-02 13:44:11 +00:00
import {
deployDelegationAwareAToken,
deployMintableDelegationERC20,
} from '../helpers/contracts-deployments';
import { DelegationAwareATokenFactory } from '../types';
import { DelegationAwareAToken } from '../types/DelegationAwareAToken';
import { MintableDelegationERC20 } from '../types/MintableDelegationERC20';
2020-11-02 13:44:11 +00:00
const { parseEther } = ethers.utils;
2020-11-02 13:44:11 +00:00
makeSuite('AToken: underlying delegation', (testEnv: TestEnv) => {
const poolConfig = loadPoolConfig(ConfigNames.Commons);
let delegationAToken = <DelegationAwareAToken>{};
let delegationERC20 = <MintableDelegationERC20>{};
2020-11-02 13:44:11 +00:00
it('Deploys a new MintableDelegationERC20 and a DelegationAwareAToken', async () => {
const { pool } = testEnv;
2020-11-02 13:44:11 +00:00
delegationERC20 = await deployMintableDelegationERC20(['DEL', 'DEL', '18']);
delegationAToken = await deployDelegationAwareAToken(
[pool.address, delegationERC20.address, 'aDEL', 'aDEL', ZERO_ADDRESS],
false
);
});
it('Tries to delegate with the caller not being the Aave admin', async () => {
const { users } = testEnv;
2020-11-02 13:44:11 +00:00
await expect(
delegationAToken.connect(users[1].signer).delegateUnderlyingTo(users[2].address)
2020-11-05 11:35:50 +00:00
).to.be.revertedWith(ProtocolErrors.CALLER_NOT_POOL_ADMIN);
2020-11-02 13:44:11 +00:00
});
it('Tries to delegate to user 2', async () => {
const { users } = testEnv;
2020-11-02 13:44:11 +00:00
await delegationAToken.delegateUnderlyingTo(users[2].address);
const delegateeAddress = await delegationERC20.delegatee();
expect(delegateeAddress).to.be.equal(users[2].address);
});
});