Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c04f89a
Parse backend type
pmikolajczyk41 Aug 2, 2023
c13ceca
Config tests
pmikolajczyk41 Aug 2, 2023
816030b
Extract client building
pmikolajczyk41 Aug 2, 2023
96c124f
OCD
pmikolajczyk41 Aug 2, 2023
d2abb06
CHANGELOG.md
pmikolajczyk41 Aug 4, 2023
316bf58
Merge remote-tracking branch 'origin/master' into pmikolajczyk41/e2e-…
pmikolajczyk41 Aug 4, 2023
37f8d09
Merge remote-tracking branch 'origin/master' into pmikolajczyk41/e2e-…
pmikolajczyk41 Aug 7, 2023
f679f73
Merge remote-tracking branch 'origin/master' into pmikolajczyk41/e2e-…
pmikolajczyk41 Aug 16, 2023
f8e295a
Add drink dependency, fix with wasm-instrument
pmikolajczyk41 Aug 17, 2023
7be1f3a
ChainApi
pmikolajczyk41 Aug 18, 2023
42484ff
Instantiate
pmikolajczyk41 Aug 18, 2023
06cbc9b
Calling
pmikolajczyk41 Aug 18, 2023
c454db3
Upload
pmikolajczyk41 Aug 18, 2023
b21fc27
Use all arguments
pmikolajczyk41 Aug 18, 2023
ec3936e
Build client in macro
pmikolajczyk41 Aug 18, 2023
17bf359
fmt, implement e2e backend
pmikolajczyk41 Aug 18, 2023
dcc746d
remove actor types
pmikolajczyk41 Aug 18, 2023
624d20f
convert accounts and hashes
pmikolajczyk41 Aug 22, 2023
2b67dc8
get rid of session
pmikolajczyk41 Aug 23, 2023
7f9b764
add dedicated example
pmikolajczyk41 Aug 23, 2023
158dd64
example working
pmikolajczyk41 Aug 23, 2023
97ac62b
clean a bit
pmikolajczyk41 Aug 23, 2023
20a36ca
Merge remote-tracking branch 'origin/master' into pmikolajczyk41/e2e-…
pmikolajczyk41 Aug 23, 2023
96f647f
merging cleanup
pmikolajczyk41 Aug 23, 2023
15aaa48
use published drink
pmikolajczyk41 Aug 23, 2023
f416edc
Review
pmikolajczyk41 Aug 24, 2023
04bb5e9
Add DRink! as valid word
pmikolajczyk41 Aug 24, 2023
ea738c2
Give it up
pmikolajczyk41 Aug 24, 2023
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
Prev Previous commit
Next Next commit
merging cleanup
  • Loading branch information
pmikolajczyk41 committed Aug 23, 2023
commit 96f647ff974e20d3389d98135da106f49e7ec735
29 changes: 14 additions & 15 deletions crates/e2e/macro/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use crate::{ir, config::Backend};
use crate::{
config::Backend,
ir,
};
use derive_more::From;
use proc_macro2::TokenStream as TokenStream2;
use quote::quote;

const DEFAULT_CONTRACTS_NODE: &str = "substrate-contracts-node";

