Mein Vertrag ist
contract SimpleContract {
uint storedData;
function set(uint x) public { storedData = x; }
function get() public returns (uint) { return storedData; }
}
Dieser Test funktioniert nicht:
var SimpleContract = artifacts.require("SimpleContract");
contract('SimpleContract', function(accounts) {
let contract;
let owner;
let web3Contract;
before(async () => {
contract = await SimpleContract.deployed();
web3Contract = web3.eth.contract(contract.abi).at(contract.address);
owner = web3Contract._eth.coinbase;
});
it("test", async function() {
await contract.set.call(10);
let result = await contract.get.call();
assert.equal(result.toNumber(), 10, "updates the field");
});
});
Ich erhalte
AssertionError: fail: expected 0 to equal 10
Irgendeine Idee?
@ Jitendra Kumar. Ballas Antwort ist die richtige. Ich rief set.call(10)
statt an set.sendTransaction(10)
.
Jitendra Kumar. Balla
Robert