Truffle console: assert.equal not printing message

Hi,
I am trying to compare the value returned by getName() using assert.equal(), but I am not getting any message:

pragma solidity >= 0.5.0 < 0.7.0;
 
contract SimpleContract {
  string  public name;
  constructor() public {
     name = 'abs';  
  }
  function getName() public view returns(string memory) {
      return (name);
   }
}

I am trying to print a message on ‘truffle console’ using assert.equal(), but I am not getting any output.
My truffle console statements are:

> truffle(development)> sci = await SimpleContract.at('0xDa0463c841E7D822f6281240cD7593bA3FD4BB0f');
> undefined
> truffle(development)> value = await sci.getName();
> truffle(development)> await sci.getName();
> 'abs'
> truffle(development)> value = await sci.getName();
> undefined
> truffle(development)> assert.equal(value, 'abs', "Both are equal");
> undefined
> truffle(development)>

Somebody please guide me how to print the message “Both are equal” using truffle console.

1 Like

Emmm, IIRC, when you use assert.equal() to do a check, if it is true, maybe it just passes and nothing will happen, only when it fails, it will throw out some error message.

2 Likes

Hi,
Thanks a lot. God blesses you. Is there any way to handle my comparison using false value?

Zulfi.

1 Like

Hi @zak100,

I wasn’t sure why you wanted to do assert checks in truffle console.

You may want to look at the Learn guide on writing automated tests: https://docs.openzeppelin.com/learn/writing-automated-tests

Hi,
Thanks a lot, I would start reading this. But mocha is something new. Truffle console has mocha but I don’t have to deal chain commands. That’s why I am using truffle console.

Zulfi.

1 Like