From 6ad8983d9aa40ed2d9650b05524977b6408ce6c3 Mon Sep 17 00:00:00 2001 From: ICavlek Date: Mon, 7 Oct 2024 11:47:24 +0200 Subject: [PATCH 1/3] test: scarb library with template test cases --- Cargo.lock | 1764 ++++++++++++++++- Cargo.toml | 2 + tests/account_katana.rs | 24 +- tests/account_mock.rs | 4 +- tests/common/err.rs | 4 + tests/common/mod.rs | 5 - tests/{common => mock}/dummies.rs | 0 tests/{common => mock}/matchers.rs | 0 tests/mock/mod.rs | 3 + tests/{common => mock}/node.rs | 0 tests/rpc.rs | 55 +- .../clob/compiled_account_contract_v2.txt | 0 .../clob/compiled_account_contract_v3.txt | 0 .../clob/declare_account_v2.txt | 0 .../clob/declare_account_v3.txt | 0 tests/{common => starknet}/constants.rs | 8 +- tests/starknet/contract/account/Scarb.toml | 11 + tests/starknet/contract/account/src/lib.cairo | 149 ++ tests/starknet/executor.rs | 128 ++ tests/{common => starknet}/katana.rs | 0 tests/starknet/mod.rs | 4 + tests/starknet/scarb.rs | 43 + 22 files changed, 2139 insertions(+), 65 deletions(-) rename tests/{common => mock}/dummies.rs (100%) rename tests/{common => mock}/matchers.rs (100%) create mode 100644 tests/mock/mod.rs rename tests/{common => mock}/node.rs (100%) rename tests/{ => starknet}/clob/compiled_account_contract_v2.txt (100%) rename tests/{ => starknet}/clob/compiled_account_contract_v3.txt (100%) rename tests/{ => starknet}/clob/declare_account_v2.txt (100%) rename tests/{ => starknet}/clob/declare_account_v3.txt (100%) rename tests/{common => starknet}/constants.rs (73%) create mode 100644 tests/starknet/contract/account/Scarb.toml create mode 100644 tests/starknet/contract/account/src/lib.cairo create mode 100644 tests/starknet/executor.rs rename tests/{common => starknet}/katana.rs (100%) create mode 100644 tests/starknet/mod.rs create mode 100644 tests/starknet/scarb.rs diff --git a/Cargo.lock b/Cargo.lock index 26250a26..0adef0a5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -45,6 +45,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ "cfg-if", + "getrandom 0.2.15", "once_cell", "version_check", "zerocopy", @@ -169,12 +170,67 @@ dependencies = [ "libc", ] +[[package]] +name = "anstream" +version = "0.6.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" + +[[package]] +name = "anstyle-parse" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" +dependencies = [ + "anstyle", + "windows-sys 0.52.0", +] + [[package]] name = "anyhow" version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" +[[package]] +name = "arc-swap" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457" + [[package]] name = "ark-ec" version = "0.4.2" @@ -589,6 +645,8 @@ dependencies = [ "once_cell", "regex", "reqwest 0.12.8", + "scarb", + "semver", "serde", "serde_json", "starknet-crypto 0.7.2", @@ -634,7 +692,7 @@ dependencies = [ "rustc-hash 1.1.0", "shlex", "syn 2.0.79", - "which", + "which 4.4.2", ] [[package]] @@ -677,7 +735,7 @@ dependencies = [ "rustc-hash 1.1.0", "shlex", "syn 2.0.79", - "which", + "which 4.4.2", ] [[package]] @@ -881,6 +939,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40723b8fb387abc38f4f4a37c09073622e41dd12327033091ef8950659e6dc0c" dependencies = [ "memchr", + "regex-automata 0.4.8", "serde", ] @@ -923,6 +982,12 @@ dependencies = [ "serde", ] +[[package]] +name = "bytesize" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3e368af43e418a04d52505cf3dbc23dda4e3407ae2fa99fd0e4f308ce546acc" + [[package]] name = "bzip2" version = "0.4.4" @@ -1280,6 +1345,33 @@ dependencies = [ "smol_str", ] +[[package]] +name = "cairo-lang-macro" +version = "0.1.0" +source = "git+https://github.com/software-mansion/scarb/?tag=v2.8.3#54938ce3b01f81959e6e0114b080cc5e1a73935b" +dependencies = [ + "cairo-lang-macro-attributes", + "cairo-lang-macro-stable", + "linkme", +] + +[[package]] +name = "cairo-lang-macro-attributes" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e32e958decd95ae122ee64daa26721da2f76e83231047f947fd9cdc5d3c90cc6" +dependencies = [ + "quote", + "scarb-stable-hash 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 2.0.79", +] + +[[package]] +name = "cairo-lang-macro-stable" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c49906d6b1c215e5814be7c5c65ecf2328898b335bee8c2409ec07cfb5530daf" + [[package]] name = "cairo-lang-parser" version = "2.7.0" @@ -1898,6 +1990,33 @@ dependencies = [ "xshell", ] +[[package]] +name = "cairo-lang-test-plugin" +version = "2.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74f1597b8229a3649183ff33b19f0aeca5d86505253ebbbce377b271d1732835" +dependencies = [ + "anyhow", + "cairo-lang-compiler 2.8.2", + "cairo-lang-debug 2.8.2", + "cairo-lang-defs 2.8.2", + "cairo-lang-filesystem 2.8.2", + "cairo-lang-lowering 2.8.2", + "cairo-lang-semantic 2.8.2", + "cairo-lang-sierra 2.8.2", + "cairo-lang-sierra-generator 2.8.2", + "cairo-lang-starknet 2.8.2", + "cairo-lang-starknet-classes 2.8.2", + "cairo-lang-syntax 2.8.2", + "cairo-lang-utils 2.8.2", + "indoc", + "itertools 0.12.1", + "num-bigint", + "num-traits 0.2.19", + "serde", + "starknet-types-core", +] + [[package]] name = "cairo-lang-test-utils" version = "2.7.0" @@ -1944,14 +2063,17 @@ version = "2.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73104609a7d865e4cd1de9cbf4e750683d076b6d0233bf81be511df274a26916" dependencies = [ + "env_logger", "hashbrown 0.14.5", "indexmap 2.5.0", "itertools 0.12.1", + "log", "num-bigint", "num-traits 0.2.19", "parity-scale-codec 3.6.12", "schemars", "serde", + "time", ] [[package]] @@ -2110,6 +2232,46 @@ dependencies = [ "libloading", ] +[[package]] +name = "clap" +version = "4.5.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7be5744db7978a28d9df86a214130d106a89ce49644cbc4e3f0c22c3fba30615" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5fbc17d3ef8278f55b282b2a2e75ae6f6c7d4bb70ed3d0382375104bfafdb4b" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim 0.11.1", +] + +[[package]] +name = "clap_derive" +version = "4.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" +dependencies = [ + "heck 0.5.0", + "proc-macro2", + "quote", + "syn 2.0.79", +] + +[[package]] +name = "clap_lex" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" + [[package]] name = "client" version = "0.5.5" @@ -2135,6 +2297,12 @@ dependencies = [ "zduny-wasm-timer", ] +[[package]] +name = "clru" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbd0f76e066e64fdc5631e3bb46381254deab9ef1158292f27c8c57e3bf3fe59" + [[package]] name = "cmake" version = "0.1.51" @@ -2202,6 +2370,12 @@ dependencies = [ "thiserror", ] +[[package]] +name = "colorchoice" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" + [[package]] name = "colored" version = "2.1.0" @@ -2278,6 +2452,19 @@ dependencies = [ "zduny-wasm-timer", ] +[[package]] +name = "console" +version = "0.15.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" +dependencies = [ + "encode_unicode", + "lazy_static", + "libc", + "unicode-width", + "windows-sys 0.52.0", +] + [[package]] name = "const-fnv1a-hash" version = "1.1.0" @@ -2354,6 +2541,16 @@ dependencies = [ "libc", ] +[[package]] +name = "core-foundation" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b55271e5c8c478ad3f38ad24ef34923091e0548492a266d19b3c0b4d82574c63" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" version = "0.8.7" @@ -2378,6 +2575,26 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "create-output-dir" +version = "1.0.0" +source = "git+https://github.com/software-mansion/scarb/?tag=v2.8.3#54938ce3b01f81959e6e0114b080cc5e1a73935b" +dependencies = [ + "anyhow", + "core-foundation 0.10.0", + "tempfile", + "winapi", +] + +[[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" @@ -2545,6 +2762,20 @@ dependencies = [ "syn 2.0.79", ] +[[package]] +name = "dashmap" +version = "6.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5041cc499144891f3790297212f32a74fb938e5136a14943f338ef9e0ae276cf" +dependencies = [ + "cfg-if", + "crossbeam-utils", + "hashbrown 0.14.5", + "lock_api", + "once_cell", + "parking_lot_core 0.9.10", +] + [[package]] name = "data-encoding" version = "2.6.0" @@ -2569,6 +2800,23 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "092966b41edc516079bdf31ec78a2e0588d1d0c08f78b91d8307215928642b2b" +[[package]] +name = "deno_task_shell" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f444918f7102c1a5a143e9d57809e499fb4d365070519bf2e8bdb16d586af2a" +dependencies = [ + "anyhow", + "futures", + "glob", + "monch", + "os_pipe", + "path-dedot", + "thiserror", + "tokio", + "tokio-util", +] + [[package]] name = "der" version = "0.7.9" @@ -2600,6 +2848,37 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "derive_builder" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd33f37ee6a119146a1781d3356a7c26028f83d779b2e04ecd45fdc75c76877b" +dependencies = [ + "derive_builder_macro", +] + +[[package]] +name = "derive_builder_core" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7431fa049613920234f22c47fdc33e6cf3ee83067091ea4277a3f8c4587aae38" +dependencies = [ + "darling 0.20.10", + "proc-macro2", + "quote", + "syn 2.0.79", +] + +[[package]] +name = "derive_builder_macro" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4abae7035bf79b9877b779505d8cf3749285b80c43941eda66604841889451dc" +dependencies = [ + "derive_builder_core", + "syn 2.0.79", +] + [[package]] name = "derive_more" version = "0.99.18" @@ -2634,6 +2913,19 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "dialoguer" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "658bce805d770f407bc62102fca7c2c64ceef2fbcb2b8bd19d2765ce093980de" +dependencies = [ + "console", + "shell-words", + "tempfile", + "thiserror", + "zeroize", +] + [[package]] name = "diff" version = "0.1.13" @@ -2670,6 +2962,15 @@ dependencies = [ "subtle", ] +[[package]] +name = "directories" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a49173b84e034382284f27f1af4dcbbd231ffa358c0fe316541a7337f376a35" +dependencies = [ + "dirs-sys 0.4.1", +] + [[package]] name = "dirs" version = "4.0.0" @@ -2823,6 +3124,12 @@ dependencies = [ "log", ] +[[package]] +name = "encode_unicode" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" + [[package]] name = "encoding_rs" version = "0.8.34" @@ -2867,12 +3174,45 @@ dependencies = [ "syn 2.0.79", ] +[[package]] +name = "env_filter" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f2c92ceda6ceec50f43169f9ee8424fe2db276791afde7b2cd8bc084cb376ab" +dependencies = [ + "log", + "regex", +] + +[[package]] +name = "env_logger" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13fa619b91fb2381732789fc5de83b45675e882f66623b7d8cb4f643017018d" +dependencies = [ + "anstream", + "anstyle", + "env_filter", + "humantime", + "log", +] + [[package]] name = "equivalent" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +[[package]] +name = "erased-serde" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24e2389d65ab4fab27dc2a5de7b191e1f6617d1f1c8855c0dc569c94a4cbb18d" +dependencies = [ + "serde", + "typeid", +] + [[package]] name = "errno" version = "0.3.9" @@ -3260,6 +3600,12 @@ dependencies = [ "once_cell", ] +[[package]] +name = "faster-hex" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2a2b11eda1d40935b26cf18f6833c526845ae8c41e58d09af6adeb6f0269183" + [[package]] name = "fastrand" version = "2.1.1" @@ -3290,6 +3636,18 @@ dependencies = [ "version_check", ] +[[package]] +name = "filetime" +version = "0.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35c0522e981e68cbfa8c3f978441a5f34b30b96e146b33cd3359176b50fe8586" +dependencies = [ + "cfg-if", + "libc", + "libredox", + "windows-sys 0.59.0", +] + [[package]] name = "fixed-hash" version = "0.5.2" @@ -3370,6 +3728,18 @@ dependencies = [ "winapi", ] +[[package]] +name = "fs4" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29f9df8a11882c4e3335eb2d18a0137c505d9ca927470b0cac9c6f0ae07d28f7" +dependencies = [ + "async-trait", + "rustix", + "tokio", + "windows-sys 0.48.0", +] + [[package]] name = "fs_extra" version = "1.3.0" @@ -3564,9 +3934,812 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32085ea23f3234fc7846555e85283ba4de91e21016dc0455a16286d87a292d64" [[package]] -name = "glob" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" +name = "gix" +version = "0.66.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9048b8d1ae2104f045cb37e5c450fc49d5d8af22609386bfc739c11ba88995eb" +dependencies = [ + "gix-actor", + "gix-archive", + "gix-attributes", + "gix-command", + "gix-commitgraph", + "gix-config", + "gix-credentials", + "gix-date", + "gix-diff", + "gix-dir", + "gix-discover", + "gix-features", + "gix-filter", + "gix-fs", + "gix-glob", + "gix-hash", + "gix-hashtable", + "gix-ignore", + "gix-index", + "gix-lock", + "gix-mailmap", + "gix-negotiate", + "gix-object", + "gix-odb", + "gix-pack", + "gix-path", + "gix-pathspec", + "gix-prompt", + "gix-ref", + "gix-refspec", + "gix-revision", + "gix-revwalk", + "gix-sec", + "gix-status", + "gix-submodule", + "gix-tempfile", + "gix-trace", + "gix-traverse", + "gix-url", + "gix-utils", + "gix-validate", + "gix-worktree", + "gix-worktree-state", + "gix-worktree-stream", + "once_cell", + "parking_lot 0.12.3", + "regex", + "signal-hook", + "smallvec", + "thiserror", +] + +[[package]] +name = "gix-actor" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc19e312cd45c4a66cd003f909163dc2f8e1623e30a0c0c6df3776e89b308665" +dependencies = [ + "bstr", + "gix-date", + "gix-utils", + "itoa", + "thiserror", + "winnow 0.6.20", +] + +[[package]] +name = "gix-archive" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9147c08a55c1398b755539e2cdd63ff690ffe4a2e5e5e0780ee6ef2b49b0a60a" +dependencies = [ + "bstr", + "gix-date", + "gix-object", + "gix-worktree-stream", + "jiff", + "thiserror", +] + +[[package]] +name = "gix-attributes" +version = "0.22.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebccbf25aa4a973dd352564a9000af69edca90623e8a16dad9cbc03713131311" +dependencies = [ + "bstr", + "gix-glob", + "gix-path", + "gix-quote", + "gix-trace", + "kstring", + "smallvec", + "thiserror", + "unicode-bom", +] + +[[package]] +name = "gix-bitmap" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a371db66cbd4e13f0ed9dc4c0fea712d7276805fccc877f77e96374d317e87ae" +dependencies = [ + "thiserror", +] + +[[package]] +name = "gix-chunk" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45c8751169961ba7640b513c3b24af61aa962c967aaf04116734975cd5af0c52" +dependencies = [ + "thiserror", +] + +[[package]] +name = "gix-command" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff2e692b36bbcf09286c70803006ca3fd56551a311de450be317a0ab8ea92e7" +dependencies = [ + "bstr", + "gix-path", + "gix-trace", + "shell-words", +] + +[[package]] +name = "gix-commitgraph" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "133b06f67f565836ec0c473e2116a60fb74f80b6435e21d88013ac0e3c60fc78" +dependencies = [ + "bstr", + "gix-chunk", + "gix-features", + "gix-hash", + "memmap2", + "thiserror", +] + +[[package]] +name = "gix-config" +version = "0.40.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78e797487e6ca3552491de1131b4f72202f282fb33f198b1c34406d765b42bb0" +dependencies = [ + "bstr", + "gix-config-value", + "gix-features", + "gix-glob", + "gix-path", + "gix-ref", + "gix-sec", + "memchr", + "once_cell", + "smallvec", + "thiserror", + "unicode-bom", + "winnow 0.6.20", +] + +[[package]] +name = "gix-config-value" +version = "0.14.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03f76169faa0dec598eac60f83d7fcdd739ec16596eca8fb144c88973dbe6f8c" +dependencies = [ + "bitflags 2.6.0", + "bstr", + "gix-path", + "libc", + "thiserror", +] + +[[package]] +name = "gix-credentials" +version = "0.24.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ce391d305968782f1ae301c4a3d42c5701df7ff1d8bc03740300f6fd12bce78" +dependencies = [ + "bstr", + "gix-command", + "gix-config-value", + "gix-path", + "gix-prompt", + "gix-sec", + "gix-trace", + "gix-url", + "thiserror", +] + +[[package]] +name = "gix-date" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35c84b7af01e68daf7a6bb8bb909c1ff5edb3ce4326f1f43063a5a96d3c3c8a5" +dependencies = [ + "bstr", + "itoa", + "jiff", + "thiserror", +] + +[[package]] +name = "gix-diff" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92c9afd80fff00f8b38b1c1928442feb4cd6d2232a6ed806b6b193151a3d336c" +dependencies = [ + "bstr", + "gix-command", + "gix-filter", + "gix-fs", + "gix-hash", + "gix-object", + "gix-path", + "gix-tempfile", + "gix-trace", + "gix-worktree", + "imara-diff", + "thiserror", +] + +[[package]] +name = "gix-dir" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ed3a9076661359a1c5a27c12ad6c3ebe2dd96b8b3c0af6488ab7c128b7bdd98" +dependencies = [ + "bstr", + "gix-discover", + "gix-fs", + "gix-ignore", + "gix-index", + "gix-object", + "gix-path", + "gix-pathspec", + "gix-trace", + "gix-utils", + "gix-worktree", + "thiserror", +] + +[[package]] +name = "gix-discover" +version = "0.35.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0577366b9567376bc26e815fd74451ebd0e6218814e242f8e5b7072c58d956d2" +dependencies = [ + "bstr", + "dunce", + "gix-fs", + "gix-hash", + "gix-path", + "gix-ref", + "gix-sec", + "thiserror", +] + +[[package]] +name = "gix-features" +version = "0.38.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac7045ac9fe5f9c727f38799d002a7ed3583cd777e3322a7c4b43e3cf437dc69" +dependencies = [ + "bytes", + "bytesize", + "crc32fast", + "crossbeam-channel", + "flate2", + "gix-hash", + "gix-trace", + "gix-utils", + "libc", + "once_cell", + "parking_lot 0.12.3", + "prodash", + "sha1_smol", + "thiserror", + "walkdir", +] + +[[package]] +name = "gix-filter" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4121790ae140066e5b953becc72e7496278138d19239be2e63b5067b0843119e" +dependencies = [ + "bstr", + "encoding_rs", + "gix-attributes", + "gix-command", + "gix-hash", + "gix-object", + "gix-packetline-blocking", + "gix-path", + "gix-quote", + "gix-trace", + "gix-utils", + "smallvec", + "thiserror", +] + +[[package]] +name = "gix-fs" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2bfe6249cfea6d0c0e0990d5226a4cb36f030444ba9e35e0639275db8f98575" +dependencies = [ + "fastrand", + "gix-features", + "gix-utils", +] + +[[package]] +name = "gix-glob" +version = "0.16.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74908b4bbc0a0a40852737e5d7889f676f081e340d5451a16e5b4c50d592f111" +dependencies = [ + "bitflags 2.6.0", + "bstr", + "gix-features", + "gix-path", +] + +[[package]] +name = "gix-hash" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f93d7df7366121b5018f947a04d37f034717e113dcf9ccd85c34b58e57a74d5e" +dependencies = [ + "faster-hex", + "thiserror", +] + +[[package]] +name = "gix-hashtable" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ddf80e16f3c19ac06ce415a38b8591993d3f73aede049cb561becb5b3a8e242" +dependencies = [ + "gix-hash", + "hashbrown 0.14.5", + "parking_lot 0.12.3", +] + +[[package]] +name = "gix-ignore" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e447cd96598460f5906a0f6c75e950a39f98c2705fc755ad2f2020c9e937fab7" +dependencies = [ + "bstr", + "gix-glob", + "gix-path", + "gix-trace", + "unicode-bom", +] + +[[package]] +name = "gix-index" +version = "0.35.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0cd4203244444017682176e65fd0180be9298e58ed90bd4a8489a357795ed22d" +dependencies = [ + "bitflags 2.6.0", + "bstr", + "filetime", + "fnv", + "gix-bitmap", + "gix-features", + "gix-fs", + "gix-hash", + "gix-lock", + "gix-object", + "gix-traverse", + "gix-utils", + "gix-validate", + "hashbrown 0.14.5", + "itoa", + "libc", + "memmap2", + "rustix", + "smallvec", + "thiserror", +] + +[[package]] +name = "gix-lock" +version = "14.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bc7fe297f1f4614774989c00ec8b1add59571dc9b024b4c00acb7dedd4e19d" +dependencies = [ + "gix-tempfile", + "gix-utils", + "thiserror", +] + +[[package]] +name = "gix-mailmap" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7d522c8ec2501e1a5b2b4cb54e83cb5d9a52471c9d23b3a1e8dadaf063752f7" +dependencies = [ + "bstr", + "gix-actor", + "gix-date", + "thiserror", +] + +[[package]] +name = "gix-negotiate" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4063bf329a191a9e24b6f948a17ccf6698c0380297f5e169cee4f1d2ab9475b" +dependencies = [ + "bitflags 2.6.0", + "gix-commitgraph", + "gix-date", + "gix-hash", + "gix-object", + "gix-revwalk", + "smallvec", + "thiserror", +] + +[[package]] +name = "gix-object" +version = "0.44.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f5b801834f1de7640731820c2df6ba88d95480dc4ab166a5882f8ff12b88efa" +dependencies = [ + "bstr", + "gix-actor", + "gix-date", + "gix-features", + "gix-hash", + "gix-utils", + "gix-validate", + "itoa", + "smallvec", + "thiserror", + "winnow 0.6.20", +] + +[[package]] +name = "gix-odb" +version = "0.63.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3158068701c17df54f0ab2adda527f5a6aca38fd5fd80ceb7e3c0a2717ec747" +dependencies = [ + "arc-swap", + "gix-date", + "gix-features", + "gix-fs", + "gix-hash", + "gix-object", + "gix-pack", + "gix-path", + "gix-quote", + "parking_lot 0.12.3", + "tempfile", + "thiserror", +] + +[[package]] +name = "gix-pack" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3223aa342eee21e1e0e403cad8ae9caf9edca55ef84c347738d10681676fd954" +dependencies = [ + "clru", + "gix-chunk", + "gix-features", + "gix-hash", + "gix-hashtable", + "gix-object", + "gix-path", + "memmap2", + "smallvec", + "thiserror", + "uluru", +] + +[[package]] +name = "gix-packetline-blocking" +version = "0.17.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9802304baa798dd6f5ff8008a2b6516d54b74a69ca2d3a2b9e2d6c3b5556b40" +dependencies = [ + "bstr", + "faster-hex", + "gix-trace", + "thiserror", +] + +[[package]] +name = "gix-path" +version = "0.10.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebfc4febd088abdcbc9f1246896e57e37b7a34f6909840045a1767c6dafac7af" +dependencies = [ + "bstr", + "gix-trace", + "home", + "once_cell", + "thiserror", +] + +[[package]] +name = "gix-pathspec" +version = "0.7.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d23bf239532b4414d0e63b8ab3a65481881f7237ed9647bb10c1e3cc54c5ceb" +dependencies = [ + "bitflags 2.6.0", + "bstr", + "gix-attributes", + "gix-config-value", + "gix-glob", + "gix-path", + "thiserror", +] + +[[package]] +name = "gix-prompt" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74fde865cdb46b30d8dad1293385d9bcf998d3a39cbf41bee67d0dab026fe6b1" +dependencies = [ + "gix-command", + "gix-config-value", + "parking_lot 0.12.3", + "rustix", + "thiserror", +] + +[[package]] +name = "gix-quote" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbff4f9b9ea3fa7a25a70ee62f545143abef624ac6aa5884344e70c8b0a1d9ff" +dependencies = [ + "bstr", + "gix-utils", + "thiserror", +] + +[[package]] +name = "gix-ref" +version = "0.47.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae0d8406ebf9aaa91f55a57f053c5a1ad1a39f60fdf0303142b7be7ea44311e5" +dependencies = [ + "gix-actor", + "gix-features", + "gix-fs", + "gix-hash", + "gix-lock", + "gix-object", + "gix-path", + "gix-tempfile", + "gix-utils", + "gix-validate", + "memmap2", + "thiserror", + "winnow 0.6.20", +] + +[[package]] +name = "gix-refspec" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebb005f82341ba67615ffdd9f7742c87787544441c88090878393d0682869ca6" +dependencies = [ + "bstr", + "gix-hash", + "gix-revision", + "gix-validate", + "smallvec", + "thiserror", +] + +[[package]] +name = "gix-revision" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba4621b219ac0cdb9256883030c3d56a6c64a6deaa829a92da73b9a576825e1e" +dependencies = [ + "bstr", + "gix-date", + "gix-hash", + "gix-hashtable", + "gix-object", + "gix-revwalk", + "gix-trace", + "thiserror", +] + +[[package]] +name = "gix-revwalk" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b41e72544b93084ee682ef3d5b31b1ba4d8fa27a017482900e5e044d5b1b3984" +dependencies = [ + "gix-commitgraph", + "gix-date", + "gix-hash", + "gix-hashtable", + "gix-object", + "smallvec", + "thiserror", +] + +[[package]] +name = "gix-sec" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fe4d52f30a737bbece5276fab5d3a8b276dc2650df963e293d0673be34e7a5f" +dependencies = [ + "bitflags 2.6.0", + "gix-path", + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "gix-status" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f70d35ba639f0c16a6e4cca81aa374a05f07b23fa36ee8beb72c100d98b4ffea" +dependencies = [ + "bstr", + "filetime", + "gix-diff", + "gix-dir", + "gix-features", + "gix-filter", + "gix-fs", + "gix-hash", + "gix-index", + "gix-object", + "gix-path", + "gix-pathspec", + "gix-worktree", + "portable-atomic", + "thiserror", +] + +[[package]] +name = "gix-submodule" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "529d0af78cc2f372b3218f15eb1e3d1635a21c8937c12e2dd0b6fc80c2ca874b" +dependencies = [ + "bstr", + "gix-config", + "gix-path", + "gix-pathspec", + "gix-refspec", + "gix-url", + "thiserror", +] + +[[package]] +name = "gix-tempfile" +version = "14.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "046b4927969fa816a150a0cda2e62c80016fe11fb3c3184e4dddf4e542f108aa" +dependencies = [ + "dashmap", + "gix-fs", + "libc", + "once_cell", + "parking_lot 0.12.3", + "signal-hook", + "signal-hook-registry", + "tempfile", +] + +[[package]] +name = "gix-trace" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6cae0e8661c3ff92688ce1c8b8058b3efb312aba9492bbe93661a21705ab431b" + +[[package]] +name = "gix-traverse" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "030da39af94e4df35472e9318228f36530989327906f38e27807df305fccb780" +dependencies = [ + "bitflags 2.6.0", + "gix-commitgraph", + "gix-date", + "gix-hash", + "gix-hashtable", + "gix-object", + "gix-revwalk", + "smallvec", + "thiserror", +] + +[[package]] +name = "gix-url" +version = "0.27.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd280c5e84fb22e128ed2a053a0daeacb6379469be6a85e3d518a0636e160c89" +dependencies = [ + "bstr", + "gix-features", + "gix-path", + "home", + "thiserror", + "url", +] + +[[package]] +name = "gix-utils" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35192df7fd0fa112263bad8021e2df7167df4cc2a6e6d15892e1e55621d3d4dc" +dependencies = [ + "bstr", + "fastrand", + "unicode-normalization", +] + +[[package]] +name = "gix-validate" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81f2badbb64e57b404593ee26b752c26991910fd0d81fe6f9a71c1a8309b6c86" +dependencies = [ + "bstr", + "thiserror", +] + +[[package]] +name = "gix-worktree" +version = "0.36.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c312ad76a3f2ba8e865b360d5cb3aa04660971d16dec6dd0ce717938d903149a" +dependencies = [ + "bstr", + "gix-attributes", + "gix-features", + "gix-fs", + "gix-glob", + "gix-hash", + "gix-ignore", + "gix-index", + "gix-object", + "gix-path", + "gix-validate", +] + +[[package]] +name = "gix-worktree-state" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b05c4b313fa702c0bacd5068dd3e01671da73b938fade97676859fee286de43" +dependencies = [ + "bstr", + "gix-features", + "gix-filter", + "gix-fs", + "gix-glob", + "gix-hash", + "gix-index", + "gix-object", + "gix-path", + "gix-worktree", + "io-close", + "thiserror", +] + +[[package]] +name = "gix-worktree-stream" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68e81b87c1a3ece22a54b682d6fdc37fbb3977132da972cafe5ec07175fddbca" +dependencies = [ + "gix-attributes", + "gix-features", + "gix-filter", + "gix-fs", + "gix-hash", + "gix-object", + "gix-path", + "gix-traverse", + "parking_lot 0.12.3", + "thiserror", +] + +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] @@ -3578,8 +4751,8 @@ dependencies = [ "aho-corasick", "bstr", "log", - "regex-automata", - "regex-syntax", + "regex-automata 0.4.8", + "regex-syntax 0.8.5", ] [[package]] @@ -3895,6 +5068,18 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" +[[package]] +name = "human_format" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c3b1f728c459d27b12448862017b96ad4767b1ec2ec5e6434e99f1577f085b8" + +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + [[package]] name = "hyper" version = "0.14.30" @@ -4091,12 +5276,22 @@ dependencies = [ "globset", "log", "memchr", - "regex-automata", + "regex-automata 0.4.8", "same-file", "walkdir", "winapi-util", ] +[[package]] +name = "imara-diff" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc9da1a252bd44cd341657203722352efc9bc0c847d06ea6d2dc1cd1135e0a01" +dependencies = [ + "ahash", + "hashbrown 0.14.5", +] + [[package]] name = "impl-codec" version = "0.4.2" @@ -4171,6 +5366,25 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "include_dir" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "923d117408f1e49d914f1a379a309cffe4f18c05cf4e3d12e613a15fc81bd0dd" +dependencies = [ + "include_dir_macros", +] + +[[package]] +name = "include_dir_macros" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cab85a7ed0bd5f0e76d93846e0147172bed2e2d3f859bcc33a8d9699cad1a75" +dependencies = [ + "proc-macro2", + "quote", +] + [[package]] name = "indent" version = "0.1.1" @@ -4205,6 +5419,19 @@ dependencies = [ "serde", ] +[[package]] +name = "indicatif" +version = "0.17.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "763a5a8f45087d6bcea4222e7b72c291a054edf80e4ef6efd2a4979878c7bea3" +dependencies = [ + "console", + "instant", + "number_prefix", + "portable-atomic", + "unicode-width", +] + [[package]] name = "indoc" version = "2.0.5" @@ -4238,6 +5465,16 @@ dependencies = [ "web-sys", ] +[[package]] +name = "io-close" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cadcf447f06744f8ce713d2d6239bb5bde2c357a452397a9ed90c625da390bc" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "ipnet" version = "2.10.0" @@ -4254,6 +5491,12 @@ dependencies = [ "serde", ] +[[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + [[package]] name = "itertools" version = "0.10.5" @@ -4318,6 +5561,31 @@ dependencies = [ "libc", ] +[[package]] +name = "jiff" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a45489186a6123c128fdf6016183fcfab7113e1820eb813127e036e287233fb" +dependencies = [ + "jiff-tzdb-platform", + "windows-sys 0.52.0", +] + +[[package]] +name = "jiff-tzdb" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91335e575850c5c4c673b9bd467b0e025f164ca59d0564f69d0c2ee0ffad4653" + +[[package]] +name = "jiff-tzdb-platform" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9835f0060a626fe59f160437bc725491a6af23133ea906500027d1bd2f8f4329" +dependencies = [ + "jiff-tzdb", +] + [[package]] name = "jobserver" version = "0.1.32" @@ -4899,6 +6167,15 @@ dependencies = [ "tiny-keccak 1.5.0", ] +[[package]] +name = "kstring" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "558bf9508a558512042d3095138b1f7b8fe90c5467d94f9f1da28b3731c5dbd1" +dependencies = [ + "static_assertions", +] + [[package]] name = "lalrpop" version = "0.20.2" @@ -4913,7 +6190,7 @@ dependencies = [ "petgraph", "pico-args", "regex", - "regex-syntax", + "regex-syntax 0.8.5", "string_cache", "term", "tiny-keccak 2.0.2", @@ -4927,7 +6204,7 @@ version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "507460a910eb7b32ee961886ff48539633b788a36b65692b95f225b844c82553" dependencies = [ - "regex-automata", + "regex-automata 0.4.8", ] [[package]] @@ -5008,6 +6285,27 @@ checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ "bitflags 2.6.0", "libc", + "redox_syscall 0.5.7", +] + +[[package]] +name = "linkme" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c943daedff228392b791b33bba32e75737756e80a613e32e246c6ce9cbab20a" +dependencies = [ + "linkme-impl", +] + +[[package]] +name = "linkme-impl" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb26336e6dc7cc76e7927d2c9e7e3bb376d7af65a6f56a0b16c47d18a9b1abc5" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.79", ] [[package]] @@ -5050,6 +6348,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 = "matchit" version = "0.7.3" @@ -5081,6 +6388,15 @@ version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" +[[package]] +name = "memmap2" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd3f7eed9d3848f8b98834af67102b720745c4ec028fcd0aa0239277e7de374f" +dependencies = [ + "libc", +] + [[package]] name = "metrics" version = "0.23.0" @@ -5140,7 +6456,7 @@ dependencies = [ "indexmap 2.5.0", "metrics", "num_cpus", - "ordered-float", + "ordered-float 4.3.0", "quanta", "radix_trie", "sketches-ddsketch", @@ -5205,6 +6521,12 @@ version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c9be0862c1b3f26a88803c4a49de6889c10e608b3ee9344e6ef5b45fb37ad3d1" +[[package]] +name = "monch" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b52c1b33ff98142aecea13138bd399b68aa7ab5d9546c300988c345004001eea" + [[package]] name = "native-tls" version = "0.2.12" @@ -5430,6 +6752,21 @@ dependencies = [ "syn 2.0.79", ] +[[package]] +name = "num_threads" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c7398b9c8b70908f6371f47ed36737907c87c52af34c268fed0bf0ceb92ead9" +dependencies = [ + "libc", +] + +[[package]] +name = "number_prefix" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" + [[package]] name = "object" version = "0.36.4" @@ -5545,13 +6882,32 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" +[[package]] +name = "ordered-float" +version = "2.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68f19d67e5a2795c94e73e0bb1cc1a7edeb2e28efd39e2e1c9b7a40c1108b11c" +dependencies = [ + "num-traits 0.2.19", +] + [[package]] name = "ordered-float" version = "4.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d501f1a72f71d3c063a6bbc8f7271fa73aa09fe5d6283b6571e2ed176a2537" +checksum = "44d501f1a72f71d3c063a6bbc8f7271fa73aa09fe5d6283b6571e2ed176a2537" +dependencies = [ + "num-traits 0.2.19", +] + +[[package]] +name = "os_pipe" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ffd2b0a5634335b135d5728d84c5e0fd726954b87111f7506a61c502280d982" dependencies = [ - "num-traits 0.2.19", + "libc", + "windows-sys 0.59.0", ] [[package]] @@ -5679,12 +7035,30 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17359afc20d7ab31fdb42bb844c8b3bb1dabd7dcf7e68428492da7f16966fcef" +[[package]] +name = "path-dedot" +version = "3.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07ba0ad7e047712414213ff67533e6dd477af0a4e1d14fb52343e53d30ea9397" +dependencies = [ + "once_cell", +] + [[package]] name = "path-slash" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e91099d4268b0e11973f036e885d652fb0b21fedcf69738c627f94db6a44f42" +[[package]] +name = "pathdiff" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" +dependencies = [ + "camino", +] + [[package]] name = "pbkdf2" version = "0.11.0" @@ -6059,6 +7433,16 @@ dependencies = [ "hex", ] +[[package]] +name = "prodash" +version = "28.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "744a264d26b88a6a7e37cbad97953fa233b94d585236310bcbc88474b4092d79" +dependencies = [ + "bytesize", + "human_format", +] + [[package]] name = "proptest" version = "1.5.0" @@ -6071,7 +7455,7 @@ dependencies = [ "rand 0.8.5", "rand_chacha 0.3.1", "rand_xorshift", - "regex-syntax", + "regex-syntax 0.8.5", "unarray", ] @@ -6147,6 +7531,16 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "ra_ap_toolchain" +version = "0.0.218" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53393fc4d85057bcca4dd2d7fa24929a094bb94712980814695f56cb9aa0b1e2" +dependencies = [ + "camino", + "home", +] + [[package]] name = "radium" version = "0.3.0" @@ -6284,6 +7678,15 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "redb" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4760ad04a88ef77075ba86ba9ea79b919e6bab29c1764c5747237cd6eaedcaa" +dependencies = [ + "libc", +] + [[package]] name = "redox_syscall" version = "0.2.16" @@ -6321,8 +7724,17 @@ checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" dependencies = [ "aho-corasick", "memchr", - "regex-automata", - "regex-syntax", + "regex-automata 0.4.8", + "regex-syntax 0.8.5", +] + +[[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]] @@ -6333,9 +7745,15 @@ checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" dependencies = [ "aho-corasick", "memchr", - "regex-syntax", + "regex-syntax 0.8.5", ] +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + [[package]] name = "regex-syntax" version = "0.8.5" @@ -6354,6 +7772,7 @@ version = "0.11.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" dependencies = [ + "async-compression", "base64 0.21.7", "bytes", "encoding_rs", @@ -6369,11 +7788,13 @@ dependencies = [ "js-sys", "log", "mime", + "mime_guess", "native-tls", "once_cell", "percent-encoding", "pin-project-lite", "rustls 0.21.12", + "rustls-native-certs 0.6.3", "rustls-pemfile 1.0.4", "serde", "serde_json", @@ -6383,10 +7804,12 @@ dependencies = [ "tokio", "tokio-native-tls", "tokio-rustls 0.24.1", + "tokio-util", "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", + "wasm-streams", "web-sys", "webpki-roots 0.25.4", "winreg", @@ -6962,6 +8385,142 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "scarb" +version = "2.8.3" +source = "git+https://github.com/software-mansion/scarb/?tag=v2.8.3#54938ce3b01f81959e6e0114b080cc5e1a73935b" +dependencies = [ + "anyhow", + "async-trait", + "cairo-lang-compiler 2.8.2", + "cairo-lang-defs 2.8.2", + "cairo-lang-diagnostics 2.8.2", + "cairo-lang-filesystem 2.8.2", + "cairo-lang-formatter 2.8.2", + "cairo-lang-lowering 2.8.2", + "cairo-lang-macro", + "cairo-lang-macro-stable", + "cairo-lang-parser 2.8.2", + "cairo-lang-semantic 2.8.2", + "cairo-lang-sierra 2.8.2", + "cairo-lang-sierra-to-casm 2.8.2", + "cairo-lang-starknet 2.8.2", + "cairo-lang-starknet-classes 2.8.2", + "cairo-lang-syntax 2.8.2", + "cairo-lang-test-plugin", + "cairo-lang-utils 2.8.2", + "camino", + "clap", + "convert_case 0.6.0", + "create-output-dir", + "data-encoding", + "deno_task_shell", + "derive_builder", + "dialoguer", + "directories", + "dunce", + "fs4", + "fs_extra", + "futures", + "gix", + "gix-path", + "glob", + "ignore", + "include_dir", + "indoc", + "itertools 0.12.1", + "libloading", + "once_cell", + "pathdiff", + "petgraph", + "ra_ap_toolchain", + "redb", + "reqwest 0.11.27", + "scarb-build-metadata", + "scarb-metadata", + "scarb-stable-hash 1.0.0 (git+https://github.com/software-mansion/scarb/?tag=v2.8.3)", + "scarb-ui", + "semver", + "serde", + "serde-untagged", + "serde-value", + "serde_json", + "serde_repr", + "sha2 0.10.8", + "smallvec", + "smol_str", + "tar", + "thiserror", + "tokio", + "toml", + "toml_edit 0.22.22", + "tracing", + "tracing-subscriber", + "typed-builder", + "url", + "walkdir", + "which 5.0.0", + "windows-sys 0.59.0", + "zip", + "zstd 0.13.2", +] + +[[package]] +name = "scarb-build-metadata" +version = "2.8.3" +source = "git+https://github.com/software-mansion/scarb/?tag=v2.8.3#54938ce3b01f81959e6e0114b080cc5e1a73935b" +dependencies = [ + "cargo_metadata", +] + +[[package]] +name = "scarb-metadata" +version = "1.12.0" +source = "git+https://github.com/software-mansion/scarb/?tag=v2.8.3#54938ce3b01f81959e6e0114b080cc5e1a73935b" +dependencies = [ + "camino", + "derive_builder", + "semver", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "scarb-stable-hash" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1902536b23a05dd165d3992865870aaf1b0650317767cbf171ed2ca5903732a9" +dependencies = [ + "data-encoding", + "xxhash-rust", +] + +[[package]] +name = "scarb-stable-hash" +version = "1.0.0" +source = "git+https://github.com/software-mansion/scarb/?tag=v2.8.3#54938ce3b01f81959e6e0114b080cc5e1a73935b" +dependencies = [ + "data-encoding", + "xxhash-rust", +] + +[[package]] +name = "scarb-ui" +version = "0.1.5" +source = "git+https://github.com/software-mansion/scarb/?tag=v2.8.3#54938ce3b01f81959e6e0114b080cc5e1a73935b" +dependencies = [ + "anyhow", + "camino", + "clap", + "console", + "indicatif", + "scarb-metadata", + "serde", + "serde_json", + "tracing-core", +] + [[package]] name = "schannel" version = "0.1.24" @@ -7063,7 +8622,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ "bitflags 2.6.0", - "core-foundation", + "core-foundation 0.9.4", "core-foundation-sys", "libc", "security-framework-sys", @@ -7109,6 +8668,27 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde-untagged" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2676ba99bd82f75cae5cbd2c8eda6fa0b8760f18978ea840e980dd5567b5c5b6" +dependencies = [ + "erased-serde", + "serde", + "typeid", +] + +[[package]] +name = "serde-value" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3a1a3341211875ef120e117ea7fd5228530ae7e7036a779fdc9117be6b3282c" +dependencies = [ + "ordered-float 2.10.1", + "serde", +] + [[package]] name = "serde_derive" version = "1.0.210" @@ -7165,6 +8745,17 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_repr" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.79", +] + [[package]] name = "serde_spanned" version = "0.6.8" @@ -7279,6 +8870,12 @@ dependencies = [ "digest 0.10.7", ] +[[package]] +name = "sha1_smol" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbfa15b3dddfee50a0fff136974b3e1bde555604ba463834a7eb7deb6417705d" + [[package]] name = "sha2" version = "0.9.9" @@ -7322,12 +8919,28 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "shell-words" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" + [[package]] name = "shlex" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +[[package]] +name = "signal-hook" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8621587d4798caf8eb44879d42e56b9a93ea5dcd315a6487c357130095b62801" +dependencies = [ + "libc", + "signal-hook-registry", +] + [[package]] name = "signal-hook-registry" version = "1.4.2" @@ -8053,7 +9666,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" dependencies = [ "bitflags 1.3.2", - "core-foundation", + "core-foundation 0.9.4", "system-configuration-sys", ] @@ -8073,6 +9686,17 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" +[[package]] +name = "tar" +version = "0.4.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ff6c40d3aedb5e06b57c6f669ad17ab063dd1e63d977c6a88e7f4dfa4f04020" +dependencies = [ + "filetime", + "libc", + "xattr", +] + [[package]] name = "tempfile" version = "3.13.0" @@ -8164,7 +9788,9 @@ checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "itoa", + "libc", "num-conv", + "num_threads", "powerfmt", "serde", "time-core", @@ -8529,10 +10155,14 @@ version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" dependencies = [ + "matchers", "nu-ansi-term", + "once_cell", + "regex", "sharded-slab", "smallvec", "thread_local", + "tracing", "tracing-core", "tracing-log", ] @@ -8593,6 +10223,32 @@ dependencies = [ "utf-8", ] +[[package]] +name = "typed-builder" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e14ed59dc8b7b26cacb2a92bad2e8b1f098806063898ab42a3bd121d7d45e75" +dependencies = [ + "typed-builder-macro", +] + +[[package]] +name = "typed-builder-macro" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "560b82d656506509d43abe30e0ba64c56b1953ab3d4fe7ba5902747a7a3cedd5" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.79", +] + +[[package]] +name = "typeid" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e13db2e0ccd5e14a544e8a246ba2312cd25223f616442d7f2cb0e3db614236e" + [[package]] name = "typenum" version = "1.17.0" @@ -8623,6 +10279,15 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "uluru" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c8a2469e56e6e5095c82ccd3afb98dad95f7af7929aab6d8ba8d6e0f73657da" +dependencies = [ + "arrayvec 0.7.6", +] + [[package]] name = "unarray" version = "0.1.4" @@ -8662,6 +10327,12 @@ version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" +[[package]] +name = "unicode-bom" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7eec5d1121208364f6793f7d2e222bf75a915c19557537745b195b253dd64217" + [[package]] name = "unicode-ident" version = "1.0.13" @@ -8683,6 +10354,12 @@ version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" +[[package]] +name = "unicode-width" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" + [[package]] name = "unicode-xid" version = "0.2.6" @@ -8743,6 +10420,12 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + [[package]] name = "uuid" version = "0.8.2" @@ -8908,6 +10591,19 @@ version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" +[[package]] +name = "wasm-streams" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e072d4e72f700fb3443d8fe94a39315df013eef1104903cdb0a2abd322bbecd" +dependencies = [ + "futures-util", + "js-sys", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + [[package]] name = "web-sys" version = "0.3.70" @@ -8964,6 +10660,19 @@ dependencies = [ "rustix", ] +[[package]] +name = "which" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bf3ea8596f3a0dd5980b46430f2058dfe2c36a27ccfbb1845d6fbfcd9ba6e14" +dependencies = [ + "either", + "home", + "once_cell", + "rustix", + "windows-sys 0.48.0", +] + [[package]] name = "winapi" version = "0.3.9" @@ -9315,6 +11024,17 @@ dependencies = [ "tap", ] +[[package]] +name = "xattr" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8da84f1a25939b27f6820d92aed108f83ff920fdf11a7b19366c27c4cda81d4f" +dependencies = [ + "libc", + "linux-raw-sys", + "rustix", +] + [[package]] name = "xshell" version = "0.2.6" @@ -9330,6 +11050,12 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d422e8e38ec76e2f06ee439ccc765e9c6a9638b9e7c9f2e8255e4d41e8bd852" +[[package]] +name = "xxhash-rust" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a5cbf750400958819fb6178eaa83bee5cd9c29a26a40cc241df8c70fdd46984" + [[package]] name = "yansi" version = "0.5.1" diff --git a/Cargo.toml b/Cargo.toml index 55386798..9197c26f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -75,6 +75,8 @@ katana-node = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-alpha. katana-primitives = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-alpha.9" } katana-rpc = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-alpha.9" } katana-rpc-api = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-alpha.9" } +scarb = { git = "https://github.com/software-mansion/scarb/", tag = "v2.8.3" } +semver = { version = "1", features = ["serde"] } wiremock = "0.6.2" [patch.crates-io] diff --git a/tests/account_katana.rs b/tests/account_katana.rs index 3a5ed152..3b1181e9 100644 --- a/tests/account_katana.rs +++ b/tests/account_katana.rs @@ -11,13 +11,19 @@ use beerus::{ TxnHash, }, }; -use common::constants::{ - CLASS_HASH, COMPILED_ACCOUNT_CONTRACT_V2, COMPILED_ACCOUNT_CONTRACT_V3, - CONTRACT_ADDRESS, DECLARE_ACCOUNT_V2, DECLARE_ACCOUNT_V3, SENDER_ADDRESS, +use common::err::Error; +use starknet::katana::Katana; +use starknet::{ + constants::{ + CLASS_HASH, COMPILED_ACCOUNT_CONTRACT_V2, COMPILED_ACCOUNT_CONTRACT_V3, + CONTRACT_ADDRESS, DECLARE_ACCOUNT_V2, DECLARE_ACCOUNT_V3, + SENDER_ADDRESS, + }, + executor::Executor, }; -use common::katana::Katana; mod common; +mod starknet; async fn setup() -> (Katana, Client) { let katana = Katana::init("http://127.0.0.1:0").await.unwrap(); @@ -41,6 +47,16 @@ async fn declare_deploy_account_v2() { deploy(client).await; } +#[tokio::test] +async fn deploy_multiple_accounts_on_katana() -> Result<(), Error> { + let _katana = Katana::init("http://127.0.0.1:0").await?; + let num_of_new_accounts = 3; + let mut executor = Executor::new(num_of_new_accounts)?; + let update_template = false; + executor.deploy_accounts(update_template)?; + Ok(()) +} + async fn declare( client: &Client, compiled_contract: &str, diff --git a/tests/account_mock.rs b/tests/account_mock.rs index 5b7f8a5a..19c1ed1c 100644 --- a/tests/account_mock.rs +++ b/tests/account_mock.rs @@ -1,6 +1,6 @@ use beerus::gen::{Address, BlockId, BlockTag, Felt, Rpc, TxnHash}; -use common::{ +use mock::{ dummies::{ declare_transaction, deploy_transaction, estimate_fee_transaction, invoke_transaction, @@ -15,7 +15,7 @@ use common::{ node::setup_client_with_mock_starknet_node, }; -mod common; +mod mock; #[tokio::test] async fn chain_id_test() { diff --git a/tests/common/err.rs b/tests/common/err.rs index 43513641..733e5e05 100644 --- a/tests/common/err.rs +++ b/tests/common/err.rs @@ -12,4 +12,8 @@ pub enum Error { Json(#[from] serde_json::Error), #[error("starknet api error: {0:?}")] Api(#[from] starknet_api::StarknetApiError), + #[error("IO error: {0:?}")] + IO(#[from] std::io::Error), + #[error("Anyhow error: {0:?}")] + Anyhow(#[from] anyhow::Error), } diff --git a/tests/common/mod.rs b/tests/common/mod.rs index b1339aeb..44a8da0a 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -1,7 +1,2 @@ -pub mod constants; pub mod ctx; -pub mod dummies; pub mod err; -pub mod katana; -pub mod matchers; -pub mod node; diff --git a/tests/common/dummies.rs b/tests/mock/dummies.rs similarity index 100% rename from tests/common/dummies.rs rename to tests/mock/dummies.rs diff --git a/tests/common/matchers.rs b/tests/mock/matchers.rs similarity index 100% rename from tests/common/matchers.rs rename to tests/mock/matchers.rs diff --git a/tests/mock/mod.rs b/tests/mock/mod.rs new file mode 100644 index 00000000..6de36c27 --- /dev/null +++ b/tests/mock/mod.rs @@ -0,0 +1,3 @@ +pub mod dummies; +pub mod matchers; +pub mod node; diff --git a/tests/common/node.rs b/tests/mock/node.rs similarity index 100% rename from tests/common/node.rs rename to tests/mock/node.rs diff --git a/tests/rpc.rs b/tests/rpc.rs index c90e15b2..1803b8ce 100644 --- a/tests/rpc.rs +++ b/tests/rpc.rs @@ -1,39 +1,18 @@ -use beerus::{ - config::MAINNET_STARKNET_CHAINID, - gen::{ - Address, BlockHash, BlockId, BlockNumber, BlockTag, - BroadcastedInvokeTxn, BroadcastedTxn, Felt, FunctionCall, - GetBlockWithTxHashesResult, GetBlockWithTxsResult, GetClassAtResult, - GetClassResult, GetTransactionByBlockIdAndIndexIndex, InvokeTxn, - InvokeTxnV1, InvokeTxnV1Version, PriceUnit, Rpc, StorageKey, - SyncingResult, Txn, TxnExecutionStatus, TxnHash, TxnReceipt, - TxnReceiptWithBlockInfo, TxnStatus, - }, +use beerus::gen::{ + Address, BlockHash, BlockId, BlockNumber, BlockTag, BroadcastedInvokeTxn, + BroadcastedTxn, Felt, FunctionCall, GetBlockWithTxHashesResult, + GetBlockWithTxsResult, GetClassAtResult, GetClassResult, + GetTransactionByBlockIdAndIndexIndex, InvokeTxn, InvokeTxnV1, + InvokeTxnV1Version, PriceUnit, Rpc, StorageKey, SyncingResult, Txn, + TxnExecutionStatus, TxnHash, TxnReceipt, TxnReceiptWithBlockInfo, + TxnStatus, }; mod common; +mod starknet; use common::err::Error; - -#[tokio::test] -#[allow(non_snake_case)] -async fn test_specVersion() -> Result<(), Error> { - let ctx = setup!(); - - let ret = ctx.client.specVersion().await?; - assert_eq!(ret, "0.7.1"); - Ok(()) -} - -#[tokio::test] -#[allow(non_snake_case)] -async fn test_chainId() -> Result<(), Error> { - let ctx = setup!(); - - let ret = ctx.client.chainId().await?; - assert_eq!(ret.as_ref(), MAINNET_STARKNET_CHAINID); - Ok(()) -} +use starknet::executor::Executor; #[tokio::test] #[allow(non_snake_case)] @@ -532,3 +511,17 @@ async fn account_call() -> Result<(), Error> { Ok(()) } + +#[tokio::test] +async fn deploy_new_account_on_sepolia() -> Result<(), Error> { + // TODO #807 + // schedule test once each month in separate workflow + // with each test, template account id is incremented by 1 + // commit from workflows to update latest state of id + let _ctx = setup!("sepolia"); + let num_of_new_accounts = 1; + let _executor = Executor::new(num_of_new_accounts)?; + let _update_template = true; + // executor.deploy_accounts(update_template)?; + Ok(()) +} diff --git a/tests/clob/compiled_account_contract_v2.txt b/tests/starknet/clob/compiled_account_contract_v2.txt similarity index 100% rename from tests/clob/compiled_account_contract_v2.txt rename to tests/starknet/clob/compiled_account_contract_v2.txt diff --git a/tests/clob/compiled_account_contract_v3.txt b/tests/starknet/clob/compiled_account_contract_v3.txt similarity index 100% rename from tests/clob/compiled_account_contract_v3.txt rename to tests/starknet/clob/compiled_account_contract_v3.txt diff --git a/tests/clob/declare_account_v2.txt b/tests/starknet/clob/declare_account_v2.txt similarity index 100% rename from tests/clob/declare_account_v2.txt rename to tests/starknet/clob/declare_account_v2.txt diff --git a/tests/clob/declare_account_v3.txt b/tests/starknet/clob/declare_account_v3.txt similarity index 100% rename from tests/clob/declare_account_v3.txt rename to tests/starknet/clob/declare_account_v3.txt diff --git a/tests/common/constants.rs b/tests/starknet/constants.rs similarity index 73% rename from tests/common/constants.rs rename to tests/starknet/constants.rs index bf436062..6b29843f 100644 --- a/tests/common/constants.rs +++ b/tests/starknet/constants.rs @@ -1,15 +1,15 @@ #[allow(dead_code)] pub const COMPILED_ACCOUNT_CONTRACT_V2: &str = - include_str!("../clob/compiled_account_contract_v2.txt"); + include_str!("./clob/compiled_account_contract_v2.txt"); #[allow(dead_code)] pub const COMPILED_ACCOUNT_CONTRACT_V3: &str = - include_str!("../clob/compiled_account_contract_v3.txt"); + include_str!("./clob/compiled_account_contract_v3.txt"); #[allow(dead_code)] pub const DECLARE_ACCOUNT_V2: &str = - include_str!("../clob/declare_account_v2.txt"); + include_str!("./clob/declare_account_v2.txt"); #[allow(dead_code)] pub const DECLARE_ACCOUNT_V3: &str = - include_str!("../clob/declare_account_v3.txt"); + include_str!("./clob/declare_account_v3.txt"); #[allow(dead_code)] pub const CLASS_HASH: &str = diff --git a/tests/starknet/contract/account/Scarb.toml b/tests/starknet/contract/account/Scarb.toml new file mode 100644 index 00000000..c7421b19 --- /dev/null +++ b/tests/starknet/contract/account/Scarb.toml @@ -0,0 +1,11 @@ +[package] +name = "account" +version = "0.1.0" +cairo-version = "2.5.4" + +[dependencies] +starknet = ">=2.5.4" + +[[target.starknet-contract]] +sierra = true +casm = true diff --git a/tests/starknet/contract/account/src/lib.cairo b/tests/starknet/contract/account/src/lib.cairo new file mode 100644 index 00000000..07e6f11f --- /dev/null +++ b/tests/starknet/contract/account/src/lib.cairo @@ -0,0 +1,149 @@ +use starknet::account::Call; + +mod SUPPORTED_TX_VERSION { + const DEPLOY_ACCOUNT: felt252 = 1; + const DECLARE: felt252 = 2; + const INVOKE: felt252 = 1; +} + +#[starknet::interface] +trait IAccount { + fn is_valid_signature(self: @T, hash: felt252, signature: Array) -> felt252; + fn supports_interface(self: @T, interface_id: felt252) -> bool; + fn public_key(self: @T) -> felt252; + fn id(self: @T) -> u128; +} + +#[starknet::contract] +mod Account { + use super::{Call, IAccount, SUPPORTED_TX_VERSION}; + use starknet::{get_caller_address, call_contract_syscall, get_tx_info, VALIDATED}; + use zeroable::Zeroable; + use array::{ArrayTrait, SpanTrait}; + use ecdsa::check_ecdsa_signature; + use box::BoxTrait; + + const SIMULATE_TX_VERSION_OFFSET: felt252 = 340282366920938463463374607431768211456; // 2**128 + const SRC6_TRAIT_ID: felt252 = 1270010605630597976495846281167968799381097569185364931397797212080166453709; // hash of SNIP-6 trait + + #[storage] + struct Storage { + public_key: felt252, + id: u128 + } + + #[constructor] + fn constructor(ref self: ContractState, public_key: felt252) { + self.public_key.write(public_key); + self.id.write(0); + } + + #[abi(embed_v0)] + impl AccountImpl of IAccount { + fn is_valid_signature(self: @ContractState, hash: felt252, signature: Array) -> felt252 { + let is_valid = self.is_valid_signature_bool(hash, signature.span()); + if is_valid { VALIDATED } else { 0 } + } + + fn supports_interface(self: @ContractState, interface_id: felt252) -> bool { + interface_id == SRC6_TRAIT_ID + } + + fn public_key(self: @ContractState) -> felt252 { + self.public_key.read() + } + + fn id(self: @ContractState) -> u128 { + self.id.read() + } + } + + #[abi(per_item)] + #[generate_trait] + impl ProtocolImpl of ProtocolTrait { + fn __execute__(ref self: ContractState, calls: Array) -> Array> { + self.only_protocol(); + self.only_supported_tx_version(SUPPORTED_TX_VERSION::INVOKE); + self.execute_multiple_calls(calls) + } + + fn __validate__(self: @ContractState, calls: Array) -> felt252 { + self.only_protocol(); + self.only_supported_tx_version(SUPPORTED_TX_VERSION::INVOKE); + self.validate_transaction() + } + + fn __validate_declare__(self: @ContractState, class_hash: felt252) -> felt252 { + self.only_protocol(); + self.only_supported_tx_version(SUPPORTED_TX_VERSION::DECLARE); + self.validate_transaction() + } + + fn __validate_deploy__(self: @ContractState, class_hash: felt252, salt: felt252, public_key: felt252) -> felt252 { + self.only_protocol(); + self.only_supported_tx_version(SUPPORTED_TX_VERSION::DEPLOY_ACCOUNT); + self.validate_transaction() + } + } + + #[generate_trait] + impl PrivateImpl of PrivateTrait { + fn only_protocol(self: @ContractState) { + let sender = get_caller_address(); + assert(sender.is_zero(), 'Account: invalid caller'); + } + + fn is_valid_signature_bool(self: @ContractState, hash: felt252, signature: Span) -> bool { + let is_valid_length = signature.len() == 2_u32; + + if !is_valid_length { + return false; + } + + check_ecdsa_signature( + hash, self.public_key.read(), *signature.at(0_u32), *signature.at(1_u32) + ) + } + + fn validate_transaction(self: @ContractState) -> felt252 { + let tx_info = get_tx_info().unbox(); + let tx_hash = tx_info.transaction_hash; + let signature = tx_info.signature; + + let is_valid = self.is_valid_signature_bool(tx_hash, signature); + assert(is_valid, 'Account: Incorrect tx signature'); + VALIDATED + } + + fn execute_single_call(self: @ContractState, call: Call) -> Span { + let Call{to, selector, calldata} = call; + call_contract_syscall(to, selector, calldata.into()).unwrap() + } + + fn execute_multiple_calls(self: @ContractState, mut calls: Array) -> Array> { + let mut res = ArrayTrait::new(); + loop { + match calls.pop_front() { + Option::Some(call) => { + let _res = self.execute_single_call(call); + res.append(_res); + }, + Option::None(_) => { + break (); + }, + }; + }; + res + } + + fn only_supported_tx_version(self: @ContractState, supported_tx_version: felt252) { + let tx_info = get_tx_info().unbox(); + let version = tx_info.version; + assert( + version == supported_tx_version || + version == SIMULATE_TX_VERSION_OFFSET + supported_tx_version, + 'Account: Unsupported tx version' + ); + } + } +} diff --git a/tests/starknet/executor.rs b/tests/starknet/executor.rs new file mode 100644 index 00000000..8da68e84 --- /dev/null +++ b/tests/starknet/executor.rs @@ -0,0 +1,128 @@ +use std::{fs, thread}; + +use anyhow::{anyhow, Error}; +use regex::Regex; + +use super::scarb::Compiler; + +#[allow(dead_code)] +pub struct Executor { + accounts: Vec, +} + +#[allow(dead_code)] +impl Executor { + pub fn new(num: usize) -> Result { + let template = "./tests/starknet/contract/account".to_string(); + let mut accounts = Vec::with_capacity(num); + accounts.push(template); + Ok(Self { accounts }) + } + + pub fn deploy_accounts( + &mut self, + update_template: bool, + ) -> Result<(), Error> { + if update_template { + self.update_account(&self.accounts[0])?; + } + self.prepare_contracts_environment()?; + self.compile()?; + // TODO + // #804 starkli signer keystore new key.json - Storing somewhere or deleting? + // #804 starkli account oz init account.json - Storing somewhere or deleting? + // #804 declare accounts + // #804 #805 fund accounts from pre-funded account + // #804 deploy accounts + // #806 iterate through class hashes and call getClass to see if they are verified + Ok(()) + } + + fn update_account(&self, path: &str) -> Result<(), Error> { + let lib_path = path.to_owned() + "/src/lib.cairo"; + let account_old = fs::read_to_string(lib_path.clone())?; + let re = Regex::new(r"self.id.write\((?\d+)\);")?; + + let Some(val) = re.captures(&account_old) else { + return Err(anyhow!("Could not find pattern in lib.cairo.")); + }; + let num_old = + &val["number"].parse::().expect("Failed to read number"); + let num_new = num_old + 1; + let account_new = account_old.replace( + &format!("self.id.write({num_old})"), + &format!("self.id.write({num_new})"), + ); + fs::write(lib_path, account_new)?; + + Ok(()) + } + + fn prepare_contracts_environment(&mut self) -> Result<(), Error> { + let capacity = self.accounts.capacity(); + let template = self.accounts[0].clone(); + let lib_path = "/src/lib.cairo"; + let toml_path = "/Scarb.toml"; + + for i in 1..capacity { + let account = template.clone() + &i.to_string(); + fs::create_dir(account.clone())?; + fs::create_dir(account.clone() + "/src")?; + fs::copy( + self.accounts[i - 1].clone() + lib_path, + account.clone() + lib_path, + )?; + fs::copy( + template.clone() + toml_path, + account.clone() + toml_path, + )?; + self.update_account(&account)?; + self.accounts.push(account); + } + + Ok(()) + } + + fn compile(&self) -> Result<(), Error> { + let mut vec_of_threads = Vec::with_capacity(self.accounts.len()); + + for account in self.accounts.iter() { + let path = account.clone() + "/Scarb.toml"; + let compilation = thread::spawn(move || -> Result<(), Error> { + let compiler = Compiler::new(&path)?; + compiler.compile() + }); + vec_of_threads.push(compilation); + } + for (i, thread) in vec_of_threads.into_iter().enumerate() { + let compilation = thread.join(); + match compilation { + Ok(val) => val?, + Err(e) => { + return Err(anyhow!("Error during thread {i} execution. Original error message: {:#?}", e)); + } + } + } + + Ok(()) + } +} + +impl Drop for Executor { + fn drop(&mut self) { + let dir = self.accounts[0].clone() + "/target"; + let scarb = self.accounts[0].clone() + "/Scarb.lock"; + if fs::exists(dir.clone()).expect("Failed to check template target") { + fs::remove_dir_all(dir).expect("Failed to remove template target"); + }; + if fs::exists(scarb.clone()).expect("Failed to check template Scarb") { + fs::remove_file(scarb).expect("Failed to remove template Scarb"); + } + for i in 1..self.accounts.len() { + let dir = self.accounts[i].clone(); + if fs::exists(dir.clone()).expect("Failed to check account dir") { + fs::remove_dir_all(dir).expect("Failed to remove account dir"); + } + } + } +} diff --git a/tests/common/katana.rs b/tests/starknet/katana.rs similarity index 100% rename from tests/common/katana.rs rename to tests/starknet/katana.rs diff --git a/tests/starknet/mod.rs b/tests/starknet/mod.rs new file mode 100644 index 00000000..26d7e2bf --- /dev/null +++ b/tests/starknet/mod.rs @@ -0,0 +1,4 @@ +pub mod constants; +pub mod executor; +pub mod katana; +pub mod scarb; diff --git a/tests/starknet/scarb.rs b/tests/starknet/scarb.rs new file mode 100644 index 00000000..cb75e22a --- /dev/null +++ b/tests/starknet/scarb.rs @@ -0,0 +1,43 @@ +use anyhow::Error; +use scarb::{ + core::{Config, PackageId, PackageName, SourceId, TargetKind}, + ops::{self, CompileOpts, FeaturesOpts, FeaturesSelector}, +}; +use semver::Version; +use std::{fs::canonicalize, path::PathBuf}; + +#[allow(dead_code)] +pub struct Compiler { + toml: PathBuf, + opts: CompileOpts, + packages: Vec, +} + +#[allow(dead_code)] +impl Compiler { + pub fn new(toml: &str) -> Result { + let toml_absolute = canonicalize(PathBuf::from(toml))?; + let opts = CompileOpts { + include_target_kinds: vec![], + exclude_target_kinds: vec![TargetKind::new("test")], + include_target_names: vec![], + features: FeaturesOpts { + features: FeaturesSelector::Features(vec![]), + no_default_features: false, + }, + }; + let packages = vec![PackageId::new( + PackageName::new("account"), + Version::new(0, 1, 0), + SourceId::for_path(toml_absolute.to_str().unwrap().into())?, + )]; + + Ok(Compiler { toml: toml_absolute, opts, packages }) + } + + pub fn compile(self) -> Result<(), Error> { + let config = Config::builder(self.toml.to_str().unwrap()).build()?; + let ws = ops::read_workspace(config.manifest_path(), &config)?; + scarb::ops::compile(self.packages, self.opts, &ws) + } +} From 00af73c18bfdc53a5b9f988c5f8c031dd5795eba Mon Sep 17 00:00:00 2001 From: Ivan Cavlek Date: Wed, 23 Oct 2024 13:34:55 +0200 Subject: [PATCH 2/3] refactor: update based on review comments --- Cargo.lock | 1 + Cargo.toml | 1 + tests/account_katana.rs | 21 ++- tests/rpc.rs | 18 ++- tests/starknet/contract/account/src/lib.cairo | 2 +- tests/starknet/coordinator.rs | 82 +++++++++++ tests/starknet/executor.rs | 128 ------------------ tests/starknet/mod.rs | 2 +- tests/starknet/scarb.rs | 18 ++- 9 files changed, 130 insertions(+), 143 deletions(-) create mode 100644 tests/starknet/coordinator.rs delete mode 100644 tests/starknet/executor.rs diff --git a/Cargo.lock b/Cargo.lock index 0adef0a5..c75a4d73 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -629,6 +629,7 @@ dependencies = [ "bitvec 1.0.1", "blockifier 0.8.0-rc.2", "cairo-lang-starknet-classes 2.7.0", + "chrono", "ethers", "eyre", "flate2", diff --git a/Cargo.toml b/Cargo.toml index 9197c26f..7ea0e868 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -69,6 +69,7 @@ gloo-timers = { version = "0.3.0", features = ["futures"] } [dev-dependencies] anyhow = "1.0.89" alloy-primitives = { version = "0.8.5", default-features = false } +chrono = "0.4.38" katana-core = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-alpha.9" } katana-executor = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-alpha.9" } katana-node = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-alpha.9" } diff --git a/tests/account_katana.rs b/tests/account_katana.rs index 3b1181e9..5791ac32 100644 --- a/tests/account_katana.rs +++ b/tests/account_katana.rs @@ -13,13 +13,14 @@ use beerus::{ }; use common::err::Error; use starknet::katana::Katana; +use starknet::scarb::Compiler; use starknet::{ constants::{ CLASS_HASH, COMPILED_ACCOUNT_CONTRACT_V2, COMPILED_ACCOUNT_CONTRACT_V3, CONTRACT_ADDRESS, DECLARE_ACCOUNT_V2, DECLARE_ACCOUNT_V3, SENDER_ADDRESS, }, - executor::Executor, + coordinator::{Coordinator, TestMode}, }; mod common; @@ -48,12 +49,20 @@ async fn declare_deploy_account_v2() { } #[tokio::test] -async fn deploy_multiple_accounts_on_katana() -> Result<(), Error> { +async fn deploy_new_account_on_katana() -> Result<(), Error> { let _katana = Katana::init("http://127.0.0.1:0").await?; - let num_of_new_accounts = 3; - let mut executor = Executor::new(num_of_new_accounts)?; - let update_template = false; - executor.deploy_accounts(update_template)?; + let coordinator = Coordinator::new(TestMode::Katana); + coordinator.copy_template_to_target()?; + coordinator.update_account()?; + let compiler = Compiler::new(&coordinator.target_scarb())?; + compiler.compile().await?; + // TODO + // #804 starkli signer keystore new key.json - Storing somewhere or deleting? + // #804 starkli account oz init account.json - Storing somewhere or deleting? + // #804 declare accounts + // #804 #805 fund accounts from pre-funded account + // #804 deploy accounts + // #806 iterate through class hashes and call getClass to see if they are verified Ok(()) } diff --git a/tests/rpc.rs b/tests/rpc.rs index 1803b8ce..f392af2b 100644 --- a/tests/rpc.rs +++ b/tests/rpc.rs @@ -12,7 +12,6 @@ mod common; mod starknet; use common::err::Error; -use starknet::executor::Executor; #[tokio::test] #[allow(non_snake_case)] @@ -518,10 +517,19 @@ async fn deploy_new_account_on_sepolia() -> Result<(), Error> { // schedule test once each month in separate workflow // with each test, template account id is incremented by 1 // commit from workflows to update latest state of id + let _ctx = setup!("sepolia"); - let num_of_new_accounts = 1; - let _executor = Executor::new(num_of_new_accounts)?; - let _update_template = true; - // executor.deploy_accounts(update_template)?; + // let coordinator = Coordinator::new(TestMode::Sepolia); + // coordinator.copy_template_to_target()?; + // coordinator.update_account()?; + // let compiler = Compiler::new(&coordinator.target_scarb())?; + // compiler.compile().await?; + + // TODO + // #804 starkli signer keystore new key.json - Storing somewhere or deleting? + // #804 starkli account oz init account.json - Storing somewhere or deleting? + // #804 declare account + // #804 #805 fund account from pre-funded account + // #804 deploy account Ok(()) } diff --git a/tests/starknet/contract/account/src/lib.cairo b/tests/starknet/contract/account/src/lib.cairo index 07e6f11f..f64cba68 100644 --- a/tests/starknet/contract/account/src/lib.cairo +++ b/tests/starknet/contract/account/src/lib.cairo @@ -35,7 +35,7 @@ mod Account { #[constructor] fn constructor(ref self: ContractState, public_key: felt252) { self.public_key.write(public_key); - self.id.write(0); + self.id.write(); } #[abi(embed_v0)] diff --git a/tests/starknet/coordinator.rs b/tests/starknet/coordinator.rs new file mode 100644 index 00000000..417693fb --- /dev/null +++ b/tests/starknet/coordinator.rs @@ -0,0 +1,82 @@ +use std::fs; + +use anyhow::Error; +use chrono; + +#[allow(dead_code)] +pub enum TestMode { + Katana, + Sepolia, +} + +#[allow(dead_code)] +pub struct Coordinator { + id: String, + mode: TestMode, + source: String, + target: String, +} + +#[allow(dead_code)] +impl Coordinator { + pub fn new(mode: TestMode) -> Self { + let now = chrono::offset::Local::now(); + let id = now.format("%Y%m%y%H%M%S").to_string(); + let target = "./target/account-".to_string() + &id; + Self { + id, + mode, + source: "./tests/starknet/contract/account".to_string(), + target, + } + } + + pub fn copy_template_to_target(&self) -> Result<(), Error> { + fs::create_dir(&self.target)?; + fs::create_dir(self.target_src())?; + fs::copy(self.source_lib(), self.target_lib())?; + fs::copy(self.source_scarb(), self.target_scarb())?; + Ok(()) + } + + pub fn update_account(&self) -> Result<(), Error> { + let account_template = fs::read_to_string(self.target_lib())?; + let account_new = account_template.replace("", &self.id); + fs::write(self.target_lib(), account_new)?; + Ok(()) + } + + pub fn source_lib(&self) -> String { + self.source.clone() + "/src/lib.cairo" + } + + pub fn source_scarb(&self) -> String { + self.source.clone() + "/Scarb.toml" + } + + pub fn target_lib(&self) -> String { + self.target.clone() + "/src/lib.cairo" + } + + pub fn target_scarb(&self) -> String { + self.target.clone() + "/Scarb.toml" + } + + pub fn target_src(&self) -> String { + self.target.clone() + "/src" + } +} + +impl Drop for Coordinator { + fn drop(&mut self) { + match self.mode { + TestMode::Katana => { + let target = self.target.clone(); + if fs::exists(&target).unwrap() { + fs::remove_dir_all(target).unwrap() + } + } + TestMode::Sepolia => {} + } + } +} diff --git a/tests/starknet/executor.rs b/tests/starknet/executor.rs deleted file mode 100644 index 8da68e84..00000000 --- a/tests/starknet/executor.rs +++ /dev/null @@ -1,128 +0,0 @@ -use std::{fs, thread}; - -use anyhow::{anyhow, Error}; -use regex::Regex; - -use super::scarb::Compiler; - -#[allow(dead_code)] -pub struct Executor { - accounts: Vec, -} - -#[allow(dead_code)] -impl Executor { - pub fn new(num: usize) -> Result { - let template = "./tests/starknet/contract/account".to_string(); - let mut accounts = Vec::with_capacity(num); - accounts.push(template); - Ok(Self { accounts }) - } - - pub fn deploy_accounts( - &mut self, - update_template: bool, - ) -> Result<(), Error> { - if update_template { - self.update_account(&self.accounts[0])?; - } - self.prepare_contracts_environment()?; - self.compile()?; - // TODO - // #804 starkli signer keystore new key.json - Storing somewhere or deleting? - // #804 starkli account oz init account.json - Storing somewhere or deleting? - // #804 declare accounts - // #804 #805 fund accounts from pre-funded account - // #804 deploy accounts - // #806 iterate through class hashes and call getClass to see if they are verified - Ok(()) - } - - fn update_account(&self, path: &str) -> Result<(), Error> { - let lib_path = path.to_owned() + "/src/lib.cairo"; - let account_old = fs::read_to_string(lib_path.clone())?; - let re = Regex::new(r"self.id.write\((?\d+)\);")?; - - let Some(val) = re.captures(&account_old) else { - return Err(anyhow!("Could not find pattern in lib.cairo.")); - }; - let num_old = - &val["number"].parse::().expect("Failed to read number"); - let num_new = num_old + 1; - let account_new = account_old.replace( - &format!("self.id.write({num_old})"), - &format!("self.id.write({num_new})"), - ); - fs::write(lib_path, account_new)?; - - Ok(()) - } - - fn prepare_contracts_environment(&mut self) -> Result<(), Error> { - let capacity = self.accounts.capacity(); - let template = self.accounts[0].clone(); - let lib_path = "/src/lib.cairo"; - let toml_path = "/Scarb.toml"; - - for i in 1..capacity { - let account = template.clone() + &i.to_string(); - fs::create_dir(account.clone())?; - fs::create_dir(account.clone() + "/src")?; - fs::copy( - self.accounts[i - 1].clone() + lib_path, - account.clone() + lib_path, - )?; - fs::copy( - template.clone() + toml_path, - account.clone() + toml_path, - )?; - self.update_account(&account)?; - self.accounts.push(account); - } - - Ok(()) - } - - fn compile(&self) -> Result<(), Error> { - let mut vec_of_threads = Vec::with_capacity(self.accounts.len()); - - for account in self.accounts.iter() { - let path = account.clone() + "/Scarb.toml"; - let compilation = thread::spawn(move || -> Result<(), Error> { - let compiler = Compiler::new(&path)?; - compiler.compile() - }); - vec_of_threads.push(compilation); - } - for (i, thread) in vec_of_threads.into_iter().enumerate() { - let compilation = thread.join(); - match compilation { - Ok(val) => val?, - Err(e) => { - return Err(anyhow!("Error during thread {i} execution. Original error message: {:#?}", e)); - } - } - } - - Ok(()) - } -} - -impl Drop for Executor { - fn drop(&mut self) { - let dir = self.accounts[0].clone() + "/target"; - let scarb = self.accounts[0].clone() + "/Scarb.lock"; - if fs::exists(dir.clone()).expect("Failed to check template target") { - fs::remove_dir_all(dir).expect("Failed to remove template target"); - }; - if fs::exists(scarb.clone()).expect("Failed to check template Scarb") { - fs::remove_file(scarb).expect("Failed to remove template Scarb"); - } - for i in 1..self.accounts.len() { - let dir = self.accounts[i].clone(); - if fs::exists(dir.clone()).expect("Failed to check account dir") { - fs::remove_dir_all(dir).expect("Failed to remove account dir"); - } - } - } -} diff --git a/tests/starknet/mod.rs b/tests/starknet/mod.rs index 26d7e2bf..280a6a6d 100644 --- a/tests/starknet/mod.rs +++ b/tests/starknet/mod.rs @@ -1,4 +1,4 @@ pub mod constants; -pub mod executor; +pub mod coordinator; pub mod katana; pub mod scarb; diff --git a/tests/starknet/scarb.rs b/tests/starknet/scarb.rs index cb75e22a..37449ce5 100644 --- a/tests/starknet/scarb.rs +++ b/tests/starknet/scarb.rs @@ -1,4 +1,4 @@ -use anyhow::Error; +use anyhow::{anyhow, Error}; use scarb::{ core::{Config, PackageId, PackageName, SourceId, TargetKind}, ops::{self, CompileOpts, FeaturesOpts, FeaturesSelector}, @@ -35,7 +35,21 @@ impl Compiler { Ok(Compiler { toml: toml_absolute, opts, packages }) } - pub fn compile(self) -> Result<(), Error> { + pub async fn compile(self) -> Result<(), Error> { + let compilation = + tokio::task::spawn_blocking(move || -> Result<(), Error> { + self.run_compilation() + }); + match compilation.await { + Ok(val) => Ok(val?), + Err(e) => Err(anyhow!( + "Error during thread execution. Original error message: {:#?}", + e, + )), + } + } + + fn run_compilation(self) -> Result<(), Error> { let config = Config::builder(self.toml.to_str().unwrap()).build()?; let ws = ops::read_workspace(config.manifest_path(), &config)?; scarb::ops::compile(self.packages, self.opts, &ws) From ba0b9810a69ee5532828f38deb4c2f304d1049e8 Mon Sep 17 00:00:00 2001 From: Ivan Cavlek Date: Thu, 24 Oct 2024 10:56:59 +0200 Subject: [PATCH 3/3] refactor: additional update based on comments --- tests/account_katana.rs | 32 ++------------ tests/rpc.rs | 62 +++++++++++++------------- tests/starknet/coordinator.rs | 82 ----------------------------------- tests/starknet/mod.rs | 2 +- tests/starknet/scarb.rs | 67 +++++++++------------------- tests/starknet/utils.rs | 28 ++++++++++++ 6 files changed, 84 insertions(+), 189 deletions(-) delete mode 100644 tests/starknet/coordinator.rs create mode 100644 tests/starknet/utils.rs diff --git a/tests/account_katana.rs b/tests/account_katana.rs index 5791ac32..b0388067 100644 --- a/tests/account_katana.rs +++ b/tests/account_katana.rs @@ -11,17 +11,11 @@ use beerus::{ TxnHash, }, }; -use common::err::Error; -use starknet::katana::Katana; -use starknet::scarb::Compiler; -use starknet::{ - constants::{ - CLASS_HASH, COMPILED_ACCOUNT_CONTRACT_V2, COMPILED_ACCOUNT_CONTRACT_V3, - CONTRACT_ADDRESS, DECLARE_ACCOUNT_V2, DECLARE_ACCOUNT_V3, - SENDER_ADDRESS, - }, - coordinator::{Coordinator, TestMode}, +use starknet::constants::{ + CLASS_HASH, COMPILED_ACCOUNT_CONTRACT_V2, COMPILED_ACCOUNT_CONTRACT_V3, + CONTRACT_ADDRESS, DECLARE_ACCOUNT_V2, DECLARE_ACCOUNT_V3, SENDER_ADDRESS, }; +use starknet::katana::Katana; mod common; mod starknet; @@ -48,24 +42,6 @@ async fn declare_deploy_account_v2() { deploy(client).await; } -#[tokio::test] -async fn deploy_new_account_on_katana() -> Result<(), Error> { - let _katana = Katana::init("http://127.0.0.1:0").await?; - let coordinator = Coordinator::new(TestMode::Katana); - coordinator.copy_template_to_target()?; - coordinator.update_account()?; - let compiler = Compiler::new(&coordinator.target_scarb())?; - compiler.compile().await?; - // TODO - // #804 starkli signer keystore new key.json - Storing somewhere or deleting? - // #804 starkli account oz init account.json - Storing somewhere or deleting? - // #804 declare accounts - // #804 #805 fund accounts from pre-funded account - // #804 deploy accounts - // #806 iterate through class hashes and call getClass to see if they are verified - Ok(()) -} - async fn declare( client: &Client, compiled_contract: &str, diff --git a/tests/rpc.rs b/tests/rpc.rs index f392af2b..ddb7190f 100644 --- a/tests/rpc.rs +++ b/tests/rpc.rs @@ -1,11 +1,14 @@ -use beerus::gen::{ - Address, BlockHash, BlockId, BlockNumber, BlockTag, BroadcastedInvokeTxn, - BroadcastedTxn, Felt, FunctionCall, GetBlockWithTxHashesResult, - GetBlockWithTxsResult, GetClassAtResult, GetClassResult, - GetTransactionByBlockIdAndIndexIndex, InvokeTxn, InvokeTxnV1, - InvokeTxnV1Version, PriceUnit, Rpc, StorageKey, SyncingResult, Txn, - TxnExecutionStatus, TxnHash, TxnReceipt, TxnReceiptWithBlockInfo, - TxnStatus, +use beerus::{ + config::MAINNET_STARKNET_CHAINID, + gen::{ + Address, BlockHash, BlockId, BlockNumber, BlockTag, + BroadcastedInvokeTxn, BroadcastedTxn, Felt, FunctionCall, + GetBlockWithTxHashesResult, GetBlockWithTxsResult, GetClassAtResult, + GetClassResult, GetTransactionByBlockIdAndIndexIndex, InvokeTxn, + InvokeTxnV1, InvokeTxnV1Version, PriceUnit, Rpc, StorageKey, + SyncingResult, Txn, TxnExecutionStatus, TxnHash, TxnReceipt, + TxnReceiptWithBlockInfo, TxnStatus, + }, }; mod common; @@ -13,6 +16,26 @@ mod starknet; use common::err::Error; +#[tokio::test] +#[allow(non_snake_case)] +async fn test_specVersion() -> Result<(), Error> { + let ctx = setup!(); + + let ret = ctx.client.specVersion().await?; + assert_eq!(ret, "0.7.1"); + Ok(()) +} + +#[tokio::test] +#[allow(non_snake_case)] +async fn test_chainId() -> Result<(), Error> { + let ctx = setup!(); + + let ret = ctx.client.chainId().await?; + assert_eq!(ret.as_ref(), MAINNET_STARKNET_CHAINID); + Ok(()) +} + #[tokio::test] #[allow(non_snake_case)] async fn test_blockHashAndNumber() -> Result<(), Error> { @@ -510,26 +533,3 @@ async fn account_call() -> Result<(), Error> { Ok(()) } - -#[tokio::test] -async fn deploy_new_account_on_sepolia() -> Result<(), Error> { - // TODO #807 - // schedule test once each month in separate workflow - // with each test, template account id is incremented by 1 - // commit from workflows to update latest state of id - - let _ctx = setup!("sepolia"); - // let coordinator = Coordinator::new(TestMode::Sepolia); - // coordinator.copy_template_to_target()?; - // coordinator.update_account()?; - // let compiler = Compiler::new(&coordinator.target_scarb())?; - // compiler.compile().await?; - - // TODO - // #804 starkli signer keystore new key.json - Storing somewhere or deleting? - // #804 starkli account oz init account.json - Storing somewhere or deleting? - // #804 declare account - // #804 #805 fund account from pre-funded account - // #804 deploy account - Ok(()) -} diff --git a/tests/starknet/coordinator.rs b/tests/starknet/coordinator.rs deleted file mode 100644 index 417693fb..00000000 --- a/tests/starknet/coordinator.rs +++ /dev/null @@ -1,82 +0,0 @@ -use std::fs; - -use anyhow::Error; -use chrono; - -#[allow(dead_code)] -pub enum TestMode { - Katana, - Sepolia, -} - -#[allow(dead_code)] -pub struct Coordinator { - id: String, - mode: TestMode, - source: String, - target: String, -} - -#[allow(dead_code)] -impl Coordinator { - pub fn new(mode: TestMode) -> Self { - let now = chrono::offset::Local::now(); - let id = now.format("%Y%m%y%H%M%S").to_string(); - let target = "./target/account-".to_string() + &id; - Self { - id, - mode, - source: "./tests/starknet/contract/account".to_string(), - target, - } - } - - pub fn copy_template_to_target(&self) -> Result<(), Error> { - fs::create_dir(&self.target)?; - fs::create_dir(self.target_src())?; - fs::copy(self.source_lib(), self.target_lib())?; - fs::copy(self.source_scarb(), self.target_scarb())?; - Ok(()) - } - - pub fn update_account(&self) -> Result<(), Error> { - let account_template = fs::read_to_string(self.target_lib())?; - let account_new = account_template.replace("", &self.id); - fs::write(self.target_lib(), account_new)?; - Ok(()) - } - - pub fn source_lib(&self) -> String { - self.source.clone() + "/src/lib.cairo" - } - - pub fn source_scarb(&self) -> String { - self.source.clone() + "/Scarb.toml" - } - - pub fn target_lib(&self) -> String { - self.target.clone() + "/src/lib.cairo" - } - - pub fn target_scarb(&self) -> String { - self.target.clone() + "/Scarb.toml" - } - - pub fn target_src(&self) -> String { - self.target.clone() + "/src" - } -} - -impl Drop for Coordinator { - fn drop(&mut self) { - match self.mode { - TestMode::Katana => { - let target = self.target.clone(); - if fs::exists(&target).unwrap() { - fs::remove_dir_all(target).unwrap() - } - } - TestMode::Sepolia => {} - } - } -} diff --git a/tests/starknet/mod.rs b/tests/starknet/mod.rs index 280a6a6d..4dae99a6 100644 --- a/tests/starknet/mod.rs +++ b/tests/starknet/mod.rs @@ -1,4 +1,4 @@ pub mod constants; -pub mod coordinator; pub mod katana; pub mod scarb; +pub mod utils; diff --git a/tests/starknet/scarb.rs b/tests/starknet/scarb.rs index 37449ce5..d597fb79 100644 --- a/tests/starknet/scarb.rs +++ b/tests/starknet/scarb.rs @@ -1,4 +1,4 @@ -use anyhow::{anyhow, Error}; +use anyhow::Error; use scarb::{ core::{Config, PackageId, PackageName, SourceId, TargetKind}, ops::{self, CompileOpts, FeaturesOpts, FeaturesSelector}, @@ -7,51 +7,24 @@ use semver::Version; use std::{fs::canonicalize, path::PathBuf}; #[allow(dead_code)] -pub struct Compiler { - toml: PathBuf, - opts: CompileOpts, - packages: Vec, -} - -#[allow(dead_code)] -impl Compiler { - pub fn new(toml: &str) -> Result { - let toml_absolute = canonicalize(PathBuf::from(toml))?; - let opts = CompileOpts { - include_target_kinds: vec![], - exclude_target_kinds: vec![TargetKind::new("test")], - include_target_names: vec![], - features: FeaturesOpts { - features: FeaturesSelector::Features(vec![]), - no_default_features: false, - }, - }; - let packages = vec![PackageId::new( - PackageName::new("account"), - Version::new(0, 1, 0), - SourceId::for_path(toml_absolute.to_str().unwrap().into())?, - )]; - - Ok(Compiler { toml: toml_absolute, opts, packages }) - } - - pub async fn compile(self) -> Result<(), Error> { - let compilation = - tokio::task::spawn_blocking(move || -> Result<(), Error> { - self.run_compilation() - }); - match compilation.await { - Ok(val) => Ok(val?), - Err(e) => Err(anyhow!( - "Error during thread execution. Original error message: {:#?}", - e, - )), - } - } +pub fn compile(toml: String) -> Result<(), Error> { + let toml_absolute = canonicalize(PathBuf::from(toml))?; + let opts = CompileOpts { + include_target_kinds: vec![], + exclude_target_kinds: vec![TargetKind::new("test")], + include_target_names: vec![], + features: FeaturesOpts { + features: FeaturesSelector::Features(vec![]), + no_default_features: false, + }, + }; + let packages = vec![PackageId::new( + PackageName::new("account"), + Version::new(0, 1, 0), + SourceId::for_path(toml_absolute.to_str().unwrap().into())?, + )]; + let config = Config::builder(toml_absolute.to_str().unwrap()).build()?; + let ws = ops::read_workspace(config.manifest_path(), &config)?; - fn run_compilation(self) -> Result<(), Error> { - let config = Config::builder(self.toml.to_str().unwrap()).build()?; - let ws = ops::read_workspace(config.manifest_path(), &config)?; - scarb::ops::compile(self.packages, self.opts, &ws) - } + scarb::ops::compile(packages, opts, &ws) } diff --git a/tests/starknet/utils.rs b/tests/starknet/utils.rs new file mode 100644 index 00000000..d3fac708 --- /dev/null +++ b/tests/starknet/utils.rs @@ -0,0 +1,28 @@ +use std::fs; + +use anyhow::Error; +use chrono; + +const SOURCE_LIB: &str = "./tests/starknet/contract/account/src/lib.cairo"; +const SOURCE_SCARB: &str = "./tests/starknet/contract/account/Scarb.toml"; + +#[allow(dead_code)] +pub fn prepare_account() -> Result { + let now = chrono::offset::Local::now(); + let id = now.format("%Y%m%y%H%M%S").to_string(); + let target = "./target/account-".to_string() + &id; + let target_lib = target.clone() + "/src/lib.cairo"; + let target_scarb = target.clone() + "/Scarb.toml"; + let target_src = target.clone() + "/src"; + + fs::create_dir(target)?; + fs::create_dir(target_src)?; + fs::copy(SOURCE_LIB, target_lib.clone())?; + fs::copy(SOURCE_SCARB, target_scarb.clone())?; + + let account_template = fs::read_to_string(target_lib.clone())?; + let account_new = account_template.replace("", &id); + fs::write(target_lib, account_new)?; + + Ok(target_scarb) +}