Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E2E: Add issue numbers + make E2E dependencies optional #1424

Merged
merged 3 commits into from
Sep 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
48 changes: 32 additions & 16 deletions crates/env/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,25 +50,25 @@ secp256k1 = { version = "0.24", features = ["recovery", "global-context"], optio
rand = { version = "0.8", default-features = false, features = ["alloc"], optional = true }
scale-info = { version = "2", default-features = false, features = ["derive"], optional = true }

contract-metadata = "2.0.0-alpha.2"
impl-serde = { version = "0.3.1", default-features = false }
jsonrpsee = { version = "0.14.0", features = ["ws-client"] }
pallet-contracts-primitives = "6.0.0"
serde = { version = "1.0.137", default-features = false, features = ["derive"] }
serde_json = "1.0.81"
tokio = { version = "1.18.2", features = ["rt-multi-thread"] }
log = "0.4"
env_logger = "0.8"
subxt = "0.24.0"
contract-metadata = { version = "2.0.0-alpha.2", optional = true }
impl-serde = { version = "0.3.1", default-features = false, optional = true }
jsonrpsee = { version = "0.14.0", features = ["ws-client"], optional = true }
pallet-contracts-primitives = { version = "6.0.0", optional = true }
serde = { version = "1.0.137", default-features = false, features = ["derive"], optional = true }
serde_json = { version = "1.0.81", optional = true }
tokio = { version = "1.18.2", features = ["rt-multi-thread"], optional = true }
log = { version = "0.4", optional = true }
env_logger = { version = "0.8", optional = true }
subxt = { version = "0.24.0", optional = true }

# Substrate
sp-rpc = "6.0.0"
sp-core = "6.0.0"
sp-keyring = "6.0.0"
sp-runtime = "6.0.0"
sp-rpc = { version = "6.0.0", optional = true }
sp-core = { version = "6.0.0", optional = true }
sp-keyring = { version = "6.0.0", optional = true }
sp-runtime = { version = "6.0.0", optional = true }

# TODO(#xxx) `smart-bench_macro` needs to be forked.
smart-bench-macro = { git = "https://github.com/paritytech/smart-bench", branch = "cmichi-ink-e2e-test-mvp", package = "smart-bench-macro"}
# TODO(#1421) `smart-bench_macro` needs to be forked.
smart-bench-macro = { git = "https://github.com/paritytech/smart-bench", branch = "cmichi-ink-e2e-test-mvp", package = "smart-bench-macro", optional = true}

[features]
default = ["std"]
Expand All @@ -89,6 +89,22 @@ std = [
"sha2",
"sha3",
"blake2",
# E2E testing environment
"contract-metadata",
"impl-serde",
"jsonrpsee",
"pallet-contracts-primitives",
"serde",
"serde_json",
"tokio",
"log",
"env_logger",
"subxt",
"sp-rpc",
"sp-core",
"sp-keyring",
"sp-runtime",
"smart-bench-macro",
]
# Enable contract debug messages via `debug_print!` and `debug_println!`.
ink-debug = []
2 changes: 1 addition & 1 deletion crates/env/src/engine/e2e/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ where

/// Returns true if the `substrate-contracts-node` log under
/// `/tmp/contracts-node.log` contains `msg`.
/// TODO(#xxx) Matches on any log entry currently, even if done
/// TODO(#1423) Matches on any log entry currently, even if done
/// by a different test.
pub fn node_log_contains(&self, msg: &str) -> bool {
let output = std::process::Command::new("grep")
Expand Down
4 changes: 2 additions & 2 deletions crates/env/src/engine/e2e/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub use client::{
Error,
};
pub use default_accounts::*;
// TODO(#xxx) `smart-bench_macro` needs to be forked.
// TODO(#1421) `smart-bench_macro` needs to be forked.
use pallet_contracts_primitives::{
ContractExecResult,
ContractInstantiateResult,
Expand Down Expand Up @@ -80,7 +80,7 @@ pub type PolkadotConfig = subxt::config::WithExtrinsicParams<
pub type Signer<C> = PairSigner<C, sr25519::Pair>;

/// Trait for contract constructors.
// TODO(#xxx) Merge this with `InkMessage` to be just `InkSelector`. Requires forking `smart-bench-macro`.
// TODO(#1421) Merge this with `InkMessage` to be just `InkSelector`. Requires forking `smart-bench-macro`.
pub trait InkConstructor: scale::Encode {
/// An ink! selector consists of four bytes.
const SELECTOR: [u8; 4];
Expand Down
21 changes: 8 additions & 13 deletions crates/env/src/engine/e2e/xts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ use subxt::{
/// The gas limit for contract instantiate and call dry runs.
const DRY_RUN_GAS_LIMIT: u64 = 500_000_000_000;

// TODO(#xxx) Should be fetched automatically.
// TODO(#1422) Should be fetched automatically.
#[subxt::subxt(runtime_metadata_path = "metadata/contracts-node.scale")]
pub(super) mod api {}

Expand Down Expand Up @@ -302,13 +302,15 @@ where
)
.unvalidated();

self
.client
self.client
.tx()
.sign_and_submit_then_watch_default(&call, signer)
.await
.map(|tx_progress| {
log_info(&format!("signed and submitted call with extrinsic hash {:?}", tx_progress.extrinsic_hash()));
log_info(&format!(
"signed and submitted call with extrinsic hash {:?}",
tx_progress.extrinsic_hash()
));
tx_progress
})
.unwrap_or_else(|err| {
Expand All @@ -317,22 +319,15 @@ where
err
);
})
// TODO(#xxx) It should be configurable to use `.wait_for_finalized_success` instead.
.wait_for_in_block()
.await
.unwrap_or_else(|err| {
panic!(
"error on call `wait_for_in_block`: {:?}",
err
);
panic!("error on call `wait_for_in_block`: {:?}", err);
})
.fetch_events()
.await
.unwrap_or_else(|err| {
panic!(
"error on call `fetch_events`: {:?}",
err
);
panic!("error on call `fetch_events`: {:?}", err);
})
}
}
2 changes: 1 addition & 1 deletion crates/ink/codegen/src/generator/ink_e2e_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ impl GenerateCode for InkE2ETest<'_> {
});

log_info("extracting metadata");
// TODO(#xxx) `smart-bench_macro` needs to be forked.
// TODO(#1421) `smart-bench_macro` needs to be forked.
ink::env::e2e::smart_bench_macro::contract!(#path);

log_info("creating new client");
Expand Down