diff --git a/framework/base/src/types/interaction/tx_rh_list/tx_rh_list_exec.rs b/framework/base/src/types/interaction/tx_rh_list/tx_rh_list_exec.rs index b8121d40d8..64f8a0a487 100644 --- a/framework/base/src/types/interaction/tx_rh_list/tx_rh_list_exec.rs +++ b/framework/base/src/types/interaction/tx_rh_list/tx_rh_list_exec.rs @@ -10,6 +10,10 @@ pub trait RHListItemExec: RHListItem where Env: TxEnv, { + fn is_error_handled(&self) -> bool { + false + } + fn item_process_result(self, raw_result: &RawResult) -> Self::Returns; } @@ -18,6 +22,8 @@ pub trait RHListExec: RHList where Env: TxEnv, { + fn is_error_handled(&self) -> bool; + fn list_process_result(self, raw_result: &RawResult) -> Self::ListReturns; } @@ -25,6 +31,10 @@ impl RHListExec for () where Env: TxEnv, { + fn is_error_handled(&self) -> bool { + false + } + fn list_process_result(self, _raw_result: &RawResult) -> Self::ListReturns {} } @@ -32,6 +42,10 @@ impl RHListExec for OriginalResultMarker where Env: TxEnv, { + fn is_error_handled(&self) -> bool { + false + } + fn list_process_result(self, _raw_result: &RawResult) -> Self::ListReturns {} } @@ -41,6 +55,10 @@ where Head: RHListItemExec, Tail: RHListExec, { + fn is_error_handled(&self) -> bool { + self.head.is_error_handled() || self.tail.is_error_handled() + } + fn list_process_result(self, raw_result: &RawResult) -> Self::ListReturns { let head_result = self.head.item_process_result(raw_result); let tail_result = self.tail.list_process_result(raw_result); @@ -54,6 +72,10 @@ where Head: RHListItemExec, Tail: RHListExec, { + fn is_error_handled(&self) -> bool { + self.head.is_error_handled() || self.tail.is_error_handled() + } + fn list_process_result(self, raw_result: &RawResult) -> Self::ListReturns { self.head.item_process_result(raw_result); self.tail.list_process_result(raw_result) diff --git a/framework/scenario/src/facade/result_handlers.rs b/framework/scenario/src/facade/result_handlers.rs index 6bb2de8216..55f541d8e0 100644 --- a/framework/scenario/src/facade/result_handlers.rs +++ b/framework/scenario/src/facade/result_handlers.rs @@ -1,3 +1,7 @@ +mod returns_message; +mod returns_status; mod with_tx_raw_response; +pub use returns_message::ReturnsMessage; +pub use returns_status::ReturnsStatus; pub use with_tx_raw_response::WithRawTxResponse; diff --git a/framework/scenario/src/facade/result_handlers/returns_message.rs b/framework/scenario/src/facade/result_handlers/returns_message.rs new file mode 100644 index 0000000000..c9e9821055 --- /dev/null +++ b/framework/scenario/src/facade/result_handlers/returns_message.rs @@ -0,0 +1,26 @@ +use multiversx_sc::types::{RHListItem, RHListItemExec, TxEnv}; + +use crate::scenario_model::TxResponse; + +/// Indicates that the error status will be returned. +pub struct ReturnsMessage; + +impl RHListItem for ReturnsMessage +where + Env: TxEnv, +{ + type Returns = String; +} + +impl RHListItemExec for ReturnsMessage +where + Env: TxEnv, +{ + fn is_error_handled(&self) -> bool { + true + } + + fn item_process_result(self, raw_result: &TxResponse) -> Self::Returns { + raw_result.tx_error.message.clone() + } +} diff --git a/framework/scenario/src/facade/result_handlers/returns_status.rs b/framework/scenario/src/facade/result_handlers/returns_status.rs new file mode 100644 index 0000000000..7e81421efb --- /dev/null +++ b/framework/scenario/src/facade/result_handlers/returns_status.rs @@ -0,0 +1,26 @@ +use multiversx_sc::types::{RHListItem, RHListItemExec, TxEnv}; + +use crate::scenario_model::TxResponse; + +/// Indicates that the error status will be returned. +pub struct ReturnsStatus; + +impl RHListItem for ReturnsStatus +where + Env: TxEnv, +{ + type Returns = u64; +} + +impl RHListItemExec for ReturnsStatus +where + Env: TxEnv, +{ + fn is_error_handled(&self) -> bool { + true + } + + fn item_process_result(self, raw_result: &TxResponse) -> Self::Returns { + raw_result.tx_error.status + } +}