I'm trying add deposit from one mock contract to my contract, but balance in my contract is zero. How do it right? Below is my code:

// imports
const { ethers, waffle } = require('hardhat')
const { deployContract } = waffle
// then
it('deposit USDT', async function () {
const [walletUSDT, walletMatrix] = await ethers.getSigners()
const tokenUSDT = await deployContract(walletUSDT, MockUSDT);
const tokenMatrix = await deployContract(walletMatrix, MXToken);
tokenUSDT.transfer(walletMatrix.address, 70)
const test = await tokenMatrix.balanceOf(walletMatrix.address)
console.log(test)
})

Jan 30, 2022, 6:59 PM
Let me help you with a boilerplate
const { expect } = require("chai");
const { ethers } = require("hardhat");

describe("Contract", function () {

let masterAccount, userAccount, addrs, usdtToken, busdToken;

before(async () => {

[masterAccount, userAccount, ...addrs] = await ethers.getSigners();

BusdToken = await ethers.getContractFactory("MockBUSD");
UsdtToken = await ethers.getContractFactory("MockUSDT");

busdToken = await BusdToken.deploy();
usdtToken = await UsdtToken.deploy();

});

describe("#Initialize", async() => {
it("Should deposit busd to userAccount balance", async() => {
let amount = ethers.utils.parseEther(String(15000));
await busdToken.connect(masterAccount).transfer(userAccount.address, amount);
let newBalance = await busdToken.balanceOf(userAccount.address);
expect(newBalance).to.equal(amount);
})
})

})
Jan 30, 2022, 7:09 PM
Thank you!
Jan 30, 2022, 7:26 PM

© 2024 Draquery.com All rights reserved.