From e5233fc46ee744569f55e7ce753eb4332974780d Mon Sep 17 00:00:00 2001 From: Cyrill Leutwiler Date: Mon, 14 Oct 2024 13:24:59 +0200 Subject: [PATCH] revive-runner: consider non-reverted transactions as success (#82) Signed-off-by: Cyrill Leutwiler --- crates/differential/src/lib.rs | 2 +- crates/integration/contracts/Call.sol | 17 ++++++----------- crates/runner/src/lib.rs | 18 ++++++++++++++---- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/crates/differential/src/lib.rs b/crates/differential/src/lib.rs index 332a86b..d294b10 100644 --- a/crates/differential/src/lib.rs +++ b/crates/differential/src/lib.rs @@ -40,7 +40,7 @@ const EXECUTABLE_ARGS_BENCH: [&str; 6] = [ "-", ]; const GAS_USED_MARKER: &str = "EVM gas used:"; -const REVERT_MARKER: &str = "error: execution reverted"; +const REVERT_MARKER: &str = " error: "; /// The geth EVM state dump structure #[derive(Clone, Debug, Default, Serialize, Deserialize)] diff --git a/crates/integration/contracts/Call.sol b/crates/integration/contracts/Call.sol index d3c4f73..77ff01d 100644 --- a/crates/integration/contracts/Call.sol +++ b/crates/integration/contracts/Call.sol @@ -21,16 +21,8 @@ pragma solidity ^0.8; "Solidity": { "contract": "Caller" } - } - } - }, - { - "Call": { - "dest": { - "Instantiated": 0 }, - "value": 123, - "data": "1eb16e5b000000000000000000000000d8b934580fce35a11b58c6d73adee468a2833fa8" + "value": 123 } }, { @@ -49,11 +41,14 @@ contract Callee { function echo(bytes memory payload) public pure returns (bytes memory) { return payload; } + + receive() external payable {} } contract Caller { - function value_transfer(address payable destination) public payable { - destination.transfer(msg.value); + constructor() payable { + Callee callee = new Callee(); + payable(address(callee)).transfer(msg.value); } function call(bytes memory payload) public returns (bytes memory) { diff --git a/crates/runner/src/lib.rs b/crates/runner/src/lib.rs index ece3d32..18425c0 100644 --- a/crates/runner/src/lib.rs +++ b/crates/runner/src/lib.rs @@ -161,7 +161,7 @@ impl VerifyCallExpectation { fn verify(self, result: &CallResult) { assert_eq!( self.success, - result.is_ok(), + !result.did_revert(), "contract execution result mismatch: {result:?}" ); @@ -190,12 +190,21 @@ pub enum CallResult { impl CallResult { /// Check if the call was successful - fn is_ok(&self) -> bool { + fn did_revert(&self) -> bool { match self { - Self::Exec { result, .. } => result.result.is_ok(), - Self::Instantiate { result, .. } => result.result.is_ok(), + Self::Exec { result, .. } => result + .result + .as_ref() + .map(|r| r.did_revert()) + .unwrap_or(true), + Self::Instantiate { result, .. } => result + .result + .as_ref() + .map(|r| r.result.did_revert()) + .unwrap_or(true), } } + /// Get the output of the call fn output(&self) -> Vec { match self { @@ -211,6 +220,7 @@ impl CallResult { .unwrap_or_default(), } } + /// Get the gas consumed by the call fn gas_consumed(&self) -> Weight { match self {