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);
market[name].push(newGood);
counter++;
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?
let datawith access to elements as data[0] – Gleichmut Dec 04 '17 at 09:26