diff --git a/crates/e2e/macro/src/codegen.rs b/crates/e2e/macro/src/codegen.rs index b2c26c2379..8918ec981e 100644 --- a/crates/e2e/macro/src/codegen.rs +++ b/crates/e2e/macro/src/codegen.rs @@ -293,7 +293,7 @@ fn build_contract(path_to_cargo_toml: &str) -> String { output_type: OutputType::HumanReadable, skip_wasm_validation: false, target: Target::Wasm, - ..ExecuteArgs::default() + ..Default::default() }; match contract_build::execute(args) { diff --git a/crates/e2e/src/backend.rs b/crates/e2e/src/backend.rs new file mode 100644 index 0000000000..c334f9c298 --- /dev/null +++ b/crates/e2e/src/backend.rs @@ -0,0 +1,155 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use crate::{ + builders::CreateBuilderPartial, + CallBuilderFinal, + CallDryRunResult, + CallResult, + InstantiationResult, + UploadResult, +}; +use ink_env::Environment; +use jsonrpsee::core::async_trait; +use pallet_contracts_primitives::ContractInstantiateResult; +use subxt::dynamic::Value; + +/// Full E2E testing backend: combines general chain API and contract-specific operations. +#[async_trait] +pub trait E2EBackend: ChainBackend + ContractsBackend {} + +/// General chain operations useful in contract testing. +#[async_trait] +pub trait ChainBackend { + /// Abstract type representing the entity that interacts with the chain. + type Actor: Send; + /// Identifier type for an actor. + type ActorId; + /// Balance type. + type Balance: Send; + /// Error type. + type Error; + /// Event log type. + type EventLog; + + /// Generate a new actor's credentials and fund it with the given amount from the + /// `sender` actor. + async fn create_and_fund_account( + &mut self, + origin: &Self::Actor, + amount: Self::Balance, + ) -> Self::Actor; + + /// Returns the balance of `actor`. + async fn balance(&self, actor: Self::ActorId) -> Result; + + /// Executes a runtime call `call_name` for the `pallet_name`. + /// The `call_data` is a `Vec`. + /// + /// Note: + /// - `pallet_name` must be in camel case, for example `Balances`. + /// - `call_name` must be snake case, for example `force_transfer`. + /// - `call_data` is a `Vec` that holds a representation of + /// some value. + /// + /// Returns when the transaction is included in a block. The return value contains all + /// events that are associated with this transaction. + async fn runtime_call<'a>( + &mut self, + actor: &Self::Actor, + pallet_name: &'a str, + call_name: &'a str, + call_data: Vec, + ) -> Result; +} + +/// Contract-specific operations. +#[async_trait] +pub trait ContractsBackend { + /// Abstract type representing the entity that interacts with the chain. + type Actor; + /// Error type. + type Error; + /// Event log type. + type EventLog; + + /// The function subsequently uploads and instantiates an instance of the contract. + /// + /// This function extracts the metadata of the contract at the file path + /// `target/ink/$contract_name.contract`. + /// + /// Calling this function multiple times should be idempotent, the contract is + /// newly instantiated each time using a unique salt. No existing contract + /// instance is reused! + async fn instantiate( + &mut self, + contract_name: &str, + caller: &Self::Actor, + constructor: CreateBuilderPartial, + value: E::Balance, + storage_deposit_limit: Option, + ) -> Result, Self::Error>; + + /// Dry run contract instantiation. + async fn instantiate_dry_run( + &mut self, + contract_name: &str, + caller: &Self::Actor, + constructor: CreateBuilderPartial, + value: E::Balance, + storage_deposit_limit: Option, + ) -> ContractInstantiateResult; + + /// The function subsequently uploads and instantiates an instance of the contract. + /// + /// This function extracts the Wasm of the contract for the specified contract. + /// + /// Calling this function multiple times should be idempotent, the contract is + /// newly instantiated each time using a unique salt. No existing contract + /// instance is reused! + async fn upload( + &mut self, + contract_name: &str, + caller: &Self::Actor, + storage_deposit_limit: Option, + ) -> Result, Self::Error>; + + /// Executes a `call` for the contract at `account_id`. + /// + /// Returns when the transaction is included in a block. The return value + /// contains all events that are associated with this transaction. + async fn call( + &mut self, + caller: &Self::Actor, + message: &CallBuilderFinal, + value: E::Balance, + storage_deposit_limit: Option, + ) -> Result, Self::Error> + where + CallBuilderFinal: Clone; + + /// Executes a dry-run `call`. + /// + /// Returns the result of the dry run, together with the decoded return value of the + /// invoked message. + async fn call_dry_run( + &mut self, + caller: &Self::Actor, + message: &CallBuilderFinal, + value: E::Balance, + storage_deposit_limit: Option, + ) -> CallDryRunResult + where + CallBuilderFinal: Clone; +} diff --git a/crates/e2e/src/contract_results.rs b/crates/e2e/src/contract_results.rs index 982691163f..63c661e4b9 100644 --- a/crates/e2e/src/contract_results.rs +++ b/crates/e2e/src/contract_results.rs @@ -1,3 +1,17 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + use ink::codegen::ContractCallBuilder; use ink_env::{ call::FromAccountId, diff --git a/crates/e2e/src/error.rs b/crates/e2e/src/error.rs index e3242d99a5..33de1d4113 100644 --- a/crates/e2e/src/error.rs +++ b/crates/e2e/src/error.rs @@ -1,3 +1,17 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + use pallet_contracts_primitives::{ CodeUploadResult, ContractExecResult, diff --git a/crates/e2e/src/lib.rs b/crates/e2e/src/lib.rs index 301c71fe3f..ec5e9608cb 100644 --- a/crates/e2e/src/lib.rs +++ b/crates/e2e/src/lib.rs @@ -19,18 +19,19 @@ html_favicon_url = "https://use.ink/crate-docs/favicon.png" )] +mod backend; mod builders; -mod client; mod contract_results; mod error; pub mod events; mod node_proc; +mod subxt_client; mod xts; -pub use client::{ - CallBuilderFinal, - Client, - Error, +pub use backend::{ + ChainBackend, + ContractsBackend, + E2EBackend, }; pub use contract_results::{ CallDryRunResult, @@ -46,6 +47,11 @@ pub use node_proc::{ pub use sp_core::H256; pub use sp_keyring::AccountKeyring; pub use subxt; +pub use subxt_client::{ + CallBuilderFinal, + Client, + Error, +}; pub use subxt_signer::sr25519::{ self, dev::*, diff --git a/crates/e2e/src/client.rs b/crates/e2e/src/subxt_client.rs similarity index 82% rename from crates/e2e/src/client.rs rename to crates/e2e/src/subxt_client.rs index 87be6c9d74..c23ca9899a 100644 --- a/crates/e2e/src/client.rs +++ b/crates/e2e/src/subxt_client.rs @@ -46,6 +46,11 @@ use ink_env::{ }, Environment, }; +use jsonrpsee::core::async_trait; +use scale::{ + Decode, + Encode, +}; #[cfg(feature = "std")] use std::{ collections::BTreeMap, @@ -53,7 +58,12 @@ use std::{ path::PathBuf, }; -use crate::events; +use crate::{ + backend::ChainBackend, + events, + ContractsBackend, + E2EBackend, +}; use subxt::{ blocks::ExtrinsicEvents, config::ExtrinsicParams, @@ -130,107 +140,6 @@ where } } - /// Generate a new keypair and fund with the given amount from the origin account. - /// - /// Because many tests may execute this in parallel, transfers may fail due to a race - /// condition with account indices. Therefore this will reattempt transfers a - /// number of times. - pub async fn create_and_fund_account( - &self, - origin: &Keypair, - amount: E::Balance, - ) -> Keypair - where - E::Balance: Clone, - C::AccountId: Clone + core::fmt::Display + Debug, - { - let (_, phrase, _) = - ::generate_with_phrase(None); - let phrase = - subxt_signer::bip39::Mnemonic::parse(phrase).expect("valid phrase expected"); - let keypair = Keypair::from_phrase(&phrase, None).expect("valid phrase expected"); - let account_id = >::account_id(&keypair); - let origin_account_id = origin.public_key().to_account_id(); - - self.api - .try_transfer_balance(origin, account_id.clone(), amount) - .await - .unwrap_or_else(|err| { - panic!( - "transfer from {} to {} failed with {:?}", - origin_account_id, account_id, err - ) - }); - - log_info(&format!( - "transfer from {} to {} succeeded", - origin_account_id, account_id, - )); - - keypair - } - - /// This function extracts the metadata of the contract at the file path - /// `target/ink/$contract_name.contract`. - /// - /// The function subsequently uploads and instantiates an instance of the contract. - /// - /// Calling this function multiple times is idempotent, the contract is - /// newly instantiated each time using a unique salt. No existing contract - /// instance is reused! - pub async fn instantiate( - &mut self, - contract_name: &str, - signer: &Keypair, - constructor: CreateBuilderPartial, - value: E::Balance, - storage_deposit_limit: Option, - ) -> Result>, Error> - where - Args: scale::Encode, - { - let code = self.load_code(contract_name); - let ret = self - .exec_instantiate::( - signer, - code, - constructor, - value, - storage_deposit_limit, - ) - .await?; - log_info(&format!("instantiated contract at {:?}", ret.account_id)); - Ok(ret) - } - - /// Dry run contract instantiation using the given constructor. - pub async fn instantiate_dry_run( - &mut self, - contract_name: &str, - signer: &Keypair, - constructor: CreateBuilderPartial, - value: E::Balance, - storage_deposit_limit: Option, - ) -> ContractInstantiateResult - where - Args: scale::Encode, - { - let code = self.load_code(contract_name); - let data = constructor_exec_input(constructor); - - let salt = Self::salt(); - self.api - .instantiate_with_code_dry_run( - value, - storage_deposit_limit, - code, - data, - salt, - signer, - ) - .await - } - /// Load the Wasm code for the given contract. fn load_code(&self, contract: &str) -> Vec { let wasm_path = self @@ -356,29 +265,8 @@ where .to_vec() } - /// This function extracts the Wasm of the contract for the specified contract. - /// - /// The function subsequently uploads and instantiates an instance of the contract. - /// - /// Calling this function multiple times is idempotent, the contract is - /// newly instantiated each time using a unique salt. No existing contract - /// instance is reused! - pub async fn upload( - &mut self, - contract_name: &str, - signer: &Keypair, - storage_deposit_limit: Option, - ) -> Result>, Error> { - let code = self.load_code(contract_name); - let ret = self - .exec_upload(signer, code, storage_deposit_limit) - .await?; - log_info(&format!("contract stored with hash {:?}", ret.code_hash)); - Ok(ret) - } - /// Executes an `upload` call and captures the resulting events. - pub async fn exec_upload( + async fn exec_upload( &mut self, signer: &Keypair, code: Vec, @@ -444,43 +332,125 @@ where events: tx_events, }) } +} - /// Executes a `call` for the contract at `account_id`. - /// - /// Returns when the transaction is included in a block. The return value - /// contains all events that are associated with this transaction. - pub async fn call( +#[async_trait] +impl ChainBackend for Client +where + C: subxt::Config + Send + Sync, + C::AccountId: Clone + + Debug + + Send + + Sync + + core::fmt::Display + + scale::Codec + + From + + serde::de::DeserializeOwned, + C::Address: From, + C::Signature: From, + C::Address: Send + Sync, + >::OtherParams: Default + Send + Sync, + + E: Environment, + E::AccountId: Debug + Send + Sync, + E::Balance: Clone + + Debug + + Send + + Sync + + TryFrom + + scale::HasCompact + + serde::Serialize, +{ + type Actor = Keypair; + type ActorId = E::AccountId; + type Balance = E::Balance; + type Error = Error; + type EventLog = ExtrinsicEvents; + + async fn create_and_fund_account( &mut self, - signer: &Keypair, - message: &CallBuilderFinal, - value: E::Balance, - storage_deposit_limit: Option, - ) -> Result>, Error> - where - Args: scale::Encode, - RetType: scale::Decode, - CallBuilderFinal: Clone, - { - let account_id = message.clone().params().callee().clone(); - let exec_input = scale::Encode::encode(message.clone().params().exec_input()); - log_info(&format!("call: {:02X?}", exec_input)); + origin: &Self::Actor, + amount: Self::Balance, + ) -> Self::Actor { + let (_, phrase, _) = + ::generate_with_phrase(None); + let phrase = + subxt_signer::bip39::Mnemonic::parse(phrase).expect("valid phrase expected"); + let keypair = Keypair::from_phrase(&phrase, None).expect("valid phrase expected"); + let account_id = >::account_id(&keypair); + let origin_account_id = origin.public_key().to_account_id(); - let dry_run = self.call_dry_run(signer, message, value, None).await; + self.api + .try_transfer_balance(origin, account_id.clone(), amount) + .await + .unwrap_or_else(|err| { + panic!( + "transfer from {} to {} failed with {:?}", + origin_account_id, account_id, err + ) + }); - if dry_run.exec_result.result.is_err() { - return Err(Error::::CallDryRun(dry_run.exec_result)) - } + log_info(&format!( + "transfer from {} to {} succeeded", + origin_account_id, account_id, + )); + + keypair + } + async fn balance(&self, actor: Self::ActorId) -> Result { + let account_addr = subxt::dynamic::storage( + "System", + "Account", + vec![ + // Something that encodes to an AccountId32 is what we need for the map + // key here: + Value::from_bytes(&actor), + ], + ); + + let account = self + .api + .client + .storage() + .at_latest() + .await + .unwrap_or_else(|err| { + panic!("unable to fetch balance: {err:?}"); + }) + .fetch_or_default(&account_addr) + .await + .unwrap_or_else(|err| { + panic!("unable to fetch balance: {err:?}"); + }) + .to_value() + .unwrap_or_else(|err| { + panic!("unable to decode account info: {err:?}"); + }); + + 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")) + })?; + let balance = E::Balance::try_from(balance).map_err(|_| { + Error::::Balance(format!("{balance:?} failed to convert from u128")) + })?; + + log_info(&format!("balance of contract {actor:?} is {balance:?}")); + Ok(balance) + } + + async fn runtime_call<'a>( + &mut self, + actor: &Self::Actor, + pallet_name: &'a str, + call_name: &'a str, + call_data: Vec, + ) -> Result { let tx_events = self .api - .call( - subxt::utils::MultiAddress::Id(account_id.clone()), - value, - dry_run.exec_result.gas_required.into(), - storage_deposit_limit, - exec_input, - signer, - ) + .runtime_call(actor, pallet_name, call_name, call_data) .await; for evt in tx_events.iter() { @@ -493,38 +463,138 @@ where let dispatch_error = subxt::error::DispatchError::decode_from(evt.field_bytes(), metadata) .map_err(|e| Error::::Decoding(e.to_string()))?; + log_error(&format!("extrinsic for call failed: {dispatch_error}")); return Err(Error::::CallExtrinsic(dispatch_error)) } } - Ok(CallResult { - dry_run, - events: tx_events, - }) + Ok(tx_events) } +} - /// Executes a runtime call `call_name` for the `pallet_name`. - /// The `call_data` is a `Vec` - /// - /// Note: - /// - `pallet_name` must be in camel case, for example `Balances`. - /// - `call_name` must be snake case, for example `force_transfer`. - /// - `call_data` is a `Vec` that holds a representation of - /// some value. - /// - /// Returns when the transaction is included in a block. The return value - /// contains all events that are associated with this transaction. - pub async fn runtime_call<'a>( +#[async_trait] +impl ContractsBackend for Client +where + C: subxt::Config + Send + Sync, + C::AccountId: Clone + + Debug + + Send + + Sync + + core::fmt::Display + + scale::Codec + + From + + serde::de::DeserializeOwned, + C::Address: From, + C::Signature: From, + C::Address: Send + Sync, + >::OtherParams: Default + Send + Sync, + + E: Environment, + E::AccountId: Debug + Send + Sync, + E::Balance: Clone + + Debug + + Send + + Sync + + TryFrom + + scale::HasCompact + + serde::Serialize, + E::Hash: Debug + Send + scale::Encode, +{ + type Actor = Keypair; + type Error = Error; + type EventLog = ExtrinsicEvents; + + async fn instantiate( &mut self, - signer: &Keypair, - pallet_name: &'a str, - call_name: &'a str, - call_data: Vec, - ) -> Result, Error> { + contract_name: &str, + caller: &Self::Actor, + constructor: CreateBuilderPartial, + value: E::Balance, + storage_deposit_limit: Option, + ) -> Result, Self::Error> { + let code = self.load_code(contract_name); + let ret = self + .exec_instantiate::( + caller, + code, + constructor, + value, + storage_deposit_limit, + ) + .await?; + log_info(&format!("instantiated contract at {:?}", ret.account_id)); + Ok(ret) + } + + async fn instantiate_dry_run( + &mut self, + contract_name: &str, + caller: &Self::Actor, + constructor: CreateBuilderPartial, + value: E::Balance, + storage_deposit_limit: Option, + ) -> ContractInstantiateResult { + let code = self.load_code(contract_name); + let data = constructor_exec_input(constructor); + + let salt = Self::salt(); + self.api + .instantiate_with_code_dry_run( + value, + storage_deposit_limit, + code, + data, + salt, + caller, + ) + .await + } + + async fn upload( + &mut self, + contract_name: &str, + caller: &Self::Actor, + storage_deposit_limit: Option, + ) -> Result, Self::Error> { + let code = self.load_code(contract_name); + let ret = self + .exec_upload(caller, code, storage_deposit_limit) + .await?; + log_info(&format!("contract stored with hash {:?}", ret.code_hash)); + Ok(ret) + } + + async fn call( + &mut self, + caller: &Self::Actor, + message: &CallBuilderFinal, + value: E::Balance, + storage_deposit_limit: Option, + ) -> Result, Self::Error> + where + CallBuilderFinal: Clone, + { + let account_id = message.clone().params().callee().clone(); + let exec_input = Encode::encode(message.clone().params().exec_input()); + log_info(&format!("call: {:02X?}", exec_input)); + + let dry_run = self.call_dry_run(caller, message, value, None).await; + + if dry_run.exec_result.result.is_err() { + return Err(Error::::CallDryRun(dry_run.exec_result)) + } + let tx_events = self .api - .runtime_call(signer, pallet_name, call_name, call_data) + .call( + subxt::utils::MultiAddress::Id(account_id.clone()), + value, + dry_run.exec_result.gas_required.into(), + storage_deposit_limit, + exec_input, + caller, + ) .await; for evt in tx_events.iter() { @@ -537,38 +607,34 @@ where let dispatch_error = subxt::error::DispatchError::decode_from(evt.field_bytes(), metadata) .map_err(|e| Error::::Decoding(e.to_string()))?; - log_error(&format!("extrinsic for call failed: {dispatch_error}")); return Err(Error::::CallExtrinsic(dispatch_error)) } } - Ok(tx_events) + Ok(CallResult { + 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( + async fn call_dry_run( &mut self, - signer: &Keypair, + caller: &Self::Actor, message: &CallBuilderFinal, value: E::Balance, storage_deposit_limit: Option, ) -> CallDryRunResult where - Args: scale::Encode, - RetType: scale::Decode, CallBuilderFinal: Clone, { let dest = message.clone().params().callee().clone(); - let exec_input = scale::Encode::encode(message.clone().params().exec_input()); + let exec_input = Encode::encode(message.clone().params().exec_input()); let exec_result = self .api .call_dry_run( - Signer::::account_id(signer), + Signer::::account_id(caller), dest, exec_input, value, @@ -586,55 +652,35 @@ where _marker: Default::default(), } } +} - /// Returns the balance of `account_id`. - pub async fn balance(&self, account_id: E::AccountId) -> Result> - where - E::Balance: TryFrom, - { - let account_addr = subxt::dynamic::storage( - "System", - "Account", - vec![ - // Something that encodes to an AccountId32 is what we need for the map - // key here: - Value::from_bytes(&account_id), - ], - ); - - let account = self - .api - .client - .storage() - .at_latest() - .await - .unwrap_or_else(|err| { - panic!("unable to fetch balance: {err:?}"); - }) - .fetch_or_default(&account_addr) - .await - .unwrap_or_else(|err| { - panic!("unable to fetch balance: {err:?}"); - }) - .to_value() - .unwrap_or_else(|err| { - panic!("unable to decode account info: {err:?}"); - }); - - 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")) - })?; - let balance = E::Balance::try_from(balance).map_err(|_| { - Error::::Balance(format!("{balance:?} failed to convert from u128")) - })?; +impl E2EBackend for Client +where + C: subxt::Config + Send + Sync, + C::AccountId: Clone + + Debug + + Send + + Sync + + core::fmt::Display + + scale::Codec + + From + + serde::de::DeserializeOwned, + C::Address: From, + C::Signature: From, + C::Address: Send + Sync, + >::OtherParams: Default + Send + Sync, - log_info(&format!( - "balance of contract {account_id:?} is {balance:?}" - )); - Ok(balance) - } + E: Environment, + E::AccountId: Debug + Send + Sync, + E::Balance: Clone + + Debug + + Send + + Sync + + TryFrom + + scale::HasCompact + + serde::Serialize, + E::Hash: Debug + Send + scale::Encode, +{ } /// Try to extract the given field from a dynamic [`Value`]. diff --git a/integration-tests/call-builder-return-value/lib.rs b/integration-tests/call-builder-return-value/lib.rs index b68210f04f..b142da61ef 100755 --- a/integration-tests/call-builder-return-value/lib.rs +++ b/integration-tests/call-builder-return-value/lib.rs @@ -113,6 +113,10 @@ mod call_builder { mod e2e_tests { use super::*; use incrementer::IncrementerRef; + use ink_e2e::{ + ChainBackend, + ContractsBackend, + }; type E2EResult = std::result::Result>; diff --git a/integration-tests/call-runtime/lib.rs b/integration-tests/call-runtime/lib.rs index 919a06f525..80335a7326 100644 --- a/integration-tests/call-runtime/lib.rs +++ b/integration-tests/call-runtime/lib.rs @@ -114,6 +114,10 @@ mod runtime_call { #[cfg(all(test, feature = "e2e-tests"))] mod e2e_tests { use super::*; + use ink_e2e::{ + ChainBackend, + ContractsBackend, + }; use ink::{ env::{ diff --git a/integration-tests/contract-terminate/lib.rs b/integration-tests/contract-terminate/lib.rs index fe19dfcae0..c215d08956 100644 --- a/integration-tests/contract-terminate/lib.rs +++ b/integration-tests/contract-terminate/lib.rs @@ -56,6 +56,8 @@ pub mod just_terminates { #[cfg(all(test, feature = "e2e-tests"))] mod e2e_tests { use super::*; + use ink_e2e::ContractsBackend; + type E2EResult = std::result::Result>; #[ink_e2e::test] diff --git a/integration-tests/contract-transfer/lib.rs b/integration-tests/contract-transfer/lib.rs index 2dc444bd48..06dafe9997 100644 --- a/integration-tests/contract-transfer/lib.rs +++ b/integration-tests/contract-transfer/lib.rs @@ -182,6 +182,11 @@ pub mod give_me { #[cfg(all(test, feature = "e2e-tests"))] mod e2e_tests { use super::*; + use ink_e2e::{ + ChainBackend, + ContractsBackend, + }; + type E2EResult = std::result::Result>; #[ink_e2e::test] diff --git a/integration-tests/custom-allocator/lib.rs b/integration-tests/custom-allocator/lib.rs index 55629ff505..ab4f21d3f1 100755 --- a/integration-tests/custom-allocator/lib.rs +++ b/integration-tests/custom-allocator/lib.rs @@ -107,6 +107,7 @@ mod custom_allocator { #[cfg(all(test, feature = "e2e-tests"))] mod e2e_tests { use super::*; + use ink_e2e::ContractsBackend; type E2EResult = std::result::Result>; diff --git a/integration-tests/custom-environment/lib.rs b/integration-tests/custom-environment/lib.rs index e14b9f6424..ce974f8aed 100644 --- a/integration-tests/custom-environment/lib.rs +++ b/integration-tests/custom-environment/lib.rs @@ -84,6 +84,7 @@ mod runtime_call { #[cfg(all(test, feature = "e2e-tests"))] mod e2e_tests { use super::*; + use ink_e2e::ContractsBackend; type E2EResult = Result>; diff --git a/integration-tests/e2e-call-runtime/lib.rs b/integration-tests/e2e-call-runtime/lib.rs index 16a899feb4..98ff0663fc 100644 --- a/integration-tests/e2e-call-runtime/lib.rs +++ b/integration-tests/e2e-call-runtime/lib.rs @@ -21,7 +21,11 @@ pub mod e2e_call_runtime { #[cfg(all(test, feature = "e2e-tests"))] mod e2e_tests { use super::*; - use ink_e2e::subxt::dynamic::Value; + use ink_e2e::{ + subxt::dynamic::Value, + ChainBackend, + ContractsBackend, + }; type E2EResult = std::result::Result>; diff --git a/integration-tests/erc20/lib.rs b/integration-tests/erc20/lib.rs index 668ba3859f..64b2d743e9 100644 --- a/integration-tests/erc20/lib.rs +++ b/integration-tests/erc20/lib.rs @@ -509,6 +509,8 @@ mod erc20 { #[cfg(all(test, feature = "e2e-tests"))] mod e2e_tests { use super::*; + use ink_e2e::ContractsBackend; + type E2EResult = std::result::Result>; #[ink_e2e::test] diff --git a/integration-tests/events/lib.rs b/integration-tests/events/lib.rs index aa88c7af2f..c7618f6be8 100644 --- a/integration-tests/events/lib.rs +++ b/integration-tests/events/lib.rs @@ -201,7 +201,10 @@ pub mod events { #[cfg(all(test, feature = "e2e-tests"))] mod e2e_tests { use super::*; - use ink_e2e::H256; + use ink_e2e::{ + ContractsBackend, + H256, + }; type E2EResult = std::result::Result>; diff --git a/integration-tests/flipper/lib.rs b/integration-tests/flipper/lib.rs index e0e96e86fc..3dd658a769 100644 --- a/integration-tests/flipper/lib.rs +++ b/integration-tests/flipper/lib.rs @@ -55,6 +55,7 @@ pub mod flipper { #[cfg(all(test, feature = "e2e-tests"))] mod e2e_tests { use super::*; + use ink_e2e::ContractsBackend; type E2EResult = std::result::Result>; diff --git a/integration-tests/lang-err-integration-tests/call-builder-delegate/lib.rs b/integration-tests/lang-err-integration-tests/call-builder-delegate/lib.rs index f3b9997cc9..9c5034636e 100755 --- a/integration-tests/lang-err-integration-tests/call-builder-delegate/lib.rs +++ b/integration-tests/lang-err-integration-tests/call-builder-delegate/lib.rs @@ -94,6 +94,10 @@ mod call_builder { #[cfg(all(test, feature = "e2e-tests"))] mod e2e_tests { use super::*; + use ink_e2e::{ + ChainBackend, + ContractsBackend, + }; type E2EResult = std::result::Result>; diff --git a/integration-tests/lang-err-integration-tests/call-builder/lib.rs b/integration-tests/lang-err-integration-tests/call-builder/lib.rs index 1d0d52cc79..beff3de39e 100755 --- a/integration-tests/lang-err-integration-tests/call-builder/lib.rs +++ b/integration-tests/lang-err-integration-tests/call-builder/lib.rs @@ -166,6 +166,10 @@ mod call_builder { #[cfg(all(test, feature = "e2e-tests"))] mod e2e_tests { use super::*; + use ink_e2e::{ + ChainBackend, + ContractsBackend, + }; use integration_flipper::{ Flipper, FlipperRef, 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 5d7d2d62b9..51a9b5b27e 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 @@ -107,6 +107,7 @@ pub mod constructors_return_value { #[cfg(all(test, feature = "e2e-tests"))] mod e2e_tests { use super::*; + use ink_e2e::ContractsBackend; use scale::Decode as _; type E2EResult = std::result::Result>; @@ -197,7 +198,7 @@ pub mod constructors_return_value { ) .await .expect("instantiate failed"); - let mut call = contract.call::(); + let call = contract.call::(); let get = call.get_value(); let value = client 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 6c070d7bd2..e305250e05 100755 --- a/integration-tests/lang-err-integration-tests/contract-ref/lib.rs +++ b/integration-tests/lang-err-integration-tests/contract-ref/lib.rs @@ -68,6 +68,7 @@ mod contract_ref { #[cfg(all(test, feature = "e2e-tests"))] mod e2e_tests { use super::*; + use ink_e2e::ContractsBackend; type E2EResult = std::result::Result>; 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 dceb8ea1da..2cea0bd018 100644 --- a/integration-tests/lang-err-integration-tests/integration-flipper/lib.rs +++ b/integration-tests/lang-err-integration-tests/integration-flipper/lib.rs @@ -67,6 +67,8 @@ pub mod integration_flipper { #[cfg(all(test, feature = "e2e-tests"))] mod e2e_tests { use super::*; + use ink_e2e::ContractsBackend; + type E2EResult = std::result::Result>; #[ink_e2e::test] diff --git a/integration-tests/mapping-integration-tests/lib.rs b/integration-tests/mapping-integration-tests/lib.rs index 64e32ac308..7f15c46f6d 100755 --- a/integration-tests/mapping-integration-tests/lib.rs +++ b/integration-tests/mapping-integration-tests/lib.rs @@ -89,6 +89,8 @@ mod mapping_integration_tests { #[cfg(all(test, feature = "e2e-tests"))] mod e2e_tests { use super::*; + use ink_e2e::ContractsBackend; + type E2EResult = std::result::Result>; #[ink_e2e::test] diff --git a/integration-tests/multi-contract-caller/lib.rs b/integration-tests/multi-contract-caller/lib.rs index 960cd19c63..fc5d4a8d35 100644 --- a/integration-tests/multi-contract-caller/lib.rs +++ b/integration-tests/multi-contract-caller/lib.rs @@ -115,6 +115,7 @@ mod multi_contract_caller { #[cfg(all(test, feature = "e2e-tests"))] mod e2e_tests { use super::*; + use ink_e2e::ContractsBackend; type E2EResult = std::result::Result>; diff --git a/integration-tests/set-code-hash/lib.rs b/integration-tests/set-code-hash/lib.rs index dd632d3592..c90bcbb536 100644 --- a/integration-tests/set-code-hash/lib.rs +++ b/integration-tests/set-code-hash/lib.rs @@ -68,6 +68,7 @@ pub mod incrementer { #[cfg(all(test, feature = "e2e-tests"))] mod e2e_tests { use super::*; + use ink_e2e::ContractsBackend; type E2EResult = std::result::Result>; diff --git a/integration-tests/trait-dyn-cross-contract-calls/lib.rs b/integration-tests/trait-dyn-cross-contract-calls/lib.rs index 9d8f8309ff..8366e97bd7 100644 --- a/integration-tests/trait-dyn-cross-contract-calls/lib.rs +++ b/integration-tests/trait-dyn-cross-contract-calls/lib.rs @@ -48,6 +48,7 @@ mod e2e_tests { CallerRef, }; use dyn_traits::Increment; + use ink_e2e::ContractsBackend; use trait_incrementer::incrementer::{ Incrementer, IncrementerRef, diff --git a/integration-tests/wildcard-selector/lib.rs b/integration-tests/wildcard-selector/lib.rs index 729bd56c3d..a1bda19f0b 100644 --- a/integration-tests/wildcard-selector/lib.rs +++ b/integration-tests/wildcard-selector/lib.rs @@ -37,6 +37,7 @@ pub mod wildcard_selector { #[cfg(all(test, feature = "e2e-tests"))] mod e2e_tests { use super::*; + use ink_e2e::ContractsBackend; use ink::env::call::utils::{ Argument,