/// Generates code for the `[ink::e2e_test]` macro.
#[derive(From)]
pub struct InkE2ETest {
Expand Down Expand Up @@ -62,8 +67,8 @@ impl InkE2ETest {
};

let client_building = match self.test.config.backend() {
Backend::Full => build_full_client(&environment, contracts),
Backend::RuntimeOnly => build_runtime_client(contracts),
Backend::Full => build_full_client(&environment, exec_build_contracts),
Backend::RuntimeOnly => build_runtime_client(exec_build_contracts),
};

quote! {
Expand Down Expand Up @@ -104,10 +109,7 @@ impl InkE2ETest {
}
}

fn build_full_client<I: Iterator<Item = TokenStream2>>(
environment: &syn::Path,
contracts: I,
) -> TokenStream2 {
fn build_full_client(environment: &syn::Path, contracts: TokenStream2) -> TokenStream2 {
// Use the user supplied `CONTRACTS_NODE` or default to `DEFAULT_CONTRACTS_NODE`.
let contracts_node: &'static str =
option_env!("CONTRACTS_NODE").unwrap_or(DEFAULT_CONTRACTS_NODE);
Expand All @@ -134,20 +136,17 @@ fn build_full_client<I: Iterator<Item = TokenStream2>>(
::core::panic!("Error spawning substrate-contracts-node: {err:?}")
);

let contracts = #contracts;
let mut client = ::ink_e2e::Client::<
::ink_e2e::PolkadotConfig,
#environment
>::new(
node_proc.client(),
[ #( #contracts ),* ]
).await;
>::new(node_proc.client(), contracts).await;
}
}

fn build_runtime_client<I: Iterator<Item = TokenStream2>>(contracts: I) -> TokenStream2 {
fn build_runtime_client(contracts: TokenStream2) -> TokenStream2 {
quote! {
let mut client = ::ink_e2e::DrinkClient::new(
[ #( #contracts ),* ]
);
let contracts = #contracts;
let mut client = ::ink_e2e::DrinkClient::new(contracts);
}
}
4 changes: 2 additions & 2 deletions crates/e2e/src/client_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ pub struct ContractsRegistry {

impl ContractsRegistry {
/// Create a new registry with the given contracts.
pub fn new<'a>(contracts: impl IntoIterator<Item = &'a str>) -> Self {
pub fn new<P: Into<PathBuf>>(contracts: impl IntoIterator<Item = P>) -> Self {
let contracts = contracts
.into_iter()
.map(|path| {
let wasm_path = PathBuf::from(path);
let wasm_path: PathBuf = path.into();
let contract_name = wasm_path.file_stem().unwrap_or_else(|| {
panic!("Invalid contract wasm path '{}'", wasm_path.display(),)
});
Expand Down
1 change: 0 additions & 1 deletion crates/e2e/src/contract_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ fn build_contract(path_to_cargo_toml: &Path) -> PathBuf {
.expect("Wasm code artifact not generated")
.canonicalize()
.expect("Invalid dest bundle path")
.to_path_buf()
}
Err(err) => {
panic!(
Expand Down
7 changes: 5 additions & 2 deletions crates/e2e/src/drink_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ use sp_core::{
sr25519::Pair,
Pair as _,
};
use std::marker::PhantomData;
use std::{
marker::PhantomData,
path::PathBuf,
};
use subxt::dynamic::Value;
use subxt_signer::sr25519::Keypair;

Expand All @@ -57,7 +60,7 @@ pub struct Client<AccountId, Hash> {
unsafe impl<AccountId, Hash> Send for Client<AccountId, Hash> {}

impl<AccountId, Hash> Client<AccountId, Hash> {
pub fn new<'a>(contracts: impl IntoIterator<Item = &'a str>) -> Self {
pub fn new<P: Into<PathBuf>>(contracts: impl IntoIterator<Item = P>) -> Self {
let mut sandbox = Sandbox::new().expect("Failed to initialize Drink! sandbox");
Self::fund_accounts(&mut sandbox);

Expand Down
2 changes: 1 addition & 1 deletion crates/e2e/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@

mod backend;
mod builders;
mod client_utils;
mod contract_build;
mod contract_results;
mod client_utils;
mod drink_client;
mod error;
pub mod events;
Expand Down
5 changes: 3 additions & 2 deletions crates/e2e/src/subxt_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ use scale::{
};
#[cfg(feature = "std")]
use std::fmt::Debug;
use std::path::PathBuf;

use crate::{
backend::ChainBackend,
Expand Down Expand Up @@ -119,9 +120,9 @@ where
E::Hash: Debug + scale::Encode,
{
/// Creates a new [`Client`] instance using a `subxt` client.
pub async fn new<P>(
pub async fn new<P: Into<PathBuf>>(
client: subxt::OnlineClient<C>,
contracts: impl IntoIterator<Item = &str>,
contracts: impl IntoIterator<Item = P>,
) -> Self {
Self {
api: ContractsApi::new(client).await,
Expand Down