Skip to content

Latest commit

 

History

History
32 lines (26 loc) · 647 Bytes

File metadata and controls

32 lines (26 loc) · 647 Bytes

Hello World

输入 "HelloWorld" 调用 answer 就行。

contract HelloWorld {
    bytes32 private immutable _answer;

    bool public success;

    constructor() {
        _answer = keccak256(abi.encodePacked("HelloWorld"));
    }

    function answer(string calldata data) external {
        bytes32 hash = keccak256(abi.encodePacked(data));
        if (hash == _answer) {
            success = true;
        }
    }
}

POC:

    function testCorrectAnswer() public {
        HelloWorld h = base.helloWorld();
        h.answer("HelloWorld");
        base.solve();
        assertTrue(base.isSolved());
    }