Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Next Next commit
remove additional_contracts arg
  • Loading branch information
SkymanOne committed Feb 5, 2024
commit dad4af82b4aab68a5a654d1488378d78fe3d41e6
12 changes: 2 additions & 10 deletions crates/e2e/macro/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,8 @@ impl InkE2ETest {
.environment()
.unwrap_or_else(|| syn::parse_quote! { ::ink::env::DefaultEnvironment });

let additional_contracts = self.test.config.additional_contracts();

let exec_build_contracts = if additional_contracts.is_empty() {
quote! {
::ink_e2e::build_root_and_contract_dependencies()
}
} else {
quote! {
::ink_e2e::build_root_and_additional_contracts([ #( #additional_contracts ),* ])
}
let exec_build_contracts = quote! {
::ink_e2e::build_root_and_contract_dependencies()
};

let node_url = self.test.config.node_url();
Expand Down
23 changes: 0 additions & 23 deletions crates/e2e/macro/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ impl From<RuntimeOnly> for syn::Path {
/// The End-to-End test configuration.
#[derive(Debug, Default, PartialEq, Eq, darling::FromMeta)]
pub struct E2EConfig {
/// Additional contracts that have to be built before executing the test.
#[darling(default)]
additional_contracts: String,
/// The [`Environment`](https://docs.rs/ink_env/4.1.0/ink_env/trait.Environment.html) to use
/// during test execution.
///
Expand All @@ -71,21 +68,6 @@ pub struct E2EConfig {
}

impl E2EConfig {
/// Returns a vector of additional contracts that have to be built
/// and imported before executing the test.
pub fn additional_contracts(&self) -> Vec<String> {
self.additional_contracts
.split(' ')
.filter_map(|s| {
if s.is_empty() {
None
} else {
Some(s.to_owned())
}
})
.collect()
}

/// Custom environment for the contracts, if specified.
pub fn environment(&self) -> Option<syn::Path> {
self.environment.clone()
Expand Down Expand Up @@ -118,18 +100,13 @@ mod tests {
#[test]
fn config_works() {
let input = quote! {
additional_contracts = "adder/Cargo.toml flipper/Cargo.toml",
environment = crate::CustomEnvironment,
backend(runtime_only),
node_url = "ws://127.0.0.1:8000"
};
let config =
E2EConfig::from_list(&NestedMeta::parse_meta_list(input).unwrap()).unwrap();

assert_eq!(
config.additional_contracts(),
vec!["adder/Cargo.toml", "flipper/Cargo.toml"]
);
assert_eq!(
config.environment(),
Some(syn::parse_quote! { crate::CustomEnvironment })
Expand Down
3 changes: 1 addition & 2 deletions crates/e2e/src/client_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ impl ContractsRegistry {
.unwrap_or_else(||
panic!(
"Unknown contract {contract}. Available contracts: {:?}.\n\
For a contract to be built, add it as a dependency to the `Cargo.toml`, or add \
the manifest path to `#[ink_e2e::test(additional_contracts = ..)]`",
For a contract to be built, add it as a dependency to the `Cargo.toml`",
self.contracts.keys()
)
);
Expand Down
14 changes: 0 additions & 14 deletions crates/e2e/src/contract_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,6 @@ use std::{
},
};

/// Builds the "root" contract (the contract in which the E2E tests are defined) together
/// with the additional contracts specified in the `additional_contracts` argument.
pub fn build_root_and_additional_contracts<P>(
additional_contracts: impl IntoIterator<Item = P>,
) -> Vec<PathBuf>
where
PathBuf: From<P>,
{
let contract_project = ContractProject::new();
let contract_manifests =
contract_project.root_with_additional_contracts(additional_contracts);
build_contracts(&contract_manifests)
}

/// Builds the "root" contract (the contract in which the E2E tests are defined) together
/// with any contracts which are a dependency of the root contract.
pub fn build_root_and_contract_dependencies() -> Vec<PathBuf> {
Expand Down
5 changes: 1 addition & 4 deletions crates/e2e/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ mod node_proc;
mod subxt_client;
mod xts;

pub use crate::contract_build::{
build_root_and_additional_contracts,
build_root_and_contract_dependencies,
};
pub use crate::contract_build::build_root_and_contract_dependencies;
pub use backend::{
ChainBackend,
ContractsBackend,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ ink = { path = "../../../crates/ink", default-features = false }

[dev-dependencies]
ink_e2e = { path = "../../../crates/e2e" }
updated-incrementer = { path = "updated-incrementer", default-features = false, features = ["ink-as-dependency"] }

[lib]
path = "lib.rs"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pub mod incrementer {

type E2EResult<T> = std::result::Result<T, Box<dyn std::error::Error>>;

#[ink_e2e::test(additional_contracts = "./updated-incrementer/Cargo.toml")]
#[ink_e2e::test]
async fn set_code_works<Client: E2EBackend>(mut client: Client) -> E2EResult<()> {
// Given
let mut constructor = IncrementerRef::new();
Expand Down