updated tests

This commit is contained in:
Richa-iitr 2022-04-04 21:26:29 +05:30
parent 3b91d64d65
commit 82add64d43

View File

@ -28,98 +28,10 @@ const account = "0xf04adbf75cdfc5ed26eea4bbbb991db002036bdd";
const DAI = "0x8f3cf7ad23cd3cadbd9735aff958023239c6a063"; const DAI = "0x8f3cf7ad23cd3cadbd9735aff958023239c6a063";
const USDC = "0x2791bca1f2de4661ed88a30c99a7a9449aa84174"; const USDC = "0x2791bca1f2de4661ed88a30c99a7a9449aa84174";
const mnemonic = "test test test test test test test test test test test junk"; const mnemonic = "test test test test test test test test test test test junk";
const connectorName = "AAVE-V3-IMPORT-PERMIT-X";
let signer: any, wallet0: any;
const erc20Abi = [ const aaveAbi = [
{
constant: false,
inputs: [
{
name: "_spender",
type: "address"
},
{
name: "_value",
type: "uint256"
}
],
name: "approve",
outputs: [
{
name: "",
type: "bool"
}
],
payable: false,
stateMutability: "nonpayable",
type: "function"
},
{
constant: true,
inputs: [],
name: "totalSupply",
outputs: [
{
name: "",
type: "uint256"
}
],
payable: false,
stateMutability: "view",
type: "function"
},
{
constant: true,
inputs: [
{
name: "_owner",
type: "address"
}
],
name: "balanceOf",
outputs: [
{
name: "balance",
type: "uint256"
}
],
payable: false,
stateMutability: "view",
type: "function"
},
{
constant: false,
inputs: [
{
name: "_to",
type: "address"
},
{
name: "_value",
type: "uint256"
}
],
name: "transfer",
outputs: [
{
name: "",
type: "bool"
}
],
payable: false,
stateMutability: "nonpayable",
type: "function"
}
];
const token = new ethers.Contract(DAI, erc20Abi);
const aDai = new ethers.Contract(aDaiAddress, ABI);
const usdcToken = new ethers.Contract(USDC, erc20Abi);
describe("Import Aave V3 with Permit", function () {
const connectorName = "AAVE-V3-IMPORT-PERMIT-X";
let signer: any, wallet0: any;
const aaveAbi = [
{ {
inputs: [ inputs: [
{ {
@ -209,8 +121,96 @@ describe("Import Aave V3 with Permit", function () {
stateMutability: "nonpayable", stateMutability: "nonpayable",
type: "function" type: "function"
} }
]; ];
const erc20Abi = [
{
constant: false,
inputs: [
{
name: "_spender",
type: "address"
},
{
name: "_value",
type: "uint256"
}
],
name: "approve",
outputs: [
{
name: "",
type: "bool"
}
],
payable: false,
stateMutability: "nonpayable",
type: "function"
},
{
constant: true,
inputs: [],
name: "totalSupply",
outputs: [
{
name: "",
type: "uint256"
}
],
payable: false,
stateMutability: "view",
type: "function"
},
{
constant: true,
inputs: [
{
name: "_owner",
type: "address"
}
],
name: "balanceOf",
outputs: [
{
name: "balance",
type: "uint256"
}
],
payable: false,
stateMutability: "view",
type: "function"
},
{
constant: false,
inputs: [
{
name: "_to",
type: "address"
},
{
name: "_value",
type: "uint256"
}
],
name: "transfer",
outputs: [
{
name: "",
type: "bool"
}
],
payable: false,
stateMutability: "nonpayable",
type: "function"
}
];
const token = new ethers.Contract(DAI, erc20Abi);
const aDai = new ethers.Contract(aDaiAddress, ABI);
const usdcToken = new ethers.Contract(USDC, erc20Abi);
const aave = new ethers.Contract(aaveAddress, aaveAbi);
describe("Import Aave", function () {
let dsaWallet0: any; let dsaWallet0: any;
let masterSigner: Signer; let masterSigner: Signer;
let instaConnectorsV2: Contract; let instaConnectorsV2: Contract;
@ -252,8 +252,10 @@ describe("Import Aave V3 with Permit", function () {
connectors: instaConnectorsV2 connectors: instaConnectorsV2
}); });
const aave = new ethers.Contract(aaveAddress, aaveAbi); });
describe("check user AAVE position", async () => {
it("Should create Aave v3 position of DAI(collateral) and USDC(debt)", async () => {
// approve DAI to aavePool // approve DAI to aavePool
await token.connect(wallet0).approve(aaveAddress, parseEther("8")); await token.connect(wallet0).approve(aaveAddress, parseEther("8"));
@ -266,6 +268,17 @@ describe("Import Aave V3 with Permit", function () {
console.log("Borrowed USDC from aave"); console.log("Borrowed USDC from aave");
}); });
it("Should check position of user", async () => {
expect(await aDai.connect(wallet0).balanceOf(wallet.address)).to.be.gte(
new BigNumber(8).multipliedBy(1e18).toString()
);
expect(await usdcToken.connect(wallet0).balanceOf(wallet.address)).to.be.gte(
new BigNumber(5).multipliedBy(1e6).toString()
);
});
});
describe("Deployment", async () => { describe("Deployment", async () => {
it("Should set correct name", async () => { it("Should set correct name", async () => {
expect(await connector.name()).to.eq("Aave-v3-import-permit-v1"); expect(await connector.name()).to.eq("Aave-v3-import-permit-v1");
@ -288,18 +301,6 @@ describe("Import Aave V3 with Permit", function () {
}); });
}); });
describe("check user AAVE position", async () => {
it("Should check position of user", async () => {
expect(await aDai.connect(wallet0).balanceOf(wallet.address)).to.be.gte(
new BigNumber(8).multipliedBy(1e18).toString()
);
expect(await usdcToken.connect(wallet0).balanceOf(wallet.address)).to.be.gte(
new BigNumber(5).multipliedBy(1e6).toString()
);
});
});
describe("Aave position migration", async () => { describe("Aave position migration", async () => {
it("Should migrate Aave position", async () => { it("Should migrate Aave position", async () => {
const DOMAIN_SEPARATOR = await aDai.connect(wallet0).DOMAIN_SEPARATOR(); const DOMAIN_SEPARATOR = await aDai.connect(wallet0).DOMAIN_SEPARATOR();