Skip to content

Commit a21784e

Browse files
committed
refactor: sandbox to runtime
1 parent 60266ff commit a21784e

File tree

38 files changed

+282
-266
lines changed

38 files changed

+282
-266
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
[Unreleased]
88

9-
## Added
9+
### Added
1010
- Implement `From<ink::Address>` for "ink-as-dependency" contract refs - [#2728](https://github.com/use-ink/ink/pull/2728)
1111

12+
### Changed
13+
- Rename `ink_sandbox` crate to `ink_runtime`, `Sandbox` trait to `RuntimeEnv`, and `SandboxClient` to `RuntimeClient` for improved clarity
14+
1215
## Version 6.0.0-beta.1
1316

1417
### Added

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ members = [
1515
"crates/revive-types",
1616
"crates/prelude",
1717
"crates/primitives",
18-
"crates/sandbox",
18+
"crates/runtime",
1919
"crates/storage",
2020
"crates/storage/traits"
2121
]

crates/e2e/macro/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ tracing = { workspace = true }
3131
[dev-dependencies]
3232
ink = { path = "../../ink" }
3333
ink_e2e = { path = "../" }
34-
ink_sandbox = { path = "../../sandbox" }
34+
ink_runtime = { path = "../../runtime" }
3535
temp-env = "0.3.6"
3636

3737
[features]

crates/e2e/macro/src/config.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ impl Node {
6565
/// The runtime emulator that should be used within `TestExternalities`
6666
#[derive(Clone, Eq, PartialEq, Debug, darling::FromMeta)]
6767
pub struct RuntimeOnly {
68-
/// The sandbox runtime type (e.g., `ink_sandbox::DefaultSandbox`)
68+
/// The sandbox runtime type (e.g., `ink_runtime::DefaultRuntime`)
6969
pub sandbox: syn::Path,
7070
/// The client type implementing the backend traits (e.g.,
71-
/// `ink_sandbox::SandboxClient`)
71+
/// `ink_runtime::RuntimeClient`)
7272
pub client: syn::Path,
7373
}
7474

@@ -144,7 +144,7 @@ mod tests {
144144
fn config_works_backend_runtime_only() {
145145
let input = quote! {
146146
environment = crate::CustomEnvironment,
147-
backend(runtime_only(sandbox = ::ink_sandbox::DefaultSandbox, client = ::ink_sandbox::SandboxClient)),
147+
backend(runtime_only(sandbox = ::ink_runtime::DefaultRuntime, client = ::ink_runtime::RuntimeClient)),
148148
};
149149
let config =
150150
E2EConfig::from_list(&NestedMeta::parse_meta_list(input).unwrap()).unwrap();
@@ -157,8 +157,8 @@ mod tests {
157157
assert_eq!(
158158
config.backend(),
159159
Backend::RuntimeOnly(RuntimeOnly {
160-
sandbox: syn::parse_quote! { ::ink_sandbox::DefaultSandbox },
161-
client: syn::parse_quote! { ::ink_sandbox::SandboxClient },
160+
sandbox: syn::parse_quote! { ::ink_runtime::DefaultRuntime },
161+
client: syn::parse_quote! { ::ink_runtime::RuntimeClient },
162162
})
163163
);
164164
}
@@ -175,25 +175,25 @@ mod tests {
175175
assert_eq!(
176176
config.backend(),
177177
Backend::RuntimeOnly(RuntimeOnly {
178-
sandbox: syn::parse_quote! { ::ink_sandbox::DefaultSandbox },
179-
client: syn::parse_quote! { ::ink_sandbox::SandboxClient },
178+
sandbox: syn::parse_quote! { ::ink_runtime::DefaultRuntime },
179+
client: syn::parse_quote! { ::ink_runtime::RuntimeClient },
180180
})
181181
);
182182
}
183183

184184
#[test]
185185
fn config_works_runtime_only_with_custom_backend() {
186186
let input = quote! {
187-
backend(runtime_only(sandbox = ::ink_sandbox::DefaultSandbox, client = ::ink_sandbox::SandboxClient)),
187+
backend(runtime_only(sandbox = ::ink_runtime::DefaultRuntime, client = ::ink_runtime::RuntimeClient)),
188188
};
189189
let config =
190190
E2EConfig::from_list(&NestedMeta::parse_meta_list(input).unwrap()).unwrap();
191191

192192
assert_eq!(
193193
config.backend(),
194194
Backend::RuntimeOnly(RuntimeOnly {
195-
sandbox: syn::parse_quote! { ::ink_sandbox::DefaultSandbox },
196-
client: syn::parse_quote! { ::ink_sandbox::SandboxClient },
195+
sandbox: syn::parse_quote! { ::ink_runtime::DefaultRuntime },
196+
client: syn::parse_quote! { ::ink_runtime::RuntimeClient },
197197
})
198198
);
199199
}

crates/e2e/macro/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ use syn::Result;
6060
/// ```
6161
/// type E2EResult<T> = std::result::Result<T, Box<dyn std::error::Error>>;
6262
///
63-
/// #[ink_sandbox::test(backend(runtime_only(sandbox = ink_sandbox::DefaultSandbox, client = ink_sandbox::SandboxClient)))]
63+
/// #[ink_runtime::test(backend(runtime_only(sandbox = ink_runtime::DefaultRuntime, client = ink_runtime::RuntimeClient)))]
6464
/// async fn runtime_call_works() -> E2EResult<()> {
6565
/// // ...
6666
/// }

crates/primitives/src/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ pub enum DefaultEnvironment {}
401401
impl Environment for DefaultEnvironment {
402402
// This number was chosen as it's also what `pallet-revive`
403403
// chooses by default. It's also the number present in the
404-
// `ink_sandbox` and the `ink-node`.
404+
// `ink_runtime` and the `ink-node`.
405405
const NATIVE_TO_ETH_RATIO: u32 = 100_000_000;
406406

407407
// These const's correspond to the settings of Asset Hub and

crates/sandbox/Cargo.toml renamed to crates/runtime/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[package]
2-
name = "ink_sandbox"
2+
name = "ink_runtime"
33
version = "6.0.0-beta.1"
44
authors = ["Use Ink <[email protected]>", "Cardinal Cryptography"]
55
edition.workspace = true
66
license.workspace = true
7-
description = "Sandbox runtime environment for ink! e2e tests"
7+
description = "Runtime environment for ink! e2e tests"
88
repository.workspace = true
9-
documentation = "https://docs.rs/ink_sandbox"
9+
documentation = "https://docs.rs/ink_runtime"
1010
homepage.workspace = true
1111

1212
[dependencies]
File renamed without changes.

crates/sandbox/src/api/assets_api.rs renamed to crates/runtime/src/api/assets_api.rs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::{
22
AccountIdFor,
33
IntoAccountId,
4-
Sandbox,
4+
RuntimeEnv,
55
};
66
use frame_support::{
77
pallet_prelude::DispatchError,
@@ -28,7 +28,7 @@ type AssetBalanceOf<T, I> = <T as pallet_assets::Config<I>>::Balance;
2828
/// Provides methods to create, mint, and manage assets in `pallet-assets`.
2929
pub trait AssetsAPI<T, I = pallet_assets::Instance1>
3030
where
31-
T: Sandbox,
31+
T: RuntimeEnv,
3232
T::Runtime: pallet_assets::Config<I>,
3333
I: 'static,
3434
{
@@ -168,7 +168,7 @@ where
168168

169169
impl<T, I> AssetsAPI<T, I> for T
170170
where
171-
T: Sandbox,
171+
T: RuntimeEnv,
172172
T::Runtime: pallet_assets::Config<I>,
173173
I: 'static,
174174
{
@@ -323,12 +323,12 @@ where
323323
#[cfg(test)]
324324
mod tests {
325325
use super::*;
326-
use crate::DefaultSandbox;
326+
use crate::DefaultRuntime;
327327

328328
#[test]
329329
fn create_works() {
330-
let mut sandbox = DefaultSandbox::default();
331-
let admin = DefaultSandbox::default_actor();
330+
let mut sandbox = DefaultRuntime::default();
331+
let admin = DefaultRuntime::default_actor();
332332
let asset_id = 1u32;
333333
let min_balance = 1u128;
334334

@@ -340,8 +340,8 @@ mod tests {
340340

341341
#[test]
342342
fn set_metadata_works() {
343-
let mut sandbox = DefaultSandbox::default();
344-
let admin = DefaultSandbox::default_actor();
343+
let mut sandbox = DefaultRuntime::default();
344+
let admin = DefaultRuntime::default_actor();
345345
let asset_id = 1u32;
346346

347347
sandbox.create(&asset_id, &admin, 1u128).unwrap();
@@ -357,8 +357,8 @@ mod tests {
357357

358358
#[test]
359359
fn metadata_works() {
360-
let mut sandbox = DefaultSandbox::default();
361-
let admin = DefaultSandbox::default_actor();
360+
let mut sandbox = DefaultRuntime::default();
361+
let admin = DefaultRuntime::default_actor();
362362
let asset_id = 1u32;
363363

364364
sandbox.create(&asset_id, &admin, 1u128).unwrap();
@@ -381,8 +381,8 @@ mod tests {
381381

382382
#[test]
383383
fn approve_works() {
384-
let mut sandbox = DefaultSandbox::default();
385-
let admin = DefaultSandbox::default_actor();
384+
let mut sandbox = DefaultRuntime::default();
385+
let admin = DefaultRuntime::default_actor();
386386
let spender = ink_e2e::bob().into_account_id();
387387
let asset_id = 1u32;
388388

@@ -402,8 +402,8 @@ mod tests {
402402

403403
#[test]
404404
fn mint_into_works() {
405-
let mut sandbox = DefaultSandbox::default();
406-
let admin = DefaultSandbox::default_actor();
405+
let mut sandbox = DefaultRuntime::default();
406+
let admin = DefaultRuntime::default_actor();
407407
let asset_id = 1u32;
408408

409409
sandbox.create(&asset_id, &admin, 1u128).unwrap();
@@ -419,8 +419,8 @@ mod tests {
419419

420420
#[test]
421421
fn transfer_works() {
422-
let mut sandbox = DefaultSandbox::default();
423-
let admin = DefaultSandbox::default_actor();
422+
let mut sandbox = DefaultRuntime::default();
423+
let admin = DefaultRuntime::default_actor();
424424
let recipient = ink_e2e::bob().into_account_id();
425425
let asset_id = 1u32;
426426

@@ -446,8 +446,8 @@ mod tests {
446446

447447
#[test]
448448
fn balance_of_works() {
449-
let mut sandbox = DefaultSandbox::default();
450-
let admin = DefaultSandbox::default_actor();
449+
let mut sandbox = DefaultRuntime::default();
450+
let admin = DefaultRuntime::default_actor();
451451
let asset_id = 1u32;
452452

453453
sandbox.create(&asset_id, &admin, 1u128).unwrap();
@@ -463,8 +463,8 @@ mod tests {
463463

464464
#[test]
465465
fn total_supply_works() {
466-
let mut sandbox = DefaultSandbox::default();
467-
let admin = DefaultSandbox::default_actor();
466+
let mut sandbox = DefaultRuntime::default();
467+
let admin = DefaultRuntime::default_actor();
468468
let asset_id = 1u32;
469469

470470
sandbox.create(&asset_id, &admin, 1u128).unwrap();
@@ -480,8 +480,8 @@ mod tests {
480480

481481
#[test]
482482
fn allowance_works() {
483-
let mut sandbox = DefaultSandbox::default();
484-
let admin = DefaultSandbox::default_actor();
483+
let mut sandbox = DefaultRuntime::default();
484+
let admin = DefaultRuntime::default_actor();
485485
let spender = ink_e2e::bob().into_account_id();
486486
let asset_id = 1u32;
487487

@@ -500,8 +500,8 @@ mod tests {
500500

501501
#[test]
502502
fn asset_exists_works() {
503-
let mut sandbox = DefaultSandbox::default();
504-
let admin = DefaultSandbox::default_actor();
503+
let mut sandbox = DefaultRuntime::default();
504+
let admin = DefaultRuntime::default_actor();
505505
let asset_id = 1u32;
506506

507507
assert!(!sandbox.asset_exists(&asset_id));

0 commit comments

Comments
 (0)