-
I have a simple contract that just sets a Below, I write a test that is supposed to set that private string variable to a new value and then I go in and read it. function test_non_owner_can_view_password() public {
// owner sets a new password
string memory newPassword = "Nicenew#pwd123";
vm.prank(address(owner));
passwordStore.setPassword(newPassword);
// non-owner can see what the new password is
vm.startPrank(address(1));
bytes32 value = vm.load(address(passwordStore), bytes32(uint256(1)));
string memory pwd = string(abi.encodePacked(value));
console.log(pwd); // we can see the password here
assertEq(abi.encodePacked(newPassword), abi.encodePacked(pwd));
} if I run the test with
If I convert to string, it still fails, even though the results appear to be the same. Assert with:
Results in
The extra characters that are returned from How can I get around this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Answered here https://ethereum.stackexchange.com/questions/155716/asserteq-fails-on-seemingly-same-strings |
Beta Was this translation helpful? Give feedback.
Answered here
https://ethereum.stackexchange.com/questions/155716/asserteq-fails-on-seemingly-same-strings