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

Replace drink sandbox by internal ink_sandbox #2158

Merged
merged 27 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
4757157
Replace drink sandbox by internal ink_sandbox
pgherveou Mar 14, 2024
a2d0dec
fix spellcheck
pgherveou Mar 14, 2024
29c16a7
Make things less verbose
pgherveou Mar 14, 2024
da3bf98
fix doc comment
pgherveou Mar 14, 2024
c22c176
Update crates/e2e/sandbox/Cargo.toml
pgherveou Mar 15, 2024
5b54c4b
Fix todo
pgherveou Mar 15, 2024
da422c6
fix cargo.toml
pgherveou Mar 15, 2024
16da264
Update crates/e2e/sandbox/src/macros.rs
pgherveou Mar 15, 2024
300f1cb
Update crates/e2e/sandbox/src/macros.rs
pgherveou Mar 15, 2024
72723dd
Update crates/e2e/sandbox/src/macros.rs
pgherveou Mar 15, 2024
76a9b54
Update crates/e2e/sandbox/src/macros.rs
pgherveou Mar 15, 2024
ad56eea
Update crates/e2e/sandbox/src/macros.rs
pgherveou Mar 15, 2024
49efbf5
Update crates/e2e/sandbox/src/macros.rs
pgherveou Mar 15, 2024
99fb619
Update crates/e2e/sandbox/src/macros.rs
pgherveou Mar 15, 2024
8f35496
Apply suggestions from code review
pgherveou Mar 15, 2024
5f1a229
restore untouched cargo.toml
pgherveou Mar 15, 2024
1bc93f9
fix
pgherveou Mar 15, 2024
3b0fb08
more untouched to restore
pgherveou Mar 15, 2024
23dbe95
Remove mininal prefix. use DefaultSandbox instead of MinimalSandbox
pgherveou Mar 15, 2024
59f483b
Refactor some shared type alias
pgherveou Mar 15, 2024
25f8429
Fix macros
pgherveou Mar 18, 2024
71adcbe
Fixes
pgherveou Mar 18, 2024
24e331e
Merge branch 'master' into pg/move-drink
pgherveou Mar 19, 2024
b25d975
fix dep
pgherveou Mar 19, 2024
62b76b7
Fix use import
pgherveou Mar 19, 2024
1175740
Move sandbox version to package instead of workspace
pgherveou Mar 19, 2024
8d8aaa6
Update RELEASES_CHECKLIST.md
pgherveou Mar 19, 2024
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
2 changes: 2 additions & 0 deletions .config/cargo_spellcheck.dic
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,5 @@ KiB
GB
DRink
^
externalities
sandbox_client
79 changes: 21 additions & 58 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ members = [
"crates/allocator",
"crates/e2e",
"crates/e2e/macro",
"crates/e2e/sandbox",
"crates/engine",
"crates/env",
"crates/ink",
Expand Down Expand Up @@ -40,7 +41,6 @@ cfg-if = { version = "1.0" }
contract-build = { version = "4.0.1" }
darling = { version = "0.20.8" }
derive_more = { version = "0.99.17", default-features = false }
drink = { version = "=0.14.0", default-features = false, features = ["std"] }
either = { version = "1.5", default-features = false }
funty = { version = "2.0.0" }
heck = { version = "0.4.0" }
Expand Down Expand Up @@ -81,12 +81,20 @@ wasm-instrument = { version = "0.4.0" }
which = { version = "6.0.0" }
xxhash-rust = { version = "0.8" }
const_env = { version = "0.1"}
wat = { version = "1.0.71" }

# Substrate dependencies
frame-metadata = { version = "16.0.0" }
frame-system = { version = "30.0.0", default-features = false }
frame-support = { version = "30.0.0", default-features = false }
pallet-contracts = { version = "29.0.0", default-features = false }
pallet-balances = { version = "30.0.0", default-features = false }
pallet-timestamp = { version = "29.0.0", default-features = false }
pallet-contracts-uapi = { package = "pallet-contracts-uapi-next", version = "=6.0.3", default-features = false }
pallet-contracts-mock-network = { version = "5.0.0", default-features = false }
sp-externalities = { version = "0.27.0", default-features = false }
sp-io = { version = "32.0.0", default-features = false }
sp-runtime-interface = { version = "26.0.0" }
sp-core = { version = "30.0.0", default-features = false }
sp-keyring = { version = "33.0.0", default-features = false }
sp-runtime = { version = "33.0.0", default-features = false }
Expand All @@ -97,6 +105,7 @@ ink = { version = "=5.0.0", path = "crates/ink", default-features = false }
ink_allocator = { version = "=5.0.0", path = "crates/allocator", default-features = false }
ink_codegen = { version = "=5.0.0", path = "crates/ink/codegen", default-features = false }
ink_e2e_macro = { version = "=5.0.0", path = "crates/e2e/macro", default-features = false }
ink_sandbox = { version = "=5.0.0", path = "crates/e2e/sandbox", default-features = false }
ink_engine = { version = "=5.0.0", path = "crates/engine", default-features = false }
ink_env = { version = "=5.0.0", path = "crates/env", default-features = false }
ink_ir = { version = "=5.0.0", path = "crates/ink/ir", default-features = false }
Expand Down
16 changes: 9 additions & 7 deletions crates/e2e/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ink_primitives = { workspace = true, default-features = true }

cargo_metadata = { workspace = true }
contract-build = { workspace = true }
drink = { workspace = true, optional = true }
ink_sandbox = { workspace = true, optional = true }
pallet-contracts-mock-network = { workspace = true, optional = true }
funty = { workspace = true }
impl-serde = { workspace = true }
Expand Down Expand Up @@ -64,13 +64,15 @@ std = [
"sp-core/std",
"sp-runtime/std",
"sp-weights/std",
"drink?/std",
"ink_e2e_macro/std",
"ink_sandbox/std",
"frame-support/std",
"pallet-contracts-mock-network?/std"
]
drink = [
"dep:drink",
"ink_e2e_macro/drink",
"pallet-contracts-mock-network",
"subxt-metadata",

sandbox = [
"dep:ink_sandbox",
"subxt-metadata",
"pallet-contracts-mock-network",
"ink_e2e_macro/sandbox",
]
4 changes: 2 additions & 2 deletions crates/e2e/macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ quote = { workspace = true }

[dev-dependencies]
ink = { path = "../../ink" }
ink_e2e = { path = "../", features = ["drink"] }
ink_e2e = { path = "../", features = ["sandbox"] }
temp-env = "0.3.6"

[features]
std = []
drink = []
sandbox = []
6 changes: 3 additions & 3 deletions crates/e2e/macro/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl InkE2ETest {
Backend::Node(node_config) => {
build_full_client(&environment, exec_build_contracts, node_config)
}
#[cfg(any(test, feature = "drink"))]
#[cfg(any(test, feature = "sandbox"))]
Backend::RuntimeOnly(runtime) => {
build_runtime_client(exec_build_contracts, runtime.into())
}
Expand Down Expand Up @@ -146,10 +146,10 @@ fn build_full_client(
}
}

#[cfg(any(test, feature = "drink"))]
#[cfg(any(test, feature = "sandbox"))]
fn build_runtime_client(contracts: TokenStream2, runtime: syn::Path) -> TokenStream2 {
quote! {
let contracts = #contracts;
let mut client = ::ink_e2e::DrinkClient::<_, _, #runtime>::new(contracts);
let mut client = ::ink_e2e::SandboxClient::<_, _, #runtime>::new(contracts);
}
}
17 changes: 8 additions & 9 deletions crates/e2e/macro/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ pub enum Backend {

/// The lightweight approach skipping node layer.
///
/// This runs a runtime emulator within `TestExternalities` (using drink! library) in
/// This runs a runtime emulator within `TestExternalities`
/// the same process as the test.
#[cfg(any(test, feature = "drink"))]
#[cfg(any(test, feature = "sandbox"))]
RuntimeOnly(RuntimeOnly),
}

Expand Down Expand Up @@ -61,9 +61,8 @@ impl Node {
}
}

/// The runtime emulator that should be used within `TestExternalities` (using drink!
/// library).
#[cfg(any(test, feature = "drink"))]
/// The runtime emulator that should be used within `TestExternalities`
#[cfg(any(test, feature = "sandbox"))]
#[derive(Clone, Eq, PartialEq, Debug, darling::FromMeta)]
pub enum RuntimeOnly {
#[darling(word)]
Expand All @@ -72,11 +71,11 @@ pub enum RuntimeOnly {
Sandbox(syn::Path),
}

#[cfg(any(test, feature = "drink"))]
#[cfg(any(test, feature = "sandbox"))]
impl From<RuntimeOnly> for syn::Path {
fn from(value: RuntimeOnly) -> Self {
match value {
RuntimeOnly::Default => syn::parse_quote! { ::ink_e2e::MinimalSandbox },
RuntimeOnly::Default => syn::parse_quote! { ::ink_e2e::DefaultSandbox },
RuntimeOnly::Sandbox(path) => path,
}
}
Expand Down Expand Up @@ -151,15 +150,15 @@ mod tests {
#[test]
fn config_works_runtime_only_with_custom_backend() {
let input = quote! {
backend(runtime_only(sandbox = ::ink_e2e::MinimalSandbox)),
backend(runtime_only(sandbox = ::ink_e2e::DefaultSandbox)),
};
let config =
E2EConfig::from_list(&NestedMeta::parse_meta_list(input).unwrap()).unwrap();

assert_eq!(
config.backend(),
Backend::RuntimeOnly(RuntimeOnly::Sandbox(
syn::parse_quote! { ::ink_e2e::MinimalSandbox }
syn::parse_quote! { ::ink_e2e::DefaultSandbox }
))
);
}
Expand Down
41 changes: 41 additions & 0 deletions crates/e2e/sandbox/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[package]
name = "ink_sandbox"
version.workspace = true
pgherveou marked this conversation as resolved.
Show resolved Hide resolved
authors = ["Cardinal Cryptography", "Parity Technologies <[email protected]>"]
edition.workspace = true
license.workspace = true
description = "Sandbox runtime environment for ink! e2e tests"

[dependencies]
frame-metadata = { workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
pallet-balances = { workspace = true }
pallet-contracts = { workspace = true }
pallet-timestamp = { workspace = true }
scale = { workspace = true }
sp-core = { workspace = true }
sp-externalities = { workspace = true }
sp-io = { workspace = true }

paste = { workspace = true }
scale-info = { workspace = true }
wat = { workspace = true }

[features]
default = [
# This is required for the runtime-interface to work properly in the std env.
"std",
]
std = [
"frame-support/std",
"frame-system/std",
"pallet-balances/std",
"pallet-contracts/std",
"pallet-timestamp/std",
"scale/std",
"scale-info/std",
"sp-core/std",
"sp-externalities/std",
"sp-io/std"
]
13 changes: 13 additions & 0 deletions crates/e2e/sandbox/src/api.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
pub mod balance_api;
pub mod contracts_api;
pub mod system_api;
pub mod timestamp_api;

pub mod prelude {
pub use super::{
balance_api::BalanceAPI,
contracts_api::ContractAPI,
system_api::SystemAPI,
timestamp_api::TimestampAPI,
};
}
Loading
Loading