Skip to content
Merged
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 whitelisted_attributes from E2EConfig
  • Loading branch information
pmikolajczyk41 committed Jun 30, 2023
commit e67b2bd6c819068f8632b37494e0c16077f977ef
39 changes: 2 additions & 37 deletions crates/e2e/macro/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,12 @@
use ink_ir::{
ast,
format_err_spanned,
utils::{
duplicate_config_err,
WhitelistedAttributes,
},
utils::duplicate_config_err,
};

/// The End-to-End test configuration.
#[derive(Debug, Default, PartialEq, Eq)]
pub struct E2EConfig {
/// The set of attributes that can be passed to call builder in the codegen.
whitelisted_attributes: WhitelistedAttributes,
/// Additional contracts that have to be built before executing the test.
additional_contracts: Vec<String>,
/// The [`Environment`](https://docs.rs/ink_env/4.1.0/ink_env/trait.Environment.html) to use
Expand All @@ -41,14 +36,11 @@ impl TryFrom<ast::AttributeArgs> for E2EConfig {
type Error = syn::Error;

fn try_from(args: ast::AttributeArgs) -> Result<Self, Self::Error> {
let mut whitelisted_attributes = WhitelistedAttributes::default();
let mut additional_contracts: Option<(syn::LitStr, ast::MetaNameValue)> = None;
let mut environment: Option<(syn::Path, ast::MetaNameValue)> = None;

for arg in args.into_iter() {
if arg.name.is_ident("keep_attr") {
whitelisted_attributes.parse_arg_value(&arg)?;
} else if arg.name.is_ident("additional_contracts") {
if arg.name.is_ident("additional_contracts") {
if let Some((_, ast)) = additional_contracts {
return Err(duplicate_config_err(
ast,
Expand Down Expand Up @@ -91,7 +83,6 @@ impl TryFrom<ast::AttributeArgs> for E2EConfig {

Ok(E2EConfig {
additional_contracts,
whitelisted_attributes,
environment,
})
}
Expand Down Expand Up @@ -197,7 +188,6 @@ mod tests {
environment = crate::CustomEnvironment,
},
Ok(E2EConfig {
whitelisted_attributes: Default::default(),
additional_contracts: vec![
"adder/Cargo.toml".into(),
"flipper/Cargo.toml".into(),
Expand All @@ -206,29 +196,4 @@ mod tests {
}),
);
}

#[test]
fn keep_attr_works() {
let mut attrs = WhitelistedAttributes::default();
attrs.0.insert("foo".to_string(), ());
attrs.0.insert("bar".to_string(), ());
assert_try_from(
syn::parse_quote! {
keep_attr = "foo, bar"
},
Ok(E2EConfig {
whitelisted_attributes: attrs,
additional_contracts: Vec::new(),
environment: None,
}),
)
}

#[test]
fn keep_attr_invalid_value_fails() {
assert_try_from(
syn::parse_quote! { keep_attr = 1u16 },
Err("expected a string with attributes separated by `,`"),
);
}
}