network,
I've been trying to finish a unit test for an investing wallet smart contract on Solidity as mentioned above:
The idea is to create a test cenarium for a vesting wallet smart contract.
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.9.0;
import "@openzeppelin/contracts/finance/VestingWallet.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract VestingContract is VestingWallet {
constructor(
address beneficiaryAddress,
uint64 startTimestamp,
uint64 durationSeconds
)
public
VestingWallet(beneficiaryAddress, startTimestamp, durationSeconds)
{}
function getBalance() public view returns (uint256) {
return address(this).balance;
}
function getBalanceFromToken(address _token) public view returns (uint256) {
return IERC20(_token).balanceOf(address(this));
}
}
and I also created these tests.
const VestingContract = artifacts.require("VestingContract");
const IoraContract = artifacts.require("Iora");
contract("VestingContract", function (accounts) {
it("should assert true", async function () {
await VestingContract.deployed();
return assert.isTrue(true);
});
it("beneficiary and accounts[0] should be the same", async function () {
const wallet = accounts[0];
const vestingInstance = await VestingContract.deployed();
const walletFromSmartContract = await vestingInstance.beneficiary();
return assert.isTrue(wallet === walletFromSmartContract)
});
it("actual timestamp should be the high or the same when it was deployed", async function () {
const vestingInstance = await VestingContract.deployed();
const vestingStarted = await vestingInstance.start();
const startTimestamp = Math.floor(Date.now() / 1000);
return assert.isTrue(startTimestamp >= vestingStarted.toNumber())
});
it("balance from erc20 token should be the same on this contract balance", async function () {
const vestingInstance = await VestingContract.deployed();
const ioraInstance = await IoraContract.deployed();
await ioraInstance.transfer(vestingInstance.address, 150);
const ioraBalance = await ioraInstance.balanceOf(vestingInstance.address);
const ioraTokenBalance = await vestingInstance.getBalanceFromToken(ioraInstance.address);
return assert.isTrue(ioraBalance.toNumber() === ioraTokenBalance.toNumber())
});
it("total released should be the same as we transfered", async function () {
const amount = 3000;
const vestingInstance = await VestingContract.deployed();
const ioraInstance = await IoraContract.deployed();
await ioraInstance.transfer(vestingInstance.address, amount);
await vestingInstance.release(ioraInstance.address);
const releasedVesting = await vestingInstance.released(vestingInstance.address);
return assert.isTrue(amount === releasedVesting.toNumber())
});
});
but, I'm getting this error:
1) Contract: VestingContract
total released should be the same as we transfered:
Error: Returned error: header not found
at Context.<anonymous> (test/vesting_contract.js:47:51)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
My question is, why my header was not found and also how can I solve it?