-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a0b1760
commit 0330c4f
Showing
6 changed files
with
94 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
framework/scenario/src/facade/result_handlers/expect_value.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use multiversx_sc::{ | ||
codec::{CodecFrom, TopEncodeMulti}, | ||
types::{RHListItem, RHListItemExec, TxEnv}, | ||
}; | ||
|
||
use crate::scenario_model::{BytesValue, CheckValue, TxExpect, TxResponse}; | ||
|
||
/// Verifies that transaction result matches the given value. | ||
/// | ||
/// Can only be used in tests and interactors, not available in contracts. | ||
pub struct ExpectValue<T>(pub T); | ||
|
||
impl<Env, Original, T> RHListItem<Env, Original> for ExpectValue<T> | ||
where | ||
Env: TxEnv, | ||
T: TopEncodeMulti, | ||
Original: CodecFrom<T>, | ||
{ | ||
type Returns = (); | ||
} | ||
|
||
impl<Env, Original, T> RHListItemExec<TxResponse, Env, Original> for ExpectValue<T> | ||
where | ||
Env: TxEnv<RHExpect = TxExpect>, | ||
T: TopEncodeMulti, | ||
Original: CodecFrom<T>, | ||
{ | ||
fn item_tx_expect(&self, mut prev: TxExpect) -> TxExpect { | ||
let mut encoded = Vec::<Vec<u8>>::new(); | ||
self.0.multi_encode(&mut encoded).expect("encoding error"); | ||
let out_values = encoded | ||
.into_iter() | ||
.map(|value| CheckValue::Equal(BytesValue::from(value))) | ||
.collect(); | ||
prev.out = CheckValue::Equal(out_values); | ||
prev | ||
} | ||
|
||
fn item_process_result(self, _: &TxResponse) -> Self::Returns {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters