I'm trying to test this smart contract but I can't seem to get the beyond this error, I'm using the latest truffle suite v5.1.16, and web3 v1.2.6.
KTokenSale.test.js
const BigNumber = web3.BigNumber;
require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();
const KToken = artifacts.require('KToken');
const KTokenCrowdsale = artifacts.require('KTokenCrowdsale');
contract('KTokenCrowdsale', function([_, wallet, investor1, investor2]) {
beforeEach(async function () {
this.name = 'TestToken';
this.symbol = 'TT';
this.decimals = 16;
this.token = await KToken.new(
this.name,
this.symbol,
this.decimals
);
this.rate = 850;
this.wallet = wallet;
this.crowdsale = await KToken.new(
this.rate,
this.wallet,
this.token.address
);
});
});
contract('crowdsale', function() {
it('tracks the rate', async function() {
const rate = await this.crowdsale.rate();
rate.should.be.bignumber.equal(this.rate);
});
it('tracks the wallet', async function() {
const wallet = await this.crowdsale.wallet();
wallet.should.equal(this.wallet);
});
it('tracks the token', async function() {
const token = await this.crowdsale.token();
token.should.equal(this.token.address);
});
});
Smart contract code being tested:
pragma solidity ^0.5.11;
import "@openzeppelin/contracts/crowdsale/Crowdsale.sol";
import "@openzeppelin/contracts/crowdsale/validation/CappedCrowdsale.sol";
contract KTokenCrowdsale is Crowdsale, CappedCrowdsale {
uint256 public investorMinCap = 7000000000000000000;
uint256 public investorMaxCap = 350000000000000000000;
mapping(address => uint256) public contributions;
constructor(
uint256 _rate,
address payable _wallet,
IERC20 _token,
uint256 _cap
)
Crowdsale(_rate, _wallet, _token)
CappedCrowdsale(_cap) public {}
}
web3.utils.BN
in v1.x onward.