Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/env/src/engine/off_chain/test_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,8 @@ pub fn assert_contract_termination<T, F>(
/// 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::<Environment>($amount);
$contract.$message($($params:ty)?)
$contract.$message($ ($params) ,*)
}}
}
2 changes: 2 additions & 0 deletions crates/ink/tests/compile_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
29 changes: 29 additions & 0 deletions crates/ink/tests/ui/pay_with_call/pass/multiple_args.rs
Original file line number Diff line number Diff line change
@@ -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) {}

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), 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ink::env::pay_with_call!(self.message2(0, 0), 0);
ink::env::pay_with_call!(self.message2(4*64, 0), 0);

just to make sure it really works with expr; fun fact: it will compile regardless the value of the expr is out of bounds

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get what you mean here, can you clarify?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nevermind, just wanted to pass it a lil more interesting expr than just 0; 4*64 evaluates to 256 which is out of u8 bounds; still this would compile, while passing just 256 - not

}
}
}

fn main() {}