<
 
 
 
 
×
>
hide You are viewing an archived web page, collected at the request of Ethereum Foundation using Archive-It. This page was captured on 09:50:57 May 01, 2021 , and is part of the Community collection. The information on this web page may be out of date. See All versions of this archived page. Loading media information

Problem with truffle test - wrong number of arguments, wrong return types...

I'm currently trying to write some unit tests in Truffle. I keep running into some bizarre issues when trying to run the tests with Truffle. For example, I'm trying to use zeppelin-solidity/contracts/token/MintableToken.sol as a baseline for my token. I have a function

function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {

when I try to call it like

return token.mint(accounts[0], 100);

I get an error of

Uncaught Error: Invalid number of arguments to Solidity function

Which is rather weird - the function takes two parameters, and I'm passing it two parameters. So I decided to deconstruct the issue as much as possible. Here is my contract:

pragma solidity ^0.4.8; import 'zeppelin-solidity/contracts/token/MintableToken.sol'; contract Token is MintableToken { }

and after trying to test it with

var Token = artifacts.require("Token"); contract ("Token", function(accounts) { it("Should mint tokens properly", function() { return Token.deployed().then(function(token) { return token.mint(accounts[0], 100); }).then(function(isOK) { assert.equal(isOK, true, "Was not able to mint tokens"); }); }); });

I get an error of:

AssertionError: Was not able to mint tokens: expected { Object (tx, receipt, ...) } to equal true

So now the function accepts two arguments, but doesn't return bool - instead opting to return some weird object...

Anything I'm doing glaringly wrong here?
Sign In or Register to comment.