From 9fcfc46a568110f7238875cacc4b361263cb7c80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Mon, 3 Jul 2023 14:35:15 +0200 Subject: [PATCH] Minor refactors in e2e crate (#1830) * Remove `whitelisted_attributes` from E2EConfig * Simplify building control * Remove unnecessary configs * Fix initializing tracing * Reexport config * Codec version in ui tests * Bump codec version * Revert codegen changes --- crates/e2e/macro/src/config.rs | 39 +------------------ crates/e2e/src/lib.rs | 26 +------------ .../fail/message-returns-non-codec.stderr | 2 +- .../fail/message_output_non_codec.stderr | 2 +- 4 files changed, 5 insertions(+), 64 deletions(-) diff --git a/crates/e2e/macro/src/config.rs b/crates/e2e/macro/src/config.rs index 425af650477..1c4da1bdf84 100644 --- a/crates/e2e/macro/src/config.rs +++ b/crates/e2e/macro/src/config.rs @@ -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, /// The [`Environment`](https://docs.rs/ink_env/4.1.0/ink_env/trait.Environment.html) to use @@ -41,14 +36,11 @@ impl TryFrom for E2EConfig { type Error = syn::Error; fn try_from(args: ast::AttributeArgs) -> Result { - 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, @@ -91,7 +83,6 @@ impl TryFrom for E2EConfig { Ok(E2EConfig { additional_contracts, - whitelisted_attributes, environment, }) } @@ -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(), @@ -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 `,`"), - ); - } } diff --git a/crates/e2e/src/lib.rs b/crates/e2e/src/lib.rs index 343361934b1..76e5641ffd1 100644 --- a/crates/e2e/src/lib.rs +++ b/crates/e2e/src/lib.rs @@ -61,31 +61,7 @@ use std::{ }; use xts::ContractsApi; -/// Default set of commonly used types by Substrate runtimes. -#[cfg(feature = "std")] -pub enum SubstrateConfig {} - -#[cfg(feature = "std")] -impl subxt::Config for SubstrateConfig { - type Index = u32; - type Hash = sp_core::H256; - type Hasher = subxt::config::substrate::BlakeTwo256; - type AccountId = subxt::config::substrate::AccountId32; - type Address = sp_runtime::MultiAddress; - type Header = subxt::config::substrate::SubstrateHeader< - u32, - subxt::config::substrate::BlakeTwo256, - >; - type Signature = sp_runtime::MultiSignature; - type ExtrinsicParams = subxt::config::substrate::SubstrateExtrinsicParams; -} - -/// Default set of commonly used types by Polkadot nodes. -#[cfg(feature = "std")] -pub type PolkadotConfig = subxt::config::WithExtrinsicParams< - SubstrateConfig, - subxt::config::polkadot::PolkadotExtrinsicParams, ->; +pub use subxt::PolkadotConfig; /// Signer that is used throughout the E2E testing. /// diff --git a/crates/ink/tests/ui/contract/fail/message-returns-non-codec.stderr b/crates/ink/tests/ui/contract/fail/message-returns-non-codec.stderr index ca1c72912dd..eecbabe13bf 100644 --- a/crates/ink/tests/ui/contract/fail/message-returns-non-codec.stderr +++ b/crates/ink/tests/ui/contract/fail/message-returns-non-codec.stderr @@ -46,7 +46,7 @@ error[E0599]: the method `try_invoke` exists for struct `CallBuilder $CARGO/parity-scale-codec-3.6.1/src/codec.rs + --> $CARGO/parity-scale-codec-3.6.3/src/codec.rs | | pub trait Decode: Sized { | ^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/crates/ink/tests/ui/trait_def/fail/message_output_non_codec.stderr b/crates/ink/tests/ui/trait_def/fail/message_output_non_codec.stderr index 7697d0ef22f..4306a056bfe 100644 --- a/crates/ink/tests/ui/trait_def/fail/message_output_non_codec.stderr +++ b/crates/ink/tests/ui/trait_def/fail/message_output_non_codec.stderr @@ -35,7 +35,7 @@ error[E0599]: the method `try_invoke` exists for struct `CallBuilder $CARGO/parity-scale-codec-3.6.1/src/codec.rs + --> $CARGO/parity-scale-codec-3.6.3/src/codec.rs | | pub trait Decode: Sized { | ^^^^^^^^^^^^^^^^^^^^^^^