mirror of
				https://github.com/Instadapp/dsa-connectors.git
				synced 2024-07-29 22:37:00 +00:00 
			
		
		
		
	updated tests
This commit is contained in:
		
							parent
							
								
									25dc808012
								
							
						
					
					
						commit
						fe4d30aee8
					
				| 
						 | 
				
			
			@ -58,7 +58,7 @@ describe("ZeroEx", function() {
 | 
			
		|||
 | 
			
		||||
  describe("DSA wallet setup", function() {
 | 
			
		||||
    it("Should build DSA v2", async function() {
 | 
			
		||||
      dsaWallet0 = await buildDSAv2(wallet0.getAddress());
 | 
			
		||||
      dsaWallet0 = await buildDSAv2(await wallet0.getAddress());
 | 
			
		||||
      expect(!!dsaWallet0.address).to.be.true;
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -146,7 +146,7 @@ describe("ZeroEx", function() {
 | 
			
		|||
      ];
 | 
			
		||||
      const tx = await dsaWallet0
 | 
			
		||||
        .connect(wallet0)
 | 
			
		||||
        .cast(...encodeSpells(spells), wallet1.getAddress());
 | 
			
		||||
        .cast(...encodeSpells(spells), await wallet1.getAddress());
 | 
			
		||||
      const receipt = await tx.wait();
 | 
			
		||||
 | 
			
		||||
      const daiToken = await ethers.getContractAt(
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,7 +7,7 @@ import { deployAndEnableConnector } from "../../../scripts/tests/deployAndEnable
 | 
			
		|||
import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2";
 | 
			
		||||
import { encodeSpells } from "../../../scripts/tests/encodeSpells";
 | 
			
		||||
import { getMasterSigner } from "../../../scripts/tests/getMasterSigner";
 | 
			
		||||
import { addresses } from "../../../scripts/tests/mainnet/addresses";
 | 
			
		||||
import { addresses } from "../../../scripts/tests/polygon/addresses";
 | 
			
		||||
import { abis } from "../../../scripts/constant/abis";
 | 
			
		||||
import { ConnectV2ZeroExPolygon, ConnectV2ZeroExPolygon__factory } from "../../../typechain";
 | 
			
		||||
import er20abi from "../../../scripts/constant/abi/basics/erc20.json";
 | 
			
		||||
| 
						 | 
				
			
			@ -19,22 +19,23 @@ describe("ZeroEx", function() {
 | 
			
		|||
  let dsaWallet0: Contract;
 | 
			
		||||
  let wallet0: Signer, wallet1: Signer;
 | 
			
		||||
  let masterSigner: Signer;
 | 
			
		||||
  let instaConnectorsV2: any;
 | 
			
		||||
  let connector: any;
 | 
			
		||||
  let instaConnectorsV2: Contract;
 | 
			
		||||
  let connector: Contract;
 | 
			
		||||
 | 
			
		||||
  before(async () => {
 | 
			
		||||
    //   await hre.network.provider.request({
 | 
			
		||||
    //     method: "hardhat_reset",
 | 
			
		||||
    //     params: [
 | 
			
		||||
    //       {
 | 
			
		||||
    //         forking: {
 | 
			
		||||
    //           // @ts-ignore
 | 
			
		||||
    //           jsonRpcUrl: hre.config.networks.forking.url,
 | 
			
		||||
    //           blockNumber: 13300000,
 | 
			
		||||
    //         },
 | 
			
		||||
    //       },
 | 
			
		||||
    //     ],
 | 
			
		||||
    // });
 | 
			
		||||
    await hre.network.provider.request({
 | 
			
		||||
      method: "hardhat_reset",
 | 
			
		||||
      params: [
 | 
			
		||||
        {
 | 
			
		||||
          forking: {
 | 
			
		||||
            // @ts-ignore
 | 
			
		||||
            jsonRpcUrl: hre.config.networks.hardhat.forking.url,
 | 
			
		||||
          },
 | 
			
		||||
        },
 | 
			
		||||
      ],
 | 
			
		||||
    });
 | 
			
		||||
    [wallet0, wallet1] = await ethers.getSigners();
 | 
			
		||||
 | 
			
		||||
    masterSigner = await getMasterSigner();
 | 
			
		||||
    instaConnectorsV2 = await ethers.getContractAt(
 | 
			
		||||
      abis.core.connectorsV2,
 | 
			
		||||
| 
						 | 
				
			
			@ -52,12 +53,12 @@ describe("ZeroEx", function() {
 | 
			
		|||
  it("Should have contracts deployed.", async function() {
 | 
			
		||||
    expect(!!instaConnectorsV2.address).to.be.true;
 | 
			
		||||
    expect(!!connector.address).to.be.true;
 | 
			
		||||
    expect(!!masterSigner.getAddress()).to.be.true;
 | 
			
		||||
    expect(!!(await masterSigner.getAddress())).to.be.true;
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  describe("DSA wallet setup", function() {
 | 
			
		||||
    it("Should build DSA v2", async function() {
 | 
			
		||||
      dsaWallet0 = await buildDSAv2(wallet0.getAddress());
 | 
			
		||||
      dsaWallet0 = await buildDSAv2(await wallet0.getAddress());
 | 
			
		||||
      expect(!!dsaWallet0.address).to.be.true;
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -78,7 +79,6 @@ describe("ZeroEx", function() {
 | 
			
		|||
      let buyTokenAmount: any;
 | 
			
		||||
      async function getArg() {
 | 
			
		||||
        // const slippage = 0.5;
 | 
			
		||||
 | 
			
		||||
        /* matic -> dai */
 | 
			
		||||
        const sellTokenAddress = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"; // matic,  decimals 18
 | 
			
		||||
        const sellTokenDecimals = 18;
 | 
			
		||||
| 
						 | 
				
			
			@ -90,8 +90,6 @@ describe("ZeroEx", function() {
 | 
			
		|||
          .times(new BigNumber(10).pow(sellTokenDecimals))
 | 
			
		||||
          .toFixed(0);
 | 
			
		||||
 | 
			
		||||
        const fromAddress = dsaWallet0.address;
 | 
			
		||||
 | 
			
		||||
        let url = `https://polygon.api.0x.org/swap/v1/quote`;
 | 
			
		||||
 | 
			
		||||
        const params = {
 | 
			
		||||
| 
						 | 
				
			
			@ -122,7 +120,6 @@ describe("ZeroEx", function() {
 | 
			
		|||
        };
 | 
			
		||||
        let unitAmt = caculateUnitAmt();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        return [
 | 
			
		||||
          buyTokenAddress,
 | 
			
		||||
          sellTokenAddress,
 | 
			
		||||
| 
						 | 
				
			
			@ -143,18 +140,17 @@ describe("ZeroEx", function() {
 | 
			
		|||
      ];
 | 
			
		||||
      const tx = await dsaWallet0
 | 
			
		||||
        .connect(wallet0)
 | 
			
		||||
        .cast(...encodeSpells(spells), wallet1.getAddress());
 | 
			
		||||
        .cast(...encodeSpells(spells), await wallet1.getAddress());
 | 
			
		||||
      const receipt = await tx.wait();
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
      const idai = await ethers.getContractAt(
 | 
			
		||||
      const daiToken = await ethers.getContractAt(
 | 
			
		||||
        er20abi,
 | 
			
		||||
        "0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063" // dai address
 | 
			
		||||
      );
 | 
			
		||||
 | 
			
		||||
        expect(await idai.balanceOf(dsaWallet0.address)).to.be.gte(
 | 
			
		||||
          buyTokenAmount
 | 
			
		||||
        );
 | 
			
		||||
      expect(await daiToken.balanceOf(dsaWallet0.address)).to.be.gte(
 | 
			
		||||
        buyTokenAmount
 | 
			
		||||
      );
 | 
			
		||||
      expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.lte(
 | 
			
		||||
        ethers.utils.parseEther("9")
 | 
			
		||||
      );
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user