We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I have a struct like this
struct Question { strings.slice question; strings.slice answer; }
And a mapping mapping(uint256 => QA) public questions; and a proposeQuestion function that looks like this
mapping(uint256 => QA) public questions;
public returns (bool done) { questions[questionId].question = _question.toSlice(); questions[questionId].answer = _answer.toSlice(); questionId++; return true; }
When I retrieve the question and the answer stored in the struct which is stored in a mapping, and console log it, using foundry
function testQuestion() public { string memory q = "What?"; console.log(q, q.toSlice().toString()); myContract.proposeQuestion(q, unicode"すみません"); assertTrue( keccak256(abi.encodePacked(q)) == keccak256(abi.encodePacked(q.toSlice().toString())) ); ( strings.slice memory question, strings.slice memory answer ) = myContract.questions(0); console.log(question.toString());
The console prints out gibberish ,.��
However, if I just do this console.log(q, q.toSlice().toString()) they print out the same thing! What's going on here?
console.log(q, q.toSlice().toString())
PS:
Also, when I tried this out, this test fails
assertEq( keccak256(abi.encodePacked(q)), keccak256(abi.encodePacked(question.toString())) );
and yields this error
Expected: 0xc649b6993c4fe2cdb223c885f0145101f4d5ef046eebceed76b6431c34626612 Actual: 0xf8a49a8b34d42855db8ed1c016fa2fe0354abc43323b8d67be08e3837aae8b60 Test result: FAILED. 0 passed; 1 failed; finished in 5.19ms```
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I have a struct like this
And a mapping
mapping(uint256 => QA) public questions;
and a proposeQuestion function that looks like thisWhen I retrieve the question and the answer stored in the struct which is stored in a mapping, and console log it, using foundry
The console prints out gibberish ,.��
However, if I just do this
console.log(q, q.toSlice().toString())
they print out the same thing! What's going on here?PS:
Also, when I tried this out, this test fails
and yields this error
The text was updated successfully, but these errors were encountered: