Skip to content

Commit

Permalink
Replace tokio::test macro with explicit async init
Browse files Browse the repository at this point in the history
  • Loading branch information
ascjones committed Oct 6, 2022
1 parent a6478b5 commit 7e63d1c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
32 changes: 21 additions & 11 deletions crates/e2e/macro/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ impl InkE2ETest {

quote! {
#( #attrs )*
#[::ink_e2e::tokio::test]
async #vis fn #fn_name () #ret {
#[test]
#vis fn #fn_name () #ret {
use ::ink_e2e::log_info;
::ink_e2e::LOG_PREFIX.with(|log_prefix| {
let str = format!("test: {}", stringify!(#fn_name));
Expand All @@ -166,16 +166,26 @@ impl InkE2ETest {

log_info("creating new client");

// TODO(#xxx) Make those two generic environments customizable.
let mut client = ::ink_e2e::Client::<
::ink_e2e::PolkadotConfig,
ink::env::DefaultEnvironment
>::new(&#path, &#ws_url, &#node_log).await;

let __ret = {
#block
let run = async {
// TODO(#xxx) Make those two generic environments customizable.
let mut client = ::ink_e2e::Client::<
::ink_e2e::PolkadotConfig,
ink::env::DefaultEnvironment
>::new(&#path, &#ws_url, &#node_log).await;

let __ret = {
#block
};
__ret
};
__ret

{
return ::ink_e2e::tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.expect("Failed building the Runtime")
.block_on(run);
}
}
}
}
Expand Down
1 change: 0 additions & 1 deletion examples/contract-transfer/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ pub mod give_me {
mod e2e_tests {
type E2EResult<T> = std::result::Result<T, Box<dyn std::error::Error>>;

// todo: [AJ] fix compilation error here with tokio reexport: `failed to resolve: use of undeclared crate or module `tokio``
#[ink_e2e::e2e_test]
async fn e2e_sending_value_to_give_me_must_fail(
mut client: ink_e2e::Client<C, E>,
Expand Down

0 comments on commit 7e63d1c

Please sign in to comment.