Skip to content

Commit

Permalink
Restrict syntax for setting ink! e2e test node to auto (#2146)
Browse files Browse the repository at this point in the history
* Restrict syntax for setting ink! e2e test node to auto

* Add changelog entry

---------

Co-authored-by: Michael Müller <michi@parity.io>
  • Loading branch information
davidsemakula and cmichi committed Mar 11, 2024
1 parent c14d00d commit 3cc52ff
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Use name-only syntax for `anonymous` ink! event item configuration argument - [#2140](https://github.com/paritytech/ink/pull/2140)
- Restrict syntax for setting default ink! e2e test runtime-only emulator - [#2143](https://github.com/paritytech/ink/pull/2143)
- Restrict syntax for setting ink! e2e test node to auto - [#2146](https://github.com/paritytech/ink/pull/2146)
- Bump Substrate crates - [#2141](https://github.com/paritytech/ink/pull/2141)
- Minor fixes - [#2144](https://github.com/paritytech/ink/pull/2144),
[#2137](https://github.com/paritytech/ink/pull/2137), [#2132](https://github.com/paritytech/ink/pull/2132)
Expand Down
26 changes: 15 additions & 11 deletions crates/e2e/macro/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ impl Default for Backend {
pub enum Node {
/// A fresh node instance will be spawned for the lifetime of the test.
#[darling(word)]
#[darling(skip)]
Auto,
/// The test will run against an already running node at the supplied URL.
Url(String),
Expand Down Expand Up @@ -137,7 +138,7 @@ mod tests {

#[test]
#[should_panic(expected = "ErrorUnknownField")]
fn config_works_backend_runtime_only_default_not_allowed() {
fn config_backend_runtime_only_default_not_allowed() {
let input = quote! {
backend(runtime_only(default)),
};
Expand All @@ -164,23 +165,14 @@ mod tests {
}

#[test]
fn config_works_backend_node_default_auto() {
fn config_works_backend_node() {
let input = quote! {
backend(node),
};
let config =
E2EConfig::from_list(&NestedMeta::parse_meta_list(input).unwrap()).unwrap();

assert_eq!(config.backend(), Backend::Node(Node::Auto));
}

#[test]
fn config_works_backend_node_auto() {
let input = quote! {
backend(node(auto)),
};
let config =
E2EConfig::from_list(&NestedMeta::parse_meta_list(input).unwrap()).unwrap();

match config.backend() {
Backend::Node(node_config) => {
Expand All @@ -204,6 +196,18 @@ mod tests {
}
}

#[test]
#[should_panic(expected = "ErrorUnknownField")]
fn config_backend_node_auto_not_allowed() {
let input = quote! {
backend(node(auto)),
};
let config =
E2EConfig::from_list(&NestedMeta::parse_meta_list(input).unwrap()).unwrap();

assert_eq!(config.backend(), Backend::Node(Node::Auto));
}

#[test]
fn config_works_backend_node_url() {
let input = quote! {
Expand Down

0 comments on commit 3cc52ff

Please sign in to comment.