diff --git a/crates/e2e/Cargo.toml b/crates/e2e/Cargo.toml index 1e0b13f8f6b..1a84ff241f0 100644 --- a/crates/e2e/Cargo.toml +++ b/crates/e2e/Cargo.toml @@ -22,7 +22,7 @@ ink_primitives = { workspace = true, default-features = true } cargo_metadata = { workspace = true } contract-build = { workspace = true } -drink = { workspace = true } +drink = { workspace = true, optional = true } funty = { workspace = true } impl-serde = { workspace = true } jsonrpsee = { workspace = true, features = ["ws-client"] } @@ -50,3 +50,7 @@ scale-info = { workspace = true, features = ["derive"] } [features] default = ["std"] std = [] +drink = [ + "dep:drink", + "ink_e2e_macro/drink", +] diff --git a/crates/e2e/macro/Cargo.toml b/crates/e2e/macro/Cargo.toml index 68eca53f58f..fe6c1bca86a 100644 --- a/crates/e2e/macro/Cargo.toml +++ b/crates/e2e/macro/Cargo.toml @@ -27,3 +27,6 @@ syn = { workspace = true } proc-macro2 = { workspace = true } quote = { workspace = true } which = { workspace = true } + +[features] +drink = [] diff --git a/crates/e2e/macro/src/codegen.rs b/crates/e2e/macro/src/codegen.rs index 1d4e157d513..5ab34fb8eb5 100644 --- a/crates/e2e/macro/src/codegen.rs +++ b/crates/e2e/macro/src/codegen.rs @@ -68,6 +68,7 @@ impl InkE2ETest { let client_building = match self.test.config.backend() { Backend::Full => build_full_client(&environment, exec_build_contracts), + #[cfg(any(test, feature = "drink"))] Backend::RuntimeOnly => build_runtime_client(exec_build_contracts), }; @@ -144,6 +145,7 @@ fn build_full_client(environment: &syn::Path, contracts: TokenStream2) -> TokenS } } +#[cfg(any(test, feature = "drink"))] fn build_runtime_client(contracts: TokenStream2) -> TokenStream2 { quote! { let contracts = #contracts; diff --git a/crates/e2e/macro/src/config.rs b/crates/e2e/macro/src/config.rs index 200793de114..917fc50e90b 100644 --- a/crates/e2e/macro/src/config.rs +++ b/crates/e2e/macro/src/config.rs @@ -29,6 +29,7 @@ pub enum Backend { /// /// This runs a runtime emulator within `TestExternalities` (using drink! library) in /// the same process as the test. + #[cfg(any(test, feature = "drink"))] RuntimeOnly, } @@ -38,7 +39,15 @@ impl TryFrom for Backend { fn try_from(value: syn::LitStr) -> Result { match value.value().as_str() { "full" => Ok(Self::Full), + #[cfg(any(test, feature = "drink"))] "runtime_only" | "runtime-only" => Ok(Self::RuntimeOnly), + #[cfg(not(any(test, feature = "drink")))] + "runtime_only" | "runtime-only" => Err( + format_err_spanned!( + value, + "the `runtime-only` backend is not available because the `drink` feature is not enabled", + ) + ), _ => { Err(format_err_spanned!( value, diff --git a/crates/e2e/src/lib.rs b/crates/e2e/src/lib.rs index 2a09ba6d6bb..8cfcf81ac80 100644 --- a/crates/e2e/src/lib.rs +++ b/crates/e2e/src/lib.rs @@ -24,6 +24,7 @@ mod builders; mod client_utils; mod contract_build; mod contract_results; +#[cfg(feature = "drink")] mod drink_client; mod error; pub mod events; @@ -46,6 +47,7 @@ pub use contract_results::{ InstantiationResult, UploadResult, }; +#[cfg(feature = "drink")] pub use drink_client::Client as DrinkClient; pub use ink_e2e_macro::test; pub use node_proc::{ diff --git a/integration-tests/e2e-runtime-only-backend/Cargo.toml b/integration-tests/e2e-runtime-only-backend/Cargo.toml index 33ea407c48b..ef9c7871a1b 100644 --- a/integration-tests/e2e-runtime-only-backend/Cargo.toml +++ b/integration-tests/e2e-runtime-only-backend/Cargo.toml @@ -12,7 +12,7 @@ scale = { package = "parity-scale-codec", version = "3", default-features = fals scale-info = { version = "2.6", default-features = false, features = ["derive"], optional = true } [dev-dependencies] -ink_e2e = { path = "../../crates/e2e" } +ink_e2e = { path = "../../crates/e2e", features = ["drink"] } [lib] path = "lib.rs"