Hi @Exctazy ,
Welcome to the community
I assume that the issue is that the test changes the owner of the contract (using transferOwnership
but doesn’t transfer any tokens to the crowdsale (using transfer
). The crowdsale doesn’t have a supply of tokens to sell.
To see this in action, we can look at the OpenZeppelin Contract tests (using OpenZeppelin Test Environment )
it('requires a non-null wallet', async function () {
await expectRevert(
Crowdsale.new(rate, ZERO_ADDRESS, this.token.address), 'Crowdsale: wallet is the zero address'
);
});
context('once deployed', async function () {
beforeEach(async function () {
this.crowdsale = await Crowdsale.new(rate, wallet, this.token.address);
await this.token.transfer(this.crowdsale.address, tokenSupply);
});
describe('accepting payments', function () {
describe('bare payments', function () {
it('should accept payments', async function () {
await this.crowdsale.send(value, { from: purchaser });
});
it('reverts on zero-valued payments', async function () {
await expectRevert(
As an aside, your ERC20 token could be simpler (I wasn’t sure of the code in the constructor). See the following example: Help me write an erc20 token and a crowdsale contract
Feel free to ask all the questions that you need.