From 7fa27b03d0d891b30a89b1b281ca3ba0661f2750 Mon Sep 17 00:00:00 2001 From: Linwei Shang Date: Tue, 28 May 2024 10:28:48 -0400 Subject: [PATCH] test: use pocket-ic in e2e-tests (#495) * script to download pocket-ic binary * use pocket-ic in e2e tests * fix canister_info * fix test_call_management * fix test_chunk * fix test_cycles_burn * fix test_scheduling_many_timers * fix test_set_global_timers * raise init cycles * ci.yml * cargo update * Revert "cargo update" This reverts commit 6c969d06e03fa62988084c4ef995ba43b7c4b46d. * pocket-ic from mono-repo tag * run cargo test on macos too * fix ci --- .github/workflows/ci.yml | 12 +- .gitignore | 2 +- Cargo.lock | 1221 ++++++++++++++++++++-- e2e-tests/Cargo.toml | 4 +- e2e-tests/canisters/canister_info.rs | 11 +- e2e-tests/canisters/chunk.rs | 2 +- e2e-tests/canisters/management_caller.rs | 8 +- e2e-tests/tests/e2e.rs | 349 ++++--- scripts/download_pocket_ic.sh | 21 + scripts/download_state_machine_binary.sh | 18 - 10 files changed, 1364 insertions(+), 284 deletions(-) create mode 100755 scripts/download_pocket_ic.sh delete mode 100755 scripts/download_state_machine_binary.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f21fe3748..814e425b4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,7 +40,10 @@ jobs: test: name: cargo test - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-12] steps: - name: Checkout repository uses: actions/checkout@v4 @@ -57,11 +60,12 @@ jobs: restore-keys: | ${{ runner.os }}-test- ${{ runner.os }}- - - name: Download ic-test-state-machine + - name: Download pocket-ic run: | - bash scripts/download_state_machine_binary.sh + bash scripts/download_pocket_ic.sh - name: Run tests - run: | # https://github.com/rust-lang/cargo/issues/6669 we have to run ALL tests with two commands + run: + | # https://github.com/rust-lang/cargo/issues/6669 we have to run ALL tests with two commands cargo test --all-targets cargo test --doc diff --git a/.gitignore b/.gitignore index 1ce6e64be..5a787c2e5 100644 --- a/.gitignore +++ b/.gitignore @@ -17,7 +17,7 @@ examples/*/Cargo.lock **/*.rs.bk .DS_Store -ic-test-state-machine +e2e-tests/pocket-ic # Generated bindings **/declarations/ diff --git a/Cargo.lock b/Cargo.lock index d1fedada8..fcd8d63b1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11,6 +11,12 @@ dependencies = [ "gimli", ] +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + [[package]] name = "ahash" version = "0.8.11" @@ -68,7 +74,7 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a64c907d4e79225ac72e2a354c9ce84d50ebb4586dee56c82b3ee73004f537f5" dependencies = [ - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -78,7 +84,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" dependencies = [ "anstyle", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -119,18 +125,51 @@ dependencies = [ "syn 2.0.61", ] +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + [[package]] name = "autocfg" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +[[package]] +name = "backtrace" +version = "0.3.71" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + [[package]] name = "base64" version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + [[package]] name = "beef" version = "0.5.2" @@ -211,6 +250,12 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" +[[package]] +name = "bytes" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" + [[package]] name = "camino" version = "1.1.6" @@ -296,15 +341,16 @@ dependencies = [ [[package]] name = "cargo_metadata" -version = "0.14.2" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4acbb09d9ee8e23699b9634375c72795d095bf268439da88562cf9b501f181fa" +checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" dependencies = [ "camino", "cargo-platform", "semver", "serde", "serde_json", + "thiserror", ] [[package]] @@ -324,33 +370,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "ciborium" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e" -dependencies = [ - "ciborium-io", - "ciborium-ll", - "serde", -] - -[[package]] -name = "ciborium-io" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757" - -[[package]] -name = "ciborium-ll" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9" -dependencies = [ - "ciborium-io", - "half 2.4.1", -] - [[package]] name = "clap" version = "4.5.4" @@ -416,6 +435,22 @@ dependencies = [ "unicode-segmentation", ] +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" + [[package]] name = "cpp_demangle" version = "0.4.3" @@ -552,6 +587,15 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "crossbeam-channel" +version = "0.5.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33480d6946193aa8033910124896ca395333cae7e2d1113d1fef6c3272217df2" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "crossbeam-deque" version = "0.8.5" @@ -608,6 +652,15 @@ dependencies = [ "uuid", ] +[[package]] +name = "deranged" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", +] + [[package]] name = "digest" version = "0.10.7" @@ -649,6 +702,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "dyn-clone" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" + [[package]] name = "either" version = "1.11.0" @@ -686,7 +745,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -719,6 +778,15 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + [[package]] name = "futures" version = "0.3.30" @@ -869,20 +937,29 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] -name = "half" -version = "1.8.3" +name = "h2" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b43ede17f21864e81be2fa654110bf1e793774238d86ef8555c37e6519c0403" +checksum = "fa82e28a107a8cc405f0839610bdc9b15f1e25ec7d696aa5cf173edbcb1486ab" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] [[package]] name = "half" -version = "2.4.1" +version = "1.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888" -dependencies = [ - "cfg-if", - "crunchy", -] +checksum = "1b43ede17f21864e81be2fa654110bf1e793774238d86ef8555c37e6519c0403" [[package]] name = "hashbrown" @@ -914,11 +991,130 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" +[[package]] +name = "hermit-abi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" + [[package]] name = "hex" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +dependencies = [ + "serde", +] + +[[package]] +name = "http" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0475f8b2ac86659c21b64320d5d653f9efe42acd2a4e560073ec61a155a34f1d" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[package]] +name = "hyper" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe575dd17d0862a9a33781c8c4696a55c320909004a67a00fb286ba8b1bc496d" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0bea761b46ae2b24eb4aef630d8d1c398157b6fc29e6350ecf090a0b70c952c" +dependencies = [ + "futures-util", + "http", + "hyper", + "hyper-util", + "rustls", + "rustls-pki-types", + "tokio", + "tokio-rustls", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d8d52be92d09acc2e01dddb7fde3ad983fc6489c7db4837e605bc3fca4cb63e" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "hyper", + "pin-project-lite", + "socket2", + "tokio", + "tower", + "tower-service", + "tracing", +] + +[[package]] +name = "ic-cdk" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8859bc2b863a77750acf199e1fb7e3fc403e1b475855ba13f59cb4e4036d238" +dependencies = [ + "candid", + "ic-cdk-macros 0.13.2", + "ic0 0.21.1", + "serde", + "serde_bytes", +] [[package]] name = "ic-cdk" @@ -926,8 +1122,8 @@ version = "0.14.0" dependencies = [ "anyhow", "candid", - "ic-cdk-macros", - "ic0", + "ic-cdk-macros 0.14.0", + "ic0 0.23.0", "rstest", "serde", "serde_bytes", @@ -954,14 +1150,28 @@ dependencies = [ "escargot", "futures", "hex", - "ic-cdk", + "ic-cdk 0.14.0", "ic-cdk-timers", - "ic-test-state-machine-client", "lazy_static", + "pocket-ic", "serde_bytes", "sha2", ] +[[package]] +name = "ic-cdk-macros" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a45800053d80a6df839a71aaea5797e723188c0b992618208ca3b941350c7355" +dependencies = [ + "candid", + "proc-macro2", + "quote", + "serde", + "serde_tokenstream 0.1.7", + "syn 1.0.109", +] + [[package]] name = "ic-cdk-macros" version = "0.14.0" @@ -970,7 +1180,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "serde_tokenstream", + "serde_tokenstream 0.2.0", "syn 2.0.61", ] @@ -979,8 +1189,8 @@ name = "ic-cdk-timers" version = "0.8.0" dependencies = [ "futures", - "ic-cdk", - "ic0", + "ic-cdk 0.14.0", + "ic0 0.23.0", "serde", "serde_bytes", "slotmap", @@ -993,7 +1203,7 @@ dependencies = [ "bincode", "candid", "hex", - "ic-cdk", + "ic-cdk 0.14.0", "serde", "serde_bytes", "serde_cbor", @@ -1007,23 +1217,17 @@ dependencies = [ "candid", "crc32fast", "hex", - "ic-cdk", + "ic-cdk 0.14.0", "serde", "serde_bytes", "sha2", ] [[package]] -name = "ic-test-state-machine-client" -version = "3.0.1" +name = "ic0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8e05a81e0cbdf178228d72ace06c60ac7fa99927b49a238f9ccf5ef82eaced6" -dependencies = [ - "candid", - "ciborium", - "serde", - "serde_bytes", -] +checksum = "a54b5297861c651551676e8c43df805dad175cc33bc97dbd992edbbb85dcbcdf" [[package]] name = "ic0" @@ -1053,6 +1257,16 @@ version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005" +[[package]] +name = "idna" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "indexmap" version = "2.2.6" @@ -1064,6 +1278,12 @@ dependencies = [ "serde", ] +[[package]] +name = "ipnet" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" + [[package]] name = "is_terminal_polyfill" version = "1.70.0" @@ -1123,6 +1343,15 @@ dependencies = [ "libc", ] +[[package]] +name = "js-sys" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +dependencies = [ + "wasm-bindgen", +] + [[package]] name = "lalrpop" version = "0.20.2" @@ -1151,7 +1380,7 @@ version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "507460a910eb7b32ee961886ff48539633b788a36b65692b95f225b844c82553" dependencies = [ - "regex-automata", + "regex-automata 0.4.6", ] [[package]] @@ -1245,6 +1474,15 @@ dependencies = [ "libc", ] +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata 0.1.10", +] + [[package]] name = "memchr" version = "2.7.2" @@ -1269,12 +1507,48 @@ dependencies = [ "autocfg", ] +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "miniz_oxide" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae" +dependencies = [ + "adler", +] + +[[package]] +name = "mio" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.48.0", +] + [[package]] name = "new_debug_unreachable" version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + [[package]] name = "num-bigint" version = "0.4.5" @@ -1286,6 +1560,12 @@ dependencies = [ "serde", ] +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + [[package]] name = "num-integer" version = "0.1.46" @@ -1304,6 +1584,16 @@ dependencies = [ "autocfg", ] +[[package]] +name = "num_cpus" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +dependencies = [ + "hermit-abi", + "libc", +] + [[package]] name = "object" version = "0.32.2" @@ -1322,6 +1612,18 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + [[package]] name = "parking_lot" version = "0.12.2" @@ -1342,7 +1644,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-targets", + "windows-targets 0.52.5", ] [[package]] @@ -1351,6 +1653,12 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + [[package]] name = "petgraph" version = "0.6.5" @@ -1376,6 +1684,26 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5be167a7af36ee22fe3115051bc51f6e6c7054c9348e28deb4f49bd6f705a315" +[[package]] +name = "pin-project" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.61", +] + [[package]] name = "pin-project-lite" version = "0.2.14" @@ -1395,7 +1723,34 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" [[package]] -name = "precomputed-hash" +name = "pocket-ic" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9765eeff77b8750cf6258eaeea237b96607cd770aa3d4003f021924192b7e4e" +dependencies = [ + "async-trait", + "base64 0.13.1", + "candid", + "hex", + "ic-cdk 0.13.2", + "reqwest", + "schemars", + "serde", + "serde_bytes", + "serde_json", + "tracing", + "tracing-appender", + "tracing-subscriber", +] + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] +name = "precomputed-hash" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" @@ -1499,10 +1854,19 @@ checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" dependencies = [ "aho-corasick", "memchr", - "regex-automata", + "regex-automata 0.4.6", "regex-syntax 0.8.3", ] +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax 0.6.29", +] + [[package]] name = "regex-automata" version = "0.4.6" @@ -1526,6 +1890,68 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" +[[package]] +name = "reqwest" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "566cafdd92868e0939d3fb961bd0dc25fcfaaed179291093b3d43e6b3150ea10" +dependencies = [ + "base64 0.22.1", + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-rustls", + "hyper-util", + "ipnet", + "js-sys", + "log", + "mime", + "once_cell", + "percent-encoding", + "pin-project-lite", + "rustls", + "rustls-native-certs", + "rustls-pemfile", + "rustls-pki-types", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tokio-rustls", + "tokio-socks", + "tokio-util", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-streams", + "web-sys", + "webpki-roots", + "winreg", +] + +[[package]] +name = "ring" +version = "0.17.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" +dependencies = [ + "cc", + "cfg-if", + "getrandom", + "libc", + "spin", + "untrusted", + "windows-sys 0.52.0", +] + [[package]] name = "rstest" version = "0.12.0" @@ -1570,7 +1996,61 @@ dependencies = [ "errno", "libc", "linux-raw-sys", - "windows-sys", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustls" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf4ef73721ac7bcd79b2b315da7779d8fc09718c6b3d2d1b2d94850eb8c18432" +dependencies = [ + "log", + "ring", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-native-certs" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f1fb85efa936c42c6d5fc28d2629bb51e4b2f4b8a5211e297d599cc5a093792" +dependencies = [ + "openssl-probe", + "rustls-pemfile", + "rustls-pki-types", + "schannel", + "security-framework", +] + +[[package]] +name = "rustls-pemfile" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" +dependencies = [ + "base64 0.22.1", + "rustls-pki-types", +] + +[[package]] +name = "rustls-pki-types" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" + +[[package]] +name = "rustls-webpki" +version = "0.102.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff448f7e92e913c4b7d4c6d8e4540a1724b319b4152b8aef6d4cf8339712b33e" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", ] [[package]] @@ -1594,12 +2074,68 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "schannel" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "schemars" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09c024468a378b7e36765cd36702b7a90cc3cba11654f6685c8f233408e89e92" +dependencies = [ + "dyn-clone", + "schemars_derive", + "serde", + "serde_json", +] + +[[package]] +name = "schemars_derive" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1eee588578aff73f856ab961cd2f79e36bc45d7ded33a7562adba4667aecc0e" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn 2.0.61", +] + [[package]] name = "scopeguard" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "security-framework" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c627723fd09706bacdb5cf41499e95098555af3c3c29d014dc3c458ef6be11c0" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "317936bbbd05227752583946b9e66d7ce3b489f84e11a94a510b4437fef407d7" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "semver" version = "1.0.23" @@ -1633,7 +2169,7 @@ version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5" dependencies = [ - "half 1.8.3", + "half", "serde", ] @@ -1648,6 +2184,17 @@ dependencies = [ "syn 2.0.61", ] +[[package]] +name = "serde_derive_internals" +version = "0.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.61", +] + [[package]] name = "serde_json" version = "1.0.117" @@ -1668,6 +2215,17 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_tokenstream" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "797ba1d80299b264f3aac68ab5d12e5825a561749db4df7cd7c8083900c5d4e9" +dependencies = [ + "proc-macro2", + "serde", + "syn 1.0.109", +] + [[package]] name = "serde_tokenstream" version = "0.2.0" @@ -1680,6 +2238,18 @@ dependencies = [ "syn 2.0.61", ] +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + [[package]] name = "sha2" version = "0.10.8" @@ -1691,6 +2261,15 @@ dependencies = [ "digest", ] +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + [[package]] name = "siphasher" version = "0.3.11" @@ -1727,6 +2306,22 @@ version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +[[package]] +name = "socket2" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + [[package]] name = "sptr" version = "0.3.2" @@ -1771,6 +2366,12 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" +[[package]] +name = "subtle" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" + [[package]] name = "syn" version = "1.0.109" @@ -1793,6 +2394,12 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + [[package]] name = "target-lexicon" version = "0.12.14" @@ -1839,6 +2446,47 @@ dependencies = [ "syn 2.0.61", ] +[[package]] +name = "thread_local" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" +dependencies = [ + "cfg-if", + "once_cell", +] + +[[package]] +name = "time" +version = "0.3.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" +dependencies = [ + "deranged", + "itoa", + "num-conv", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" + +[[package]] +name = "time-macros" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" +dependencies = [ + "num-conv", + "time-core", +] + [[package]] name = "tiny-keccak" version = "2.0.2" @@ -1848,6 +2496,73 @@ dependencies = [ "crunchy", ] +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "num_cpus", + "pin-project-lite", + "socket2", + "windows-sys 0.48.0", +] + +[[package]] +name = "tokio-rustls" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" +dependencies = [ + "rustls", + "rustls-pki-types", + "tokio", +] + +[[package]] +name = "tokio-socks" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51165dfa029d2a65969413a6cc96f354b86b464498702f174a4efa13608fd8c0" +dependencies = [ + "either", + "futures-util", + "thiserror", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + [[package]] name = "toml" version = "0.8.12" @@ -1882,6 +2597,125 @@ dependencies = [ "winnow", ] +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "pin-project", + "pin-project-lite", + "tokio", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-layer" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-appender" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3566e8ce28cc0a3fe42519fc80e6b4c943cc4c8cef275620eb8dac2d3d4e06cf" +dependencies = [ + "crossbeam-channel", + "thiserror", + "time", + "tracing-subscriber", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.61", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-serde" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc6b213177105856957181934e4920de57730fc69bf42c37ee5bb664d406d9e1" +dependencies = [ + "serde", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex", + "serde", + "serde_json", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", + "tracing-serde", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + [[package]] name = "trybuild" version = "1.0.95" @@ -1908,12 +2742,27 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +[[package]] +name = "unicode-bidi" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" + [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +[[package]] +name = "unicode-normalization" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" +dependencies = [ + "tinyvec", +] + [[package]] name = "unicode-segmentation" version = "1.11.0" @@ -1932,6 +2781,23 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "url" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + [[package]] name = "utf8parse" version = "0.2.1" @@ -1944,6 +2810,12 @@ version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + [[package]] name = "version_check" version = "0.9.4" @@ -1960,12 +2832,87 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasm-bindgen" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.61", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.61", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" + [[package]] name = "wasm-encoder" version = "0.201.0" @@ -1984,6 +2931,19 @@ dependencies = [ "leb128", ] +[[package]] +name = "wasm-streams" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b65dc4c90b63b118468cf747d8bf3566c1913ef60be765b5730ead9e0a3ba129" +dependencies = [ + "futures-util", + "js-sys", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + [[package]] name = "wasmparser" version = "0.201.0" @@ -2048,7 +3008,7 @@ dependencies = [ "wasmtime-slab", "wasmtime-winch", "wat", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -2067,7 +3027,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4e660537b0ac2fc76917fb0cc9d403d2448b6983a84e59c51f7fea7b7dae024" dependencies = [ "anyhow", - "base64", + "base64 0.21.7", "bincode", "directories-next", "log", @@ -2076,7 +3036,7 @@ dependencies = [ "serde_derive", "sha2", "toml", - "windows-sys", + "windows-sys 0.52.0", "zstd", ] @@ -2180,7 +3140,7 @@ dependencies = [ "rustix", "wasmtime-asm-macros", "wasmtime-versioned-export-macros", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -2203,7 +3163,7 @@ checksum = "c22ca2ef4d87b23d400660373453e274b2251bc2d674e3102497f690135e04b0" dependencies = [ "cfg-if", "libc", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -2233,7 +3193,7 @@ dependencies = [ "wasmtime-jit-debug", "wasmtime-versioned-export-macros", "wasmtime-wmemcheck", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -2323,6 +3283,25 @@ dependencies = [ "wast", ] +[[package]] +name = "web-sys" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webpki-roots" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3de34ae270483955a94f4b21bdaaeb83d508bb84a01435f393818edb0012009" +dependencies = [ + "rustls-pki-types", +] + [[package]] name = "winapi" version = "0.3.9" @@ -2345,7 +3324,7 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" dependencies = [ - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -2370,13 +3349,37 @@ dependencies = [ "wasmtime-environ", ] +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + [[package]] name = "windows-sys" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets", + "windows-targets 0.52.5", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", ] [[package]] @@ -2385,28 +3388,46 @@ version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", + "windows_aarch64_gnullvm 0.52.5", + "windows_aarch64_msvc 0.52.5", + "windows_i686_gnu 0.52.5", "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_i686_msvc 0.52.5", + "windows_x86_64_gnu 0.52.5", + "windows_x86_64_gnullvm 0.52.5", + "windows_x86_64_msvc 0.52.5", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + [[package]] name = "windows_aarch64_gnullvm" version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + [[package]] name = "windows_aarch64_msvc" version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + [[package]] name = "windows_i686_gnu" version = "0.52.5" @@ -2419,24 +3440,48 @@ version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + [[package]] name = "windows_i686_msvc" version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + [[package]] name = "windows_x86_64_gnu" version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + [[package]] name = "windows_x86_64_gnullvm" version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + [[package]] name = "windows_x86_64_msvc" version = "0.52.5" @@ -2452,6 +3497,16 @@ dependencies = [ "memchr", ] +[[package]] +name = "winreg" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" +dependencies = [ + "cfg-if", + "windows-sys 0.48.0", +] + [[package]] name = "wit-parser" version = "0.201.0" @@ -2490,6 +3545,12 @@ dependencies = [ "syn 2.0.61", ] +[[package]] +name = "zeroize" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" + [[package]] name = "zstd" version = "0.13.1" diff --git a/e2e-tests/Cargo.toml b/e2e-tests/Cargo.toml index a5fe20ec5..2466e94a2 100644 --- a/e2e-tests/Cargo.toml +++ b/e2e-tests/Cargo.toml @@ -10,7 +10,7 @@ publish = false [dependencies] candid.workspace = true -cargo_metadata = "0.14.2" +cargo_metadata = "0.18" escargot = { version = "0.5.7", features = ["print"] } ic-cdk.workspace = true ic-cdk-timers.workspace = true @@ -53,4 +53,4 @@ path = "canisters/chunk.rs" [dev-dependencies] hex.workspace = true -ic-test-state-machine-client = "3" +pocket-ic = "3" diff --git a/e2e-tests/canisters/canister_info.rs b/e2e-tests/canisters/canister_info.rs index 33a108b22..354d7fa1c 100644 --- a/e2e-tests/canisters/canister_info.rs +++ b/e2e-tests/canisters/canister_info.rs @@ -17,13 +17,10 @@ async fn info(canister_id: Principal) -> CanisterInfoResponse { #[ic_cdk::update] async fn canister_lifecycle() -> Principal { - let canister_id = create_canister( - CreateCanisterArgument { settings: None }, - 100_000_000_000 / 13, - ) - .await - .unwrap() - .0; + let canister_id = create_canister(CreateCanisterArgument { settings: None }, 1_000_000_000_000) + .await + .unwrap() + .0; install_code(InstallCodeArgument { mode: Install, arg: vec![], diff --git a/e2e-tests/canisters/chunk.rs b/e2e-tests/canisters/chunk.rs index ad46f7d3f..8eb977cdf 100644 --- a/e2e-tests/canisters/chunk.rs +++ b/e2e-tests/canisters/chunk.rs @@ -10,7 +10,7 @@ use ic_cdk::update; async fn call_create_canister() -> Principal { let arg = CreateCanisterArgument::default(); - create_canister(arg, 100_000_000_000u128) + create_canister(arg, 200_000_000_000u128) .await .unwrap() .0 diff --git a/e2e-tests/canisters/management_caller.rs b/e2e-tests/canisters/management_caller.rs index 07b9cb444..a5c1f53ca 100644 --- a/e2e-tests/canisters/management_caller.rs +++ b/e2e-tests/canisters/management_caller.rs @@ -12,7 +12,7 @@ mod main { settings: Some(CanisterSettings { controllers: Some(vec![ic_cdk::id()]), // There is no canister in the subnet, so we can set it to 100. - compute_allocation: Some(100u8.into()), + compute_allocation: Some(1u8.into()), // Though the upper limit is 256TiB, the actual subnet may have less memory resource (e.g. local replica). // Here we set it to 10KiB for testing. memory_allocation: Some(10000u16.into()), @@ -21,7 +21,7 @@ mod main { wasm_memory_limit: Some((2u64.pow(48) - 1).into()), }), }; - let canister_id = create_canister(arg, 100_000_000_000u128 / 13) + let canister_id = create_canister(arg, 200_000_000_000_000_000_000_000_000u128) .await .unwrap() .0 @@ -33,7 +33,7 @@ mod main { assert_eq!(response.reserved_cycles.0, 0u128.into()); let definite_canister_setting = response.settings; assert_eq!(definite_canister_setting.controllers, vec![ic_cdk::id()]); - assert_eq!(definite_canister_setting.compute_allocation, 100u8); + assert_eq!(definite_canister_setting.compute_allocation, 1u8); assert_eq!(definite_canister_setting.memory_allocation, 10000u16); assert_eq!(definite_canister_setting.freezing_threshold, u64::MAX); assert_eq!(definite_canister_setting.reserved_cycles_limit, u128::MAX); @@ -85,7 +85,7 @@ mod provisional { wasm_memory_limit: Some(10000u16.into()), }; let arg = ProvisionalCreateCanisterWithCyclesArgument { - amount: Some(1_000_000_000u64.into()), + amount: Some(10_000_000_000_000u64.into()), settings: Some(settings), }; let canister_id = provisional_create_canister_with_cycles(arg) diff --git a/e2e-tests/tests/e2e.rs b/e2e-tests/tests/e2e.rs index 879d4598c..54a4f652c 100644 --- a/e2e-tests/tests/e2e.rs +++ b/e2e-tests/tests/e2e.rs @@ -1,6 +1,8 @@ use std::time::Duration; use std::time::SystemTime; +use candid::utils::ArgumentDecoder; +use candid::utils::ArgumentEncoder; use candid::{Encode, Principal}; use ic_cdk::api::management_canister::main::{ CanisterChange, CanisterChangeDetails, CanisterChangeOrigin, CanisterIdRecord, @@ -10,24 +12,27 @@ use ic_cdk::api::management_canister::main::{ FromUserRecord, InstallCodeArgument, }; use ic_cdk_e2e_tests::cargo_build_canister; -use ic_test_state_machine_client::{ - call_candid, call_candid_as, query_candid, CallError, ErrorCode, StateMachine, WasmResult, -}; +use pocket_ic::common::rest::RawEffectivePrincipal; +use pocket_ic::{call_candid_as, query_candid, CallError, ErrorCode, PocketIc, WasmResult}; + use serde_bytes::ByteBuf; use sha2::Digest; -pub static STATE_MACHINE_BINARY: &str = "../ic-test-state-machine"; - -pub fn env() -> StateMachine { - if !std::path::Path::new(STATE_MACHINE_BINARY).exists() { - eprintln!( - " -ERROR: Could not find state machine binary to run e2e tests. - Please run `bash scripts/download_state_machine_binary.sh`." - ); - } - - StateMachine::new(STATE_MACHINE_BINARY, false) +// 2T cycles +const INIT_CYCLES: u128 = 2_000_000_000_000; + +/// wrapper around `pocket_ic::call_candid` that uses None as the effective principal. +fn call_candid( + env: &PocketIc, + canister_id: Principal, + method: &str, + input: Input, +) -> Result +where + Input: ArgumentEncoder, + Output: for<'a> ArgumentDecoder<'a>, +{ + pocket_ic::call_candid(env, canister_id, RawEffectivePrincipal::None, method, input) } /// Checks that a canister that uses [`ic_cdk::storage::stable_store`] @@ -35,31 +40,33 @@ ERROR: Could not find state machine binary to run e2e tests. /// across upgrades. #[test] fn test_storage_roundtrip() { - let env = env(); + let pic = PocketIc::new(); let wasm = cargo_build_canister("simple-kv-store"); - let canister_id = env.create_canister(None); - env.install_canister(canister_id, wasm.clone(), vec![], None); + let canister_id = pic.create_canister(); + pic.add_cycles(canister_id, INIT_CYCLES); + pic.install_canister(canister_id, wasm.clone(), vec![], None); - let () = call_candid(&env, canister_id, "insert", (&"candid", &b"did")) + let () = call_candid(&pic, canister_id, "insert", (&"candid", &b"did")) .expect("failed to insert 'candid'"); - env.upgrade_canister(canister_id, wasm, vec![], None) + pic.upgrade_canister(canister_id, wasm, vec![], None) .expect("failed to upgrade the simple-kv-store canister"); let (result,): (Option,) = - query_candid(&env, canister_id, "lookup", (&"candid",)).expect("failed to lookup 'candid'"); + query_candid(&pic, canister_id, "lookup", (&"candid",)).expect("failed to lookup 'candid'"); assert_eq!(result, Some(ByteBuf::from(b"did".to_vec()))); } #[test] fn test_panic_after_async_frees_resources() { - let env = env(); + let pic: PocketIc = PocketIc::new(); let wasm = cargo_build_canister("async"); - let canister_id = env.create_canister(None); - env.install_canister(canister_id, wasm, vec![], None); + let canister_id = pic.create_canister(); + pic.add_cycles(canister_id, INIT_CYCLES); + pic.install_canister(canister_id, wasm, vec![], None); for i in 1..3 { - match call_candid(&env, canister_id, "panic_after_async", ()) { + match call_candid(&pic, canister_id, "panic_after_async", ()) { Ok(()) => (), Err(CallError::Reject(msg)) => panic!("unexpected reject: {}", msg), Err(CallError::UserError(e)) => { @@ -76,36 +83,37 @@ fn test_panic_after_async_frees_resources() { } } - let (n,): (u64,) = call_candid(&env, canister_id, "invocation_count", ()) + let (n,): (u64,) = call_candid(&pic, canister_id, "invocation_count", ()) .expect("failed to call invocation_count"); assert_eq!(i, n, "expected the invocation count to be {}, got {}", i, n); } let (message,): (String,) = - call_candid(&env, canister_id, "invalid_reply_payload_does_not_trap", ()) + call_candid(&pic, canister_id, "invalid_reply_payload_does_not_trap", ()) .expect("call failed"); assert_eq!(&message, "handled decoding error gracefully with code 5"); let err = - call_candid::<_, ()>(&env, canister_id, "panic_twice", ()).expect_err("failed to panic"); + call_candid::<_, ()>(&pic, canister_id, "panic_twice", ()).expect_err("failed to panic"); assert!( matches!(err, CallError::UserError(u) if u.description.contains("Call already trapped")) ); - let _: (u64,) = call_candid(&env, canister_id, "notifications_received", ()) + let _: (u64,) = call_candid(&pic, canister_id, "notifications_received", ()) .expect("failed to call unrelated function afterwards"); let _: (u64,) = - call_candid(&env, canister_id, "invocation_count", ()).expect("failed to recover lock"); + call_candid(&pic, canister_id, "invocation_count", ()).expect("failed to recover lock"); } #[test] fn test_raw_api() { - let env = env(); + let pic = PocketIc::new(); let wasm = cargo_build_canister("reverse"); - let canister_id = env.create_canister(None); - env.install_canister(canister_id, wasm, vec![], None); + let canister_id = pic.create_canister(); + pic.add_cycles(canister_id, INIT_CYCLES); + pic.install_canister(canister_id, wasm, vec![], None); - let result = env + let result = pic .query_call( canister_id, Principal::anonymous(), @@ -115,7 +123,7 @@ fn test_raw_api() { .unwrap(); assert_eq!(result, WasmResult::Reply(vec![4, 3, 2, 1])); - let result = env + let result = pic .update_call( canister_id, Principal::anonymous(), @@ -128,21 +136,23 @@ fn test_raw_api() { #[test] fn test_notify_calls() { - let env = env(); + let pic = PocketIc::new(); let wasm = cargo_build_canister("async"); - let sender_id = env.create_canister(None); - env.install_canister(sender_id, wasm.clone(), vec![], None); - let receiver_id = env.create_canister(None); - env.install_canister(receiver_id, wasm, vec![], None); - - let (n,): (u64,) = query_candid(&env, receiver_id, "notifications_received", ()) + let sender_id = pic.create_canister(); + pic.add_cycles(sender_id, INIT_CYCLES); + pic.install_canister(sender_id, wasm.clone(), vec![], None); + let receiver_id = pic.create_canister(); + pic.add_cycles(receiver_id, INIT_CYCLES); + pic.install_canister(receiver_id, wasm, vec![], None); + + let (n,): (u64,) = query_candid(&pic, receiver_id, "notifications_received", ()) .expect("failed to query 'notifications_received'"); assert_eq!(n, 0); - let () = call_candid(&env, sender_id, "notify", (receiver_id, "on_notify")) + let () = call_candid(&pic, sender_id, "notify", (receiver_id, "on_notify")) .expect("failed to call 'notify'"); - let (n,): (u64,) = query_candid(&env, receiver_id, "notifications_received", ()) + let (n,): (u64,) = query_candid(&pic, receiver_id, "notifications_received", ()) .expect("failed to query 'notifications_received'"); assert_eq!(n, 1); } @@ -151,29 +161,32 @@ fn test_notify_calls() { #[test] #[ignore] fn test_composite_query() { - let env = env(); + let pic = PocketIc::new(); let wasm = cargo_build_canister("async"); - let sender_id = env.create_canister(None); - env.install_canister(sender_id, wasm.clone(), vec![], None); - let receiver_id = env.create_canister(None); - env.install_canister(receiver_id, wasm, vec![], None); - - let (greeting,): (String,) = query_candid(&env, sender_id, "greet_self", (receiver_id,)) + let sender_id = pic.create_canister(); + pic.add_cycles(sender_id, INIT_CYCLES); + pic.install_canister(sender_id, wasm.clone(), vec![], None); + let receiver_id = pic.create_canister(); + pic.add_cycles(receiver_id, INIT_CYCLES); + pic.install_canister(receiver_id, wasm, vec![], None); + + let (greeting,): (String,) = query_candid(&pic, sender_id, "greet_self", (receiver_id,)) .expect("failed to query 'greet_self'"); assert_eq!(greeting, "Hello, myself"); } #[test] fn test_api_call() { - let env = env(); + let pic = PocketIc::new(); let wasm = cargo_build_canister("api-call"); - let canister_id = env.create_canister(None); - env.install_canister(canister_id, wasm, vec![], None); - let (result,): (u64,) = query_candid(&env, canister_id, "instruction_counter", ()) + let canister_id = pic.create_canister(); + pic.add_cycles(canister_id, INIT_CYCLES); + pic.install_canister(canister_id, wasm, vec![], None); + let (result,): (u64,) = query_candid(&pic, canister_id, "instruction_counter", ()) .expect("failed to query instruction_counter"); assert!(result > 0); - let result = env + let result = pic .query_call( canister_id, Principal::anonymous(), @@ -183,40 +196,41 @@ fn test_api_call() { .unwrap(); assert_eq!(result, WasmResult::Reject("manual reject".to_string())); - let (result,): (bool,) = call_candid(&env, canister_id, "update_is_replicated", ()) + let (result,): (bool,) = call_candid(&pic, canister_id, "update_is_replicated", ()) .expect("Failed to call update_is_replicated"); assert!(result); - let (result,): (bool,) = query_candid(&env, canister_id, "query_is_not_replicated", ()) + let (result,): (bool,) = query_candid(&pic, canister_id, "query_is_not_replicated", ()) .expect("Failed to call query_is_not_replicated"); assert!(!result); } #[test] fn test_timers() { - let env = env(); + let pic = PocketIc::new(); let wasm = cargo_build_canister("timers"); - let canister_id = env.create_canister(None); - env.install_canister(canister_id, wasm, vec![], None); + let canister_id = pic.create_canister(); + pic.add_cycles(canister_id, INIT_CYCLES); + pic.install_canister(canister_id, wasm, vec![], None); - call_candid::<(), ()>(&env, canister_id, "schedule", ()).expect("Failed to call schedule"); - advance_seconds(&env, 5); + call_candid::<(), ()>(&pic, canister_id, "schedule", ()).expect("Failed to call schedule"); + advance_seconds(&pic, 5); - call_candid::<_, ()>(&env, canister_id, "schedule_long", ()) + call_candid::<_, ()>(&pic, canister_id, "schedule_long", ()) .expect("Failed to call schedule_long"); - advance_seconds(&env, 5); - call_candid::<_, ()>(&env, canister_id, "cancel_long", ()).expect("Failed to call cancel_long"); - advance_seconds(&env, 5); + advance_seconds(&pic, 5); + call_candid::<_, ()>(&pic, canister_id, "cancel_long", ()).expect("Failed to call cancel_long"); + advance_seconds(&pic, 5); - call_candid::<_, ()>(&env, canister_id, "start_repeating", ()) + call_candid::<_, ()>(&pic, canister_id, "start_repeating", ()) .expect("Failed to call start_repeating"); - advance_seconds(&env, 3); - call_candid::<_, ()>(&env, canister_id, "stop_repeating", ()) + advance_seconds(&pic, 3); + call_candid::<_, ()>(&pic, canister_id, "stop_repeating", ()) .expect("Failed to call stop_repeating"); - advance_seconds(&env, 2); + advance_seconds(&pic, 2); let (events,): (Vec,) = - query_candid(&env, canister_id, "get_events", ()).expect("Failed to call get_events"); + query_candid(&pic, canister_id, "get_events", ()).expect("Failed to call get_events"); assert_eq!( events[..], ["1", "2", "3", "4", "repeat", "repeat", "repeat"] @@ -225,20 +239,21 @@ fn test_timers() { #[test] fn test_timers_can_cancel_themselves() { - let env = env(); + let pic = PocketIc::new(); let wasm = cargo_build_canister("timers"); - let canister_id = env.create_canister(None); - env.install_canister(canister_id, wasm, vec![], None); + let canister_id = pic.create_canister(); + pic.add_cycles(canister_id, INIT_CYCLES); + pic.install_canister(canister_id, wasm, vec![], None); - call_candid::<_, ()>(&env, canister_id, "set_self_cancelling_timer", ()) + call_candid::<_, ()>(&pic, canister_id, "set_self_cancelling_timer", ()) .expect("Failed to call set_self_cancelling_timer"); - call_candid::<_, ()>(&env, canister_id, "set_self_cancelling_periodic_timer", ()) + call_candid::<_, ()>(&pic, canister_id, "set_self_cancelling_periodic_timer", ()) .expect("Failed to call set_self_cancelling_periodic_timer"); - advance_seconds(&env, 1); + advance_seconds(&pic, 1); let (events,): (Vec,) = - query_candid(&env, canister_id, "get_events", ()).expect("Failed to call get_events"); + query_candid(&pic, canister_id, "get_events", ()).expect("Failed to call get_events"); assert_eq!( events, ["timer cancelled self", "periodic timer cancelled self"] @@ -249,82 +264,88 @@ fn test_timers_can_cancel_themselves() { fn test_scheduling_many_timers() { // Must be more than the queue limit (500) let timers_to_schedule = 1_000; - let env = env(); + let pic = PocketIc::new(); let wasm = cargo_build_canister("timers"); - let canister_id = env.create_canister(None); - env.install_canister(canister_id, wasm, vec![], None); + let canister_id = pic.create_canister(); + pic.add_cycles(canister_id, 100_000_000_000_000u128); + pic.install_canister(canister_id, wasm, vec![], None); let () = call_candid( - &env, + &pic, canister_id, "schedule_n_timers", (timers_to_schedule,), ) .expect("Error calling schedule_n_timers"); - // Up to 500 timers will be executed per round - advance_seconds(&env, timers_to_schedule / 500); + // Up to 20 timers will be executed per round + // Be conservative that advance 2 times the minimum number of rounds + const TIMERS_PER_ROUND: u32 = 20; + advance_seconds(&pic, 2 * timers_to_schedule / TIMERS_PER_ROUND); - let (executed_timers,): (u32,) = query_candid(&env, canister_id, "executed_timers", ()) + let (executed_timers,): (u32,) = query_candid(&pic, canister_id, "executed_timers", ()) .expect("Error querying executed_timers"); assert_eq!(timers_to_schedule, executed_timers); } -fn advance_seconds(env: &StateMachine, seconds: u32) { +fn advance_seconds(pic: &PocketIc, seconds: u32) { for _ in 0..seconds { - env.advance_time(Duration::from_secs(1)); - env.tick(); + pic.advance_time(Duration::from_secs(1)); + pic.tick(); } } #[test] fn test_set_global_timers() { - // Must be more than the queue limit (500) - let env = env(); - let system_time = std::time::SystemTime::now(); - - env.set_time(system_time); + let pic = PocketIc::new(); let wasm = cargo_build_canister("timers"); - let canister_id = env.create_canister(None); - env.install_canister(canister_id, wasm, vec![], None); + let canister_id = pic.create_canister(); + pic.add_cycles(canister_id, INIT_CYCLES); + pic.install_canister(canister_id, wasm, vec![], None); - call_candid::<_, ()>(&env, canister_id, "schedule_long", ()) - .expect("Failed to call schedule_long"); - let ts0 = system_time - .duration_since(std::time::UNIX_EPOCH) + // Set a 9s timer at t0, it expires at t1 = t0 + 9s + let t0 = pic + .get_time() + .duration_since(SystemTime::UNIX_EPOCH) .unwrap() - .as_nanos() as u64 - + 9_000_000_000; // the long event is scheduled 9 seconds from ts0 - advance_seconds(&env, 5); + .as_nanos() as u64; + let t1 = t0 + 9_000_000_000; + call_candid::<_, ()>(&pic, canister_id, "schedule_long", ()) + .expect("Failed to call schedule_long"); + + // 5 seconds later, the 9s timer is still active + advance_seconds(&pic, 5); - // set the timer to 5 seconds from ts0 - let ts1 = ts0 + 5_000_000_000; - let (previous,) = call_candid::<(u64,), (u64,)>(&env, canister_id, "set_global_timer", (ts1,)) + // Set the expiration time of the timer to t2 = t1 + 5s + let t2 = t1 + 5_000_000_000; + let (previous,) = call_candid::<(u64,), (u64,)>(&pic, canister_id, "set_global_timer", (t2,)) .expect("Failed to call set_global_timer"); - assert_eq!(previous, ts0); + assert!(previous.abs_diff(t1) < 2); // time error no more than 1 nanosecond - // deactivate the timer - let (previous,) = call_candid::<(u64,), (u64,)>(&env, canister_id, "set_global_timer", (0,)) + // Deactivate the timer + let (previous,) = call_candid::<(u64,), (u64,)>(&pic, canister_id, "set_global_timer", (0,)) .expect("Failed to call set_global_timer"); - assert_eq!(previous, ts1); + assert!(previous.abs_diff(t2) < 2); // time error no more than 1 nanosecond } #[test] fn test_canister_info() { - let env = env(); + let pic = PocketIc::new(); let wasm = cargo_build_canister("canister_info"); - let canister_id = env.create_canister(None); - env.add_cycles(canister_id, 1_000_000_000_000); - env.install_canister(canister_id, wasm, vec![], None); + pic.set_time(SystemTime::UNIX_EPOCH); + let canister_id = pic.create_canister(); + pic.add_cycles(canister_id, INIT_CYCLES); + pic.install_canister(canister_id, wasm, vec![], None); - let new_canister: (Principal,) = call_candid(&env, canister_id, "canister_lifecycle", ()) + let new_canister: (Principal,) = call_candid(&pic, canister_id, "canister_lifecycle", ()) .expect("Error calling canister_lifecycle"); let () = call_candid_as( - &env, + &pic, Principal::management_canister(), + RawEffectivePrincipal::None, Principal::anonymous(), "uninstall_code", (CanisterIdRecord { @@ -333,8 +354,9 @@ fn test_canister_info() { ) .expect("Error calling uninstall_code"); let () = call_candid_as( - &env, + &pic, Principal::management_canister(), + RawEffectivePrincipal::None, Principal::anonymous(), "install_code", (InstallCodeArgument { @@ -346,21 +368,16 @@ fn test_canister_info() { ) .expect("Error calling install_code"); - let info: (CanisterInfoResponse,) = call_candid(&env, canister_id, "info", (new_canister.0,)) + let info: (CanisterInfoResponse,) = call_candid(&pic, canister_id, "info", (new_canister.0,)) .expect("Error calling canister_info"); - let timestamp_nanos = env - .time() - .duration_since(SystemTime::UNIX_EPOCH) - .unwrap() - .as_nanos() as u64; assert_eq!( info.0, CanisterInfoResponse { total_num_changes: 9, recent_changes: vec![ CanisterChange { - timestamp_nanos, + timestamp_nanos: 4, canister_version: 0, origin: CanisterChangeOrigin::FromCanister(FromCanisterRecord { canister_id, @@ -371,7 +388,7 @@ fn test_canister_info() { }), }, CanisterChange { - timestamp_nanos, + timestamp_nanos: 6, canister_version: 1, origin: CanisterChangeOrigin::FromCanister(FromCanisterRecord { canister_id, @@ -386,7 +403,7 @@ fn test_canister_info() { }), }, CanisterChange { - timestamp_nanos, + timestamp_nanos: 8, canister_version: 2, origin: CanisterChangeOrigin::FromCanister(FromCanisterRecord { canister_id, @@ -395,7 +412,7 @@ fn test_canister_info() { details: CanisterChangeDetails::CodeUninstall, }, CanisterChange { - timestamp_nanos, + timestamp_nanos: 10, canister_version: 3, origin: CanisterChangeOrigin::FromCanister(FromCanisterRecord { canister_id, @@ -410,7 +427,7 @@ fn test_canister_info() { }), }, CanisterChange { - timestamp_nanos, + timestamp_nanos: 12, canister_version: 4, origin: CanisterChangeOrigin::FromCanister(FromCanisterRecord { canister_id, @@ -425,7 +442,7 @@ fn test_canister_info() { }), }, CanisterChange { - timestamp_nanos, + timestamp_nanos: 14, canister_version: 5, origin: CanisterChangeOrigin::FromCanister(FromCanisterRecord { canister_id, @@ -440,7 +457,7 @@ fn test_canister_info() { }), }, CanisterChange { - timestamp_nanos, + timestamp_nanos: 16, canister_version: 6, origin: CanisterChangeOrigin::FromCanister(FromCanisterRecord { canister_id, @@ -451,7 +468,7 @@ fn test_canister_info() { }), }, CanisterChange { - timestamp_nanos, + timestamp_nanos: 18, canister_version: 7, origin: CanisterChangeOrigin::FromUser(FromUserRecord { user_id: Principal::anonymous(), @@ -459,7 +476,7 @@ fn test_canister_info() { details: CanisterChangeDetails::CodeUninstall, }, CanisterChange { - timestamp_nanos, + timestamp_nanos: 19, canister_version: 8, origin: CanisterChangeOrigin::FromUser(FromUserRecord { user_id: Principal::anonymous(), @@ -484,59 +501,57 @@ fn test_canister_info() { #[test] fn test_cycles_burn() { - let env = env(); + let pic = PocketIc::new(); let wasm = cargo_build_canister("api-call"); - let canister_id = env.create_canister(None); - env.add_cycles(canister_id, 1500); + let canister_id = pic.create_canister(); + pic.add_cycles(canister_id, INIT_CYCLES); - env.install_canister(canister_id, wasm, vec![], None); + pic.install_canister(canister_id, wasm, vec![], None); eprintln!("Canister installed."); - let balance1 = env.cycle_balance(canister_id); + let balance1 = pic.cycle_balance(canister_id); eprintln!("Balance 1: {balance1}"); - let attempted = 1000u128; - // Scenario 1: burn less than balance - let (burned,): (u128,) = call_candid(&env, canister_id, "cycles_burn", (attempted,)) + let attempted1 = 1000u128; + let (burned,): (u128,) = call_candid(&pic, canister_id, "cycles_burn", (attempted1,)) .expect("Error calling cycles_burn"); - eprintln!("Attempted to burn {attempted}, actually burned {burned}"); - assert_eq!(burned, attempted); - let balance2 = env.cycle_balance(canister_id); + eprintln!("Attempted to burn {attempted1}, actually burned {burned}"); + assert_eq!(burned, attempted1); + let balance2 = pic.cycle_balance(canister_id); eprintln!("Balance 2: {balance2}"); // Scenario 2: burn more than balance - let (burned,): (u128,) = call_candid(&env, canister_id, "cycles_burn", (attempted,)) + let attempted2 = balance2 + 1; + let (burned,): (u128,) = call_candid(&pic, canister_id, "cycles_burn", (attempted2,)) .expect("Error calling cycles_burn"); - eprintln!("Attempted to burn {attempted}, actually burned {burned}"); - assert!(burned < attempted); - assert_eq!(burned, balance2); - let balance3 = env.cycle_balance(canister_id); + eprintln!("Attempted to burn {attempted2}, actually burned {burned}"); + assert!(burned < balance2); // restrained by reserved_balance and freezing_limit + let balance3 = pic.cycle_balance(canister_id); eprintln!("Balance 3: {balance3}"); - assert_eq!(balance3, 0); } #[test] -fn call_management() { - let env = env(); +fn test_call_management() { + let pic = PocketIc::new(); let wasm = cargo_build_canister("management_caller"); - let canister_id = env.create_canister(None); - env.add_cycles(canister_id, 100_000_000_000_000); - env.install_canister(canister_id, wasm, vec![], None); - let () = call_candid(&env, canister_id, "execute_main_methods", ()) + let canister_id = pic.create_canister(); + pic.add_cycles(canister_id, 300_000_000_000_000_000_000_000_000u128); + pic.install_canister(canister_id, wasm, vec![], None); + let () = call_candid(&pic, canister_id, "execute_main_methods", ()) .expect("Error calling execute_main_methods"); - let () = call_candid(&env, canister_id, "execute_provisional_methods", ()) + let () = call_candid(&pic, canister_id, "execute_provisional_methods", ()) .expect("Error calling execute_provisional_methods"); } #[test] fn test_chunk() { - let env = env(); + let pic = PocketIc::new(); let wasm = cargo_build_canister("chunk"); - let canister_id = env.create_canister(None); - env.add_cycles(canister_id, 100_000_000_000_000); - env.install_canister(canister_id, wasm, vec![], None); + let canister_id = pic.create_canister(); + pic.add_cycles(canister_id, 100_000_000_000_000); + pic.install_canister(canister_id, wasm, vec![], None); let (target_canister_id,): (Principal,) = - call_candid(&env, canister_id, "call_create_canister", ()) + call_candid(&pic, canister_id, "call_create_canister", ()) .expect("Error calling call_create_canister"); let wasm_module = b"\x00asm\x01\x00\x00\x00".to_vec(); @@ -547,7 +562,7 @@ fn test_chunk() { let hash2_expected = sha2::Sha256::digest(&chunk2).to_vec(); let (hash1_return,): (Vec,) = call_candid( - &env, + &pic, canister_id, "call_upload_chunk", (target_canister_id, chunk1.clone()), @@ -556,7 +571,7 @@ fn test_chunk() { assert_eq!(&hash1_return, &hash1_expected); let () = call_candid( - &env, + &pic, canister_id, "call_clear_chunk_store", (target_canister_id,), @@ -564,14 +579,14 @@ fn test_chunk() { .expect("Error calling call_clear_chunk_store"); let (_hash1_return,): (Vec,) = call_candid( - &env, + &pic, canister_id, "call_upload_chunk", (target_canister_id, chunk1), ) .expect("Error calling call_upload_chunk"); let (_hash2_return,): (Vec,) = call_candid( - &env, + &pic, canister_id, "call_upload_chunk", (target_canister_id, chunk2), @@ -579,7 +594,7 @@ fn test_chunk() { .expect("Error calling call_upload_chunk"); let (hashes,): (Vec>,) = call_candid( - &env, + &pic, canister_id, "call_stored_chunks", (target_canister_id,), @@ -591,7 +606,7 @@ fn test_chunk() { assert!(hashes.contains(&hash2_expected)); let () = call_candid( - &env, + &pic, canister_id, "call_install_chunked_code", ( diff --git a/scripts/download_pocket_ic.sh b/scripts/download_pocket_ic.sh new file mode 100755 index 000000000..545dd8306 --- /dev/null +++ b/scripts/download_pocket_ic.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# Make sure we always run from the root +SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +cd "$SCRIPTS_DIR/../e2e-tests" + +uname_sys=$(uname -s | tr '[:upper:]' '[:lower:]') +echo "uname_sys: $uname_sys" + +tag="release-2024-05-22_23-01-base" + +curl -sL "https://github.com/dfinity/ic/releases/download/$tag/pocket-ic-x86_64-$uname_sys.gz" --output pocket-ic.gz +gzip -df pocket-ic.gz +chmod a+x pocket-ic +./pocket-ic --version + +if [[ "$uname_sys" == "darwin" ]]; then + xattr -dr com.apple.quarantine pocket-ic +fi diff --git a/scripts/download_state_machine_binary.sh b/scripts/download_state_machine_binary.sh deleted file mode 100755 index 1f75ff622..000000000 --- a/scripts/download_state_machine_binary.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -# Make sure we always run from the root -SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -cd "$SCRIPTS_DIR/.." - -uname_sys=$(uname -s | tr '[:upper:]' '[:lower:]') -echo "uname_sys: $uname_sys" -# Check https://gitlab.com/dfinity-lab/public/ic/-/commits/master -# Find the most recent commit with a green check mark (the artifacts were built successfully) -commit_sha="ba6d8b136549f0acf8a2eafddab031156d53accd" - -curl -sLO "https://download.dfinity.systems/ic/$commit_sha/binaries/x86_64-$uname_sys/ic-test-state-machine.gz" -gzip -d ic-test-state-machine.gz -chmod a+x ic-test-state-machine -./ic-test-state-machine --version