Skip to content

Commit 24aef72

Browse files
committed
better stabilized tests
1 parent 912b13c commit 24aef72

File tree

12 files changed

+194
-74
lines changed

12 files changed

+194
-74
lines changed

fuzz-tests/src/bindings/fs_tests_backend.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@ impl FsTestsBackendCanister {
2727
args,
2828
)
2929
}
30-
pub fn do_fs_test_basic(&self, arg0: u64) -> super::CallBuilder<String> {
31-
let args = Encode!(&arg0);
30+
pub fn do_fs_test(&self) -> super::CallBuilder<String> {
31+
let args = Encode!();
3232
self.caller.call(
3333
self.canister_id,
3434
super::CallMode::Update,
35-
"do_fs_test_basic",
35+
"do_fs_test",
3636
args,
3737
)
3838
}
39-
pub fn generate_random_fs(&self, arg0: u64, arg1: u64, arg2: u64) -> super::CallBuilder<()> {
39+
pub fn generate_random_fs(&self, arg0: u64, arg1: u64, arg2: u64) -> super::CallBuilder<u64> {
4040
let args = Encode!(&arg0, &arg1, &arg2);
4141
self.caller.call(
4242
self.canister_id,

fuzz-tests/src/test_setup.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
use std::path::PathBuf;
1+
// This is a generated test setup file.
2+
// Manual changes are possible, but you still need to make sure they are not lost, if the file is regenerated.
3+
// If possible, it is best to keep any additional manual test preparation steps outside, in `tests.rs`,
4+
// then this file can be regenerated without risk of losing work.
25

3-
use candid::Principal;
4-
use ic_test::{IcpTest, IcpUser};
6+
use ic_test::IcpTest;
57

68
use crate::bindings::{
79
canister_initial_backend::{self, CanisterInitialBackendCanister},
@@ -27,9 +29,6 @@ pub(crate) async fn setup(icp_test: IcpTest) -> Env {
2729

2830
let fs_tests_backend = fs_tests_backend::deploy(&icp_user).call().await;
2931

30-
// Additional setup steps
31-
// ...
32-
3332
Env {
3433
icp_test,
3534
canister_initial_backend,

fuzz-tests/src/tests.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ async fn test_fs_durability() {
2121

2222
let env = test_setup::setup(IcpTest::new().await).await;
2323

24-
let seed = 42;
25-
26-
let c = env.fs_tests_backend.do_fs_test_basic(seed).call().await;
24+
let c = env.fs_tests_backend.do_fs_test().call().await;
2725
let computed = c.trim();
2826

2927
let e = std::fs::read_to_string("../target/release/report.txt").unwrap();

ic-wasi-polyfill/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ ic-cdk = "0.18.5"
1212
ic-stable-structures = "0.6.7"
1313
stable-fs = "0.8.1"
1414

15-
1615
rand = "0.9.1"
1716
function_name = "0.3.0"
1817

test/canisters/fs_tests/dfx.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"package": "fs_tests_backend",
66
"wasm": "target/wasm32-wasip1/release/fs_tests_backend_nowasi.wasm",
77
"build": "scripts/build.sh",
8-
"type": "custom"
8+
"type": "custom",
9+
"init_arg": "(40, 45)"
910
}
1011
},
1112
"defaults": {

test/canisters/fs_tests/src/fs_tests_backend/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ candid.workspace = true
1818
ic-cdk = "0.18.3"
1919
ic-stable-structures = "0.6.9"
2020

21-
ic-wasi-polyfill = {path="../../../../../ic-wasi-polyfill"}
21+
ic-wasi-polyfill = {path="../../../../../ic-wasi-polyfill", features=["report_wasi_calls"]}
2222

2323

2424
sha2 = "0.10"

test/canisters/fs_tests/src/fs_tests_backend/fs_tests_backend.did

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
service : () -> {
22
basic_fs_test : () -> ();
33
compute_file_hash : (text) -> (text);
4-
do_fs_test_basic : (nat64) -> (text);
5-
generate_random_fs : (nat64, nat64, nat64) -> ();
4+
do_fs_test : () -> (text);
5+
generate_random_fs : (nat64, nat64, nat64) -> (nat64);
66
get_log : () -> (text) query;
77
greet : (text) -> (text) query;
88
read_file : (text) -> (text);

test/canisters/fs_tests/src/fs_tests_backend/some_file.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)