I'm trying to test function (stake) which contains reference to another contract function (transferFrom). But when I test it I have a mistake. But MyToken has deployed and has address to hardhat network.
Here is a contract
import "./MyToken.sol"; contract Staking { MyToken public myToken; function stake(uint256 _value) public { myToken.transferFrom(msg.sender, address(this), _value); } } Here is a test
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers"; import { expect } from "chai"; import { assert } from "console"; import { ethers } from "hardhat"; import { MyToken, MyToken__factory, Staking, Staking__factory } from "../typechain"; // import { MyToken, MyToken__factory } from "../typechain"; describe("MyToken", function () { let staking: Staking; let myToken: MyToken; let bob: SignerWithAddress, alice: SignerWithAddress; before(async () => { [bob, alice] = await ethers.getSigners(); }) beforeEach(async () => { const MyToken = await ethers.getContractFactory("MyToken") as MyToken__factory; myToken = await MyToken.deploy() as MyToken; await myToken.deployed(); const Staking = await ethers.getContractFactory("Staking") as Staking__factory; staking = await Staking.deploy() as Staking; await staking.deployed(); }) **it("staking", async function () { const value = 100; await staking.stake(value); })** 