Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c04f89a
Parse backend type
pmikolajczyk41 Aug 2, 2023
c13ceca
Config tests
pmikolajczyk41 Aug 2, 2023
816030b
Extract client building
pmikolajczyk41 Aug 2, 2023
96c124f
OCD
pmikolajczyk41 Aug 2, 2023
d2abb06
CHANGELOG.md
pmikolajczyk41 Aug 4, 2023
316bf58
Merge remote-tracking branch 'origin/master' into pmikolajczyk41/e2e-…
pmikolajczyk41 Aug 4, 2023
37f8d09
Merge remote-tracking branch 'origin/master' into pmikolajczyk41/e2e-…
pmikolajczyk41 Aug 7, 2023
f679f73
Merge remote-tracking branch 'origin/master' into pmikolajczyk41/e2e-…
pmikolajczyk41 Aug 16, 2023
f8e295a
Add drink dependency, fix with wasm-instrument
pmikolajczyk41 Aug 17, 2023
7be1f3a
ChainApi
pmikolajczyk41 Aug 18, 2023
42484ff
Instantiate
pmikolajczyk41 Aug 18, 2023
06cbc9b
Calling
pmikolajczyk41 Aug 18, 2023
c454db3
Upload
pmikolajczyk41 Aug 18, 2023
b21fc27
Use all arguments
pmikolajczyk41 Aug 18, 2023
ec3936e
Build client in macro
pmikolajczyk41 Aug 18, 2023
17bf359
fmt, implement e2e backend
pmikolajczyk41 Aug 18, 2023
dcc746d
remove actor types
pmikolajczyk41 Aug 18, 2023
624d20f
convert accounts and hashes
pmikolajczyk41 Aug 22, 2023
2b67dc8
get rid of session
pmikolajczyk41 Aug 23, 2023
7f9b764
add dedicated example
pmikolajczyk41 Aug 23, 2023
158dd64
example working
pmikolajczyk41 Aug 23, 2023
97ac62b
clean a bit
pmikolajczyk41 Aug 23, 2023
20a36ca
Merge remote-tracking branch 'origin/master' into pmikolajczyk41/e2e-…
pmikolajczyk41 Aug 23, 2023
96f647f
merging cleanup
pmikolajczyk41 Aug 23, 2023
15aaa48
use published drink
pmikolajczyk41 Aug 23, 2023
f416edc
Review
pmikolajczyk41 Aug 24, 2023
04bb5e9
Add DRink! as valid word
pmikolajczyk41 Aug 24, 2023
ea738c2
Give it up
pmikolajczyk41 Aug 24, 2023
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
Prev Previous commit
Next Next commit
Config tests
  • Loading branch information
pmikolajczyk41 committed Aug 2, 2023
commit c13ceca906a6c1fbb6e89d776744fbb79df6516c
71 changes: 54 additions & 17 deletions crates/e2e/macro/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,17 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use ink_ir::{ast, format_err_spanned, utils::duplicate_config_err};
use ink_ir::{
ast,
format_err_spanned,
utils::duplicate_config_err,
};

/// The type of the architecture that should be used to run test.
#[derive(Copy, Clone, Eq, PartialEq, Debug, Default)]
enum Backend {
/// The standard approach with running dedicated single-node blockchain in a background process.
/// The standard approach with running dedicated single-node blockchain in a
/// background process.
#[default]
Full,
/// The lightweight approach skipping node layer.
Expand All @@ -30,12 +35,14 @@ impl TryFrom<syn::LitStr> for Backend {
fn try_from(value: syn::LitStr) -> Result<Self, Self::Error> {
match value.value().as_str() {
"full" => Ok(Self::Full),
"runtime_only" => Ok(Self::RuntimeOnly),
_ => Err(format_err_spanned!(
value,
"unknown backend `{}` for ink! E2E test configuration argument",
value.value()
)),
"runtime_only" | "runtime-only" => Ok(Self::RuntimeOnly),
_ => {
Err(format_err_spanned!(
value,
"unknown backend `{}` for ink! E2E test configuration argument",
value.value()
))
}
}
}
}
Expand Down Expand Up @@ -84,12 +91,7 @@ impl TryFrom<ast::AttributeArgs> for E2EConfig {
}
} else if arg.name.is_ident("environment") {
if let Some((_, ast)) = environment {
return Err(duplicate_config_err(
ast,
arg,
"environment",
"E2E test",
));
return Err(duplicate_config_err(ast, arg, "environment", "E2E test"))
}
if let ast::MetaValue::Path(path) = &arg.value {
environment = Some((path.clone(), arg))
Expand All @@ -101,7 +103,7 @@ impl TryFrom<ast::AttributeArgs> for E2EConfig {
}
} else if arg.name.is_ident("backend") {
if let Some((_, ast)) = backend {
return Err(duplicate_config_err(ast, arg, "backend", "E2E test"));
return Err(duplicate_config_err(ast, arg, "backend", "E2E test"))
}
if let ast::MetaValue::Lit(syn::Lit::Str(lit_str)) = &arg.value {
backend = Some((lit_str.clone(), arg))
Expand All @@ -115,14 +117,17 @@ impl TryFrom<ast::AttributeArgs> for E2EConfig {
return Err(format_err_spanned!(
arg,
"encountered unknown or unsupported ink! configuration argument",
));
))
}
}
let additional_contracts = additional_contracts
.map(|(value, _)| value.value().split(' ').map(String::from).collect())
.unwrap_or_else(Vec::new);
let environment = environment.map(|(path, _)| path);
let backend = backend.map(|(b, _)| Backend::try_from(b)).transpose()?.unwrap_or_default();
let backend = backend
.map(|(b, _)| Backend::try_from(b))
.transpose()?
.unwrap_or_default();

Ok(E2EConfig {
additional_contracts,
Expand Down Expand Up @@ -224,19 +229,51 @@ mod tests {
);
}

#[test]
fn backend_must_be_literal() {
assert_try_from(
syn::parse_quote! { backend = full },
Err("expected a string literal for `backend` ink! E2E test configuration argument"),
);
}

#[test]
fn duplicate_backend_fails() {
assert_try_from(
syn::parse_quote! {
backend = "full",
backend = "runtime-only",
},
Err("encountered duplicate ink! E2E test `backend` configuration argument"),
);
}

#[test]
fn specifying_backend_works() {
assert_try_from(
syn::parse_quote! { backend = "runtime-only" },
Ok(E2EConfig {
backend: Backend::RuntimeOnly,
..Default::default()
}),
);
}

#[test]
fn full_config_works() {
assert_try_from(
syn::parse_quote! {
additional_contracts = "adder/Cargo.toml flipper/Cargo.toml",
environment = crate::CustomEnvironment,
backend = "full",
},
Ok(E2EConfig {
additional_contracts: vec![
"adder/Cargo.toml".into(),
"flipper/Cargo.toml".into(),
],
environment: Some(syn::parse_quote! { crate::CustomEnvironment }),
backend: Backend::Full,
}),
);
}
Expand Down