mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-04-22 17:18:01 +00:00
revive-runner: consider non-reverted transactions as success (#82)
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
This commit is contained in:
@@ -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)]
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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<u8> {
|
||||
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 {
|
||||
|
||||
Reference in New Issue
Block a user