Skip to content

Commit

Permalink
add test cases for dev revert string on final revert
Browse files Browse the repository at this point in the history
  • Loading branch information
iamdefinitelyahuman committed Feb 19, 2020
1 parent 8724c6a commit 30e9038
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions tests/network/transaction/test_revert_msg.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,52 @@
from brownie.project import compile_source


def test_dev_revert_on_final_statement(console_mode, evmtester, accounts):

code = """pragma solidity >=0.4.22;
contract foo {
function foo1 () external returns (bool) {
revert(); // dev: yuss
}
function foo2 () external returns (bool) {
uint b = 33;
revert(); // dev: yuss
}
function foo3 (uint a) external returns (bool) {
if (a < 3) {
return true;
}
revert(); // dev: yuss
}
function foo4 (uint a) external returns (bool) {
require(a >= 3);
revert(); // dev: yuss
}
function foo5 (uint a) external {
require(a >= 3);
revert(); // dev: yuss
}
}"""

contract = compile_source(code).foo.deploy({"from": accounts[0]})
tx = contract.foo1()
assert tx.revert_msg == "dev: yuss"
tx = contract.foo2()
assert tx.revert_msg == "dev: yuss"
tx = contract.foo3(4)
assert tx.revert_msg == "dev: yuss"
tx = contract.foo4(4)
assert tx.revert_msg == "dev: yuss"
tx = contract.foo5(4)
assert tx.revert_msg == "dev: yuss"


def test_revert_msg_via_jump(ext_tester, console_mode):
tx = ext_tester.getCalled(2)
assert tx.revert_msg == "dev: should jump to a revert"
Expand Down

0 comments on commit 30e9038

Please sign in to comment.