Solidity Error: Member "equal" is not available in type(library Assert) outside of storage

0 votes

I have this code:

Token.sol

pragma solidity ^0.4.8;


contract Token {

    /* The amount of tokens a person will get for 1 ETH */

    uint256 public exchangeRate;


    /* The name of the token */

    string public name;


    /* The address which controls the token */

    address public owner;


    /* The symbol of the token */

    string public symbol;


    /* The balances of all registered addresses */

    mapping (address => uint256) balances;


    /* Token constructor */

    function Token(uint256 _exchangeRate, string _name, string _symbol) {

        exchangeRate = _exchangeRate;

        name = _name;

        owner = msg.sender;

        symbol = _symbol;

    }


    function getBalance(address account) returns (uint256 balance) {

        return balances[account];

    }

}

TestToken.sol

pragma solidity ^0.4.8;


// Framework libraries

import "truffle/Assert.sol";

import "truffle/DeployedAddresses.sol";


// Custom libraries and contracts

import "../contracts/Token.sol";


contract TestToken {

    function testExchangeRate() {

        Token token = new Token(500, "Dollar", "$");


        uint256 expected = 500;


        Assert.equal(token.exchangeRate(), expected, "The exchange rate should be 500 tokens for 1 ETH");

    }


    function testSymbol() {

        Token token = new Token(500, "Dollar", "$");


        Assert.equal(token.symbol(), "$", "The symbol of the token should be $");

    }

}

And I get this error when I try to execute it:

Error: Member "equal" is not available in type(library Assert) outside of storage.

        Assert.equal(token.symbol(), "$", "The symbol of the token should be $");

        ^----------^

Compiliation failed. See above.
Aug 9, 2018 in Blockchain by digger
• 27,630 points
56 views

1 answer to this question.

0 votes
You can get error because solidity does not support returning strings in between contracts because the length of string can not be determined. You can use bytes32 in place of string.
answered Aug 9, 2018 by slayer
• 29,050 points

Related Questions In Blockchain

+1 vote
1 answer

what is use of msg.sender in solidity code?

msg.sender(address) function indicated the sender of the ...READ MORE

answered Apr 24, 2018 in Blockchain by Shashank
• 10,330 points
348 views
0 votes
1 answer

Solidity mocha : address is not a contract error

Try the following: // Initialize contract variable with ...READ MORE

answered Oct 1, 2018 in Blockchain by digger
• 27,630 points
46 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
125 views
0 votes
1 answer
0 votes
1 answer
0 votes
2 answers