From b8312ab4a40ba1a151430fec1f6127ee1580d322 Mon Sep 17 00:00:00 2001 From: damirka Date: Wed, 21 Apr 2021 13:01:11 +0300 Subject: [PATCH 01/14] adds integration tests to Leo CLI - leo tests are now written as cli commands - leo libraries and binaries removed from package and cli - small code optimizations and removals --- Cargo.lock | 724 ++++++++++++++++++++- Cargo.toml | 6 + examples/silly-sudoku/inputs/test_input.in | 14 + leo/commands/build.rs | 200 +++--- leo/commands/init.rs | 4 +- leo/commands/new.rs | 2 +- leo/commands/setup.rs | 3 +- leo/commands/watch.rs | 9 +- leo/tests/cmd.rs | 122 ++++ leo/tests/mod.rs | 3 +- package/src/lib.rs | 9 +- package/src/package.rs | 112 ++-- package/src/source/library.rs | 76 --- package/src/source/mod.rs | 3 - package/tests/initialize/initialize.rs | 72 +- 15 files changed, 1020 insertions(+), 339 deletions(-) create mode 100644 examples/silly-sudoku/inputs/test_input.in create mode 100644 leo/tests/cmd.rs delete mode 100644 package/src/source/library.rs diff --git a/Cargo.lock b/Cargo.lock index a5661976ca..f32906f20a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -87,6 +87,140 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" +[[package]] +name = "assert_cmd" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2475b58cd94eb4f70159f4fd8844ba3b807532fe3131b3373fae060bbe30396" +dependencies = [ + "bstr", + "doc-comment", + "predicates", + "predicates-core", + "predicates-tree", + "wait-timeout", +] + +[[package]] +name = "async-channel" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2114d64672151c0c5eaa5e131ec84a74f06e1e559830dabba01ca30605d66319" +dependencies = [ + "concurrent-queue", + "event-listener", + "futures-core", +] + +[[package]] +name = "async-executor" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb877970c7b440ead138f6321a3b5395d6061183af779340b65e20c0fede9146" +dependencies = [ + "async-task 4.0.3", + "concurrent-queue", + "fastrand", + "futures-lite 1.11.3", + "once_cell", + "vec-arena", +] + +[[package]] +name = "async-fs" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b3ca4f8ff117c37c278a2f7415ce9be55560b846b5bc4412aaa5d29c1c3dae2" +dependencies = [ + "async-lock", + "blocking 1.0.2", + "futures-lite 1.11.3", +] + +[[package]] +name = "async-io" +version = "1.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5bfd63f6fc8fd2925473a147d3f4d252c712291efdde0d7057b25146563402c" +dependencies = [ + "concurrent-queue", + "fastrand", + "futures-lite 1.11.3", + "log", + "nb-connect", + "once_cell", + "parking 2.0.0", + "polling", + "vec-arena", + "waker-fn", +] + +[[package]] +name = "async-lock" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6a8ea61bf9947a1007c5cada31e647dbc77b103c679858150003ba697ea798b" +dependencies = [ + "event-listener", +] + +[[package]] +name = "async-net" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06de475c85affe184648202401d7622afb32f0f74e02192857d0201a16defbe5" +dependencies = [ + "async-io", + "blocking 1.0.2", + "fastrand", + "futures-lite 1.11.3", +] + +[[package]] +name = "async-process" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef37b86e2fa961bae5a4d212708ea0154f904ce31d1a4a7f47e1bbc33a0c040b" +dependencies = [ + "async-io", + "blocking 1.0.2", + "cfg-if 1.0.0", + "event-listener", + "futures-lite 1.11.3", + "once_cell", + "signal-hook", + "winapi 0.3.9", +] + +[[package]] +name = "async-task" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c17772156ef2829aadc587461c7753af20b7e8db1529bc66855add962a3b35d3" + +[[package]] +name = "async-task" +version = "4.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e91831deabf0d6d7ec49552e489aed63b7456a7a3c46cff62adad428110b0af0" + +[[package]] +name = "async-trait" +version = "0.1.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b98e84bbb4cbcdd97da190ba0c58a1bb0de2c1fdf67d159e192ed766aeca722" +dependencies = [ + "proc-macro2 1.0.24", + "quote 1.0.9", + "syn 1.0.64", +] + +[[package]] +name = "atomic-waker" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "065374052e7df7ee4047b1160cca5e1467a12351a40b3da123c870ba0b8eda2a" + [[package]] name = "atty" version = "0.2.14" @@ -239,6 +373,34 @@ dependencies = [ "byte-tools", ] +[[package]] +name = "blocking" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2468ff7bf85066b4a3678fede6fe66db31846d753ff0adfbfab2c6a6e81612b" +dependencies = [ + "async-channel", + "atomic-waker", + "futures-lite 0.1.11", + "once_cell", + "parking 1.0.6", + "waker-fn", +] + +[[package]] +name = "blocking" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5e170dbede1f740736619b776d7251cb1b9095c435c34d8ca9f57fcd2f335e9" +dependencies = [ + "async-channel", + "async-task 4.0.3", + "atomic-waker", + "fastrand", + "futures-lite 1.11.3", + "once_cell", +] + [[package]] name = "bstr" version = "0.2.15" @@ -296,6 +458,12 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "cache-padded" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "631ae5198c9be5e753e5cc215e1bd73c2b466a3565173db433f52bb9d3e66dba" + [[package]] name = "cast" version = "0.2.3" @@ -395,6 +563,15 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "concurrent-queue" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30ed07550be01594c6026cff2a1d7fe9c8f683caa798e12b68694ac9e88286a3" +dependencies = [ + "cache-padded", +] + [[package]] name = "console" version = "0.14.1" @@ -571,7 +748,7 @@ dependencies = [ "openssl-probe", "openssl-sys", "schannel", - "socket2", + "socket2 0.3.19", "winapi 0.3.9", ] @@ -590,6 +767,26 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "darwin-libproc" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb90051930c9a0f09e585762152048e23ac74d20c10590ef7cf01c0343c3046" +dependencies = [ + "darwin-libproc-sys", + "libc", + "memchr", +] + +[[package]] +name = "darwin-libproc-sys" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57cebb5bde66eecdd30ddc4b9cd208238b15db4982ccc72db59d699ea10867c1" +dependencies = [ + "libc", +] + [[package]] name = "derivative" version = "2.2.0" @@ -601,6 +798,12 @@ dependencies = [ "syn 1.0.64", ] +[[package]] +name = "difference" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" + [[package]] name = "digest" version = "0.8.1" @@ -639,6 +842,12 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "doc-comment" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" + [[package]] name = "dtoa" version = "0.4.8" @@ -689,6 +898,12 @@ dependencies = [ "indexmap", ] +[[package]] +name = "event-listener" +version = "2.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7531096570974c3a9dcf9e4b8e1cede1ec26cf5046219fb3b9d897503b9be59" + [[package]] name = "failure" version = "0.1.8" @@ -717,6 +932,15 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" +[[package]] +name = "fastrand" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca5faf057445ce5c9d4329e382b2ce7ca38550ef3b73a5348362d5f24e0c7fe3" +dependencies = [ + "instant", +] + [[package]] name = "filetime" version = "0.2.14" @@ -839,6 +1063,20 @@ dependencies = [ "new_debug_unreachable", ] +[[package]] +name = "futures" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f55667319111d593ba876406af7c409c0ebb44dc4be6132a783ccf163ea14c1" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + [[package]] name = "futures-channel" version = "0.3.13" @@ -846,6 +1084,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c2dd2df839b57db9ab69c2c9d8f3e8c81984781937fe2807dc6dcf3b2ad2939" dependencies = [ "futures-core", + "futures-sink", ] [[package]] @@ -860,6 +1099,36 @@ version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d71c2c65c57704c32f5241c1223167c2c3294fd34ac020c807ddbe6db287ba59" +[[package]] +name = "futures-lite" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97999970129b808f0ccba93211201d431fcc12d7e1ffae03a61b5cedd1a7ced2" +dependencies = [ + "fastrand", + "futures-core", + "futures-io", + "memchr", + "parking 2.0.0", + "pin-project-lite 0.1.12", + "waker-fn", +] + +[[package]] +name = "futures-lite" +version = "1.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4481d0cd0de1d204a4fa55e7d45f07b1d958abcb06714b3446438e2eff695fb" +dependencies = [ + "fastrand", + "futures-core", + "futures-io", + "memchr", + "parking 2.0.0", + "pin-project-lite 0.2.4", + "waker-fn", +] + [[package]] name = "futures-sink" version = "0.3.13" @@ -872,17 +1141,25 @@ version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa189ef211c15ee602667a6fcfe1c1fd9e07d42250d2156382820fba33c9df80" +[[package]] +name = "futures-timer" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" + [[package]] name = "futures-util" version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1812c7ab8aedf8d6f2701a43e1243acdbcc2b36ab26e2ad421eb99ac963d96d1" dependencies = [ + "futures-channel", "futures-core", "futures-io", + "futures-sink", "futures-task", "memchr", - "pin-project-lite", + "pin-project-lite 0.2.4", "pin-utils", "slab", ] @@ -999,6 +1276,125 @@ dependencies = [ "unicode-segmentation", ] +[[package]] +name = "heim" +version = "0.1.0-beta.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1014732324a9baf5a691525faabb33909bf6f40dcc2b03c8f2fb07bb01e7e3f" +dependencies = [ + "heim-common", + "heim-process", + "heim-runtime", +] + +[[package]] +name = "heim-common" +version = "0.1.0-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d767e6e47cf88abe7c9a5ebb4df82f180d30d9c0ba0269b6d166482461765834" +dependencies = [ + "cfg-if 1.0.0", + "core-foundation", + "futures-core", + "futures-util", + "lazy_static", + "libc", + "mach", + "nix 0.19.1", + "pin-utils", + "uom", + "winapi 0.3.9", +] + +[[package]] +name = "heim-cpu" +version = "0.1.0-beta.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73b1442359831aa671aa931f0a084aab210e77b1330ded78f1e60cc305abc4bb" +dependencies = [ + "cfg-if 0.1.10", + "futures", + "glob", + "heim-common", + "heim-runtime", + "lazy_static", + "libc", + "mach", + "ntapi", + "smol 0.1.18", + "winapi 0.3.9", +] + +[[package]] +name = "heim-host" +version = "0.1.0-beta.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79cce3ce658bd45e510ff0a2fb5c668cbe1a7368929fd1db123741c99fd6902e" +dependencies = [ + "cfg-if 0.1.10", + "heim-common", + "heim-runtime", + "lazy_static", + "libc", + "log", + "mach", + "ntapi", + "platforms", + "winapi 0.3.9", +] + +[[package]] +name = "heim-net" +version = "0.1.0-beta.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59da1108e732afcda77e1429b5d0ce648b9a31d1f8cf385108b83bea4cf91342" +dependencies = [ + "bitflags", + "cfg-if 0.1.10", + "heim-common", + "heim-runtime", + "libc", + "macaddr", + "nix 0.17.0", +] + +[[package]] +name = "heim-process" +version = "0.1.1-beta.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd969deb2a89a488b6a9bf18a65923ae4cdef6b128fa2dedb74ef5c694deb5ae" +dependencies = [ + "async-trait", + "cfg-if 0.1.10", + "darwin-libproc", + "futures", + "heim-common", + "heim-cpu", + "heim-host", + "heim-net", + "heim-runtime", + "lazy_static", + "libc", + "mach", + "memchr", + "ntapi", + "ordered-float", + "smol 0.1.18", + "winapi 0.3.9", +] + +[[package]] +name = "heim-runtime" +version = "0.1.0-beta.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "906dd26ed2eb6b9f5f0dc3dfc04caeb82785ccc05a3b3326e4c841613451acc7" +dependencies = [ + "futures", + "futures-timer", + "smol 0.1.18", + "version-sync", +] + [[package]] name = "hermit-abi" version = "0.1.18" @@ -1073,7 +1469,7 @@ dependencies = [ "httpdate", "itoa", "pin-project", - "socket2", + "socket2 0.3.19", "tokio", "tower-service", "tracing", @@ -1354,6 +1750,7 @@ version = "1.4.0" dependencies = [ "ansi_term 0.12.1", "anyhow", + "assert_cmd", "clap", "colored", "console", @@ -1381,6 +1778,7 @@ dependencies = [ "snarkvm-r1cs", "snarkvm-utilities", "structopt", + "testdir", "thiserror", "toml", "tracing", @@ -1535,6 +1933,21 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4" +[[package]] +name = "macaddr" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baee0bbc17ce759db233beb01648088061bf678383130602a298e6998eedb2d8" + +[[package]] +name = "mach" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" +dependencies = [ + "libc", +] + [[package]] name = "maplit" version = "1.0.2" @@ -1668,7 +2081,7 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a33c1b55807fbed163481b5ba66db4b2fa6cde694a5027be10fb724206c5897" dependencies = [ - "socket2", + "socket2 0.3.19", "winapi 0.3.9", ] @@ -1690,6 +2103,16 @@ dependencies = [ "tempfile", ] +[[package]] +name = "nb-connect" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a19900e7eee95eb2b3c2e26d12a874cc80aaf750e31be6fcbe743ead369fa45d" +dependencies = [ + "libc", + "socket2 0.4.0", +] + [[package]] name = "net2" version = "0.2.37" @@ -1713,6 +2136,31 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab250442c86f1850815b5d268639dff018c0627022bc1940eb2d642ca1ce12f0" +[[package]] +name = "nix" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50e4785f2c3b7589a0d0c1dd60285e1188adac4006e8abd6dd578e1567027363" +dependencies = [ + "bitflags", + "cc", + "cfg-if 0.1.10", + "libc", + "void", +] + +[[package]] +name = "nix" +version = "0.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2ccba0cfe4fdf15982d1674c69b1fd80bad427d293849982668dfe454bd61f2" +dependencies = [ + "bitflags", + "cc", + "cfg-if 1.0.0", + "libc", +] + [[package]] name = "nom" version = "5.1.2" @@ -1784,6 +2232,17 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-rational" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12ac428b1cb17fce6f731001d307d351ec70a6d202fc2e60f7d4c5e42d8f4f07" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.14" @@ -1872,6 +2331,27 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "ordered-float" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18869315e81473c951eb56ad5558bbc56978562d3ecfb87abb7a1e944cea4518" +dependencies = [ + "num-traits", +] + +[[package]] +name = "parking" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6cb300f271742d4a2a66c01b6b2fa0c83dfebd2e0bf11addb879a3547b4ed87c" + +[[package]] +name = "parking" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" + [[package]] name = "parking_lot" version = "0.11.1" @@ -1985,6 +2465,12 @@ dependencies = [ "syn 1.0.64", ] +[[package]] +name = "pin-project-lite" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777" + [[package]] name = "pin-project-lite" version = "0.2.4" @@ -2003,6 +2489,12 @@ version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" +[[package]] +name = "platforms" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "feb3b2b1033b8a60b4da6ee470325f887758c95d5320f52f9ce0df055a55940e" + [[package]] name = "plotters" version = "0.3.0" @@ -2031,12 +2523,51 @@ dependencies = [ "plotters-backend", ] +[[package]] +name = "polling" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0720e0b9ea9d52451cf29d3413ba8a9303f8815d9d9653ef70e03ff73e65566" +dependencies = [ + "cfg-if 0.1.10", + "libc", + "log", + "wepoll-sys-stjepang", + "winapi 0.3.9", +] + [[package]] name = "ppv-lite86" version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" +[[package]] +name = "predicates" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eeb433456c1a57cc93554dea3ce40b4c19c4057e41c55d4a0f3d84ea71c325aa" +dependencies = [ + "difference", + "predicates-core", +] + +[[package]] +name = "predicates-core" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57e35a3326b75e49aa85f5dc6ec15b41108cf5aee58eabb1f274dd18b73c2451" + +[[package]] +name = "predicates-tree" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15f553275e5721409451eb85e15fd9a860a6e5ab4496eb215987502b5f5391f2" +dependencies = [ + "predicates-core", + "treeline", +] + [[package]] name = "proc-macro-crate" version = "0.1.5" @@ -2088,6 +2619,17 @@ dependencies = [ "unicode-xid 0.2.1", ] +[[package]] +name = "pulldown-cmark" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffade02495f22453cd593159ea2f59827aae7f53fa8323f756799b670881dcf8" +dependencies = [ + "bitflags", + "memchr", + "unicase", +] + [[package]] name = "quick-error" version = "1.2.3" @@ -2286,7 +2828,7 @@ dependencies = [ "mime_guess", "native-tls", "percent-encoding", - "pin-project-lite", + "pin-project-lite 0.2.4", "serde", "serde_json", "serde_urlencoded", @@ -2388,6 +2930,12 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "scoped-tls" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" + [[package]] name = "scopeguard" version = "1.1.0" @@ -2459,6 +3007,12 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" +[[package]] +name = "semver-parser" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b46e1121e8180c12ff69a742aabc4f310542b6ccb69f1691689ac17fdf8618aa" + [[package]] name = "semver-parser" version = "0.10.2" @@ -2573,6 +3127,25 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2" +[[package]] +name = "signal-hook" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef33d6d0cd06e0840fba9985aab098c147e67e05cee14d412d3345ed14ff30ac" +dependencies = [ + "libc", + "signal-hook-registry", +] + +[[package]] +name = "signal-hook-registry" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16f1d0fef1604ba8f7a073c7e701f213e056707210e9020af4528e0101ce11a6" +dependencies = [ + "libc", +] + [[package]] name = "single" version = "1.0.0" @@ -2594,6 +3167,45 @@ version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" +[[package]] +name = "smol" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "620cbb3c6e34da57d3a248cda0cd01cd5848164dc062e764e65d06fe3ea7aed5" +dependencies = [ + "async-task 3.0.0", + "blocking 0.4.7", + "concurrent-queue", + "fastrand", + "futures-io", + "futures-util", + "libc", + "once_cell", + "scoped-tls", + "slab", + "socket2 0.3.19", + "wepoll-sys-stjepang", + "winapi 0.3.9", +] + +[[package]] +name = "smol" +version = "1.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85cf3b5351f3e783c1d79ab5fc604eeed8b8ae9abd36b166e8b87a089efd85e4" +dependencies = [ + "async-channel", + "async-executor", + "async-fs", + "async-io", + "async-lock", + "async-net", + "async-process", + "blocking 1.0.2", + "futures-lite 1.11.3", + "once_cell", +] + [[package]] name = "snarkvm-algorithms" version = "0.2.2" @@ -2803,6 +3415,16 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "socket2" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e3dfc207c526015c632472a77be09cf1b6e46866581aecae5cc38fb4235dea2" +dependencies = [ + "libc", + "winapi 0.3.9", +] + [[package]] name = "static_assertions" version = "1.1.0" @@ -2929,6 +3551,20 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "testdir" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c13a556e110c7d373db3c12464a80e4d24ed25942381242b17aad43aee98085" +dependencies = [ + "anyhow", + "backtrace", + "heim", + "once_cell", + "smol 1.2.5", + "whoami", +] + [[package]] name = "textwrap" version = "0.11.0" @@ -3014,7 +3650,7 @@ dependencies = [ "memchr", "mio 0.7.10", "num_cpus", - "pin-project-lite", + "pin-project-lite 0.2.4", ] [[package]] @@ -3037,7 +3673,7 @@ dependencies = [ "futures-core", "futures-sink", "log", - "pin-project-lite", + "pin-project-lite 0.2.4", "tokio", ] @@ -3063,7 +3699,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "01ebdc2bb4498ab1ab5f5b73c5803825e60199229ccba0698170e3be0e7f959f" dependencies = [ "cfg-if 1.0.0", - "pin-project-lite", + "pin-project-lite 0.2.4", "tracing-attributes", "tracing-core", ] @@ -3141,6 +3777,12 @@ dependencies = [ "tracing-serde", ] +[[package]] +name = "treeline" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7f741b240f1a48843f9b8e0444fb55fb2a4ff67293b50a9179dfd5ea67f8d41" + [[package]] name = "try-lock" version = "0.2.3" @@ -3216,6 +3858,17 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" +[[package]] +name = "uom" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e76503e636584f1e10b9b3b9498538279561adcef5412927ba00c2b32c4ce5ed" +dependencies = [ + "num-rational", + "num-traits", + "typenum", +] + [[package]] name = "url" version = "2.2.1" @@ -3240,12 +3893,33 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b00bca6106a5e23f3eee943593759b7fcddb00554332e856d990c893966879fb" +[[package]] +name = "vec-arena" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34b2f665b594b07095e3ac3f718e13c2197143416fae4c5706cffb7b1af8d7f1" + [[package]] name = "vec_map" version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" +[[package]] +name = "version-sync" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cb94ca10ca0cf44f5d926ac977f0cac2d13e9789aa4bbe9d9388de445e61028" +dependencies = [ + "proc-macro2 1.0.24", + "pulldown-cmark", + "regex", + "semver-parser 0.9.0", + "syn 1.0.64", + "toml", + "url", +] + [[package]] name = "version_check" version = "0.9.2" @@ -3258,6 +3932,21 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" +[[package]] +name = "wait-timeout" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" +dependencies = [ + "libc", +] + +[[package]] +name = "waker-fn" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" + [[package]] name = "walkdir" version = "2.3.2" @@ -3369,6 +4058,15 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "wepoll-sys-stjepang" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fdfbb03f290ca0b27922e8d48a0997b4ceea12df33269b9f75e713311eb178d" +dependencies = [ + "cc", +] + [[package]] name = "which" version = "3.1.1" @@ -3378,6 +4076,16 @@ dependencies = [ "libc", ] +[[package]] +name = "whoami" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4abacf325c958dfeaf1046931d37f2a901b6dfe0968ee965a29e94c6766b2af6" +dependencies = [ + "wasm-bindgen", + "web-sys", +] + [[package]] name = "winapi" version = "0.2.8" diff --git a/Cargo.toml b/Cargo.toml index dc9bfb5f6f..2aca1ffe77 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -156,6 +156,12 @@ version = "0.12.1" [dev-dependencies.rusty-hook] version = "0.11.2" +[dev-dependencies.assert_cmd] +version = "1.0.3" + +[dev-dependencies.testdir] +version = "0.4.0" + [features] default = [ ] ci_skip = [ "leo-compiler/ci_skip" ] diff --git a/examples/silly-sudoku/inputs/test_input.in b/examples/silly-sudoku/inputs/test_input.in new file mode 100644 index 0000000000..36f8362978 --- /dev/null +++ b/examples/silly-sudoku/inputs/test_input.in @@ -0,0 +1,14 @@ +// The program input for tmp-test/src/main.leo +[main] +puzzle: [u8; (3, 3)] = [[1, 0, 5], + [0, 2, 0], + [7, 0, 0]]; + +answer: [u8; (3, 3)] = [[1, 4, 5], + [3, 2, 6], + [7, 8, 9]]; + +expected: bool = true; + +[registers] +r: bool = false; diff --git a/leo/commands/build.rs b/leo/commands/build.rs index 392859e238..dba9414016 100644 --- a/leo/commands/build.rs +++ b/leo/commands/build.rs @@ -22,11 +22,11 @@ use leo_compiler::{ use leo_package::{ inputs::*, outputs::{ChecksumFile, CircuitFile, OutputsDirectory, OUTPUTS_DIRECTORY_NAME}, - source::{LibraryFile, MainFile, LIBRARY_FILENAME, MAIN_FILENAME, SOURCE_DIRECTORY_NAME}, + source::{MainFile, MAIN_FILENAME, SOURCE_DIRECTORY_NAME}, }; use leo_synthesizer::{CircuitSynthesizer, SerializedCircuit}; -use anyhow::Result; +use anyhow::{anyhow, Result}; use snarkvm_curves::{bls12_377::Bls12_377, edwards_bls12::Fq}; use snarkvm_r1cs::ConstraintSystem; use structopt::StructOpt; @@ -39,7 +39,7 @@ pub struct Build {} impl Command for Build { type Input = (); - type Output = Option<(Compiler<'static, Fq, EdwardsGroupType>, bool)>; + type Output = (Compiler<'static, Fq, EdwardsGroupType>, bool); fn log_span(&self) -> Span { tracing::span!(tracing::Level::INFO, "Build") @@ -65,115 +65,95 @@ impl Command for Build { tracing::info!("Starting..."); - // Compile the package starting with the lib.leo file - if LibraryFile::exists_at(&package_path) { - // Construct the path to the library file in the source directory - let mut lib_file_path = package_path.clone(); - lib_file_path.push(SOURCE_DIRECTORY_NAME); - lib_file_path.push(LIBRARY_FILENAME); - - // Log compilation of library file to console - tracing::info!("Compiling library... ({:?})", lib_file_path); - - // Compile the library file but do not output - let _program = Compiler::::parse_program_without_input( - package_name.clone(), - lib_file_path, - output_directory.clone(), - thread_leaked_context(), - )?; - tracing::info!("Complete"); - }; - // Compile the main.leo file along with constraints - if MainFile::exists_at(&package_path) { - // Create the output directory - OutputsDirectory::create(&package_path)?; - - // Construct the path to the main file in the source directory - let mut main_file_path = package_path.clone(); - main_file_path.push(SOURCE_DIRECTORY_NAME); - main_file_path.push(MAIN_FILENAME); - - // Load the input file at `package_name.in` - let (input_string, input_path) = InputFile::new(&package_name).read_from(&path)?; - - // Load the state file at `package_name.in` - let (state_string, state_path) = StateFile::new(&package_name).read_from(&path)?; - - // Log compilation of files to console - tracing::info!("Compiling main program... ({:?})", main_file_path); - - // Load the program at `main_file_path` - let program = Compiler::::parse_program_with_input( - package_name.clone(), - main_file_path, - output_directory, - &input_string, - &input_path, - &state_string, - &state_path, - thread_leaked_context(), - )?; - - // Compute the current program checksum - let program_checksum = program.checksum()?; - - // Generate the program on the constraint system and verify correctness - { - let mut cs = CircuitSynthesizer:: { - constraints: Default::default(), - public_variables: Default::default(), - private_variables: Default::default(), - namespaces: Default::default(), - }; - let temporary_program = program.clone(); - let output = temporary_program.compile_constraints(&mut cs)?; - - tracing::debug!("Compiled output - {:#?}", output); - tracing::info!("Number of constraints - {:#?}", cs.num_constraints()); - - // Serialize the circuit - let circuit_object = SerializedCircuit::from(cs); - let json = circuit_object.to_json_string().unwrap(); - // println!("json: {}", json); - - // Write serialized circuit to circuit `.json` file. - let circuit_file = CircuitFile::new(&package_name); - circuit_file.write_to(&path, json)?; - - // Check that we can read the serialized circuit file - // let serialized = circuit_file.read_from(&package_path)?; - - // Deserialize the circuit - // let deserialized = SerializedCircuit::from_json_string(&serialized).unwrap(); - // let _circuit_synthesizer = CircuitSynthesizer::::try_from(deserialized).unwrap(); - // println!("deserialized {:?}", circuit_synthesizer.num_constraints()); - } - - // If a checksum file exists, check if it differs from the new checksum - let checksum_file = ChecksumFile::new(&package_name); - let checksum_differs = if checksum_file.exists_at(&package_path) { - let previous_checksum = checksum_file.read_from(&package_path)?; - program_checksum != previous_checksum - } else { - // By default, the checksum differs if there is no checksum to compare against - true - }; - - // If checksum differs, compile the program - if checksum_differs { - // Write the new checksum to the output directory - checksum_file.write_to(&path, program_checksum)?; - - tracing::debug!("Checksum saved ({:?})", path); - } - - tracing::info!("Complete"); - - return Ok(Some((program, checksum_differs))); + if !MainFile::exists_at(&package_path) { + return Err(anyhow!("File main.leo not found in src/ directory")); } - Ok(None) + // Create the output directory + OutputsDirectory::create(&package_path)?; + + // Construct the path to the main file in the source directory + let mut main_file_path = package_path.clone(); + main_file_path.push(SOURCE_DIRECTORY_NAME); + main_file_path.push(MAIN_FILENAME); + + // Load the input file at `package_name.in` + let (input_string, input_path) = InputFile::new(&package_name).read_from(&path)?; + + // Load the state file at `package_name.in` + let (state_string, state_path) = StateFile::new(&package_name).read_from(&path)?; + + // Log compilation of files to console + tracing::info!("Compiling main program... ({:?})", main_file_path); + + // Load the program at `main_file_path` + let program = Compiler::::parse_program_with_input( + package_name.clone(), + main_file_path, + output_directory, + &input_string, + &input_path, + &state_string, + &state_path, + thread_leaked_context(), + )?; + + // Compute the current program checksum + let program_checksum = program.checksum()?; + + // Generate the program on the constraint system and verify correctness + { + let mut cs = CircuitSynthesizer:: { + constraints: Default::default(), + public_variables: Default::default(), + private_variables: Default::default(), + namespaces: Default::default(), + }; + let temporary_program = program.clone(); + let output = temporary_program.compile_constraints(&mut cs)?; + + tracing::debug!("Compiled output - {:#?}", output); + tracing::info!("Number of constraints - {:#?}", cs.num_constraints()); + + // Serialize the circuit + let circuit_object = SerializedCircuit::from(cs); + let json = circuit_object.to_json_string().unwrap(); + // println!("json: {}", json); + + // Write serialized circuit to circuit `.json` file. + let circuit_file = CircuitFile::new(&package_name); + circuit_file.write_to(&path, json)?; + + // Check that we can read the serialized circuit file + // let serialized = circuit_file.read_from(&package_path)?; + + // Deserialize the circuit + // let deserialized = SerializedCircuit::from_json_string(&serialized).unwrap(); + // let _circuit_synthesizer = CircuitSynthesizer::::try_from(deserialized).unwrap(); + // println!("deserialized {:?}", circuit_synthesizer.num_constraints()); + } + + // If a checksum file exists, check if it differs from the new checksum + let checksum_file = ChecksumFile::new(&package_name); + let checksum_differs = if checksum_file.exists_at(&package_path) { + let previous_checksum = checksum_file.read_from(&package_path)?; + program_checksum != previous_checksum + } else { + // By default, the checksum differs if there is no checksum to compare against + true + }; + + // If checksum differs, compile the program + if checksum_differs { + // Write the new checksum to the output directory + checksum_file.write_to(&path, program_checksum)?; + + tracing::debug!("Checksum saved ({:?})", path); + } + + tracing::info!("Complete"); + + Ok((program, checksum_differs)) } } diff --git a/leo/commands/init.rs b/leo/commands/init.rs index 98b63a755c..2896f84630 100644 --- a/leo/commands/init.rs +++ b/leo/commands/init.rs @@ -55,12 +55,12 @@ impl Command for Init { .to_string_lossy() .to_string(); if !LeoPackage::is_package_name_valid(&package_name) { - return Err(anyhow!("Invalid Leo project name")); + return Err(anyhow!("Invalid Leo project name: {}", package_name)); } let username = read_username().ok(); - LeoPackage::initialize(&package_name, false, &path, username)?; + LeoPackage::initialize(&package_name, &path, username)?; Ok(()) } diff --git a/leo/commands/new.rs b/leo/commands/new.rs index df9a92e376..fe4096d062 100644 --- a/leo/commands/new.rs +++ b/leo/commands/new.rs @@ -63,7 +63,7 @@ impl Command for New { // Create the package directory fs::create_dir_all(&path).map_err(|err| anyhow!("Could not create directory {}", err))?; - LeoPackage::initialize(&package_name, false, &path, username)?; + LeoPackage::initialize(&package_name, &path, username)?; Ok(()) } diff --git a/leo/commands/setup.rs b/leo/commands/setup.rs index 2553129f7d..5a474c9867 100644 --- a/leo/commands/setup.rs +++ b/leo/commands/setup.rs @@ -58,8 +58,7 @@ impl Command for Setup { let package_name = context.manifest()?.get_package_name(); // Check if leo build failed - let (program, checksum_differs) = - input.ok_or_else(|| anyhow!("Unable to build, check that main file exists"))?; + let (program, checksum_differs) = input; // Check if a proving key and verification key already exists let keys_exist = ProvingKeyFile::new(&package_name).exists_at(&path) diff --git a/leo/commands/watch.rs b/leo/commands/watch.rs index 77e9e5f304..5127433272 100644 --- a/leo/commands/watch.rs +++ b/leo/commands/watch.rs @@ -65,13 +65,8 @@ impl Command for Watch { // See changes on the write event Ok(DebouncedEvent::Write(_write)) => { match (Build {}).execute(context.clone()) { - Ok(_output) => { - tracing::info!("Built successfully"); - } - Err(e) => { - // Syntax error - tracing::error!("Error {:?}", e); - } + Ok(_output) => tracing::info!("Built successfully"), + Err(e) => tracing::error!("Error {:?}", e), }; } // Other events diff --git a/leo/tests/cmd.rs b/leo/tests/cmd.rs new file mode 100644 index 0000000000..d11aa8864f --- /dev/null +++ b/leo/tests/cmd.rs @@ -0,0 +1,122 @@ +// Copyright (C) 2019-2021 Aleo Systems Inc. +// This file is part of the Leo library. + +// The Leo library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Leo library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the Leo library. If not, see . + +use assert_cmd::Command; +use std::path::PathBuf; +use testdir::testdir; + +/// Create Command from given arguments and CWD. +fn command(args: &str, cwd: Option) -> Command { + let args = args.split(" ").collect::>(); + let mut cmd = Command::cargo_bin("leo").unwrap(); + + if let Some(cwd) = cwd { + cmd.current_dir(cwd); + } + + cmd.args(args); + cmd +} + +fn expect_success(args: &str, cwd: Option) { + command(args, cwd).unwrap(); +} + +fn expect_fail(args: &str, cwd: Option) { + command(args, cwd).unwrap_err(); +} + +#[test] +fn test_global_options() { + expect_success("--path examples/pedersen-hash build", None); + expect_success("--path examples/pedersen-hash -q build", None); + expect_success("--path examples/pedersen-hash -d build", None); + + expect_fail("--path examples/no-directory-there build", None); + expect_fail("-v build", None); // no such option +} + +#[test] +fn init() { + let dir = Some(testdir!()); + + expect_success("init", dir.clone()); + expect_fail("init", dir); // can't do twice +} + +#[test] +fn init_fail() { + let dir = Some(testdir!()); // directory is named /init_fail - as test name + + expect_fail("init", Some("directory-doesnt-exist".into())); + expect_fail("init", dir); +} + +#[test] +fn new() { + let dir = Some(testdir!()); + + expect_success("new test", dir.clone()); + expect_fail("new test", dir.clone()); // duplicate + expect_fail("new wrong_name123123", dir.clone()); +} + +#[test] +fn unimplemented() { + expect_fail("lint", None); + expect_fail("deploy", None); +} + +#[test] +fn clean() { + expect_success("--path examples/pedersen-hash build", None); + expect_success("--path examples/pedersen-hash clean", None); +} + +#[test] +fn setup_prove_run_clean() { + let dir = testdir!(); + + expect_success("new setup", Some(dir.clone())); + + let dir = Some(dir.join("setup")); + + expect_success("setup", dir.clone()); + expect_success("setup", dir.clone()); + expect_success("setup --skip-key-check", dir.clone()); + expect_success("prove --skip-key-check", dir.clone()); + expect_success("run --skip-key-check", dir.clone()); + expect_success("clean", dir); +} + +#[test] +fn test_sudoku() { + let path = "examples/silly-sudoku"; + + expect_success("build", Some(path.into())); + expect_success("test", Some(path.into())); + expect_success("test -f src/lib.leo", Some(path.into())); + expect_success("test -f src/main.leo", Some(path.into())); +} + +#[test] +fn test_missing_file() { + let path = testdir!(); + + expect_success("new missing-file-test", Some(path.clone())); + std::fs::remove_file(&path.clone().join("missing-file-test/src/main.leo")).unwrap(); + expect_fail("test", Some(path.join("missing-file"))); +} diff --git a/leo/tests/mod.rs b/leo/tests/mod.rs index 7bc611f49d..fe4f9f3540 100644 --- a/leo/tests/mod.rs +++ b/leo/tests/mod.rs @@ -14,9 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use std::path::PathBuf; +mod cmd; use anyhow::Result; +use std::path::PathBuf; use crate::{ commands::{ diff --git a/package/src/lib.rs b/package/src/lib.rs index 8006282739..1ae814a303 100644 --- a/package/src/lib.rs +++ b/package/src/lib.rs @@ -33,13 +33,8 @@ pub struct LeoPackage; impl LeoPackage { /// Initializes a Leo package at the given path. - pub fn initialize( - package_name: &str, - is_lib: bool, - path: &Path, - author: Option, - ) -> Result<(), PackageError> { - package::Package::initialize(package_name, is_lib, path, author) + pub fn initialize(package_name: &str, path: &Path, author: Option) -> Result<(), PackageError> { + package::Package::initialize(package_name, path, author) } /// Returns `true` if the given Leo package name is valid. diff --git a/package/src/package.rs b/package/src/package.rs index cf09d3509c..8a7fb861e7 100644 --- a/package/src/package.rs +++ b/package/src/package.rs @@ -19,7 +19,7 @@ use crate::{ imports::ImportsDirectory, inputs::{InputFile, InputsDirectory, StateFile}, root::{Gitignore, Manifest, README}, - source::{LibraryFile, MainFile, SourceDirectory}, + source::{MainFile, SourceDirectory}, }; use serde::Deserialize; @@ -107,7 +107,7 @@ impl Package { } /// Returns `true` if a package is can be initialized at a given path. - pub fn can_initialize(package_name: &str, is_lib: bool, path: &Path) -> bool { + pub fn can_initialize(package_name: &str, path: &Path) -> bool { // Check that the package name is valid. if !Self::is_package_name_valid(package_name) { return false; @@ -122,32 +122,24 @@ impl Package { result = false; } - if is_lib { - // Check if the library file already exists. - if LibraryFile::exists_at(path) { - existing_files.push(LibraryFile::filename()); - result = false; - } - } else { - // Check if the input file already exists. - let input_file = InputFile::new(&package_name); - if input_file.exists_at(path) { - existing_files.push(input_file.filename()); - result = false; - } + // Check if the input file already exists. + let input_file = InputFile::new(&package_name); + if input_file.exists_at(path) { + existing_files.push(input_file.filename()); + result = false; + } - // Check if the state file already exists. - let state_file = StateFile::new(&package_name); - if state_file.exists_at(path) { - existing_files.push(state_file.filename()); - result = false; - } + // Check if the state file already exists. + let state_file = StateFile::new(&package_name); + if state_file.exists_at(path) { + existing_files.push(state_file.filename()); + result = false; + } - // Check if the main file already exists. - if MainFile::exists_at(path) { - existing_files.push(MainFile::filename()); - result = false; - } + // Check if the main file already exists. + if MainFile::exists_at(path) { + existing_files.push(MainFile::filename()); + result = false; } if !existing_files.is_empty() { @@ -158,7 +150,7 @@ impl Package { } /// Returns `true` if a package is initialized at the given path - pub fn is_initialized(package_name: &str, is_lib: bool, path: &Path) -> bool { + pub fn is_initialized(package_name: &str, path: &Path) -> bool { // Check that the package name is valid. if !Self::is_package_name_valid(package_name) { return false; @@ -169,43 +161,31 @@ impl Package { return false; } - if is_lib { - // Check if the library file exists. - if !LibraryFile::exists_at(&path) { - return false; - } - } else { - // Check if the input file exists. - let input_file = InputFile::new(&package_name); - if !input_file.exists_at(&path) { - return false; - } + // Check if the input file exists. + let input_file = InputFile::new(&package_name); + if !input_file.exists_at(&path) { + return false; + } - // Check if the state file exists. - let state_file = StateFile::new(&package_name); - if !state_file.exists_at(&path) { - return false; - } + // Check if the state file exists. + let state_file = StateFile::new(&package_name); + if !state_file.exists_at(&path) { + return false; + } - // Check if the main file exists. - if !MainFile::exists_at(&path) { - return false; - } + // Check if the main file exists. + if !MainFile::exists_at(&path) { + return false; } true } /// Creates a package at the given path - pub fn initialize( - package_name: &str, - is_lib: bool, - path: &Path, - author: Option, - ) -> Result<(), PackageError> { + pub fn initialize(package_name: &str, path: &Path, author: Option) -> Result<(), PackageError> { // First, verify that this directory is not already initialized as a Leo package. { - if !Self::can_initialize(package_name, is_lib, path) { + if !Self::can_initialize(package_name, path) { return Err(PackageError::FailedToInitialize( package_name.to_owned(), path.as_os_str().to_owned(), @@ -232,27 +212,21 @@ impl Package { // Create the source directory. SourceDirectory::create(&path)?; - // Create a new library or binary file. - if is_lib { - // Create the library file in the source directory. - LibraryFile::new(&package_name).write_to(&path)?; - } else { - // Create the input directory. - InputsDirectory::create(&path)?; + // Create the input directory. + InputsDirectory::create(&path)?; - // Create the input file in the inputs directory. - InputFile::new(&package_name).write_to(&path)?; + // Create the input file in the inputs directory. + InputFile::new(&package_name).write_to(&path)?; - // Create the state file in the inputs directory. - StateFile::new(&package_name).write_to(&path)?; + // Create the state file in the inputs directory. + StateFile::new(&package_name).write_to(&path)?; - // Create the main file in the source directory. - MainFile::new(&package_name).write_to(&path)?; - } + // Create the main file in the source directory. + MainFile::new(&package_name).write_to(&path)?; } // Next, verify that a valid Leo package has been initialized in this directory { - if !Self::is_initialized(package_name, is_lib, path) { + if !Self::is_initialized(package_name, path) { return Err(PackageError::FailedToInitialize( package_name.to_owned(), path.as_os_str().to_owned(), diff --git a/package/src/source/library.rs b/package/src/source/library.rs deleted file mode 100644 index 90a5193b85..0000000000 --- a/package/src/source/library.rs +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (C) 2019-2021 Aleo Systems Inc. -// This file is part of the Leo library. - -// The Leo library is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// The Leo library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with the Leo library. If not, see . - -//! The `lib.leo` file. - -use crate::{errors::LibraryFileError, source::directory::SOURCE_DIRECTORY_NAME}; - -use serde::Deserialize; -use std::{borrow::Cow, fs::File, io::Write, path::Path}; - -pub static LIBRARY_FILENAME: &str = "lib.leo"; - -#[derive(Deserialize)] -pub struct LibraryFile { - pub package_name: String, -} - -impl LibraryFile { - pub fn new(package_name: &str) -> Self { - Self { - package_name: package_name.to_string(), - } - } - - pub fn filename() -> String { - format!("{}{}", SOURCE_DIRECTORY_NAME, LIBRARY_FILENAME) - } - - pub fn exists_at(path: &Path) -> bool { - let mut path = Cow::from(path); - if path.is_dir() { - if !path.ends_with(SOURCE_DIRECTORY_NAME) { - path.to_mut().push(SOURCE_DIRECTORY_NAME); - } - path.to_mut().push(LIBRARY_FILENAME); - } - path.exists() - } - - pub fn write_to(self, path: &Path) -> Result<(), LibraryFileError> { - let mut path = Cow::from(path); - if path.is_dir() { - if !path.ends_with(SOURCE_DIRECTORY_NAME) { - path.to_mut().push(SOURCE_DIRECTORY_NAME); - } - path.to_mut().push(LIBRARY_FILENAME); - } - - let mut file = File::create(&path)?; - Ok(file.write_all(self.template().as_bytes())?) - } - - fn template(&self) -> String { - format!( - r#"// The '{}' library circuit. -circuit Foo {{ - a: field -}} -"#, - self.package_name - ) - } -} diff --git a/package/src/source/mod.rs b/package/src/source/mod.rs index 3057d1a2b5..489cee59da 100644 --- a/package/src/source/mod.rs +++ b/package/src/source/mod.rs @@ -17,8 +17,5 @@ pub mod directory; pub use directory::*; -pub mod library; -pub use library::*; - pub mod main; pub use main::*; diff --git a/package/tests/initialize/initialize.rs b/package/tests/initialize/initialize.rs index 67bd922ef7..882e4ae707 100644 --- a/package/tests/initialize/initialize.rs +++ b/package/tests/initialize/initialize.rs @@ -19,7 +19,7 @@ use leo_package::{ inputs::{InputFile, InputsDirectory, StateFile}, package::Package, root::Manifest, - source::{LibraryFile, MainFile, SourceDirectory}, + source::{MainFile, SourceDirectory}, }; const TEST_PACKAGE_NAME: &str = "test-package"; @@ -29,13 +29,13 @@ fn initialize_valid_package() { let test_directory = test_dir(); // Ensure a package can be initialized at the `test_directory` - assert!(Package::can_initialize(TEST_PACKAGE_NAME, false, &test_directory)); + assert!(Package::can_initialize(TEST_PACKAGE_NAME, &test_directory)); // Initialize a package at the `test_directory` - assert!(Package::initialize(TEST_PACKAGE_NAME, false, &test_directory, None).is_ok()); + assert!(Package::initialize(TEST_PACKAGE_NAME, &test_directory, None).is_ok()); // Ensure a package is initialized at the `test_directory` - assert!(Package::is_initialized(TEST_PACKAGE_NAME, false, &test_directory)); + assert!(Package::is_initialized(TEST_PACKAGE_NAME, &test_directory)); } #[test] @@ -43,21 +43,13 @@ fn initialize_valid_package_with_author() { let test_directory = test_dir(); // Ensure a package can be initialized at the `test_directory` - assert!(Package::can_initialize(TEST_PACKAGE_NAME, false, &test_directory)); + assert!(Package::can_initialize(TEST_PACKAGE_NAME, &test_directory)); // Initialize a package at the `test_directory` - assert!( - Package::initialize( - TEST_PACKAGE_NAME, - false, - &test_directory, - Some(String::from("test_user")) - ) - .is_ok() - ); + assert!(Package::initialize(TEST_PACKAGE_NAME, &test_directory, Some(String::from("test_user"))).is_ok()); // Ensure a package is initialized at the `test_directory` - assert!(Package::is_initialized(TEST_PACKAGE_NAME, false, &test_directory)); + assert!(Package::is_initialized(TEST_PACKAGE_NAME, &test_directory)); } #[test] @@ -71,7 +63,7 @@ fn initialize_fails_with_existing_manifest() { let test_directory = test_dir(); // Ensure a package can be initialized at the `test_directory` - assert!(Package::can_initialize(TEST_PACKAGE_NAME, false, &test_directory)); + assert!(Package::can_initialize(TEST_PACKAGE_NAME, &test_directory)); // Manually add a manifest file to the `test_directory` Manifest::new(TEST_PACKAGE_NAME, None) @@ -80,28 +72,10 @@ fn initialize_fails_with_existing_manifest() { .unwrap(); // Attempt to initialize a package at the `test_directory` - assert!(Package::initialize(TEST_PACKAGE_NAME, false, &test_directory, None).is_err()); + assert!(Package::initialize(TEST_PACKAGE_NAME, &test_directory, None).is_err()); // Ensure package is not initialized at the `test_directory` - assert!(!Package::is_initialized(TEST_PACKAGE_NAME, false, &test_directory)); -} - -#[test] -fn initialize_fails_with_existing_library_file() { - let test_directory = test_dir(); - - // Ensure a package can be initialized at the `test_directory` - assert!(Package::can_initialize(TEST_PACKAGE_NAME, true, &test_directory)); - - // Manually add a source directory and a library file to the `test_directory` - SourceDirectory::create(&test_directory).unwrap(); - LibraryFile::new(TEST_PACKAGE_NAME).write_to(&test_directory).unwrap(); - - // Attempt to initialize a package at the `test_directory` - assert!(Package::initialize(TEST_PACKAGE_NAME, true, &test_directory, None).is_err()); - - // Ensure package is not initialized at the `test_directory` - assert!(!Package::is_initialized(TEST_PACKAGE_NAME, true, &test_directory)); + assert!(!Package::is_initialized(TEST_PACKAGE_NAME, &test_directory)); } #[test] @@ -109,25 +83,17 @@ fn initialize_fails_with_existing_input_file() { let test_directory = test_dir(); // Ensure a package can be initialized at the `test_directory` - assert!(Package::can_initialize(TEST_PACKAGE_NAME, false, &test_directory)); + assert!(Package::can_initialize(TEST_PACKAGE_NAME, &test_directory)); // Manually add an inputs directory and an input file to the `test_directory` InputsDirectory::create(&test_directory).unwrap(); InputFile::new(TEST_PACKAGE_NAME).write_to(&test_directory).unwrap(); // Attempt to initialize a package at the `test_directory` - assert!( - Package::initialize( - TEST_PACKAGE_NAME, - false, - &test_directory, - Some(String::from("test_user")) - ) - .is_err() - ); + assert!(Package::initialize(TEST_PACKAGE_NAME, &test_directory, Some(String::from("test_user"))).is_err()); // Ensure package is not initialized at the `test_directory` - assert!(!Package::is_initialized(TEST_PACKAGE_NAME, false, &test_directory)); + assert!(!Package::is_initialized(TEST_PACKAGE_NAME, &test_directory)); } #[test] @@ -135,17 +101,17 @@ fn initialize_fails_with_existing_state_file() { let test_directory = test_dir(); // Ensure a package can be initialized at the `test_directory` - assert!(Package::can_initialize(TEST_PACKAGE_NAME, false, &test_directory)); + assert!(Package::can_initialize(TEST_PACKAGE_NAME, &test_directory)); // Manually add an inputs directory and a state file to the `test_directory` InputsDirectory::create(&test_directory).unwrap(); StateFile::new(TEST_PACKAGE_NAME).write_to(&test_directory).unwrap(); // Attempt to initialize a package at the `test_directory` - assert!(Package::initialize(TEST_PACKAGE_NAME, false, &test_directory, None).is_err()); + assert!(Package::initialize(TEST_PACKAGE_NAME, &test_directory, None).is_err()); // Ensure package is not initialized at the `test_directory` - assert!(!Package::is_initialized(TEST_PACKAGE_NAME, false, &test_directory)); + assert!(!Package::is_initialized(TEST_PACKAGE_NAME, &test_directory)); } #[test] @@ -153,15 +119,15 @@ fn initialize_fails_with_existing_main_file() { let test_directory = test_dir(); // Ensure a package can be initialized at the `test_directory` - assert!(Package::can_initialize(TEST_PACKAGE_NAME, false, &test_directory)); + assert!(Package::can_initialize(TEST_PACKAGE_NAME, &test_directory)); // Manually add a source directory and a main file to the `test_directory` SourceDirectory::create(&test_directory).unwrap(); MainFile::new(TEST_PACKAGE_NAME).write_to(&test_directory).unwrap(); // Attempt to initialize a package at the `test_directory` - assert!(Package::initialize(TEST_PACKAGE_NAME, false, &test_directory, None).is_err()); + assert!(Package::initialize(TEST_PACKAGE_NAME, &test_directory, None).is_err()); // Ensure package is not initialized at the `test_directory` - assert!(!Package::is_initialized(TEST_PACKAGE_NAME, false, &test_directory)); + assert!(!Package::is_initialized(TEST_PACKAGE_NAME, &test_directory)); } From e7fd30b44db4eec0a8944205f42226123d073001 Mon Sep 17 00:00:00 2001 From: damirka Date: Fri, 23 Apr 2021 23:38:10 +0300 Subject: [PATCH 02/14] try to use older testdir version --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 2aca1ffe77..5d71a63201 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -160,7 +160,7 @@ version = "0.11.2" version = "1.0.3" [dev-dependencies.testdir] -version = "0.4.0" +version = "0.3.1" [features] default = [ ] From 851e5fc200b3d7ab51dc982c4d16e0941bcdccaf Mon Sep 17 00:00:00 2001 From: damirka Date: Mon, 26 Apr 2021 11:59:05 +0300 Subject: [PATCH 03/14] pushing lockfile as well --- Cargo.lock | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f32906f20a..28cc62bff6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3553,11 +3553,10 @@ dependencies = [ [[package]] name = "testdir" -version = "0.4.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c13a556e110c7d373db3c12464a80e4d24ed25942381242b17aad43aee98085" +checksum = "2bb6a886d8d62f13a3bf818936ee3ed204b74658b8efe4ff0184d9e9ee0a49b7" dependencies = [ - "anyhow", "backtrace", "heim", "once_cell", From cdfbf64fe51a13af2218925cc2f6f08d8463d53d Mon Sep 17 00:00:00 2001 From: damirka Date: Mon, 26 Apr 2021 12:03:48 +0300 Subject: [PATCH 04/14] revert version change --- Cargo.lock | 5 +++-- Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 28cc62bff6..f32906f20a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3553,10 +3553,11 @@ dependencies = [ [[package]] name = "testdir" -version = "0.3.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bb6a886d8d62f13a3bf818936ee3ed204b74658b8efe4ff0184d9e9ee0a49b7" +checksum = "1c13a556e110c7d373db3c12464a80e4d24ed25942381242b17aad43aee98085" dependencies = [ + "anyhow", "backtrace", "heim", "once_cell", diff --git a/Cargo.toml b/Cargo.toml index 5d71a63201..2aca1ffe77 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -160,7 +160,7 @@ version = "0.11.2" version = "1.0.3" [dev-dependencies.testdir] -version = "0.3.1" +version = "0.4.0" [features] default = [ ] From cd242925dd3c3e633b3e6ca3b684885fe2c8fe42 Mon Sep 17 00:00:00 2001 From: damirka Date: Mon, 26 Apr 2021 12:24:56 +0300 Subject: [PATCH 05/14] removes testdir and uses test_dir instead --- Cargo.lock | 739 +++++------------------------------------------ Cargo.toml | 4 +- leo/tests/cmd.rs | 32 +- 3 files changed, 96 insertions(+), 679 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cf19391b2d..6ace978d46 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -101,126 +101,6 @@ dependencies = [ "wait-timeout", ] -[[package]] -name = "async-channel" -version = "1.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2114d64672151c0c5eaa5e131ec84a74f06e1e559830dabba01ca30605d66319" -dependencies = [ - "concurrent-queue", - "event-listener", - "futures-core", -] - -[[package]] -name = "async-executor" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb877970c7b440ead138f6321a3b5395d6061183af779340b65e20c0fede9146" -dependencies = [ - "async-task 4.0.3", - "concurrent-queue", - "fastrand", - "futures-lite 1.11.3", - "once_cell", - "vec-arena", -] - -[[package]] -name = "async-fs" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b3ca4f8ff117c37c278a2f7415ce9be55560b846b5bc4412aaa5d29c1c3dae2" -dependencies = [ - "async-lock", - "blocking 1.0.2", - "futures-lite 1.11.3", -] - -[[package]] -name = "async-io" -version = "1.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5bfd63f6fc8fd2925473a147d3f4d252c712291efdde0d7057b25146563402c" -dependencies = [ - "concurrent-queue", - "fastrand", - "futures-lite 1.11.3", - "log", - "nb-connect", - "once_cell", - "parking 2.0.0", - "polling", - "vec-arena", - "waker-fn", -] - -[[package]] -name = "async-lock" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6a8ea61bf9947a1007c5cada31e647dbc77b103c679858150003ba697ea798b" -dependencies = [ - "event-listener", -] - -[[package]] -name = "async-net" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06de475c85affe184648202401d7622afb32f0f74e02192857d0201a16defbe5" -dependencies = [ - "async-io", - "blocking 1.0.2", - "fastrand", - "futures-lite 1.11.3", -] - -[[package]] -name = "async-process" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef37b86e2fa961bae5a4d212708ea0154f904ce31d1a4a7f47e1bbc33a0c040b" -dependencies = [ - "async-io", - "blocking 1.0.2", - "cfg-if 1.0.0", - "event-listener", - "futures-lite 1.11.3", - "once_cell", - "signal-hook", - "winapi 0.3.9", -] - -[[package]] -name = "async-task" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c17772156ef2829aadc587461c7753af20b7e8db1529bc66855add962a3b35d3" - -[[package]] -name = "async-task" -version = "4.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91831deabf0d6d7ec49552e489aed63b7456a7a3c46cff62adad428110b0af0" - -[[package]] -name = "async-trait" -version = "0.1.50" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b98e84bbb4cbcdd97da190ba0c58a1bb0de2c1fdf67d159e192ed766aeca722" -dependencies = [ - "proc-macro2 1.0.24", - "quote 1.0.9", - "syn 1.0.64", -] - -[[package]] -name = "atomic-waker" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "065374052e7df7ee4047b1160cca5e1467a12351a40b3da123c870ba0b8eda2a" - [[package]] name = "atty" version = "0.2.14" @@ -373,34 +253,6 @@ dependencies = [ "byte-tools", ] -[[package]] -name = "blocking" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2468ff7bf85066b4a3678fede6fe66db31846d753ff0adfbfab2c6a6e81612b" -dependencies = [ - "async-channel", - "atomic-waker", - "futures-lite 0.1.11", - "once_cell", - "parking 1.0.6", - "waker-fn", -] - -[[package]] -name = "blocking" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5e170dbede1f740736619b776d7251cb1b9095c435c34d8ca9f57fcd2f335e9" -dependencies = [ - "async-channel", - "async-task 4.0.3", - "atomic-waker", - "fastrand", - "futures-lite 1.11.3", - "once_cell", -] - [[package]] name = "bstr" version = "0.2.15" @@ -458,12 +310,6 @@ dependencies = [ "pkg-config", ] -[[package]] -name = "cache-padded" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "631ae5198c9be5e753e5cc215e1bd73c2b466a3565173db433f52bb9d3e66dba" - [[package]] name = "cast" version = "0.2.3" @@ -563,15 +409,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "concurrent-queue" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30ed07550be01594c6026cff2a1d7fe9c8f683caa798e12b68694ac9e88286a3" -dependencies = [ - "cache-padded", -] - [[package]] name = "console" version = "0.14.1" @@ -748,7 +585,7 @@ dependencies = [ "openssl-probe", "openssl-sys", "schannel", - "socket2 0.3.19", + "socket2", "winapi 0.3.9", ] @@ -767,26 +604,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "darwin-libproc" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb90051930c9a0f09e585762152048e23ac74d20c10590ef7cf01c0343c3046" -dependencies = [ - "darwin-libproc-sys", - "libc", - "memchr", -] - -[[package]] -name = "darwin-libproc-sys" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57cebb5bde66eecdd30ddc4b9cd208238b15db4982ccc72db59d699ea10867c1" -dependencies = [ - "libc", -] - [[package]] name = "derivative" version = "2.2.0" @@ -898,12 +715,6 @@ dependencies = [ "indexmap", ] -[[package]] -name = "event-listener" -version = "2.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7531096570974c3a9dcf9e4b8e1cede1ec26cf5046219fb3b9d897503b9be59" - [[package]] name = "failure" version = "0.1.8" @@ -932,15 +743,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" -[[package]] -name = "fastrand" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca5faf057445ce5c9d4329e382b2ce7ca38550ef3b73a5348362d5f24e0c7fe3" -dependencies = [ - "instant", -] - [[package]] name = "filetime" version = "0.2.14" @@ -1063,20 +865,6 @@ dependencies = [ "new_debug_unreachable", ] -[[package]] -name = "futures" -version = "0.3.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f55667319111d593ba876406af7c409c0ebb44dc4be6132a783ccf163ea14c1" -dependencies = [ - "futures-channel", - "futures-core", - "futures-io", - "futures-sink", - "futures-task", - "futures-util", -] - [[package]] name = "futures-channel" version = "0.3.13" @@ -1084,7 +872,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c2dd2df839b57db9ab69c2c9d8f3e8c81984781937fe2807dc6dcf3b2ad2939" dependencies = [ "futures-core", - "futures-sink", ] [[package]] @@ -1099,36 +886,6 @@ version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d71c2c65c57704c32f5241c1223167c2c3294fd34ac020c807ddbe6db287ba59" -[[package]] -name = "futures-lite" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97999970129b808f0ccba93211201d431fcc12d7e1ffae03a61b5cedd1a7ced2" -dependencies = [ - "fastrand", - "futures-core", - "futures-io", - "memchr", - "parking 2.0.0", - "pin-project-lite 0.1.12", - "waker-fn", -] - -[[package]] -name = "futures-lite" -version = "1.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4481d0cd0de1d204a4fa55e7d45f07b1d958abcb06714b3446438e2eff695fb" -dependencies = [ - "fastrand", - "futures-core", - "futures-io", - "memchr", - "parking 2.0.0", - "pin-project-lite 0.2.4", - "waker-fn", -] - [[package]] name = "futures-sink" version = "0.3.13" @@ -1141,25 +898,17 @@ version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa189ef211c15ee602667a6fcfe1c1fd9e07d42250d2156382820fba33c9df80" -[[package]] -name = "futures-timer" -version = "3.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" - [[package]] name = "futures-util" version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1812c7ab8aedf8d6f2701a43e1243acdbcc2b36ab26e2ad421eb99ac963d96d1" dependencies = [ - "futures-channel", "futures-core", "futures-io", - "futures-sink", "futures-task", "memchr", - "pin-project-lite 0.2.4", + "pin-project-lite", "pin-utils", "slab", ] @@ -1276,125 +1025,6 @@ dependencies = [ "unicode-segmentation", ] -[[package]] -name = "heim" -version = "0.1.0-beta.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1014732324a9baf5a691525faabb33909bf6f40dcc2b03c8f2fb07bb01e7e3f" -dependencies = [ - "heim-common", - "heim-process", - "heim-runtime", -] - -[[package]] -name = "heim-common" -version = "0.1.0-rc.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d767e6e47cf88abe7c9a5ebb4df82f180d30d9c0ba0269b6d166482461765834" -dependencies = [ - "cfg-if 1.0.0", - "core-foundation", - "futures-core", - "futures-util", - "lazy_static", - "libc", - "mach", - "nix 0.19.1", - "pin-utils", - "uom", - "winapi 0.3.9", -] - -[[package]] -name = "heim-cpu" -version = "0.1.0-beta.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73b1442359831aa671aa931f0a084aab210e77b1330ded78f1e60cc305abc4bb" -dependencies = [ - "cfg-if 0.1.10", - "futures", - "glob", - "heim-common", - "heim-runtime", - "lazy_static", - "libc", - "mach", - "ntapi", - "smol 0.1.18", - "winapi 0.3.9", -] - -[[package]] -name = "heim-host" -version = "0.1.0-beta.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79cce3ce658bd45e510ff0a2fb5c668cbe1a7368929fd1db123741c99fd6902e" -dependencies = [ - "cfg-if 0.1.10", - "heim-common", - "heim-runtime", - "lazy_static", - "libc", - "log", - "mach", - "ntapi", - "platforms", - "winapi 0.3.9", -] - -[[package]] -name = "heim-net" -version = "0.1.0-beta.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59da1108e732afcda77e1429b5d0ce648b9a31d1f8cf385108b83bea4cf91342" -dependencies = [ - "bitflags", - "cfg-if 0.1.10", - "heim-common", - "heim-runtime", - "libc", - "macaddr", - "nix 0.17.0", -] - -[[package]] -name = "heim-process" -version = "0.1.1-beta.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd969deb2a89a488b6a9bf18a65923ae4cdef6b128fa2dedb74ef5c694deb5ae" -dependencies = [ - "async-trait", - "cfg-if 0.1.10", - "darwin-libproc", - "futures", - "heim-common", - "heim-cpu", - "heim-host", - "heim-net", - "heim-runtime", - "lazy_static", - "libc", - "mach", - "memchr", - "ntapi", - "ordered-float", - "smol 0.1.18", - "winapi 0.3.9", -] - -[[package]] -name = "heim-runtime" -version = "0.1.0-beta.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "906dd26ed2eb6b9f5f0dc3dfc04caeb82785ccc05a3b3326e4c841613451acc7" -dependencies = [ - "futures", - "futures-timer", - "smol 0.1.18", - "version-sync", -] - [[package]] name = "hermit-abi" version = "0.1.18" @@ -1469,7 +1099,7 @@ dependencies = [ "httpdate", "itoa", "pin-project", - "socket2 0.3.19", + "socket2", "tokio", "tower-service", "tracing", @@ -1703,8 +1333,8 @@ dependencies = [ "leo-state", "num-bigint", "pest", - "rand", - "rand_core", + "rand 0.8.3", + "rand_core 0.6.2", "rand_xorshift", "serde", "sha2", @@ -1766,8 +1396,8 @@ dependencies = [ "leo-state", "leo-synthesizer", "notify", - "rand", - "rand_core", + "rand 0.8.3", + "rand_core 0.6.2", "reqwest", "rusty-hook", "self_update", @@ -1779,7 +1409,7 @@ dependencies = [ "snarkvm-r1cs", "snarkvm-utilities", "structopt", - "testdir", + "test_dir", "thiserror", "toml", "tracing", @@ -1828,8 +1458,8 @@ dependencies = [ "indexmap", "leo-ast", "leo-input", - "rand", - "rand_core", + "rand 0.8.3", + "rand_core 0.6.2", "rand_xorshift", "snarkvm-algorithms", "snarkvm-curves", @@ -1944,21 +1574,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4" -[[package]] -name = "macaddr" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baee0bbc17ce759db233beb01648088061bf678383130602a298e6998eedb2d8" - -[[package]] -name = "mach" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" -dependencies = [ - "libc", -] - [[package]] name = "maplit" version = "1.0.2" @@ -2092,7 +1707,7 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a33c1b55807fbed163481b5ba66db4b2fa6cde694a5027be10fb724206c5897" dependencies = [ - "socket2 0.3.19", + "socket2", "winapi 0.3.9", ] @@ -2114,16 +1729,6 @@ dependencies = [ "tempfile", ] -[[package]] -name = "nb-connect" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a19900e7eee95eb2b3c2e26d12a874cc80aaf750e31be6fcbe743ead369fa45d" -dependencies = [ - "libc", - "socket2 0.4.0", -] - [[package]] name = "net2" version = "0.2.37" @@ -2147,31 +1752,6 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab250442c86f1850815b5d268639dff018c0627022bc1940eb2d642ca1ce12f0" -[[package]] -name = "nix" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50e4785f2c3b7589a0d0c1dd60285e1188adac4006e8abd6dd578e1567027363" -dependencies = [ - "bitflags", - "cc", - "cfg-if 0.1.10", - "libc", - "void", -] - -[[package]] -name = "nix" -version = "0.19.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ccba0cfe4fdf15982d1674c69b1fd80bad427d293849982668dfe454bd61f2" -dependencies = [ - "bitflags", - "cc", - "cfg-if 1.0.0", - "libc", -] - [[package]] name = "nom" version = "5.1.2" @@ -2243,17 +1823,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-rational" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12ac428b1cb17fce6f731001d307d351ec70a6d202fc2e60f7d4c5e42d8f4f07" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - [[package]] name = "num-traits" version = "0.2.14" @@ -2342,27 +1911,6 @@ dependencies = [ "vcpkg", ] -[[package]] -name = "ordered-float" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18869315e81473c951eb56ad5558bbc56978562d3ecfb87abb7a1e944cea4518" -dependencies = [ - "num-traits", -] - -[[package]] -name = "parking" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6cb300f271742d4a2a66c01b6b2fa0c83dfebd2e0bf11addb879a3547b4ed87c" - -[[package]] -name = "parking" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" - [[package]] name = "parking_lot" version = "0.11.1" @@ -2476,12 +2024,6 @@ dependencies = [ "syn 1.0.64", ] -[[package]] -name = "pin-project-lite" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777" - [[package]] name = "pin-project-lite" version = "0.2.4" @@ -2500,12 +2042,6 @@ version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" -[[package]] -name = "platforms" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "feb3b2b1033b8a60b4da6ee470325f887758c95d5320f52f9ce0df055a55940e" - [[package]] name = "plotters" version = "0.3.0" @@ -2534,19 +2070,6 @@ dependencies = [ "plotters-backend", ] -[[package]] -name = "polling" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0720e0b9ea9d52451cf29d3413ba8a9303f8815d9d9653ef70e03ff73e65566" -dependencies = [ - "cfg-if 0.1.10", - "libc", - "log", - "wepoll-sys-stjepang", - "winapi 0.3.9", -] - [[package]] name = "ppv-lite86" version = "0.2.10" @@ -2630,17 +2153,6 @@ dependencies = [ "unicode-xid 0.2.1", ] -[[package]] -name = "pulldown-cmark" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffade02495f22453cd593159ea2f59827aae7f53fa8323f756799b670881dcf8" -dependencies = [ - "bitflags", - "memchr", - "unicase", -] - [[package]] name = "quick-error" version = "1.2.3" @@ -2680,6 +2192,19 @@ version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "941ba9d78d8e2f7ce474c015eea4d9c6d25b6a3327f9832ee29a4de27f91bbb8" +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom 0.1.16", + "libc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc 0.2.0", +] + [[package]] name = "rand" version = "0.8.3" @@ -2687,9 +2212,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e" dependencies = [ "libc", - "rand_chacha", - "rand_core", - "rand_hc", + "rand_chacha 0.3.0", + "rand_core 0.6.2", + "rand_hc 0.3.0", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core 0.5.1", ] [[package]] @@ -2699,7 +2234,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.6.2", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom 0.1.16", ] [[package]] @@ -2711,13 +2255,22 @@ dependencies = [ "getrandom 0.2.2", ] +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core 0.5.1", +] + [[package]] name = "rand_hc" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73" dependencies = [ - "rand_core", + "rand_core 0.6.2", ] [[package]] @@ -2726,7 +2279,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f" dependencies = [ - "rand_core", + "rand_core 0.6.2", ] [[package]] @@ -2839,7 +2392,7 @@ dependencies = [ "mime_guess", "native-tls", "percent-encoding", - "pin-project-lite 0.2.4", + "pin-project-lite", "serde", "serde_json", "serde_urlencoded", @@ -2941,12 +2494,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "scoped-tls" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" - [[package]] name = "scopeguard" version = "1.1.0" @@ -3018,12 +2565,6 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -[[package]] -name = "semver-parser" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b46e1121e8180c12ff69a742aabc4f310542b6ccb69f1691689ac17fdf8618aa" - [[package]] name = "semver-parser" version = "0.10.2" @@ -3138,25 +2679,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2" -[[package]] -name = "signal-hook" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef33d6d0cd06e0840fba9985aab098c147e67e05cee14d412d3345ed14ff30ac" -dependencies = [ - "libc", - "signal-hook-registry", -] - -[[package]] -name = "signal-hook-registry" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16f1d0fef1604ba8f7a073c7e701f213e056707210e9020af4528e0101ce11a6" -dependencies = [ - "libc", -] - [[package]] name = "single" version = "1.0.0" @@ -3178,45 +2700,6 @@ version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" -[[package]] -name = "smol" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "620cbb3c6e34da57d3a248cda0cd01cd5848164dc062e764e65d06fe3ea7aed5" -dependencies = [ - "async-task 3.0.0", - "blocking 0.4.7", - "concurrent-queue", - "fastrand", - "futures-io", - "futures-util", - "libc", - "once_cell", - "scoped-tls", - "slab", - "socket2 0.3.19", - "wepoll-sys-stjepang", - "winapi 0.3.9", -] - -[[package]] -name = "smol" -version = "1.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85cf3b5351f3e783c1d79ab5fc604eeed8b8ae9abd36b166e8b87a089efd85e4" -dependencies = [ - "async-channel", - "async-executor", - "async-fs", - "async-io", - "async-lock", - "async-net", - "async-process", - "blocking 1.0.2", - "futures-lite 1.11.3", - "once_cell", -] - [[package]] name = "snarkvm-algorithms" version = "0.2.2" @@ -3227,8 +2710,8 @@ dependencies = [ "derivative", "digest 0.9.0", "itertools 0.10.0", - "rand", - "rand_chacha", + "rand 0.8.3", + "rand_chacha 0.3.0", "rayon", "sha2", "smallvec", @@ -3247,7 +2730,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64610b135b8b1152439d5dfa4f745515933366082f08651961344aa0bb5abfca" dependencies = [ "derivative", - "rand", + "rand 0.8.3", "rand_xorshift", "rustc_version 0.3.3", "serde", @@ -3282,7 +2765,7 @@ dependencies = [ "derivative", "hex", "itertools 0.10.0", - "rand", + "rand 0.8.3", "snarkvm-algorithms", "snarkvm-curves", "snarkvm-fields", @@ -3303,7 +2786,7 @@ checksum = "8c49c69d02df11be58e07f626c9d6f5804c6dd4ccf42e425f2be8d79fe6e5bb7" dependencies = [ "bincode", "derivative", - "rand", + "rand 0.8.3", "rand_xorshift", "serde", "snarkvm-utilities", @@ -3338,7 +2821,7 @@ dependencies = [ "chrono", "hex", "once_cell", - "rand", + "rand 0.8.3", "serde", "sha2", "snarkvm-algorithms", @@ -3392,7 +2875,7 @@ dependencies = [ "bincode", "hex", "parking_lot", - "rand", + "rand 0.8.3", "rocksdb", "serde", "snarkvm-algorithms", @@ -3410,7 +2893,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c763843fa67a3aa4ce68173c8cd96b4f04aaa135a5792bc051c36eec0fe1cd73" dependencies = [ "bincode", - "rand", + "rand 0.8.3", "snarkvm-derives", "thiserror", ] @@ -3426,16 +2909,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "socket2" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e3dfc207c526015c632472a77be09cf1b6e46866581aecae5cc38fb4235dea2" -dependencies = [ - "libc", - "winapi 0.3.9", -] - [[package]] name = "static_assertions" version = "1.1.0" @@ -3526,7 +2999,7 @@ checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" dependencies = [ "cfg-if 1.0.0", "libc", - "rand", + "rand 0.8.3", "redox_syscall 0.2.5", "remove_dir_all", "winapi 0.3.9", @@ -3563,17 +3036,12 @@ dependencies = [ ] [[package]] -name = "testdir" -version = "0.4.0" +name = "test_dir" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c13a556e110c7d373db3c12464a80e4d24ed25942381242b17aad43aee98085" +checksum = "e571ebf9127a9da821890a9fa8a8ef777fce3e0f959ff6949cf06ca8b736381d" dependencies = [ - "anyhow", - "backtrace", - "heim", - "once_cell", - "smol 1.2.5", - "whoami", + "rand 0.7.3", ] [[package]] @@ -3661,7 +3129,7 @@ dependencies = [ "memchr", "mio 0.7.10", "num_cpus", - "pin-project-lite 0.2.4", + "pin-project-lite", ] [[package]] @@ -3684,7 +3152,7 @@ dependencies = [ "futures-core", "futures-sink", "log", - "pin-project-lite 0.2.4", + "pin-project-lite", "tokio", ] @@ -3710,7 +3178,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "01ebdc2bb4498ab1ab5f5b73c5803825e60199229ccba0698170e3be0e7f959f" dependencies = [ "cfg-if 1.0.0", - "pin-project-lite 0.2.4", + "pin-project-lite", "tracing-attributes", "tracing-core", ] @@ -3869,17 +3337,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" -[[package]] -name = "uom" -version = "0.30.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e76503e636584f1e10b9b3b9498538279561adcef5412927ba00c2b32c4ce5ed" -dependencies = [ - "num-rational", - "num-traits", - "typenum", -] - [[package]] name = "url" version = "2.2.1" @@ -3904,33 +3361,12 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b00bca6106a5e23f3eee943593759b7fcddb00554332e856d990c893966879fb" -[[package]] -name = "vec-arena" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34b2f665b594b07095e3ac3f718e13c2197143416fae4c5706cffb7b1af8d7f1" - [[package]] name = "vec_map" version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" -[[package]] -name = "version-sync" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cb94ca10ca0cf44f5d926ac977f0cac2d13e9789aa4bbe9d9388de445e61028" -dependencies = [ - "proc-macro2 1.0.24", - "pulldown-cmark", - "regex", - "semver-parser 0.9.0", - "syn 1.0.64", - "toml", - "url", -] - [[package]] name = "version_check" version = "0.9.2" @@ -3952,12 +3388,6 @@ dependencies = [ "libc", ] -[[package]] -name = "waker-fn" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" - [[package]] name = "walkdir" version = "2.3.2" @@ -4069,15 +3499,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "wepoll-sys-stjepang" -version = "1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fdfbb03f290ca0b27922e8d48a0997b4ceea12df33269b9f75e713311eb178d" -dependencies = [ - "cc", -] - [[package]] name = "which" version = "3.1.1" @@ -4087,16 +3508,6 @@ dependencies = [ "libc", ] -[[package]] -name = "whoami" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4abacf325c958dfeaf1046931d37f2a901b6dfe0968ee965a29e94c6766b2af6" -dependencies = [ - "wasm-bindgen", - "web-sys", -] - [[package]] name = "winapi" version = "0.2.8" diff --git a/Cargo.toml b/Cargo.toml index fbbc0c8283..b85a76cb98 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -160,8 +160,8 @@ version = "0.11.2" [dev-dependencies.assert_cmd] version = "1.0.3" -[dev-dependencies.testdir] -version = "0.4.0" +[dev-dependencies.test_dir] +version = "0.1.0" [features] default = [ ] diff --git a/leo/tests/cmd.rs b/leo/tests/cmd.rs index d11aa8864f..4aa26ec993 100644 --- a/leo/tests/cmd.rs +++ b/leo/tests/cmd.rs @@ -16,7 +16,7 @@ use assert_cmd::Command; use std::path::PathBuf; -use testdir::testdir; +use test_dir::{DirBuilder, FileType, TestDir}; /// Create Command from given arguments and CWD. fn command(args: &str, cwd: Option) -> Command { @@ -51,7 +51,8 @@ fn test_global_options() { #[test] fn init() { - let dir = Some(testdir!()); + let dir = TestDir::temp().create("init", FileType::Dir); + let dir = Some(dir.path("init")); expect_success("init", dir.clone()); expect_fail("init", dir); // can't do twice @@ -59,7 +60,8 @@ fn init() { #[test] fn init_fail() { - let dir = Some(testdir!()); // directory is named /init_fail - as test name + let dir = TestDir::temp().create("incorrect_name", FileType::Dir); + let dir = Some(dir.path("incorrect_name")); expect_fail("init", Some("directory-doesnt-exist".into())); expect_fail("init", dir); @@ -67,7 +69,8 @@ fn init_fail() { #[test] fn new() { - let dir = Some(testdir!()); + let dir = TestDir::temp().create("new", FileType::Dir); + let dir = Some(dir.path("new")); expect_success("new test", dir.clone()); expect_fail("new test", dir.clone()); // duplicate @@ -88,18 +91,20 @@ fn clean() { #[test] fn setup_prove_run_clean() { - let dir = testdir!(); + let dir = TestDir::temp().create("test", FileType::Dir); + let dir = dir.path("test"); expect_success("new setup", Some(dir.clone())); - let dir = Some(dir.join("setup")); + // 'cd' into newly created setup directory + let new_dir = Some(dir.join("setup")); - expect_success("setup", dir.clone()); - expect_success("setup", dir.clone()); - expect_success("setup --skip-key-check", dir.clone()); - expect_success("prove --skip-key-check", dir.clone()); - expect_success("run --skip-key-check", dir.clone()); - expect_success("clean", dir); + expect_success("setup", new_dir.clone()); + expect_success("setup", new_dir.clone()); + expect_success("setup --skip-key-check", new_dir.clone()); + expect_success("prove --skip-key-check", new_dir.clone()); + expect_success("run --skip-key-check", new_dir.clone()); + expect_success("clean", new_dir); } #[test] @@ -114,7 +119,8 @@ fn test_sudoku() { #[test] fn test_missing_file() { - let path = testdir!(); + let path = TestDir::temp().create("test", FileType::Dir); + let path = path.path("test"); expect_success("new missing-file-test", Some(path.clone())); std::fs::remove_file(&path.clone().join("missing-file-test/src/main.leo")).unwrap(); From b58f38fbbcc5ace42b5e602b500e156b027a9639 Mon Sep 17 00:00:00 2001 From: damirka Date: Mon, 26 Apr 2021 12:37:53 +0300 Subject: [PATCH 06/14] clippy --- leo/tests/cmd.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/leo/tests/cmd.rs b/leo/tests/cmd.rs index 4aa26ec993..829d1aefbe 100644 --- a/leo/tests/cmd.rs +++ b/leo/tests/cmd.rs @@ -20,7 +20,7 @@ use test_dir::{DirBuilder, FileType, TestDir}; /// Create Command from given arguments and CWD. fn command(args: &str, cwd: Option) -> Command { - let args = args.split(" ").collect::>(); + let args = args.split(' ').collect::>(); let mut cmd = Command::cargo_bin("leo").unwrap(); if let Some(cwd) = cwd { @@ -74,7 +74,7 @@ fn new() { expect_success("new test", dir.clone()); expect_fail("new test", dir.clone()); // duplicate - expect_fail("new wrong_name123123", dir.clone()); + expect_fail("new wrong_name123123", dir); } #[test] @@ -123,6 +123,6 @@ fn test_missing_file() { let path = path.path("test"); expect_success("new missing-file-test", Some(path.clone())); - std::fs::remove_file(&path.clone().join("missing-file-test/src/main.leo")).unwrap(); + std::fs::remove_file(&path.join("missing-file-test/src/main.leo")).unwrap(); expect_fail("test", Some(path.join("missing-file"))); } From 794251bb43bc5963556b7b4b964bc5f2d46fe5c4 Mon Sep 17 00:00:00 2001 From: damirka Date: Mon, 26 Apr 2021 12:51:51 +0300 Subject: [PATCH 07/14] integration tests rely on leo binary - for that build step is added before running tests --- .circleci/config.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index da084c94e1..d76e5c1fa8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -50,8 +50,11 @@ jobs: - checkout - setup_environment: cache_key: leo-stable-cache + - build: + name: Build leo binary + command: cargo build - run: - name: Build and run tests + name: Run tests no_output_timeout: 30m command: cargo test --all - persist_to_workspace: @@ -68,8 +71,11 @@ jobs: - checkout - setup_environment: cache_key: leo-nightly-cache + - build: + name: Build leo binary + command: cargo build - run: - name: Build and test + name: Run tests no_output_timeout: 30m command: cargo test --all - clear_environment: From 1b273f40ffea1d3d4b38982435d6962dbb906e23 Mon Sep 17 00:00:00 2001 From: damirka Date: Mon, 26 Apr 2021 14:40:28 +0300 Subject: [PATCH 08/14] trying adding build directly --- .circleci/config.yml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d76e5c1fa8..6556ff9d18 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -50,13 +50,10 @@ jobs: - checkout - setup_environment: cache_key: leo-stable-cache - - build: - name: Build leo binary - command: cargo build - run: name: Run tests no_output_timeout: 30m - command: cargo test --all + command: cargo build && cargo test --all - persist_to_workspace: root: ~/ paths: project/ @@ -71,13 +68,10 @@ jobs: - checkout - setup_environment: cache_key: leo-nightly-cache - - build: - name: Build leo binary - command: cargo build - run: name: Run tests no_output_timeout: 30m - command: cargo test --all + command: cargo build && cargo test --all - clear_environment: cache_key: leo-nightly-cache From f520201017727341a2c702aa1c977b8737e602ac Mon Sep 17 00:00:00 2001 From: damirka Date: Mon, 26 Apr 2021 14:47:44 +0300 Subject: [PATCH 09/14] attmpt to add build to gh actions --- .github/workflows/ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 54871c0d37..e14b9d6816 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -114,6 +114,11 @@ jobs: override: true components: rustfmt + - name: Build Leo binary + uses: actions-rs/cargo@v1 + with: + command: build + - name: Test uses: actions-rs/cargo@v1 with: From 2e9be1a2bae965fdf4e05da8a1c305f0fe36a6cc Mon Sep 17 00:00:00 2001 From: damirka Date: Mon, 26 Apr 2021 16:18:34 +0300 Subject: [PATCH 10/14] attmpt to fix gh actions ci again --- .circleci/config.yml | 12 ++++++++---- .github/workflows/ci.yml | 9 +++++---- leo/tests/cmd.rs | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6556ff9d18..1fde743772 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -53,7 +53,7 @@ jobs: - run: name: Run tests no_output_timeout: 30m - command: cargo build && cargo test --all + command: LEO=/home/circleci/project/project/bin/leo cargo test --all - persist_to_workspace: root: ~/ paths: project/ @@ -71,7 +71,7 @@ jobs: - run: name: Run tests no_output_timeout: 30m - command: cargo build && cargo test --all + command: LEO=/home/circleci/project/project/bin/leo cargo test --all - clear_environment: cache_key: leo-nightly-cache @@ -214,9 +214,13 @@ workflows: version: 2 main-workflow: jobs: - - rust-stable - - rust-nightly - leo-executable + - rust-stable + requires: + - leo-executable + - rust-nightly + requires: + - leo-executable - leo-new: requires: - leo-executable diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e14b9d6816..c179dc7fd7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -114,10 +114,11 @@ jobs: override: true components: rustfmt - - name: Build Leo binary - uses: actions-rs/cargo@v1 - with: - command: build + - name: Install Leo binary and set env + run: | + cargo install --path . + export LEO=$(which leo) + printenv - name: Test uses: actions-rs/cargo@v1 diff --git a/leo/tests/cmd.rs b/leo/tests/cmd.rs index 829d1aefbe..a6823aa6f9 100644 --- a/leo/tests/cmd.rs +++ b/leo/tests/cmd.rs @@ -21,7 +21,7 @@ use test_dir::{DirBuilder, FileType, TestDir}; /// Create Command from given arguments and CWD. fn command(args: &str, cwd: Option) -> Command { let args = args.split(' ').collect::>(); - let mut cmd = Command::cargo_bin("leo").unwrap(); + let mut cmd = Command::cargo_bin("leo").unwrap_or_else(|_| Command::new(std::env::var("LEO").unwrap())); if let Some(cwd) = cwd { cmd.current_dir(cwd); From 498dc99e6cc1954506b72919c9dc571dae35146e Mon Sep 17 00:00:00 2001 From: damirka Date: Mon, 26 Apr 2021 16:20:18 +0300 Subject: [PATCH 11/14] fix circle ci config typo --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1fde743772..bb8db159cb 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -215,10 +215,10 @@ workflows: main-workflow: jobs: - leo-executable - - rust-stable + - rust-stable: requires: - leo-executable - - rust-nightly + - rust-nightly: requires: - leo-executable - leo-new: From 30fc5b97ae36c8852ce27250d9f17b7da662843c Mon Sep 17 00:00:00 2001 From: damirka Date: Mon, 26 Apr 2021 19:35:12 +0300 Subject: [PATCH 12/14] changed testing approach --- .circleci/config.yml | 12 ++-- .github/workflows/ci.yml | 6 -- leo/commands/init.rs | 5 +- leo/commands/new.rs | 8 +-- leo/commands/update.rs | 2 +- leo/logger.rs | 9 ++- leo/main.rs | 147 +++++++++++++++++++++++++++++++++++++-- leo/tests/cmd.rs | 128 ---------------------------------- leo/tests/mod.rs | 2 - 9 files changed, 161 insertions(+), 158 deletions(-) delete mode 100644 leo/tests/cmd.rs diff --git a/.circleci/config.yml b/.circleci/config.yml index bb8db159cb..1daecd3897 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -53,7 +53,7 @@ jobs: - run: name: Run tests no_output_timeout: 30m - command: LEO=/home/circleci/project/project/bin/leo cargo test --all + command: cargo test --all - persist_to_workspace: root: ~/ paths: project/ @@ -71,7 +71,7 @@ jobs: - run: name: Run tests no_output_timeout: 30m - command: LEO=/home/circleci/project/project/bin/leo cargo test --all + command: cargo test --all - clear_environment: cache_key: leo-nightly-cache @@ -214,13 +214,9 @@ workflows: version: 2 main-workflow: jobs: + - rust-stable + - rust-nightly - leo-executable - - rust-stable: - requires: - - leo-executable - - rust-nightly: - requires: - - leo-executable - leo-new: requires: - leo-executable diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c179dc7fd7..54871c0d37 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -114,12 +114,6 @@ jobs: override: true components: rustfmt - - name: Install Leo binary and set env - run: | - cargo install --path . - export LEO=$(which leo) - printenv - - name: Test uses: actions-rs/cargo@v1 with: diff --git a/leo/commands/init.rs b/leo/commands/init.rs index 2896f84630..18711d6923 100644 --- a/leo/commands/init.rs +++ b/leo/commands/init.rs @@ -18,7 +18,6 @@ use crate::{commands::Command, config::*, context::Context}; use leo_package::LeoPackage; use anyhow::{anyhow, Result}; -use std::env::current_dir; use structopt::StructOpt; use tracing::span::Span; @@ -39,9 +38,9 @@ impl Command for Init { Ok(()) } - fn apply(self, _: Context, _: Self::Input) -> Result { + fn apply(self, context: Context, _: Self::Input) -> Result { // Derive the package directory path. - let path = current_dir()?; + let path = context.dir()?; // Check that the current package directory path exists. if !path.exists() { diff --git a/leo/commands/new.rs b/leo/commands/new.rs index fe4096d062..c5b8e6ed89 100644 --- a/leo/commands/new.rs +++ b/leo/commands/new.rs @@ -18,12 +18,12 @@ use crate::{commands::Command, config::*, context::Context}; use leo_package::LeoPackage; use anyhow::{anyhow, Result}; -use std::{env::current_dir, fs}; +use std::fs; use structopt::StructOpt; use tracing::span::Span; /// Create new Leo project -#[derive(StructOpt, Debug)] +#[derive(StructOpt, Debug, PartialEq)] #[structopt(setting = structopt::clap::AppSettings::ColoredHelp)] pub struct New { #[structopt(name = "NAME", help = "Set package name")] @@ -42,7 +42,7 @@ impl Command for New { Ok(()) } - fn apply(self, _: Context, _: Self::Input) -> Result { + fn apply(self, context: Context, _: Self::Input) -> Result { // Check that the given package name is valid. let package_name = self.name; if !LeoPackage::is_package_name_valid(&package_name) { @@ -52,7 +52,7 @@ impl Command for New { let username = read_username().ok(); // Derive the package directory path. - let mut path = current_dir()?; + let mut path = context.dir()?; path.push(&package_name); // Verify the package directory path does not exist yet. diff --git a/leo/commands/update.rs b/leo/commands/update.rs index 605633b730..07b382a1a0 100644 --- a/leo/commands/update.rs +++ b/leo/commands/update.rs @@ -21,7 +21,7 @@ use structopt::StructOpt; use tracing::span::Span; /// Setting for automatic updates of Leo -#[derive(Debug, StructOpt, PartialEq)] +#[derive(Debug, StructOpt)] pub enum Automatic { Automatic { #[structopt(name = "bool", help = "Boolean value: true or false", parse(try_from_str))] diff --git a/leo/logger.rs b/leo/logger.rs index ccb9d54406..0445f39002 100644 --- a/leo/logger.rs +++ b/leo/logger.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use std::fmt; +use std::{fmt, sync::Once}; use colored::Colorize; use tracing::{event::Event, subscriber::Subscriber}; @@ -24,6 +24,8 @@ use tracing_subscriber::{ FmtSubscriber, }; +static START: Once = Once::new(); + #[derive(Debug, Clone)] pub struct Format { format: F, @@ -220,5 +222,8 @@ pub fn init_logger(_app_name: &'static str, verbosity: usize) { .event_format(Format::default()) .finish(); - tracing::subscriber::set_global_default(subscriber).expect("setting default subscriber failed"); + // call this line only once per process. needed for tests using same thread + START.call_once(|| { + tracing::subscriber::set_global_default(subscriber).expect("setting default subscriber failed"); + }); } diff --git a/leo/main.rs b/leo/main.rs index 73589df29d..5c9a5655c8 100644 --- a/leo/main.rs +++ b/leo/main.rs @@ -181,9 +181,11 @@ enum CommandOpts { } fn main() { - // Read command line arguments. - let opt = Opt::from_args(); + handle_error(run_with_args(Opt::from_args())) +} +/// Run command with custom build arguments. +fn run_with_args(opt: Opt) -> Result<(), Error> { if !opt.quiet { // Init logger with optional debug flag. logger::init_logger("leo", match opt.debug { @@ -199,7 +201,7 @@ fn main() { None => context::get_context(opt.api), }); - handle_error(match opt.command { + match opt.command { CommandOpts::Init { command } => command.try_execute(context), CommandOpts::New { command } => command.try_execute(context), CommandOpts::Build { command } => command.try_execute(context), @@ -220,7 +222,7 @@ fn main() { CommandOpts::Lint { command } => command.try_execute(context), CommandOpts::Deploy { command } => command.try_execute(context), - }); + } } fn handle_error(res: Result) -> T { @@ -232,3 +234,140 @@ fn handle_error(res: Result) -> T { } } } + +#[cfg(test)] +mod cli_tests { + use crate::{run_with_args, Opt}; + + use anyhow::Error; + use std::path::PathBuf; + use structopt::StructOpt; + use test_dir::{DirBuilder, FileType, TestDir}; + + // Runs Command from cmd-like argument "leo run --arg1 --arg2". + fn run_cmd(args: &str, path: &Option) -> Result<(), Error> { + let args = args.split(' ').collect::>(); + let mut opts = Opt::from_iter_safe(args)?; + + if path.is_some() { + opts.path = path.clone(); + } + + if !opts.debug { + // turn off tracing for all tests + opts.quiet = true; + } + + run_with_args(opts) + } + + // Create a test directory with name. + fn testdir(name: &str) -> TestDir { + TestDir::temp().create(name, FileType::Dir) + } + + #[test] + fn global_options() { + let path = Some(PathBuf::from("examples/pedersen-hash")); + + assert!(run_cmd("leo build", &path).is_ok()); + assert!(run_cmd("leo -q build", &path).is_ok()); + + assert!(run_cmd("leo --path ../../examples/no-directory-there build", &None).is_err()); + assert!(run_cmd("leo -v build", &None).is_err()); + } + + #[test] + fn global_options_fail() { + assert!(run_cmd("leo --path ../../examples/no-directory-there build", &None).is_err()); + assert!(run_cmd("leo -v build", &None).is_err()); + } + + #[test] + fn init() { + let dir = testdir("test"); + let path = Some(dir.path("test")); + + assert!(run_cmd("leo init", &path).is_ok()); + assert!(run_cmd("leo init", &path).is_err()); // 2nd time + } + + #[test] + fn init_fail() { + let dir = testdir("incorrect_name"); + let path = Some(dir.path("incorrect_name")); + let fake = Some(PathBuf::from("no_such_directory")); + + assert!(run_cmd("leo init", &fake).is_err()); + assert!(run_cmd("leo init", &path).is_err()); + } + + #[test] + fn new() { + let dir = testdir("new"); + let path = Some(dir.path("new")); + + assert!(run_cmd("leo new test", &path).is_ok()); + assert!(run_cmd("leo new test", &path).is_err()); // 2nd time + assert!(run_cmd("leo new wrong_name", &path).is_err()); + } + + #[test] + #[should_panic] + fn unimplemented() { + assert!(run_cmd("leo lint", &None).is_err()); + assert!(run_cmd("leo deploy", &None).is_err()); + } + + #[test] + fn clean() { + let path = &Some(PathBuf::from("examples/pedersen-hash")); + + assert!(run_cmd("leo build", path).is_ok()); + assert!(run_cmd("leo clean", path).is_ok()); + } + + #[test] + fn setup_prove_run_clean() { + let dir = testdir("test"); + let path = dir.path("test"); + + assert!(run_cmd("leo new setup-test", &Some(path.clone())).is_ok()); + + let setup_path = &Some(path.join("setup-test")); + + assert!(run_cmd("leo setup", setup_path).is_ok()); + assert!(run_cmd("leo setup", setup_path).is_ok()); + assert!(run_cmd("leo setup --skip-key-check", setup_path).is_ok()); + assert!(run_cmd("leo prove --skip-key-check", setup_path).is_ok()); + assert!(run_cmd("leo run --skip-key-check", setup_path).is_ok()); + assert!(run_cmd("leo clean", setup_path).is_ok()); + } + + #[test] + fn test_missing_file() { + let dir = testdir("test"); + let path = dir.path("test"); + + assert!(run_cmd("leo new test-file-missing", &Some(path.clone())).is_ok()); + + let path = path.join("test-file-missing"); + let file = path.clone().join("src/main.leo"); + let path = Some(path); + + assert!(run_cmd("leo test", &path).is_ok()); + std::fs::remove_file(&file).unwrap(); + assert!(run_cmd("leo test", &path).is_err()); + } + + #[test] + #[ignore] // ignore until imports path is fixed #875 + fn test_sudoku() { + let path = &Some(PathBuf::from("examples/silly-sudoku")); + + assert!(run_cmd("leo build", path).is_ok()); + assert!(run_cmd("leo test", path).is_ok()); + assert!(run_cmd("leo test -f src/lib.leo", path).is_ok()); + assert!(run_cmd("leo test -f src/main.leo", path).is_ok()); + } +} diff --git a/leo/tests/cmd.rs b/leo/tests/cmd.rs deleted file mode 100644 index a6823aa6f9..0000000000 --- a/leo/tests/cmd.rs +++ /dev/null @@ -1,128 +0,0 @@ -// Copyright (C) 2019-2021 Aleo Systems Inc. -// This file is part of the Leo library. - -// The Leo library is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// The Leo library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with the Leo library. If not, see . - -use assert_cmd::Command; -use std::path::PathBuf; -use test_dir::{DirBuilder, FileType, TestDir}; - -/// Create Command from given arguments and CWD. -fn command(args: &str, cwd: Option) -> Command { - let args = args.split(' ').collect::>(); - let mut cmd = Command::cargo_bin("leo").unwrap_or_else(|_| Command::new(std::env::var("LEO").unwrap())); - - if let Some(cwd) = cwd { - cmd.current_dir(cwd); - } - - cmd.args(args); - cmd -} - -fn expect_success(args: &str, cwd: Option) { - command(args, cwd).unwrap(); -} - -fn expect_fail(args: &str, cwd: Option) { - command(args, cwd).unwrap_err(); -} - -#[test] -fn test_global_options() { - expect_success("--path examples/pedersen-hash build", None); - expect_success("--path examples/pedersen-hash -q build", None); - expect_success("--path examples/pedersen-hash -d build", None); - - expect_fail("--path examples/no-directory-there build", None); - expect_fail("-v build", None); // no such option -} - -#[test] -fn init() { - let dir = TestDir::temp().create("init", FileType::Dir); - let dir = Some(dir.path("init")); - - expect_success("init", dir.clone()); - expect_fail("init", dir); // can't do twice -} - -#[test] -fn init_fail() { - let dir = TestDir::temp().create("incorrect_name", FileType::Dir); - let dir = Some(dir.path("incorrect_name")); - - expect_fail("init", Some("directory-doesnt-exist".into())); - expect_fail("init", dir); -} - -#[test] -fn new() { - let dir = TestDir::temp().create("new", FileType::Dir); - let dir = Some(dir.path("new")); - - expect_success("new test", dir.clone()); - expect_fail("new test", dir.clone()); // duplicate - expect_fail("new wrong_name123123", dir); -} - -#[test] -fn unimplemented() { - expect_fail("lint", None); - expect_fail("deploy", None); -} - -#[test] -fn clean() { - expect_success("--path examples/pedersen-hash build", None); - expect_success("--path examples/pedersen-hash clean", None); -} - -#[test] -fn setup_prove_run_clean() { - let dir = TestDir::temp().create("test", FileType::Dir); - let dir = dir.path("test"); - - expect_success("new setup", Some(dir.clone())); - - // 'cd' into newly created setup directory - let new_dir = Some(dir.join("setup")); - - expect_success("setup", new_dir.clone()); - expect_success("setup", new_dir.clone()); - expect_success("setup --skip-key-check", new_dir.clone()); - expect_success("prove --skip-key-check", new_dir.clone()); - expect_success("run --skip-key-check", new_dir.clone()); - expect_success("clean", new_dir); -} - -#[test] -fn test_sudoku() { - let path = "examples/silly-sudoku"; - - expect_success("build", Some(path.into())); - expect_success("test", Some(path.into())); - expect_success("test -f src/lib.leo", Some(path.into())); - expect_success("test -f src/main.leo", Some(path.into())); -} - -#[test] -fn test_missing_file() { - let path = TestDir::temp().create("test", FileType::Dir); - let path = path.path("test"); - - expect_success("new missing-file-test", Some(path.clone())); - std::fs::remove_file(&path.join("missing-file-test/src/main.leo")).unwrap(); - expect_fail("test", Some(path.join("missing-file"))); -} diff --git a/leo/tests/mod.rs b/leo/tests/mod.rs index 1f25aced37..9fec776ed7 100644 --- a/leo/tests/mod.rs +++ b/leo/tests/mod.rs @@ -14,8 +14,6 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -mod cmd; - use anyhow::Result; use std::path::PathBuf; From 296b92acf6cac3a071d2a940e49e67763c9538a7 Mon Sep 17 00:00:00 2001 From: damirka Date: Mon, 26 Apr 2021 19:37:29 +0300 Subject: [PATCH 13/14] final fixes --- .circleci/config.yml | 4 ++-- leo/commands/new.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1daecd3897..da084c94e1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -51,7 +51,7 @@ jobs: - setup_environment: cache_key: leo-stable-cache - run: - name: Run tests + name: Build and run tests no_output_timeout: 30m command: cargo test --all - persist_to_workspace: @@ -69,7 +69,7 @@ jobs: - setup_environment: cache_key: leo-nightly-cache - run: - name: Run tests + name: Build and test no_output_timeout: 30m command: cargo test --all - clear_environment: diff --git a/leo/commands/new.rs b/leo/commands/new.rs index c5b8e6ed89..9f72988bb4 100644 --- a/leo/commands/new.rs +++ b/leo/commands/new.rs @@ -23,7 +23,7 @@ use structopt::StructOpt; use tracing::span::Span; /// Create new Leo project -#[derive(StructOpt, Debug, PartialEq)] +#[derive(StructOpt, Debug)] #[structopt(setting = structopt::clap::AppSettings::ColoredHelp)] pub struct New { #[structopt(name = "NAME", help = "Set package name")] From ef277c85b5d97f9ec538bd450eaabe2ebb0e1708 Mon Sep 17 00:00:00 2001 From: damirka Date: Mon, 26 Apr 2021 19:55:54 +0300 Subject: [PATCH 14/14] clippy --- leo/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/leo/main.rs b/leo/main.rs index 5c9a5655c8..7a69c7f616 100644 --- a/leo/main.rs +++ b/leo/main.rs @@ -352,7 +352,7 @@ mod cli_tests { assert!(run_cmd("leo new test-file-missing", &Some(path.clone())).is_ok()); let path = path.join("test-file-missing"); - let file = path.clone().join("src/main.leo"); + let file = path.join("src/main.leo"); let path = Some(path); assert!(run_cmd("leo test", &path).is_ok());