I can't figure out why this error occurs
Here my test js code:
var YarockToken = artifacts.require("./YarockToken.sol");
contract('YarockToken', function(accounts) {
var tokenInstance;
it('initializes the contract with the correct values', function() {
return YarockToken.deployed().then(function(instance) {
tokenInstance = instance;
return tokenInstance.name();
}).then(function(name) {
assert.equal(name, 'Yarock Token', 'has the correct name');
return tokenInstance.symbol();
}).then(function(symbol) {
assert.equal(symbol, 'YAROCK', 'has the correct symbol');
return tokenInstance.standard();
}).then(function(standard) {
assert.equal(standard, 'Yarock Token v1.0', 'has the correct standard');
});
})
it('allocates the initial supply upon deployment', function() {
return YarockToken.deployed().then(function(instance) {
tokenInstance = instance;
return tokenInstance.totalSupply();
}).then(function(totalSupply) {
assert.equal(totalSupply.toNumber(), 1000000, 'sets the total supply to 1,000,000');
return tokenInstance.balanceOf(accounts[0]);
}).then(function(adminBalance) {
assert.equal(adminBalance.toNumber(), 1000000, 'it allocates the initial supply to the admin account');
});
});
it('transfers token ownership', function() {
return YarockToken.deployed().then(function(instance) {
tokenInstance = instance;
// Test `require` statement first by transferring something larger than the sender's balance
return tokenInstance.transfer.call(accounts[1], 99999999999999999999999);
}).then(assert.fail).catch(function(error) {
assert(error.message.indexOf('revert') >= 0, 'error message must contain revert');
})
})
});
and here my contract code:
pragma solidity ^0.5.16;
contract YarockToken {
string public name = "Yarock Token";
string public symbol = "YAROCK";
string public standard = "Yarock Token v1.0";
uint256 public totalSupply;
event Transfer(
address indexed _from,
address indexed _to,
uint256 _value
);
event Approval(
address indexed _owner,
address indexed _spender,
uint256 _value
);
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;
constructor(uint256 _initialSupply) public {
balanceOf[msg.sender] = _initialSupply;
totalSupply = _initialSupply;
}
function transfer(address _to, uint256 _value) public returns (bool success) {
require(balanceOf[msg.sender] >= _value);
balanceOf[msg.sender] -= _value;
}
}
and this is the error I am getting
Contract: YarockToken
✓ initializes the contract with the correct values (238ms)
✓ allocates the initial supply upon deployment (123ms)
1) transfers token ownership
> No events were emitted
2 passing (541ms)
1 failing
1) Contract: YarockToken
transfers token ownership:
AssertionError: error message must contain revert
at /Users/Kantemirovs/token_sale/test/YarockToken.js:39:7
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Can someone please enlighten me about this ??
tokenInstance.transfer(accounts[1], 99999999999999999999999)
instead, ie remove.call
.