I'm trying to test smart contract's payable method in truffle framework:
contract Contract {
mapping (address => uint) public balances;
function myBalance() public view returns(uint) {
return balances[msg.sender];
}
function deposit() external payable {
balances[msg.sender] += msg.value;
}
}
contract TestContract {
function testDeposit() external payable {
Contract c = new Contract();
c.deposit.value(1);
Assert.equal(c.myBalance(), 1, "#myBalance() should returns 1");
}
}
After I run truffle test
, it's fails with TestEvent(result: <indexed>, message: #myBalance() should returns 1 (Tested: 0, Against: 1))
error. Why?
Aucun commentaire:
Enregistrer un commentaire