Skip to content
New issue

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

Experimental prank support #897

Merged
merged 1 commit into from
Jan 10, 2023
Merged

Experimental prank support #897

merged 1 commit into from
Jan 10, 2023

Conversation

ggrieco-tob
Copy link
Member

No description provided.

@rappie
Copy link

rappie commented Jan 9, 2023

I'm getting an error when using prank. I've tested warp as well and it works fine.

pragma solidity ^0.8.0;

interface IHevm {
    function prank(address sender) external;

    function warp(uint256 x) external;
}

contract EchidnaTest {
    event MsgSender(address);
    event BlockTimestamp(uint256);

    IHevm hevm;

    constructor() {
        hevm = IHevm(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);
    }

    function debugWarp() public {
        hevm.warp(123);
        emit BlockTimestamp(block.timestamp);
        assert(false);
    }

    function debugPrank() public {
        hevm.prank(address(123));
        prankMe();
    }

    function prankMe() public {
        emit MsgSender(msg.sender);
        assert(false);
    }
}
testMode: assertion
testLimit: 100000
❯ echidna-test . --contract EchidnaTest --config echidna-config.yaml --format text
Analyzing contract: /home/rappie/Desktop/echidna-prank-test/EchidnaTestPrank.sol:EchidnaTest
echidna-test: VM failed for unhandled reason, BadCheatCode (Just 3395723175). This shouldn't happen. Please file a ticket with this error message and steps to reproduce!

@rappie rappie mentioned this pull request Jan 9, 2023
@ggrieco-tob
Copy link
Member Author

@arcz can you take a look?

@rappie
Copy link

rappie commented Jan 9, 2023

Correction, it works! 😄

I forgot to update my echidna-test binary after downloading 😰

pragma solidity ^0.8.0;

interface IHevm {
    function prank(address sender) external;

    function warp(uint256 x) external;
}

contract PrankMe {
    event MsgSender(address);

    function prankMe() public {
        emit MsgSender(msg.sender);
        assert(false);
    }
}

contract EchidnaTest {
    event BlockTimestamp(uint256);

    IHevm hevm;

    constructor() {
        hevm = IHevm(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);
    }

    function debugWarp() public {
        hevm.warp(123);
        emit BlockTimestamp(block.timestamp);
        assert(false);
    }

    function debugPrank() public {
        hevm.prank(address(123));
        PrankMe prankMe = new PrankMe();
        prankMe.prankMe();
    }
}
debugPrank(): failed!💥
  Call sequence:
    debugPrank()

Event sequence: Panic(1), MsgSender(@0x000000000000000000000000000000000000007B) from: 0xb4c79dab8f259c7aee6e5b2aa729821864227e84, merror Revert Panic(1)

@ggrieco-tob ggrieco-tob marked this pull request as ready for review January 10, 2023 14:20
@ggrieco-tob ggrieco-tob merged commit 0ac89ae into master Jan 10, 2023
@ggrieco-tob ggrieco-tob deleted the dev-prank branch January 10, 2023 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants