Skip to content

Commit

Permalink
next review round suggestions applied
Browse files Browse the repository at this point in the history
  • Loading branch information
agryaznov committed Sep 10, 2022
1 parent 655e59c commit 96908b7
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions crates/env/src/engine/off_chain/test_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ where
}

/// Sets the value transferred from the caller to the callee as part of the call.
///
/// Please note that the acting accounts should be set with [`set_caller()`] and [`set_callee()`] beforehand.
pub fn set_value_transferred<T>(value: T::Balance)
where
Expand All @@ -211,6 +212,7 @@ where
}

/// Transfers value from the caller account to the contract.
///
/// Please note that the acting accounts should be set with [`set_caller()`] and [`set_callee()`] beforehand.
pub fn transfer_in<T>(value: T::Balance)
where
Expand Down Expand Up @@ -394,11 +396,11 @@ pub fn assert_contract_termination<T, F>(
assert_eq!(beneficiary, expected_beneficiary);
}

#[macro_export]
/// Prepend contract message call with value transfer. Used for tests in off-chain environment.
#[macro_export]
macro_rules! pay_with_call {
($contract:ident . $message:ident ( $($params:ty)? ) , $amount:expr) => {{
::ink_env::test::transfer_in::<Environment>($amount);
($contract:ident . $message:ident ( $($params:ty)? ) , $amount:expr) => {{
$crate::test::transfer_in::<Environment>($amount);
$contract.$message($($params:ty)?)
}}
}}
}

0 comments on commit 96908b7

Please sign in to comment.