Skip to content

Commit

Permalink
Feat(tests): Test for trying to obtain TransactionStatus::CallTooDeep…
Browse files Browse the repository at this point in the history
… from the Engine
  • Loading branch information
birchmd committed Oct 21, 2022
1 parent d0f0e77 commit 111b9b7
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
12 changes: 12 additions & 0 deletions engine-tests/src/tests/res/CallTooDeep.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.0;

interface ICallTooDeep {
function test() external;
}

contract CallTooDeep {
function test() external {
ICallTooDeep(address(this)).test();
}
}
35 changes: 35 additions & 0 deletions engine-tests/src/tests/sanity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,41 @@ fn test_revert_during_contract_deploy() {
assert_eq!(revert_message.as_str(), "Revert message");
}

#[test]
fn test_call_too_deep_error() {
let (mut runner, mut signer, _) = initialize_transfer();

let constructor = test_utils::solidity::ContractConstructor::compile_from_source(
"src/tests/res",
"target/solidity_build",
"CallTooDeep.sol",
"CallTooDeep",
);

let nonce = signer.use_nonce();
let contract = runner.deploy_contract(
&signer.secret_key,
|c| c.deploy_without_constructor(nonce.into()),
constructor,
);

let result = runner
.submit_with_signer(&mut signer, |nonce| {
contract.call_method_without_args("test", nonce)
})
.unwrap();

// It is counter-intuitive that this returns a `Revert` instead of `CallTooDeep`.
// The reason this is the case is because it is only the last call that triggers the
// `CallTooDeep` exit status, while the one before only sees that the call it made failed
// and therefore reverts. As a result, the `CallTooDeep` exit status is not actually
// visible to users.
match result.status {
TransactionStatus::Revert(_) => (),
other => panic!("Unexpected status {:?}", other),
}
}

#[test]
fn test_timestamp() {
let (mut runner, mut signer, _) = initialize_transfer();
Expand Down

0 comments on commit 111b9b7

Please sign in to comment.