I have a simple contract with a function that should return a byte32 which is passed as a parameter.

This is a snippet of my contract

contract SimpleContract{
   function simple(byte32 toReturn, byte32 otherArg) public returns (byte32){
        //Work with the values
        return toReturn; //Unmodified

Now, if I test it in Solidity, works seamlessly, but since I want to run more complex test, I turned to Truffle and used its JS library to run the test. Specifically, simple is tested this way:

contract("SimpleContract", function(accounts){
   it("should return the passed value", function (){
          var arg1 = 0xec40808d22324ec2fd140c398284c2a263871d111f54eb6f1b308c874ea1abc9;
          var arg2 = 0x1234567890;
          instance.simple.call(arg1, arg2).then(function(returnedValue){

Then I get this error:

AssertionError: expected 'ec40808d22324ec2fd140c398284c2a263871d111f54eb6f1b308c874ea1abc9' to equal '0xbd4419d46aafe6c72f31a89e54fd9976c34fe7cd385253d36e4226f94376e6dd'

I suspect there is some encoding issue, but I still haven't been able to wrap my head around it.

  • Your function should be declared as constant function simple(bytes32 toReturn, bytes32 otherArg) public constant returns (bytes32) Commented Oct 25, 2017 at 22:50
  • Also isn't byte32 is bytes32 Commented Oct 25, 2017 at 22:55

1 Answer 1


Your test passes for me when run under the latest truffle version Truffle v4.0.0-beta.2 (core: 4.0.0-beta.2) Solidity v0.4.17 (solc-js)

I haven't tried earlier versions.

  • The issue happened with truffle 3.4.11, upgrading fixed it. I didn't find what was changed to fix this, but it seems to me that it was some truffle issue.
    – frollo
    Commented Oct 30, 2017 at 9:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.