From 448b827d2cc10fd2a13afdb59860bd8e7707ea93 Mon Sep 17 00:00:00 2001 From: Tim Pechersky Date: Tue, 19 Nov 2024 23:03:37 +0700 Subject: [PATCH] fixed MAO test --- deploy/05_deployMocks.ts | 2 +- deploy/mao.ts | 1 - test/MAODistribution.ts | 11 +++++++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/deploy/05_deployMocks.ts b/deploy/05_deployMocks.ts index bf941b4..86f2949 100644 --- a/deploy/05_deployMocks.ts +++ b/deploy/05_deployMocks.ts @@ -11,7 +11,7 @@ const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => { from: deployer, skipIfAlreadyDeployed: true, }); - console.log('deployed rank token at', result.address); +// console.log('deployed rank token at', result.address); }; export default func; diff --git a/deploy/mao.ts b/deploy/mao.ts index 0b7da0f..d526da3 100644 --- a/deploy/mao.ts +++ b/deploy/mao.ts @@ -176,7 +176,6 @@ const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => { _distributionVersion, ], }); - console.warn('where 0'); const MaoDistrCode = await hre.ethers.provider.getCode(result.address); const MaoDistrCodeId = ethers.utils.keccak256(MaoDistrCode); diff --git a/test/MAODistribution.ts b/test/MAODistribution.ts index 4fe8100..3e66b57 100644 --- a/test/MAODistribution.ts +++ b/test/MAODistribution.ts @@ -1,6 +1,6 @@ /* global ethers */ -import { deployments, ethers } from 'hardhat'; +import { deployments, ethers, getNamedAccounts } from 'hardhat'; import hre from 'hardhat'; import { expect } from 'chai'; import { IDAO, MAODistribution, DAODistributor, Rankify, RankifyDiamondInstance } from '../types'; @@ -77,7 +77,14 @@ describe('MAODistribution', async function () { const distributorsDistId = ethers.utils.keccak256( ethers.utils.defaultAbiCoder.encode(['bytes32', 'address'], [maoId, ethers.constants.AddressZero]), ); - const tx = await distributorContract.instantiate(distributorsDistId, data); + const token = await deployments.get('Rankify'); + const { owner } = await getNamedAccounts(); + const oSigner = await ethers.getSigner(owner); + const tokenContract = new ethers.Contract(token.address, token.abi, oSigner) as Rankify; + await tokenContract.mint(oSigner.address, ethers.utils.parseEther('100')); + await tokenContract.approve(distributorContract.address, ethers.constants.MaxUint256); + + const tx = await distributorContract.connect(oSigner).instantiate(distributorsDistId, data); // const receipt = await tx.wait(1); await expect(tx).not.reverted; expect((await distributorContract.functions.getDistributions()).length).to.equal(1);