Skip to content

Commit

Permalink
Add ckb-std-wrapper on tests
Browse files Browse the repository at this point in the history
To facilitate version switching of ckb-std during debugging, ckb-std-wrapper has been added in the tests as a dependency for ckb-std
  • Loading branch information
joii2020 committed Sep 30, 2024
1 parent 848ac9b commit af004df
Show file tree
Hide file tree
Showing 20 changed files with 48 additions and 20 deletions.
23 changes: 15 additions & 8 deletions tests/Cargo.lock

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

1 change: 1 addition & 0 deletions tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ members = [
"contracts/exec-child",
"contracts/exec-parent",
"libs/spawn_cmd",
"libs/ckb-std-wrapper",
"tests",
]

Expand Down
4 changes: 2 additions & 2 deletions tests/contracts/exec-child/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ version = "0.1.0"
edition = "2021"

[dependencies]
ckb-std = { git = "https://github.com/joii2020/ckb-std.git", rev = "5bd8c01" }
ckb-std-wrapper = { path = "../../libs/ckb-std-wrapper" }

[features]
native-simulator = ["ckb-std/native-simulator"]
native-simulator = ["ckb-std-wrapper/native-simulator"]

1 change: 1 addition & 0 deletions tests/contracts/exec-child/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use ckb_std::default_alloc;
ckb_std::entry!(program_entry);
#[cfg(not(any(feature = "native-simulator", test)))]
default_alloc!();
use ckb_std_wrapper::ckb_std;

pub fn program_entry() -> i8 {
ckb_std::debug!("This is a sample contract exec-child!");
Expand Down
4 changes: 2 additions & 2 deletions tests/contracts/exec-parent/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ version = "0.1.0"
edition = "2021"

[dependencies]
ckb-std = { git = "https://github.com/joii2020/ckb-std.git", rev = "5bd8c01" }
ckb-std-wrapper = { path = "../../libs/ckb-std-wrapper" }

[features]
native-simulator = ["ckb-std/native-simulator"]
native-simulator = ["ckb-std-wrapper/native-simulator"]

1 change: 1 addition & 0 deletions tests/contracts/exec-parent/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use ckb_std::default_alloc;
ckb_std::entry!(program_entry);
#[cfg(not(any(feature = "native-simulator", test)))]
default_alloc!();
use ckb_std_wrapper::ckb_std;

use ckb_std::ckb_types::bytes::Bytes;
use ckb_std::ckb_types::core::ScriptHashType;
Expand Down
4 changes: 2 additions & 2 deletions tests/contracts/spawn-child/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ version = "0.1.0"
edition = "2021"

[dependencies]
ckb-std = { git = "https://github.com/joii2020/ckb-std.git", rev = "5bd8c01" }
ckb-std-wrapper = { path = "../../libs/ckb-std-wrapper" }
spawn_cmd = { path = "../../libs/spawn_cmd" }

[features]
native-simulator = ["ckb-std/native-simulator"]
native-simulator = ["ckb-std-wrapper/native-simulator"]

1 change: 1 addition & 0 deletions tests/contracts/spawn-child/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ ckb_std::default_alloc!();

#[cfg(any(feature = "native-simulator", test))]
extern crate alloc;
use ckb_std_wrapper::ckb_std;

use alloc::{
string::{String, ToString},
Expand Down
4 changes: 2 additions & 2 deletions tests/contracts/spawn-parent/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ version = "0.1.0"
edition = "2021"

[dependencies]
ckb-std = { git = "https://github.com/joii2020/ckb-std.git", rev = "5bd8c01" }
ckb-std-wrapper = { path = "../../libs/ckb-std-wrapper" }
spawn_cmd = { path = "../../libs/spawn_cmd" }

[features]
native-simulator = ["ckb-std/native-simulator"]
native-simulator = ["ckb-std-wrapper/native-simulator"]

1 change: 1 addition & 0 deletions tests/contracts/spawn-parent/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ ckb_std::default_alloc!();

#[cfg(any(feature = "native-simulator", test))]
extern crate alloc;
use ckb_std_wrapper::ckb_std;

use alloc::{
string::{String, ToString},
Expand Down
10 changes: 10 additions & 0 deletions tests/libs/ckb-std-wrapper/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "ckb-std-wrapper"
version = "0.1.0"
edition = "2021"

[features]
native-simulator = ["ckb-std/native-simulator"]

[dependencies]
ckb-std = { git = "https://github.com/joii2020/ckb-std.git", rev = "5bd8c01" }
2 changes: 2 additions & 0 deletions tests/libs/ckb-std-wrapper/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#![cfg_attr(not(feature = "native-simulator"), no_std)]
pub use ckb_std;
2 changes: 1 addition & 1 deletion tests/native-simulators/exec-child-sim/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
exec-child = { path = "../../contracts/exec-child", features = ["native-simulator"] }
ckb-std = { git = "https://github.com/joii2020/ckb-std.git", rev = "5bd8c01", features = ["native-simulator"] }
ckb-std-wrapper = { path = "../../libs/ckb-std-wrapper" }

[lib]
crate-type = ["cdylib"]
1 change: 1 addition & 0 deletions tests/native-simulators/exec-child-sim/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
use ckb_std_wrapper::ckb_std;
ckb_std::entry_simulator!(exec_child::program_entry);
2 changes: 1 addition & 1 deletion tests/native-simulators/exec-parent-sim/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
exec-parent = { path = "../../contracts/exec-parent", features = ["native-simulator"] }
ckb-std = { git = "https://github.com/joii2020/ckb-std.git", rev = "5bd8c01", features = ["native-simulator"] }
ckb-std-wrapper = { path = "../../libs/ckb-std-wrapper" }

[lib]
crate-type = ["cdylib"]
1 change: 1 addition & 0 deletions tests/native-simulators/exec-parent-sim/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
use ckb_std_wrapper::ckb_std;
ckb_std::entry_simulator!(exec_parent::program_entry);
2 changes: 1 addition & 1 deletion tests/native-simulators/spawn-child-sim/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
spawn-child = { path = "../../contracts/spawn-child", features = ["native-simulator"] }
ckb-std = { git = "https://github.com/joii2020/ckb-std.git", rev = "5bd8c01", features = ["native-simulator"] }
ckb-std-wrapper = { path = "../../libs/ckb-std-wrapper" }

[lib]
crate-type = ["cdylib"]
1 change: 1 addition & 0 deletions tests/native-simulators/spawn-child-sim/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
use ckb_std_wrapper::ckb_std;
ckb_std::entry_simulator!(spawn_child::program_entry);
2 changes: 1 addition & 1 deletion tests/native-simulators/spawn-parent-sim/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
spawn-parent = { path = "../../contracts/spawn-parent", features = ["native-simulator"] }
ckb-std = { git = "https://github.com/joii2020/ckb-std.git", rev = "5bd8c01", features = ["native-simulator"] }
ckb-std-wrapper = { path = "../../libs/ckb-std-wrapper" }

[lib]
crate-type = ["cdylib"]
1 change: 1 addition & 0 deletions tests/native-simulators/spawn-parent-sim/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
use ckb_std_wrapper::ckb_std;
ckb_std::entry_simulator!(spawn_parent::program_entry);

0 comments on commit af004df

Please sign in to comment.