0

I want to test if the balance updates when I send some eths

it("the balance matches the price of a person", async function(){
  let instance = await People.deployed()
  await instance.createPerson("BOB2", 89, 110,  {value : 1000000000000000000});
  let balance = await web3.eth.getBalance(instance.address);
  console.log(balance);

});
function createPerson(string memory name, uint age, uint height) public payable costs(100){
        Person memory newPerson;
        newPerson.name = name;
        newPerson.height = height;
        newPerson.age = age;
        insertPerson(newPerson);
        creators.push(msg.sender);
        assert(keccak256(abi.encodePacked(people[msg.sender].name,  people[msg.sender].age, people[msg.sender].height, people[msg.sender].senior)) == keccak256(abi.encodePacked(newPerson.name, newPerson.age,newPerson.height, newPerson.senior)));
        emit personCreated(newPerson.name, newPerson.senior);

    }

The problem that I am facing is that when I send for example 1 eth, the balance in the console updates from 0 to 1, but then if I run "truffle test" again ,the balance does not change, same thing if the I change {value : 1000000000000000000} to {value : 1000000000000000001}. but if I change {value : 1000000000000000000} to for example {value : 2000000000000000000} it outputs the right balance, 3 eths so what am I doing wrong here?

and one last thing , this has nothing to do with the old problem: why does "await truffleAssert.fails(1 == 9);" return false and "await truffleAssert.passes(balance == 9);" return true?, isn't it supposed to be the opposite?

Your Answer

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

Browse other questions tagged or ask your own question.