diff --git a/crates/e2e/src/client.rs b/crates/e2e/src/client.rs index 6427e5a8e5..08984fd097 100644 --- a/crates/e2e/src/client.rs +++ b/crates/e2e/src/client.rs @@ -30,11 +30,12 @@ use super::{ use contract_metadata::ContractMetadata; use ink_env::Environment; use ink_primitives::MessageResult; - +use pallet_contracts_primitives::ExecReturnValue; use sp_core::Pair; use std::{ collections::BTreeMap, fmt::Debug, + marker::PhantomData, path::Path, }; @@ -113,37 +114,46 @@ where pub struct CallResult { /// The result of the dry run, contains debug messages /// if there were any. - pub dry_run: ContractExecResult, + pub dry_run: CallDryRunResult, /// Events that happened with the contract instantiation. pub events: ExtrinsicEvents, - /// Contains the result of decoding the return value of the called - /// function. - pub value: Result, scale::Error>, - /// Returns the bytes of the encoded dry-run return value. - pub data: Vec, } impl CallResult where C: subxt::Config, E: Environment, + V: scale::Decode, { + /// Returns the [`MessageResult`] from the execution of the dry-run message + /// call. + /// + /// # Panics + /// - if the dry-run message call failed to execute. + /// - if message result cannot be decoded into the expected return value + /// type. + pub fn message_result(&self) -> MessageResult { + self.dry_run.message_result() + } + /// Returns the decoded return value of the message from the dry-run. /// /// Panics if the value could not be decoded. The raw bytes can be accessed - /// via [`return_data`]. + /// via [`CallResult::return_data`]. pub fn return_value(self) -> V { - self.value - .unwrap_or_else(|env_err| { - panic!( - "Decoding dry run result to ink! message return type failed: {env_err}" - ) - }) - .unwrap_or_else(|lang_err| { - panic!( - "Encountered a `LangError` while decoding dry run result to ink! message: {lang_err:?}" - ) - }) + self.dry_run.return_value() + } + + /// Returns the return value as raw bytes of the message from the dry-run. + /// + /// Panics if the dry-run message call failed to execute. + pub fn return_data(&self) -> &[u8] { + &self.dry_run.exec_return_value().data + } + + /// Returns any debug message output by the contract decoded as UTF-8. + pub fn debug_message(&self) -> String { + self.dry_run.debug_message() } /// Returns true if the specified event was triggered by the call. @@ -158,11 +168,12 @@ where /// We implement a custom `Debug` here, as to avoid requiring the trait /// bound `Debug` for `E`. // TODO(#xxx) Improve the `Debug` implementation. -impl core::fmt::Debug for CallResult +impl Debug for CallResult where - C: subxt::Config, - E: Environment, - ::Balance: core::fmt::Debug, + C: subxt::Config + Debug, + E: Environment + Debug, + ::Balance: Debug, + V: Debug, { fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("CallResult") @@ -172,6 +183,77 @@ where } } +/// Result of the dry run of a contract call. +#[derive(Debug)] +pub struct CallDryRunResult { + /// The result of the dry run, contains debug messages + /// if there were any. + pub exec_result: ContractExecResult, + _marker: PhantomData, +} + +impl CallDryRunResult +where + E: Environment, + V: scale::Decode, +{ + /// Returns true if the dry-run execution resulted in an error. + pub fn is_err(&self) -> bool { + self.exec_result.result.is_err() + } + + /// Returns the [`ExecReturnValue`] resulting from the dry-run message call. + /// + /// Panics if the dry-run message call failed to execute. + pub fn exec_return_value(&self) -> &ExecReturnValue { + self.exec_result + .result + .as_ref() + .unwrap_or_else(|call_err| panic!("Call dry-run failed: {call_err:?}")) + } + + /// Returns the [`MessageResult`] from the execution of the dry-run message + /// call. + /// + /// # Panics + /// - if the dry-run message call failed to execute. + /// - if message result cannot be decoded into the expected return value + /// type. + pub fn message_result(&self) -> MessageResult { + let data = &self.exec_return_value().data; + scale::Decode::decode(&mut data.as_ref()).unwrap_or_else(|env_err| { + panic!( + "Decoding dry run result to ink! message return type failed: {env_err}" + ) + }) + } + + /// Returns the decoded return value of the message from the dry-run. + /// + /// Panics if the value could not be decoded. The raw bytes can be accessed + /// via [`CallResult::return_data`]. + pub fn return_value(self) -> V { + self.message_result() + .unwrap_or_else(|lang_err| { + panic!( + "Encountered a `LangError` while decoding dry run result to ink! message: {lang_err:?}" + ) + }) + } + + /// Returns the return value as raw bytes of the message from the dry-run. + /// + /// Panics if the dry-run message call failed to execute. + pub fn return_data(&self) -> &[u8] { + &self.exec_return_value().data + } + + /// Returns any debug message output by the contract decoded as UTF-8. + pub fn debug_message(&self) -> String { + String::from_utf8_lossy(&self.exec_result.debug_message).into() + } +} + /// An error occurred while interacting with the Substrate node. /// /// We only convey errors here that are caused by the contract's @@ -280,8 +362,10 @@ where impl Client where C: subxt::Config, - C::AccountId: serde::de::DeserializeOwned, - C::AccountId: scale::Codec + Debug, + C::AccountId: From + + scale::Codec + + serde::de::DeserializeOwned + + Debug, C::Signature: From, >::OtherParams: Default, @@ -650,22 +734,10 @@ where { log_info(&format!("call: {:02X?}", message.exec_input())); - let dry_run = self - .api - .call_dry_run( - subxt::tx::Signer::account_id(signer).clone(), - &message, - value, - None, - ) - .await; - log_info(&format!("call dry run: {:?}", &dry_run.result)); - log_info(&format!( - "call dry run debug message: {}", - String::from_utf8_lossy(&dry_run.debug_message) - )); - if dry_run.result.is_err() { - return Err(Error::CallDryRun(dry_run)) + let dry_run = self.call_dry_run(signer, &message, value, None).await; + + if dry_run.exec_result.result.is_err() { + return Err(Error::CallDryRun(dry_run.exec_result)) } let tx_events = self @@ -673,7 +745,7 @@ where .call( sp_runtime::MultiAddress::Id(message.account_id().clone()), value, - dry_run.gas_required, + dry_run.exec_result.gas_required, storage_deposit_limit, message.exec_input().to_vec(), signer, @@ -696,18 +768,47 @@ where } } - let bytes = &dry_run.result.as_ref().unwrap().data; - let value: Result, scale::Error> = - scale::Decode::decode(&mut bytes.as_ref()); - Ok(CallResult { - value, - data: bytes.clone(), dry_run, events: tx_events, }) } + /// Executes a dry-run `call`. + /// + /// Returns the result of the dry run, together with the decoded return value of the invoked + /// message. + pub async fn call_dry_run( + &mut self, + signer: &Signer, + message: &Message, + value: E::Balance, + storage_deposit_limit: Option, + ) -> CallDryRunResult + where + RetType: scale::Decode, + { + let exec_result = self + .api + .call_dry_run( + Signer::account_id(signer).clone(), + message, + value, + storage_deposit_limit, + ) + .await; + log_info(&format!("call dry run: {:?}", &exec_result.result)); + log_info(&format!( + "call dry run debug message: {}", + String::from_utf8_lossy(&exec_result.debug_message) + )); + + CallDryRunResult { + exec_result, + _marker: Default::default(), + } + } + /// Returns the balance of `account_id`. pub async fn balance( &self, diff --git a/crates/e2e/src/lib.rs b/crates/e2e/src/lib.rs index f03f3f5bfd..d6a7788dc1 100644 --- a/crates/e2e/src/lib.rs +++ b/crates/e2e/src/lib.rs @@ -32,8 +32,12 @@ pub use builders::{ MessageBuilder, }; pub use client::{ + CallDryRunResult, + CallResult, Client, Error, + InstantiationResult, + UploadResult, }; pub use default_accounts::*; pub use env_logger; diff --git a/examples/contract-terminate/lib.rs b/examples/contract-terminate/lib.rs index 3e2a5dbfe2..3d278127dd 100644 --- a/examples/contract-terminate/lib.rs +++ b/examples/contract-terminate/lib.rs @@ -86,7 +86,7 @@ pub mod just_terminates { .expect("terminate_me messages failed"); assert!( - call_res.data.is_empty(), + call_res.return_data().is_empty(), "Terminated contract never returns" ); diff --git a/examples/contract-transfer/lib.rs b/examples/contract-transfer/lib.rs index a479f4dae2..f73372f9c9 100644 --- a/examples/contract-transfer/lib.rs +++ b/examples/contract-transfer/lib.rs @@ -210,15 +210,12 @@ pub mod give_me { let call_res = client.call(&ink_e2e::bob(), transfer, 10, None).await; // then - assert!(call_res.is_err()); - let contains_err_msg = match call_res.unwrap_err() { - ink_e2e::Error::CallDryRun(dry_run) => { - String::from_utf8_lossy(&dry_run.debug_message) - .contains("paid an unpayable message") - } - _ => false, - }; - assert!(contains_err_msg); + if let Err(ink_e2e::Error::CallDryRun(dry_run)) = call_res { + let debug_message = String::from_utf8_lossy(&dry_run.debug_message); + assert!(debug_message.contains("paid an unpayable message")) + } else { + panic!("Paying an unpayable message should fail") + } Ok(()) } @@ -254,10 +251,7 @@ pub mod give_me { .expect("call failed"); // then - let contains_debug_println = - String::from_utf8_lossy(&call_res.dry_run.debug_message) - .contains("requested value: 120\n"); - assert!(contains_debug_println); + assert!(call_res.debug_message().contains("requested value: 120\n")); let balance_after: Balance = client .balance(contract_acc_id) diff --git a/examples/delegator/lib.rs b/examples/delegator/lib.rs index 69f5c5ab35..880c3dcbd8 100644 --- a/examples/delegator/lib.rs +++ b/examples/delegator/lib.rs @@ -159,9 +159,8 @@ mod delegator { let get = build_message::(delegator_acc_id.clone()) .call(|contract| contract.get()); let value = client - .call(&ink_e2e::bob(), get, 0, None) + .call_dry_run(&ink_e2e::bob(), &get, 0, None) .await - .expect("calling `get` failed") .return_value(); assert_eq!(value, 1234); let change = build_message::(delegator_acc_id.clone()) @@ -175,9 +174,8 @@ mod delegator { let get = build_message::(delegator_acc_id.clone()) .call(|contract| contract.get()); let value = client - .call(&ink_e2e::bob(), get, 0, None) + .call_dry_run(&ink_e2e::bob(), &get, 0, None) .await - .expect("calling `get` failed") .return_value(); assert_eq!(value, 1234 + 6); @@ -199,9 +197,8 @@ mod delegator { let get = build_message::(delegator_acc_id.clone()) .call(|contract| contract.get()); let value = client - .call(&ink_e2e::bob(), get, 0, None) + .call_dry_run(&ink_e2e::bob(), &get, 0, None) .await - .expect("calling `get` failed") .return_value(); assert_eq!(value, 1234 + 6 - 3); diff --git a/examples/erc20/lib.rs b/examples/erc20/lib.rs index b83da3eff5..1e34d09d28 100644 --- a/examples/erc20/lib.rs +++ b/examples/erc20/lib.rs @@ -553,9 +553,8 @@ mod erc20 { let total_supply_msg = build_message::(contract_acc_id.clone()) .call(|erc20| erc20.total_supply()); let total_supply_res = client - .call(&ink_e2e::bob(), total_supply_msg, 0, None) - .await - .expect("total_supply failed"); + .call_dry_run(&ink_e2e::bob(), &total_supply_msg, 0, None) + .await; let bob_account = ink_e2e::account_id(ink_e2e::AccountKeyring::Bob); let transfer_to_bob = 500_000_000u128; @@ -569,9 +568,8 @@ mod erc20 { let balance_of = build_message::(contract_acc_id.clone()) .call(|erc20| erc20.balance_of(bob_account)); let balance_of_res = client - .call(&ink_e2e::alice(), balance_of, 0, None) - .await - .expect("balance_of failed"); + .call_dry_run(&ink_e2e::alice(), &balance_of, 0, None) + .await; // then assert_eq!( @@ -647,9 +645,8 @@ mod erc20 { let balance_of = build_message::(contract_acc_id.clone()) .call(|erc20| erc20.balance_of(bob_account)); let balance_of_res = client - .call(&ink_e2e::alice(), balance_of, 0, None) - .await - .expect("balance_of failed"); + .call_dry_run(&ink_e2e::alice(), &balance_of, 0, None) + .await; // `transfer_from` again, this time exceeding the approved amount let transfer_from = diff --git a/examples/flipper/lib.rs b/examples/flipper/lib.rs index 3525b8b633..9efc23bb78 100644 --- a/examples/flipper/lib.rs +++ b/examples/flipper/lib.rs @@ -71,10 +71,7 @@ pub mod flipper { let get = build_message::(contract_acc_id.clone()) .call(|flipper| flipper.get()); - let get_res = client - .call(&ink_e2e::bob(), get, 0, None) - .await - .expect("get failed"); + let get_res = client.call_dry_run(&ink_e2e::bob(), &get, 0, None).await; assert!(matches!(get_res.return_value(), false)); // when @@ -88,10 +85,7 @@ pub mod flipper { // then let get = build_message::(contract_acc_id.clone()) .call(|flipper| flipper.get()); - let get_res = client - .call(&ink_e2e::bob(), get, 0, None) - .await - .expect("get failed"); + let get_res = client.call_dry_run(&ink_e2e::bob(), &get, 0, None).await; assert!(matches!(get_res.return_value(), true)); Ok(()) @@ -112,10 +106,7 @@ pub mod flipper { // then let get = build_message::(contract_acc_id.clone()) .call(|flipper| flipper.get()); - let get_res = client - .call(&ink_e2e::bob(), get, 0, None) - .await - .expect("get failed"); + let get_res = client.call_dry_run(&ink_e2e::bob(), &get, 0, None).await; assert!(matches!(get_res.return_value(), false)); Ok(()) diff --git a/examples/lang-err-integration-tests/call-builder/lib.rs b/examples/lang-err-integration-tests/call-builder/lib.rs index 874138c29e..1d143fadec 100755 --- a/examples/lang-err-integration-tests/call-builder/lib.rs +++ b/examples/lang-err-integration-tests/call-builder/lib.rs @@ -193,10 +193,8 @@ mod call_builder { let flipper_get = build_message::(flipper_acc_id) .call(|contract| contract.get()); - let get_call_result = client - .call(&origin, flipper_get, 0, None) - .await - .expect("Calling `flipper::get` failed"); + let get_call_result = + client.call_dry_run(&origin, &flipper_get, 0, None).await; let initial_value = get_call_result.return_value(); let selector = ink::selector_bytes!("invalid_selector"); @@ -216,10 +214,8 @@ mod call_builder { let flipper_get = build_message::(flipper_acc_id) .call(|contract| contract.get()); - let get_call_result = client - .call(&origin, flipper_get, 0, None) - .await - .expect("Calling `flipper::get` failed"); + let get_call_result = + client.call_dry_run(&origin, &flipper_get, 0, None).await; let flipped_value = get_call_result.return_value(); assert!(flipped_value == initial_value); @@ -253,17 +249,12 @@ mod call_builder { let invalid_selector = [0x00, 0x00, 0x00, 0x00]; let call = build_message::(contract_acc_id) .call(|contract| contract.invoke(flipper_acc_id, invalid_selector)); - let call_result = client.call(&origin, call, 0, None).await; + let call_result = client.call_dry_run(&origin, &call, 0, None).await; assert!(call_result.is_err()); - let contains_err_msg = match call_result.unwrap_err() { - ink_e2e::Error::CallDryRun(dry_run) => { - String::from_utf8_lossy(&dry_run.debug_message) - .contains("Cross-contract call failed with CouldNotReadInput") - } - _ => false, - }; - assert!(contains_err_msg); + assert!(call_result + .debug_message() + .contains("Cross-contract call failed with CouldNotReadInput")); Ok(()) } @@ -378,18 +369,15 @@ mod call_builder { contract.call_instantiate(code_hash, selector, init_value) }); - let call_result = client.call(&origin, call, 0, None).await; + let call_result = client.call_dry_run(&origin, &call, 0, None).await; assert!( call_result.is_err(), "Call execution should've failed, but didn't." ); - let contains_err_msg = match call_result.unwrap_err() { - ink_e2e::Error::CallDryRun(dry_run) => { - String::from_utf8_lossy(&dry_run.debug_message) - .contains("The callee reverted, but did not encode an error in the output buffer.") - } - _ => false, - }; + let contains_err_msg = call_result.debug_message().contains( + "The callee reverted, but did not encode an error in the output buffer.", + ); + assert!( contains_err_msg, "Call execution failed for an unexpected reason." @@ -514,20 +502,16 @@ mod call_builder { build_message::(contract_acc_id).call(|contract| { contract.call_instantiate_fallible(code_hash, selector, init_value) }); - let call_result = client.call(&origin, call, 0, None).await; + let call_result = client.call_dry_run(&origin, &call, 0, None).await; assert!( call_result.is_err(), "Call execution should've failed, but didn't." ); - let contains_err_msg = match call_result.unwrap_err() { - ink_e2e::Error::CallDryRun(dry_run) => { - String::from_utf8_lossy(&dry_run.debug_message) - .contains("The callee reverted, but did not encode an error in the output buffer.") - } - _ => false, - }; + let contains_err_msg = call_result.debug_message().contains( + "The callee reverted, but did not encode an error in the output buffer.", + ); assert!( contains_err_msg, "Call execution failed for an unexpected reason." diff --git a/examples/lang-err-integration-tests/constructors-return-value/lib.rs b/examples/lang-err-integration-tests/constructors-return-value/lib.rs index 111b1daa2c..c25fa6e1a5 100644 --- a/examples/lang-err-integration-tests/constructors-return-value/lib.rs +++ b/examples/lang-err-integration-tests/constructors-return-value/lib.rs @@ -213,9 +213,8 @@ pub mod constructors_return_value { ink_e2e::build_message::(contract_acc_id) .call(|contract| contract.get_value()); let value = client - .call(&ink_e2e::bob(), get, 0, None) + .call_dry_run(&ink_e2e::bob(), &get, 0, None) .await - .expect("Calling `get_value` failed") .return_value(); assert_eq!( diff --git a/examples/lang-err-integration-tests/contract-ref/lib.rs b/examples/lang-err-integration-tests/contract-ref/lib.rs index 20ec210c87..963722d79d 100755 --- a/examples/lang-err-integration-tests/contract-ref/lib.rs +++ b/examples/lang-err-integration-tests/contract-ref/lib.rs @@ -92,9 +92,9 @@ mod contract_ref { let get_check = build_message::(contract_acc_id.clone()) .call(|contract| contract.get_check()); let get_call_result = client - .call(&ink_e2e::alice(), get_check, 0, None) - .await - .expect("Calling `get_check` failed"); + .call_dry_run(&ink_e2e::alice(), &get_check, 0, None) + .await; + let initial_value = get_call_result.return_value(); let flip_check = build_message::(contract_acc_id.clone()) @@ -104,16 +104,13 @@ mod contract_ref { .await .expect("Calling `flip` failed"); assert!( - flip_call_result.value.is_ok(), + flip_call_result.message_result().is_ok(), "Messages now return a `Result`, which should be `Ok` here." ); - let get_check = build_message::(contract_acc_id.clone()) - .call(|contract| contract.get_check()); let get_call_result = client - .call(&ink_e2e::alice(), get_check, 0, None) - .await - .expect("Calling `get_check` failed"); + .call_dry_run(&ink_e2e::alice(), &get_check, 0, None) + .await; let flipped_value = get_call_result.return_value(); assert!(flipped_value != initial_value); @@ -141,10 +138,10 @@ mod contract_ref { let get_check = build_message::(contract_acc_id.clone()) .call(|contract| contract.get_check()); let get_call_result = client - .call(&ink_e2e::bob(), get_check, 0, None) - .await - .expect("Calling `get_check` failed"); + .call_dry_run(&ink_e2e::bob(), &get_check, 0, None) + .await; let initial_value = get_call_result.return_value(); + assert!(initial_value); Ok(()) diff --git a/examples/lang-err-integration-tests/integration-flipper/lib.rs b/examples/lang-err-integration-tests/integration-flipper/lib.rs index 1a9eeaf70f..2a7b12d7d5 100644 --- a/examples/lang-err-integration-tests/integration-flipper/lib.rs +++ b/examples/lang-err-integration-tests/integration-flipper/lib.rs @@ -88,11 +88,10 @@ pub mod integration_flipper { let get = build_message::(contract_acc_id.clone()) .call(|contract| contract.get()); - let get_call_result = client - .call(&ink_e2e::alice(), get, 0, None) + let initial_value = client + .call_dry_run(&ink_e2e::alice(), &get, 0, None) .await - .expect("Calling `get` failed"); - let initial_value = get_call_result.return_value(); + .return_value(); let flip = build_message::(contract_acc_id) .call(|contract| contract.flip()); @@ -101,17 +100,14 @@ pub mod integration_flipper { .await .expect("Calling `flip` failed"); assert!( - flip_call_result.value.is_ok(), + flip_call_result.message_result().is_ok(), "Messages now return a `Result`, which should be `Ok` here." ); - let get = build_message::(contract_acc_id.clone()) - .call(|contract| contract.get()); - let get_call_result = client - .call(&ink_e2e::alice(), get, 0, None) + let flipped_value = client + .call_dry_run(&ink_e2e::alice(), &get, 0, None) .await - .expect("Calling `get` failed"); - let flipped_value = get_call_result.return_value(); + .return_value(); assert!(flipped_value != initial_value); Ok(()) @@ -130,11 +126,10 @@ pub mod integration_flipper { let get = build_message::(contract_acc_id.clone()) .call(|contract| contract.get()); - let get_call_result = client - .call(&ink_e2e::bob(), get, 0, None) + let initial_value = client + .call_dry_run(&ink_e2e::bob(), &get, 0, None) .await - .expect("Calling `get` failed"); - let initial_value = get_call_result.return_value(); + .return_value(); let err_flip = build_message::(contract_acc_id) .call(|contract| contract.err_flip()); @@ -146,13 +141,10 @@ pub mod integration_flipper { Err(ink_e2e::Error::CallExtrinsic(_)) )); - let get = build_message::(contract_acc_id.clone()) - .call(|contract| contract.get()); - let get_call_result = client - .call(&ink_e2e::bob(), get, 0, None) + let flipped_value = client + .call_dry_run(&ink_e2e::bob(), &get, 0, None) .await - .expect("Calling `get` failed"); - let flipped_value = get_call_result.return_value(); + .return_value(); assert!(flipped_value == initial_value); Ok(()) diff --git a/examples/mapping_integration_tests/lib.rs b/examples/mapping_integration_tests/lib.rs index 515bb5cedd..cc2bf52787 100755 --- a/examples/mapping_integration_tests/lib.rs +++ b/examples/mapping_integration_tests/lib.rs @@ -115,20 +115,15 @@ mod mapping_integration_tests { .call(&ink_e2e::alice(), insert, 0, None) .await .expect("Calling `insert_balance` failed") - .value - .expect("Input is valid, call must not fail.") - .expect("Execution should not fail."); + .return_value(); // then let get = ink_e2e::build_message::(contract_id) .call(|contract| contract.get_balance()); let balance = client - .call(&ink_e2e::alice(), get, 0, None) + .call_dry_run(&ink_e2e::alice(), &get, 0, None) .await - .expect("Calling `get_balance` failed") - .value - .expect("Input is valid, call must not fail.") - .expect("Execution should not fail."); + .return_value(); assert!(size.is_none()); assert_eq!(balance, Some(1_000)); @@ -161,19 +156,15 @@ mod mapping_integration_tests { .call(&ink_e2e::bob(), insert, 0, None) .await .expect("Calling `insert_balance` failed") - .value - .expect("Input is valid, call must not fail."); + .return_value(); // then let contains = ink_e2e::build_message::(contract_id) .call(|contract| contract.contains_balance()); let is_there = client - .call(&ink_e2e::bob(), contains, 0, None) + .call_dry_run(&ink_e2e::bob(), &contains, 0, None) .await - .expect("Calling `contains_balance` failed") - .value - .expect("Input is valid, call must not fail.") - .expect("Execution should not fail."); + .return_value(); assert!(is_there); @@ -203,8 +194,7 @@ mod mapping_integration_tests { .call(&ink_e2e::charlie(), first_insert, 0, None) .await .expect("Calling `insert_balance` failed") - .value - .expect("Input is valid, call must not fail."); + .return_value(); let insert = ink_e2e::build_message::(contract_id) .call(|contract| contract.insert_balance(10_000)); @@ -212,9 +202,7 @@ mod mapping_integration_tests { .call(&ink_e2e::charlie(), insert, 0, None) .await .expect("Calling `insert_balance` failed") - .value - .expect("Input is valid, call must not fail.") - .expect("Execution should not fail."); + .return_value(); // then assert!(size.is_some()); @@ -222,12 +210,9 @@ mod mapping_integration_tests { let get = ink_e2e::build_message::(contract_id) .call(|contract| contract.get_balance()); let balance = client - .call(&ink_e2e::charlie(), get, 0, None) + .call_dry_run(&ink_e2e::charlie(), &get, 0, None) .await - .expect("Calling `get_balance` failed") - .value - .expect("Input is valid, call must not fail.") - .expect("Execution should not fail."); + .return_value(); assert_eq!(balance, Some(10_000)); @@ -259,9 +244,7 @@ mod mapping_integration_tests { .call(&ink_e2e::dave(), insert, 0, None) .await .expect("Calling `insert_balance` failed") - .value - .expect("Input is valid, call must not fail.") - .expect("Execution should not fail."); + .return_value(); let remove = ink_e2e::build_message::(contract_id) .call(|contract| contract.remove_balance()); @@ -274,12 +257,9 @@ mod mapping_integration_tests { let get = ink_e2e::build_message::(contract_id) .call(|contract| contract.get_balance()); let balance = client - .call(&ink_e2e::dave(), get, 0, None) + .call_dry_run(&ink_e2e::dave(), &get, 0, None) .await - .expect("Calling `get_balance` failed") - .value - .expect("Input is valid, call must not fail.") - .expect("Execution should not fail."); + .return_value(); assert_eq!(balance, None); @@ -311,8 +291,7 @@ mod mapping_integration_tests { .call(&ink_e2e::eve(), insert, 0, None) .await .expect("Calling `insert_balance` failed") - .value - .expect("Input is valid, call must not fail."); + .return_value(); let take = ink_e2e::build_message::(contract_id) .call(|contract| contract.take_balance()); @@ -320,9 +299,7 @@ mod mapping_integration_tests { .call(&ink_e2e::eve(), take, 0, None) .await .expect("Calling `take_balance` failed") - .value - .expect("Input is valid, call must not fail.") - .expect("Execution should not fail."); + .return_value(); // then assert_eq!(balance, Some(4_000)); @@ -330,12 +307,9 @@ mod mapping_integration_tests { let contains = ink_e2e::build_message::(contract_id) .call(|contract| contract.contains_balance()); let is_there = client - .call(&ink_e2e::eve(), contains, 0, None) + .call_dry_run(&ink_e2e::eve(), &contains, 0, None) .await - .expect("Calling `contains_balance` failed") - .value - .expect("Input is valid, call must not fail.") - .expect("Execution should not fail."); + .return_value(); assert!(!is_there);