diff --git a/crates/e2e/macro/src/config.rs b/crates/e2e/macro/src/config.rs index 1c4da1bdf84..f84486df0b1 100644 --- a/crates/e2e/macro/src/config.rs +++ b/crates/e2e/macro/src/config.rs @@ -55,7 +55,7 @@ impl TryFrom for E2EConfig { return Err(format_err_spanned!( arg, "expected a string literal for `additional_contracts` ink! E2E test configuration argument", - )) + )); } } else if arg.name.is_ident("environment") { if let Some((_, ast)) = environment { @@ -67,7 +67,7 @@ impl TryFrom for E2EConfig { return Err(format_err_spanned!( arg, "expected a path for `environment` ink! E2E test configuration argument", - )) + )); } } else { return Err(format_err_spanned!( diff --git a/crates/e2e/src/client.rs b/crates/e2e/src/client.rs index c8bf879cee2..8c221c7f43d 100644 --- a/crates/e2e/src/client.rs +++ b/crates/e2e/src/client.rs @@ -20,13 +20,16 @@ use super::{ log_error, log_info, sr25519, - CodeUploadResult, - ContractExecResult, ContractInstantiateResult, ContractsApi, Signer, }; -use ink::codegen::ContractCallBuilder; +use crate::contract_results::{ + CallDryRunResult, + CallResult, + InstantiationResult, + UploadResult, +}; use ink_env::{ call::{ utils::{ @@ -35,18 +38,14 @@ use ink_env::{ }, Call, ExecutionInput, - FromAccountId, }, Environment, }; -use ink_primitives::MessageResult; -use pallet_contracts_primitives::ExecReturnValue; use sp_core::Pair; #[cfg(feature = "std")] use std::{ collections::BTreeMap, fmt::Debug, - marker::PhantomData, path::PathBuf, }; @@ -64,9 +63,15 @@ use subxt::{ }, }, tx::PairSigner, - Config, }; +pub type Error = crate::error::Error< + ::AccountId, + ::Balance, + ::Hash, + subxt::error::DispatchError, +>; + /// Represents an initialized contract message builder. pub type CallBuilderFinal = ink_env::call::CallBuilder< E, @@ -75,286 +80,6 @@ pub type CallBuilderFinal = ink_env::call::CallBuilder< Set>, >; -/// Result of a contract instantiation. -pub struct InstantiationResult { - /// The account id at which the contract was instantiated. - pub account_id: E::AccountId, - /// The result of the dry run, contains debug messages - /// if there were any. - pub dry_run: ContractInstantiateResult, - /// Events that happened with the contract instantiation. - pub events: ExtrinsicEvents, -} - -impl InstantiationResult -where - C: subxt::Config, - E: Environment, -{ - pub fn call(&self) -> ::Type - where - Contract: ContractCallBuilder, - ::Type: FromAccountId, - { - <::Type as FromAccountId>::from_account_id( - self.account_id.clone(), - ) - } -} - -/// Result of a contract upload. -pub struct UploadResult { - /// The hash with which the contract can be instantiated. - pub code_hash: E::Hash, - /// The result of the dry run, contains debug messages - /// if there were any. - pub dry_run: CodeUploadResult, - /// Events that happened with the contract instantiation. - pub events: ExtrinsicEvents, -} - -/// We implement a custom `Debug` here, to avoid requiring the trait -/// bound `Debug` for `E`. -impl Debug for UploadResult -where - C: subxt::Config, - E: Environment, - ::Balance: Debug, - ::Hash: Debug, -{ - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { - f.debug_struct("UploadResult") - .field("code_hash", &self.code_hash) - .field("dry_run", &self.dry_run) - .field("events", &self.events) - .finish() - } -} - -/// We implement a custom `Debug` here, as to avoid requiring the trait -/// bound `Debug` for `E`. -impl core::fmt::Debug for InstantiationResult -where - C: subxt::Config, - C::AccountId: Debug, - E: Environment, - ::AccountId: Debug, - ::Balance: Debug, -{ - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { - f.debug_struct("InstantiationResult") - .field("account_id", &self.account_id) - .field("dry_run", &self.dry_run) - .field("events", &self.events) - .finish() - } -} - -/// Result of a contract call. -pub struct CallResult { - /// The result of the dry run, contains debug messages - /// if there were any. - pub dry_run: CallDryRunResult, - /// Events that happened with the contract instantiation. - pub events: ExtrinsicEvents, -} - -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 [`CallResult::return_data`]. - pub fn return_value(self) -> V { - 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. - pub fn contains_event(&self, pallet_name: &str, variant_name: &str) -> bool { - self.events.iter().any(|event| { - let event = event.unwrap(); - event.pallet_name() == pallet_name && event.variant_name() == variant_name - }) - } -} - -/// We implement a custom `Debug` here, as to avoid requiring the trait -/// bound `Debug` for `E`. -// TODO(#xxx) Improve the `Debug` implementation. -impl Debug for CallResult -where - 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") - .field("dry_run", &self.dry_run) - .field("events", &self.events) - .finish() - } -} - -/// 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 -/// testing logic. For anything concerning the node (like inability -/// to communicate with it, fetch the nonce, account info, etc.) we -/// panic. -pub enum Error -where - C: subxt::Config, - E: Environment, - ::Balance: core::fmt::Debug, -{ - /// No contract with the given name found in scope. - ContractNotFound(String), - /// The `instantiate_with_code` dry run failed. - InstantiateDryRun(ContractInstantiateResult), - /// The `instantiate_with_code` extrinsic failed. - InstantiateExtrinsic(subxt::error::DispatchError), - /// The `upload` dry run failed. - UploadDryRun(CodeUploadResult), - /// The `upload` extrinsic failed. - UploadExtrinsic(subxt::error::DispatchError), - /// The `call` dry run failed. - CallDryRun(ContractExecResult), - /// The `call` extrinsic failed. - CallExtrinsic(subxt::error::DispatchError), - /// Error fetching account balance. - Balance(String), - /// Decoding failed. - Decoding(subxt::Error), -} - -// We implement a custom `Debug` here, as to avoid requiring the trait -// bound `Debug` for `C`. -// TODO(#xxx) Improve the Debug implementations below to also output `_`. -impl core::fmt::Debug for Error -where - C: subxt::Config, - E: Environment, - ::Balance: core::fmt::Debug, -{ - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { - match &self { - Error::ContractNotFound(name) => { - f.write_str(&format!("ContractNotFound: {name}")) - } - Error::InstantiateDryRun(res) => { - f.write_str(&format!( - "InstantiateDryRun: {}", - &String::from_utf8_lossy(&res.debug_message) - )) - } - Error::InstantiateExtrinsic(_) => f.write_str("InstantiateExtrinsic"), - Error::UploadDryRun(_) => f.write_str("UploadDryRun"), - Error::UploadExtrinsic(_) => f.write_str("UploadExtrinsic"), - Error::CallDryRun(_) => f.write_str("CallDryRun"), - Error::CallExtrinsic(_) => f.write_str("CallExtrinsic"), - Error::Balance(msg) => write!(f, "Balance: {msg}"), - Error::Decoding(err) => write!(f, "Decoding: {err}"), - } - } -} - /// A contract was successfully instantiated. #[derive( Debug, @@ -508,7 +233,7 @@ where constructor: CreateBuilderPartial, value: E::Balance, storage_deposit_limit: Option, - ) -> Result, Error> + ) -> Result>, Error> where Args: scale::Encode, { @@ -534,7 +259,7 @@ where constructor: CreateBuilderPartial, value: E::Balance, storage_deposit_limit: Option, - ) -> ContractInstantiateResult + ) -> ContractInstantiateResult where Args: scale::Encode, { @@ -582,7 +307,7 @@ where constructor: CreateBuilderPartial, value: E::Balance, storage_deposit_limit: Option, - ) -> Result, Error> + ) -> Result>, Error> where Args: scale::Encode, { @@ -607,7 +332,7 @@ where )); log_info(&format!("instantiate dry run result: {:?}", dry_run.result)); if dry_run.result.is_err() { - return Err(Error::InstantiateDryRun(dry_run)) + return Err(Error::::InstantiateDryRun(dry_run)) } let tx_events = self @@ -648,11 +373,11 @@ where let metadata = self.api.client.metadata(); let dispatch_error = subxt::error::DispatchError::decode_from(evt.field_bytes(), metadata) - .map_err(Error::Decoding)?; + .map_err(|e| Error::::Decoding(e.to_string()))?; log_error(&format!( "extrinsic for instantiate failed: {dispatch_error}" )); - return Err(Error::InstantiateExtrinsic(dispatch_error)) + return Err(Error::::InstantiateExtrinsic(dispatch_error)) } } let account_id = account_id.expect("cannot extract `account_id` from events"); @@ -691,7 +416,7 @@ where contract_name: &str, signer: &Signer, storage_deposit_limit: Option, - ) -> Result, Error> { + ) -> Result>, Error> { let code = self.load_code(contract_name); let ret = self .exec_upload(signer, code, storage_deposit_limit) @@ -706,7 +431,7 @@ where signer: &Signer, code: Vec, storage_deposit_limit: Option, - ) -> Result, Error> { + ) -> Result>, Error> { // dry run the instantiate to calculate the gas limit let dry_run = self .api @@ -714,7 +439,7 @@ where .await; log_info(&format!("upload dry run: {dry_run:?}")); if dry_run.is_err() { - return Err(Error::UploadDryRun(dry_run)) + return Err(Error::::UploadDryRun(dry_run)) } let tx_events = self.api.upload(signer, code, storage_deposit_limit).await; @@ -740,10 +465,10 @@ where let metadata = self.api.client.metadata(); let dispatch_error = subxt::error::DispatchError::decode_from(evt.field_bytes(), metadata) - .map_err(Error::Decoding)?; + .map_err(|e| Error::::Decoding(e.to_string()))?; log_error(&format!("extrinsic for upload failed: {dispatch_error}")); - return Err(Error::UploadExtrinsic(dispatch_error)) + return Err(Error::::UploadExtrinsic(dispatch_error)) } } @@ -778,7 +503,7 @@ where message: &CallBuilderFinal, value: E::Balance, storage_deposit_limit: Option, - ) -> Result, Error> + ) -> Result>, Error> where Args: scale::Encode, RetType: scale::Decode, @@ -791,7 +516,7 @@ where 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)) + return Err(Error::::CallDryRun(dry_run.exec_result)) } let tx_events = self @@ -815,9 +540,9 @@ where let metadata = self.api.client.metadata(); let dispatch_error = subxt::error::DispatchError::decode_from(evt.field_bytes(), metadata) - .map_err(Error::Decoding)?; + .map_err(|e| Error::::Decoding(e.to_string()))?; log_error(&format!("extrinsic for call failed: {dispatch_error}")); - return Err(Error::CallExtrinsic(dispatch_error)) + return Err(Error::::CallExtrinsic(dispatch_error)) } } @@ -844,7 +569,7 @@ where pallet_name: &'a str, call_name: &'a str, call_data: Vec, - ) -> Result, Error> { + ) -> Result, Error> { let tx_events = self .api .runtime_call(signer, pallet_name, call_name, call_data) @@ -859,10 +584,10 @@ where let metadata = self.api.client.metadata(); let dispatch_error = subxt::error::DispatchError::decode_from(evt.field_bytes(), metadata) - .map_err(Error::Decoding)?; + .map_err(|e| Error::::Decoding(e.to_string()))?; log_error(&format!("extrinsic for call failed: {dispatch_error}")); - return Err(Error::CallExtrinsic(dispatch_error)) + return Err(Error::::CallExtrinsic(dispatch_error)) } } @@ -911,10 +636,7 @@ where } /// Returns the balance of `account_id`. - pub async fn balance( - &self, - account_id: E::AccountId, - ) -> Result> + pub async fn balance(&self, account_id: E::AccountId) -> Result> where E::Balance: TryFrom, { @@ -947,13 +669,13 @@ where panic!("unable to decode account info: {err:?}"); }); - let account_data = get_composite_field_value(&account, "data")?; - let balance = get_composite_field_value(account_data, "free")?; + let account_data = get_composite_field_value::<_, E>(&account, "data")?; + let balance = get_composite_field_value::<_, E>(account_data, "free")?; let balance = balance.as_u128().ok_or_else(|| { - Error::Balance(format!("{balance:?} should convert to u128")) + Error::::Balance(format!("{balance:?} should convert to u128")) })?; let balance = E::Balance::try_from(balance).map_err(|_| { - Error::Balance(format!("{balance:?} failed to convert from u128")) + Error::::Balance(format!("{balance:?} failed to convert from u128")) })?; log_info(&format!( @@ -968,12 +690,11 @@ where /// Returns `Err` if: /// - The value is not a [`Value::Composite`] with [`Composite::Named`] fields /// - The value does not contain a field with the given name. -fn get_composite_field_value<'a, T, C, E>( +fn get_composite_field_value<'a, T, E>( value: &'a Value, field_name: &str, -) -> Result<&'a Value, Error> +) -> Result<&'a Value, Error> where - C: subxt::Config, E: Environment, E::Balance: Debug, { @@ -982,17 +703,27 @@ where .iter() .find(|(name, _)| name == field_name) .ok_or_else(|| { - Error::Balance(format!("No field named '{field_name}' found")) + Error::::Balance(format!("No field named '{field_name}' found")) })?; Ok(field) } else { - Err(Error::Balance( + Err(Error::::Balance( "Expected a composite type with named fields".into(), )) } } /// Returns true if the give event is System::Extrinsic failed. -fn is_extrinsic_failed_event(event: &EventDetails) -> bool { +fn is_extrinsic_failed_event(event: &EventDetails) -> bool { event.pallet_name() == "System" && event.variant_name() == "ExtrinsicFailed" } + +impl CallResult> { + /// Returns true if the specified event was triggered by the call. + pub fn contains_event(&self, pallet_name: &str, variant_name: &str) -> bool { + self.events.iter().any(|event| { + let event = event.unwrap(); + event.pallet_name() == pallet_name && event.variant_name() == variant_name + }) + } +} diff --git a/crates/e2e/src/contract_results.rs b/crates/e2e/src/contract_results.rs new file mode 100644 index 00000000000..982691163f0 --- /dev/null +++ b/crates/e2e/src/contract_results.rs @@ -0,0 +1,204 @@ +use ink::codegen::ContractCallBuilder; +use ink_env::{ + call::FromAccountId, + Environment, +}; +use ink_primitives::MessageResult; +use pallet_contracts_primitives::{ + CodeUploadResult, + ContractExecResult, + ContractInstantiateResult, + ExecReturnValue, +}; +use std::{ + fmt::Debug, + marker::PhantomData, +}; + +/// Result of a contract instantiation. +pub struct InstantiationResult { + /// The account id at which the contract was instantiated. + pub account_id: E::AccountId, + /// The result of the dry run, contains debug messages + /// if there were any. + pub dry_run: ContractInstantiateResult, + /// Events that happened with the contract instantiation. + pub events: EventLog, +} + +impl InstantiationResult { + /// Returns the account id at which the contract was instantiated. + pub fn call(&self) -> ::Type + where + Contract: ContractCallBuilder, + Contract::Type: FromAccountId, + { + <::Type as FromAccountId>::from_account_id( + self.account_id.clone(), + ) + } +} + +/// We implement a custom `Debug` here, as to avoid requiring the trait bound `Debug` for +/// `E`. +impl Debug for InstantiationResult +where + E::AccountId: Debug, + E::Balance: Debug, + EventLog: Debug, +{ + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + f.debug_struct("InstantiationResult") + .field("account_id", &self.account_id) + .field("dry_run", &self.dry_run) + .field("events", &self.events) + .finish() + } +} + +/// Result of a contract upload. +pub struct UploadResult { + /// The hash with which the contract can be instantiated. + pub code_hash: E::Hash, + /// The result of the dry run, contains debug messages if there were any. + pub dry_run: CodeUploadResult, + /// Events that happened with the contract instantiation. + pub events: EventLog, +} + +/// We implement a custom `Debug` here, to avoid requiring the trait bound `Debug` for +/// `E`. +impl Debug for UploadResult +where + E::Balance: Debug, + E::Hash: Debug, + EventLog: Debug, +{ + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + f.debug_struct("UploadResult") + .field("code_hash", &self.code_hash) + .field("dry_run", &self.dry_run) + .field("events", &self.events) + .finish() + } +} + +/// Result of a contract call. +pub struct CallResult { + /// The result of the dry run, contains debug messages if there were any. + pub dry_run: CallDryRunResult, + /// Events that happened with the contract instantiation. + pub events: EventLog, +} + +impl CallResult { + /// 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 [`CallResult::return_data`]. + pub fn return_value(self) -> V { + 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() + } +} + +// TODO(#xxx) Improve the `Debug` implementation. +impl Debug for CallResult +where + E: Debug, + E::Balance: Debug, + V: Debug, + EventLog: Debug, +{ + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + f.debug_struct("CallResult") + .field("dry_run", &self.dry_run) + .field("events", &self.events) + .finish() + } +} + +/// 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, + pub _marker: PhantomData, +} + +impl CallDryRunResult { + /// 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() + } +} diff --git a/crates/e2e/src/error.rs b/crates/e2e/src/error.rs new file mode 100644 index 00000000000..e3242d99a57 --- /dev/null +++ b/crates/e2e/src/error.rs @@ -0,0 +1,32 @@ +use pallet_contracts_primitives::{ + CodeUploadResult, + ContractExecResult, + ContractInstantiateResult, +}; + +/// An error occurred while interacting with the E2E backend. +/// +/// We only convey errors here that are caused by the contract's testing logic. For +/// anything concerning the execution environment (like inability to communicate with node +/// or runtime, fetch the nonce, account info, etc.) we panic. +#[derive(Debug)] +pub enum Error { + /// No contract with the given name found in scope. + ContractNotFound(String), + /// The `instantiate_with_code` dry run failed. + InstantiateDryRun(ContractInstantiateResult), + /// The `instantiate_with_code` extrinsic failed. + InstantiateExtrinsic(DispatchError), + /// The `upload` dry run failed. + UploadDryRun(CodeUploadResult), + /// The `upload` extrinsic failed. + UploadExtrinsic(DispatchError), + /// The `call` dry run failed. + CallDryRun(ContractExecResult), + /// The `call` extrinsic failed. + CallExtrinsic(DispatchError), + /// Error fetching account balance. + Balance(String), + /// Decoding failed. + Decoding(String), +} diff --git a/crates/e2e/src/lib.rs b/crates/e2e/src/lib.rs index 76e5641ffd1..795c3411cc4 100644 --- a/crates/e2e/src/lib.rs +++ b/crates/e2e/src/lib.rs @@ -21,16 +21,20 @@ mod builders; mod client; +mod contract_results; mod default_accounts; +mod error; mod node_proc; mod xts; pub use client::{ CallBuilderFinal, - CallDryRunResult, - CallResult, Client, Error, +}; +pub use contract_results::{ + CallDryRunResult, + CallResult, InstantiationResult, UploadResult, }; @@ -50,7 +54,6 @@ pub use tokio; pub use tracing_subscriber; use pallet_contracts_primitives::{ - CodeUploadResult, ContractExecResult, ContractInstantiateResult, }; diff --git a/crates/e2e/src/xts.rs b/crates/e2e/src/xts.rs index fc2463227db..49e9245dbd2 100644 --- a/crates/e2e/src/xts.rs +++ b/crates/e2e/src/xts.rs @@ -267,7 +267,7 @@ where data: Vec, salt: Vec, signer: &Signer, - ) -> ContractInstantiateResult { + ) -> ContractInstantiateResult { let code = Code::Upload(code); let call_request = RpcInstantiateRequest:: { origin: subxt::tx::Signer::account_id(signer).clone(), diff --git a/crates/ink/ir/src/ir/item_mod.rs b/crates/ink/ir/src/ir/item_mod.rs index 5d70a43bb28..9e60e6d02a4 100644 --- a/crates/ink/ir/src/ir/item_mod.rs +++ b/crates/ink/ir/src/ir/item_mod.rs @@ -316,7 +316,7 @@ impl ItemMod { message.callable().span(), "encountered ink! message with wildcard complement `selector = @` but no \ wildcard `selector = _` defined" - )) + )); } } } diff --git a/crates/ink/ir/src/ir/trait_def/item/mod.rs b/crates/ink/ir/src/ir/trait_def/item/mod.rs index 69b8f95b266..6297a20acc9 100644 --- a/crates/ink/ir/src/ir/trait_def/item/mod.rs +++ b/crates/ink/ir/src/ir/trait_def/item/mod.rs @@ -384,7 +384,7 @@ impl InkItemTrait { ).into_combine(format_err_spanned!( duplicate_selector, "first ink! trait constructor or message with same selector found here", - ))) + ))); } assert!( duplicate_ident.is_none(), diff --git a/integration-tests/contract-transfer/lib.rs b/integration-tests/contract-transfer/lib.rs index 1e403697a25..2dc444bd486 100644 --- a/integration-tests/contract-transfer/lib.rs +++ b/integration-tests/contract-transfer/lib.rs @@ -208,7 +208,10 @@ pub mod give_me { let call_res = client.call(&ink_e2e::bob(), &transfer, 10, None).await; // then - if let Err(ink_e2e::Error::CallDryRun(dry_run)) = call_res { + 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 { diff --git a/integration-tests/lang-err-integration-tests/constructors-return-value/lib.rs b/integration-tests/lang-err-integration-tests/constructors-return-value/lib.rs index 0242694b625..5d7d2d62b9e 100644 --- a/integration-tests/lang-err-integration-tests/constructors-return-value/lib.rs +++ b/integration-tests/lang-err-integration-tests/constructors-return-value/lib.rs @@ -259,7 +259,7 @@ pub mod constructors_return_value { .await; assert!( - matches!(result, Err(ink_e2e::Error::InstantiateExtrinsic(_))), + matches!(result, Err(ink_e2e::Error::::InstantiateExtrinsic(_))), "Constructor should fail" ); diff --git a/integration-tests/lang-err-integration-tests/contract-ref/lib.rs b/integration-tests/lang-err-integration-tests/contract-ref/lib.rs index 55c6a4652e2..6c070d7bd28 100755 --- a/integration-tests/lang-err-integration-tests/contract-ref/lib.rs +++ b/integration-tests/lang-err-integration-tests/contract-ref/lib.rs @@ -165,7 +165,7 @@ mod contract_ref { ); let contains_err_msg = match instantiate_result.unwrap_err() { - ink_e2e::Error::InstantiateDryRun(dry_run) => { + ink_e2e::Error::::InstantiateDryRun(dry_run) => { String::from_utf8_lossy(&dry_run.debug_message).contains( "Received an error from the Flipper constructor while instantiating Flipper FlipperError" ) diff --git a/integration-tests/lang-err-integration-tests/integration-flipper/lib.rs b/integration-tests/lang-err-integration-tests/integration-flipper/lib.rs index 9d05434c555..dceb8ea1da4 100644 --- a/integration-tests/lang-err-integration-tests/integration-flipper/lib.rs +++ b/integration-tests/lang-err-integration-tests/integration-flipper/lib.rs @@ -134,7 +134,7 @@ pub mod integration_flipper { assert!(matches!( err_flip_call_result, - Err(ink_e2e::Error::CallExtrinsic(_)) + Err(ink_e2e::Error::::CallExtrinsic(_)) )); let flipped_value = client