Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pgherveou committed Nov 2, 2023
1 parent 02c4f0d commit 830777c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
4 changes: 2 additions & 2 deletions crates/e2e/macro/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ 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, self.test.config.runtime())
Backend::RuntimeOnly{runtime} => {
build_runtime_client(exec_build_contracts, runtime)
}
};

Expand Down
12 changes: 4 additions & 8 deletions crates/e2e/macro/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,19 @@

/// The type of the architecture that should be used to run test.
#[derive(Copy, Clone, Eq, PartialEq, Debug, Default, darling::FromMeta)]
#[darling(rename_all = "snake_case")]
pub enum Backend {
/// The standard approach with running dedicated single-node blockchain in a
/// background process.
#[default]
Full,

/// The lightweight approach skipping node layer.
///
/// This runs a runtime emulator within `TestExternalities` (using drink! library) in
/// the same process as the test.
#[cfg(any(test, feature = "drink"))]
RuntimeOnly,
RuntimeOnly{runtime: Option<syn::Path>},
}

/// The End-to-End test configuration.
Expand All @@ -44,10 +46,6 @@ pub struct E2EConfig {
/// The type of the architecture that should be used to run test.
#[darling(default)]
backend: Backend,
/// The runtime to use for the runtime only test.
#[cfg(any(test, feature = "drink"))]
#[darling(default)]
runtime: Option<syn::Path>,
}

impl E2EConfig {
Expand Down Expand Up @@ -97,8 +95,7 @@ mod tests {
let input = quote! {
additional_contracts = "adder/Cargo.toml flipper/Cargo.toml",
environment = crate::CustomEnvironment,
backend = "runtime_only",
runtime = ::drink::MinimalRuntime,
backend(runtime_only(runtime = ::drink::MinimalRuntime)),
};
let config =
E2EConfig::from_list(&NestedMeta::parse_meta_list(input).unwrap()).unwrap();
Expand All @@ -111,7 +108,6 @@ mod tests {
config.environment(),
Some(syn::parse_quote! { crate::CustomEnvironment })
);
assert_eq!(config.backend(), Backend::RuntimeOnly);
assert_eq!(
config.runtime(),
Some(syn::parse_quote! { ::drink::MinimalRuntime })
Expand Down
6 changes: 3 additions & 3 deletions integration-tests/e2e-runtime-only-backend/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pub mod flipper {
/// - flip the flipper
/// - get the flipper's value
/// - assert that the value is `true`
#[ink_e2e::test(backend = "runtime_only")]
#[ink_e2e::test(backend(runtime_only = ::drink::MinimalRuntime))]
async fn it_works<Client: E2EBackend>(mut client: Client) -> E2EResult<()> {
// given
const INITIAL_VALUE: bool = false;
Expand Down Expand Up @@ -115,7 +115,7 @@ pub mod flipper {
/// - transfer some funds to the contract using runtime call
/// - get the contract's balance again
/// - assert that the contract's balance increased by the transferred amount
#[ink_e2e::test(backend = "runtime_only")]
#[ink_e2e::test(backend(runtime_only()))]
async fn runtime_call_works() -> E2EResult<()> {
// given
let contract = deploy(&mut client, false).await.expect("deploy failed");
Expand Down Expand Up @@ -156,7 +156,7 @@ pub mod flipper {
}

/// Just instantiate a contract using non-default runtime.
#[ink_e2e::test(backend = "runtime_only", runtime = ink_e2e::MinimalRuntime)]
#[ink_e2e::test(backend(runtime_only(runtime = ink_e2e::MinimalRuntime)))]
async fn custom_runtime<Client: E2EBackend>(mut client: Client) -> E2EResult<()> {
client
.instantiate(
Expand Down

0 comments on commit 830777c

Please sign in to comment.