diff --git a/crates/env/src/engine/off_chain/test_api.rs b/crates/env/src/engine/off_chain/test_api.rs index 09f9c82ad2d..01bef923811 100644 --- a/crates/env/src/engine/off_chain/test_api.rs +++ b/crates/env/src/engine/off_chain/test_api.rs @@ -399,8 +399,8 @@ pub fn assert_contract_termination( /// 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) => {{ + ($contract:ident . $message:ident ( $( $params:expr ),* ) , $amount:expr) => {{ $crate::test::transfer_in::($amount); - $contract.$message($($params:ty)?) + $contract.$message($ ($params) ,*) }} } diff --git a/crates/ink/tests/compile_tests.rs b/crates/ink/tests/compile_tests.rs index 5a18e4c63f0..78635475b0f 100644 --- a/crates/ink/tests/compile_tests.rs +++ b/crates/ink/tests/compile_tests.rs @@ -35,4 +35,6 @@ fn ui_tests() { t.compile_fail("tests/ui/trait_def/fail/*.rs"); t.pass("tests/ui/chain_extension/E-01-simple.rs"); + + t.pass("tests/ui/pay_with_call/pass/multiple_args.rs"); } diff --git a/crates/ink/tests/ui/pay_with_call/pass/multiple_args.rs b/crates/ink/tests/ui/pay_with_call/pass/multiple_args.rs new file mode 100644 index 00000000000..77fbfdab6ff --- /dev/null +++ b/crates/ink/tests/ui/pay_with_call/pass/multiple_args.rs @@ -0,0 +1,29 @@ +#[ink::contract] +mod contract { + #[ink(storage)] + pub struct Contract {} + + impl Contract { + #[ink(constructor)] + pub fn new() -> Self { + Self {} + } + + #[ink(message)] + pub fn message0(&self) {} + + #[ink(message)] + pub fn message1(&self, _arg1: u8) {} + + #[ink(message)] + pub fn message2(&self, _arg1: u8, _arg2: (u8, AccountId)) {} + + fn check_compiles(&self) { + ink::env::pay_with_call!(self.message0(), 0); + ink::env::pay_with_call!(self.message1(0), 0); + ink::env::pay_with_call!(self.message2(0, (0, Self::env().account_id())), 0); + } + } +} + +fn main() {}