I'm playing around with truffle and I have this simple program here that I can't seem to get to work...
contract MyContract {
struct Test {
bool testBool;
}
mapping (address => Test[]) public tests;
function issueTest(address _owner) public {
Test memory test;
test.testBool = false;
tests[_owner].push(test);
}
function setTestBool(address _owner, uint _index) public
returns (bool sucess) {
tests[_owner][_index].testBool = true;
return tests[_owner][_index].testBool;
}
function getTestBool(address _owner, uint _index) public returns (bool testBool) {
return tests[_owner][_index].testBool;
}
}
in my test file I have:
let myContract;
var reciever = web3.eth.accounts[1];
before(async() => {
myContract = await MyContract.deployed();
});
it("Test Bool", async() => {
await myContract.issueTest.call(reciever);
var sucess = await myContract.setTestBool.call(reciever, 0);
assert.equal(sucess, true, "Test Bool was set.");
var result = await myContract.getTestBool.call(reciever, 0);
assert.equal(result, true, "Bool is true.");
});
When I do truffle test I get this error:
Error: Error: VM Exception while executing eth_call: invalid opcode
I think the problem is with .call(). I dont understand what call does very well.
Any help would be great Thanks!