I write a bit more than plain contract on solidity and working on test to it. I faced with issue to put pass variables inside.

If I define variable as let I receive compilation error like this:

BigNumber Error: new BigNumber() not a number: entity

My attempts to define it as solidity variable are failed, seems test doesn't support any type except let

Here is a sample of the contract and test for it.

contract Market {

    struct good {
        address owner;
        bytes32 goodName;
        uint amount;

    mapping(bytes32 => good[]) market;

    uint counter;

    function Market() {}

    function putGood(bytes32 name, address owner, uint quantity) public returns (uint) {
        good memory newGood = good(owner, name, quantity);
        return counter;

  function getGood(bytes32 good) public view returns (bytes32, uint)     {
    return (market[good].owner, market[good].goodName, market[good].amount);

Related test

const Market = artifacts.require('../test/Market.sol')

contract('Market', function(accounts) {

let market;

beforeEach(`create subject instance before each test`, async function() {
    market = await Market.new();

it(`client put good on the market - one good - one good is available on the market`, async function() {
    let testGood = stringToUint("test good");

    await market.putGood(testGood, accounts[0], 1);

    let good = await market.getGood(testGood);

    assert.equals(good.owner, accounts[0]);

Could you please help me with place where I can learn more about defning different types in solidity tests?


More information about Solidity elementary types is here: http://solidity.readthedocs.io/en/develop/abi-spec.html#types.

  1. You can learn how to set/get bytes32 from web3 here: web3 return bytes32 string

  2. address in Solidity -> "0x..." string in Javascript

  3. Other inputs in Solidity: bool, int/uint, string have the similar types in Javascript.

  • Thanks! web3.toUtf8() and web3.fromAscii() functions work are what I need. For structures I use let data with access to elements as data[0] – Gleichmut Dec 4 '17 at 9:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.