I want my function to be able to accept an array of Hashed secrets as a parameter and since solidity doesn't allow for strings, I had to use a byte32[].
The string parameter is an intake for the user's secret which I am hashing with Keccak256 which should convert it to a byte32 value.
Since (or so I think) the hashed secret string is a byte32 and so is the hashed secret stored in the first element of the byte32 array, the assertion should evaluate to true when comparing them
Test:
it("Checking secrets", function() {
return myContract.deployed().then(function(instance){
contract = instance;
return contract.test.call("hello", ["1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8"])
.then(function(testVals){
assert.equal(testVals[0].valueOf(), testVals[1][0].valueOf())
})
});
});
Function:
function test(string val1, bytes32[] val2) public returns(bytes32, bytes32[]){
return(keccak256(val1), val2);
}
Result:
AssertionError: expected '0x1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8' to equal '0x3163386166663935303638356332656434626333313734663334373232383762'
0x
, i.e.0x1c8aff95...
– user19510 Jun 8 '18 at 3:02