From 353818ef38b09e7362502171039c32d0c47d01fc Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Tue, 8 Oct 2024 13:34:26 +0700 Subject: [PATCH 01/11] chore: Update vscode extension recommendations --- .vscode/extensions.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 9fff89180..cc32c5923 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -14,7 +14,6 @@ "tamasfe.even-better-toml", "rust-lang.rust-analyzer", "JScearcy.rust-doc-viewer", - "serayuzgur.crates", "bierner.markdown-checkbox", "bierner.markdown-emoji", "bierner.markdown-footnotes", @@ -24,5 +23,7 @@ "foxundermoon.shell-format", "dtsvet.vscode-wasm", "terrastruct.d2", + "tintinweb.graphviz-interactive-preview", + "fill-labs.dependi" ] } \ No newline at end of file From 1906c736fb4b88326c83d9a62155b64fe9bdebb2 Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Tue, 8 Oct 2024 13:40:45 +0700 Subject: [PATCH 02/11] chore(general): Update PR Scopes --- .github/workflows/semantic_pull_request.yml | 9 +++++++++ .vscode/settings.recommended.json | 14 +++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/.github/workflows/semantic_pull_request.yml b/.github/workflows/semantic_pull_request.yml index 6c0fedb69..1f2b0eba2 100644 --- a/.github/workflows/semantic_pull_request.yml +++ b/.github/workflows/semantic_pull_request.yml @@ -12,3 +12,12 @@ jobs: build: name: Validate PR title uses: input-output-hk/catalyst-ci/.github/workflows/semantic_pull_request.yml@master + with: + requireScope: true + scopes: | + dashboard + hermes + docs + wasm + utils + general diff --git a/.vscode/settings.recommended.json b/.vscode/settings.recommended.json index 912a9ca09..4157109b3 100644 --- a/.vscode/settings.recommended.json +++ b/.vscode/settings.recommended.json @@ -34,16 +34,12 @@ }, "window.title": "${dirty}${activeEditorShort}", "conventionalCommits.scopes": [ - "vscode", - "hermes", "dashboard", - "hermes-lib", - "mdlint", - "languages", - "spelling", - "issues", - "gateway", - "docs" + "hermes", + "docs", + "wasm", + "utils", + "general" ], "conventionalCommits.gitmoji": false, "markdown.extension.toc.unorderedList.marker": "*", From 43ce74b5d374d108349923bd65e1d6c2e0c320be Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Tue, 8 Oct 2024 13:45:35 +0700 Subject: [PATCH 03/11] chore(general): Update recommended settings for dependi for rust. --- .vscode/settings.recommended.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.vscode/settings.recommended.json b/.vscode/settings.recommended.json index 4157109b3..0bcaceb0a 100644 --- a/.vscode/settings.recommended.json +++ b/.vscode/settings.recommended.json @@ -76,5 +76,7 @@ "rust-analyzer.rustfmt.extraArgs": [ "+nightly" ], - "rust-analyzer.lens.enable": true + "rust-analyzer.lens.enable": true, + "dependi.rust.informPatchUpdates": true, + "dependi.decoration.compatible.style": null } \ No newline at end of file From 2fada3f571d3915d3a3eb2643e2713372d616735 Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Tue, 8 Oct 2024 22:23:31 +0700 Subject: [PATCH 04/11] chore(general): Update cat-ci version, and add basic Justfiles --- .config/dictionaries/project.dic | 20 +++------ .markdownlint.jsonc | 2 +- Earthfile | 9 ++-- docs/Earthfile | 2 +- hermes/Earthfile | 8 +++- hermes/Justfile | 45 +++++++++++++++++++ hermes/rust-toolchain.toml | 3 +- justfile | 25 +++++++++++ wasm/.cspell.json | 2 +- wasm/integration-test/cardano/Earthfile | 2 +- wasm/integration-test/clocks/Earthfile | 2 +- wasm/integration-test/cron/Earthfile | 2 +- wasm/integration-test/crypto/Earthfile | 2 +- wasm/integration-test/golang/Earthfile | 2 +- wasm/integration-test/hashing/Earthfile | 2 +- wasm/integration-test/http_reply/Earthfile | 2 +- wasm/integration-test/ipfs/Earthfile | 2 +- wasm/integration-test/localtime/Earthfile | 2 +- wasm/integration-test/logger/Earthfile | 2 +- wasm/integration-test/smoke-test/Earthfile | 2 +- wasm/integration-test/sqlite/Earthfile | 2 +- .../wasi-filesystem/Earthfile | 2 +- wasm/stub-module/Earthfile | 2 +- wasm/wasi-hermes-component-adapter/Earthfile | 2 +- 24 files changed, 108 insertions(+), 38 deletions(-) create mode 100644 hermes/Justfile create mode 100644 justfile diff --git a/.config/dictionaries/project.dic b/.config/dictionaries/project.dic index 13d0d6f5c..d5f2a2527 100644 --- a/.config/dictionaries/project.dic +++ b/.config/dictionaries/project.dic @@ -1,6 +1,5 @@ aarch abnf -ABNF addrr adminer apskhem @@ -18,12 +17,10 @@ BROTLI cantopen cardano cbor -CBOR cbork cdylib CEST CHAINCODE -chaincode chainsync childs chrono @@ -38,8 +35,6 @@ crontagged cstring dalek dashmap -dashmap -Datelike Datelike DBSTATUS dbsync @@ -83,24 +78,23 @@ highwater hmod ideascale idents -ipfs -ipld IFMT Intellij ioerr iohk ipfs +ipld jetbrains -jsonschema jorm jormungandr Jörmungandr +jsonschema lcov Leshiy -libsqlite -libtest libipld libp2p +libsqlite +libtest linkat lintfix lipsum @@ -121,6 +115,7 @@ moderations Multiaddr multiera nanos +nbaz netkey nextest nolfs @@ -140,8 +135,8 @@ plpgsql pollable Pozhylenkov pread -preopened preopen +preopened preopens preprod psql @@ -159,7 +154,6 @@ renameat retriggering rulelist rulename -RULENAME rustc rustdoc rustdocflags @@ -203,13 +197,11 @@ voteplan voteplans wasi wasip -WASI wasmtime webasm webassembly WORKDIR xprivate XPRV -xprv xpub yoroi diff --git a/.markdownlint.jsonc b/.markdownlint.jsonc index a83548c02..be69f34a4 100644 --- a/.markdownlint.jsonc +++ b/.markdownlint.jsonc @@ -1,7 +1,7 @@ { // markdownlint JSON(C) configuration for Catalyst Standards // Do not individually set markdown lint rules in documents. - // It is permissable to disable a rule in a document if it is a false positive. + // It is permissible to disable a rule in a document if it is a false positive. // Keep the scope of the lint disable to as small as possible. // See: https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md // Default state for all rules diff --git a/Earthfile b/Earthfile index aa159fa37..6e6ddaa60 100644 --- a/Earthfile +++ b/Earthfile @@ -1,7 +1,7 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/mdlint:v3.1.24 AS mdlint-ci -IMPORT github.com/input-output-hk/catalyst-ci/earthly/cspell:v3.1.24 AS cspell-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/mdlint:v3.2.15 AS mdlint-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/cspell:v3.2.15 AS cspell-ci FROM debian:stable-slim @@ -17,6 +17,10 @@ markdown-check-fix: DO mdlint-ci+MDLINT_LOCALLY --src=$(echo ${PWD}) --fix=--fix +# clean-spelling-list : Make sure the project dictionary is properly sorted. +clean-spelling-list: + DO cspell-ci+CLEAN + # check-spelling : Check spelling in this repo inside a container. check-spelling: DO cspell-ci+CHECK @@ -30,7 +34,6 @@ spell-list-words: RUN cspell-cli --words-only --unique "wasm/**" | sort -f - # repo-docs : target to store the documentation from the root of the repo. repo-docs: # Create artifacts of extra files we embed inside the documentation when its built. diff --git a/docs/Earthfile b/docs/Earthfile index 308496b05..be2670947 100644 --- a/docs/Earthfile +++ b/docs/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/docs:v3.2.03 AS docs-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/docs:v3.2.15 AS docs-ci IMPORT .. AS repo IMPORT ../hermes AS hermes diff --git a/hermes/Earthfile b/hermes/Earthfile index 1f5eea940..566694021 100644 --- a/hermes/Earthfile +++ b/hermes/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.2.03 AS rust-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.2.15 AS rust-ci # Use when debugging cat-ci locally. # IMPORT ../../catalyst-ci/earthly/rust AS rust-ci @@ -19,6 +19,12 @@ builder: # Compiled WASM component for benchmarks COPY stub-module+build/stub.wasm /wasm/stub-module/stub.wasm +# sync-cfg: Synchronize local config with CI version. +# Must be run by the developer manually. +sync-cfg: + FROM +builder + DO rust-ci+SYNC_STD_CFG + # bindings-expand : Expands `wasmtime::bindgen!` macro into the `bindings.rs` file bindings-expand: FROM +builder diff --git a/hermes/Justfile b/hermes/Justfile new file mode 100644 index 000000000..25e7e2b2f --- /dev/null +++ b/hermes/Justfile @@ -0,0 +1,45 @@ +# use with https://github.com/casey/just +# +# Hermes developer convenience functions + +# cspell: words prereqs, commitlog, rustls, nocapture + +default: + @just --list --unsorted + +# Show the dependency tree and all enabled feature flags of every crate. +cargo-tree: + cargo tree -e features,normal,build -f "{p}[{f}]" --workspace --frozen + +# Check Dependency licenses and CVE's +license-check: + cargo deny check --exclude-dev + +# Format the rust code +code-format: + cargo +nightly fmtfix + cargo +nightly fmtchk + +# Lint the rust code +code-lint: + cargo lintfix -r + cargo lint -r + +# Synchronize Rust Configs +sync-cfg: + cd .. && earthly ./hermes+sync-cfg + +# Pre Push Checks +pre-push: sync-cfg code-format code-lint license-check + # Make sure we can actually build inside Earthly which needs to happen in CI. + cd .. && earthly ./hermes+check + cd .. && earthly ./hermes+build + +# Build Local release build of catalyst gateway +build-hermes: code-format code-lint + cargo update + cargo build -r + +# Run hermes +run-hermes: build-hermes + ./target/release/hermes run diff --git a/hermes/rust-toolchain.toml b/hermes/rust-toolchain.toml index ff6c11e3f..20a42f2a9 100644 --- a/hermes/rust-toolchain.toml +++ b/hermes/rust-toolchain.toml @@ -1,4 +1,3 @@ [toolchain] channel = "1.80" -profile = "default" -targets = ["x86_64-unknown-linux-musl"] +profile = "default" \ No newline at end of file diff --git a/justfile b/justfile new file mode 100644 index 000000000..4cd37e828 --- /dev/null +++ b/justfile @@ -0,0 +1,25 @@ +# use with https://github.com/casey/just +# + +# cspell: words prereqs, commitlog + +default: + @just --list --unsorted + + +# Fix and Check Markdown files +check-markdown: + earthly +markdown-check-fix + +# Check Spelling +check-spelling: + earthly +clean-spelling-list + earthly +check-spelling + +# Pre Push Checks - intended to be run by a git pre-push hook. +pre-push: check-markdown check-spelling + just hermes/pre-push + +# Run hermes locally +run-hermes: + just hermes/run-hermes diff --git a/wasm/.cspell.json b/wasm/.cspell.json index c2e1db6d0..cbd307e7e 100644 --- a/wasm/.cspell.json +++ b/wasm/.cspell.json @@ -1,5 +1,5 @@ { - "$schema": "https: //raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json", + "$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json", "version": "0.2", "words": [ "ABSTIME", diff --git a/wasm/integration-test/cardano/Earthfile b/wasm/integration-test/cardano/Earthfile index 858e61618..777ad3951 100644 --- a/wasm/integration-test/cardano/Earthfile +++ b/wasm/integration-test/cardano/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.2.03 AS rust-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.2.15 AS rust-ci # Use when debugging cat-ci locally. # IMPORT ../../catalyst-ci/earthly/rust AS rust-ci diff --git a/wasm/integration-test/clocks/Earthfile b/wasm/integration-test/clocks/Earthfile index f68197dec..d68d86a68 100644 --- a/wasm/integration-test/clocks/Earthfile +++ b/wasm/integration-test/clocks/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/wasm/c:v3.2.03 AS wasm-c-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/wasm/c:v3.2.15 AS wasm-c-ci # Use when debugging cat-ci locally. # IMPORT ../../../catalyst-ci/earthly/wasm/c AS wasm-c-ci diff --git a/wasm/integration-test/cron/Earthfile b/wasm/integration-test/cron/Earthfile index 7d1b6ccf0..64f8450f5 100644 --- a/wasm/integration-test/cron/Earthfile +++ b/wasm/integration-test/cron/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/wasm/c:v3.2.03 AS wasm-c-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/wasm/c:v3.2.15 AS wasm-c-ci # Use when debugging cat-ci locally. # IMPORT ../../../catalyst-ci/earthly/wasm/c AS wasm-c-ci diff --git a/wasm/integration-test/crypto/Earthfile b/wasm/integration-test/crypto/Earthfile index 8a63a362e..9b09b2e9e 100644 --- a/wasm/integration-test/crypto/Earthfile +++ b/wasm/integration-test/crypto/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/wasm/c:v3.2.03 AS wasm-c-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/wasm/c:v3.2.15 AS wasm-c-ci # Use when debugging cat-ci locally. # IMPORT ../../../catalyst-ci/earthly/wasm/c AS wasm-c-ci diff --git a/wasm/integration-test/golang/Earthfile b/wasm/integration-test/golang/Earthfile index 155b66181..0011450a2 100644 --- a/wasm/integration-test/golang/Earthfile +++ b/wasm/integration-test/golang/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust/tools:v3.2.03 AS rust-tools +IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust/tools:v3.2.15 AS rust-tools IMPORT ../../wasi AS wasi IMPORT ../../wasi-hermes-component-adapter AS wasi-hermes-component-adapter diff --git a/wasm/integration-test/hashing/Earthfile b/wasm/integration-test/hashing/Earthfile index a80eb9b91..495ce203d 100644 --- a/wasm/integration-test/hashing/Earthfile +++ b/wasm/integration-test/hashing/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/wasm/c:v3.2.03 AS wasm-c-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/wasm/c:v3.2.15 AS wasm-c-ci # Use when debugging cat-ci locally. # IMPORT ../../../catalyst-ci/earthly/wasm/c AS wasm-c-ci diff --git a/wasm/integration-test/http_reply/Earthfile b/wasm/integration-test/http_reply/Earthfile index 9462f86f8..2096a4181 100644 --- a/wasm/integration-test/http_reply/Earthfile +++ b/wasm/integration-test/http_reply/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.2.03 AS rust-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.2.15 AS rust-ci # Use when debugging cat-ci locally. # IMPORT ../../catalyst-ci/earthly/rust AS rust-ci diff --git a/wasm/integration-test/ipfs/Earthfile b/wasm/integration-test/ipfs/Earthfile index 9477d535a..e2f7ca729 100644 --- a/wasm/integration-test/ipfs/Earthfile +++ b/wasm/integration-test/ipfs/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.2.03 AS rust-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.2.15 AS rust-ci # Use when debugging cat-ci locally. # IMPORT ../../catalyst-ci/earthly/rust AS rust-ci diff --git a/wasm/integration-test/localtime/Earthfile b/wasm/integration-test/localtime/Earthfile index 242f80122..b25459fcb 100644 --- a/wasm/integration-test/localtime/Earthfile +++ b/wasm/integration-test/localtime/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/wasm/c:v3.2.03 AS wasm-c-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/wasm/c:v3.2.15 AS wasm-c-ci # Use when debugging cat-ci locally. # IMPORT ../../../catalyst-ci/earthly/wasm/c AS wasm-c-ci diff --git a/wasm/integration-test/logger/Earthfile b/wasm/integration-test/logger/Earthfile index add3dbd4a..40600be0e 100644 --- a/wasm/integration-test/logger/Earthfile +++ b/wasm/integration-test/logger/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/wasm/c:v3.2.03 AS wasm-c-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/wasm/c:v3.2.15 AS wasm-c-ci # Use when debugging cat-ci locally. # IMPORT ../../../catalyst-ci/earthly/wasm/c AS wasm-c-ci diff --git a/wasm/integration-test/smoke-test/Earthfile b/wasm/integration-test/smoke-test/Earthfile index 8f591aab3..8c347b2d6 100644 --- a/wasm/integration-test/smoke-test/Earthfile +++ b/wasm/integration-test/smoke-test/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/wasm/c:v3.2.03 AS wasm-c-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/wasm/c:v3.2.15 AS wasm-c-ci # Use when debugging cat-ci locally. # IMPORT ../../../catalyst-ci/earthly/wasm/c AS wasm-c-ci diff --git a/wasm/integration-test/sqlite/Earthfile b/wasm/integration-test/sqlite/Earthfile index 3f2622716..147b0cb8c 100644 --- a/wasm/integration-test/sqlite/Earthfile +++ b/wasm/integration-test/sqlite/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.2.03 AS rust-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.2.15 AS rust-ci # Use when debugging cat-ci locally. # IMPORT ../../catalyst-ci/earthly/rust AS rust-ci diff --git a/wasm/integration-test/wasi-filesystem/Earthfile b/wasm/integration-test/wasi-filesystem/Earthfile index e76909d30..35405f7b4 100644 --- a/wasm/integration-test/wasi-filesystem/Earthfile +++ b/wasm/integration-test/wasi-filesystem/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.2.03 AS rust-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.2.15 AS rust-ci # Use when debugging cat-ci locally. # IMPORT ../../catalyst-ci/earthly/rust AS rust-ci diff --git a/wasm/stub-module/Earthfile b/wasm/stub-module/Earthfile index 4117b870e..6f6901d0c 100644 --- a/wasm/stub-module/Earthfile +++ b/wasm/stub-module/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/wasm/c:v3.2.03 AS wasm-c-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/wasm/c:v3.2.15 AS wasm-c-ci # Use when debugging cat-ci locally. # IMPORT ../../../catalyst-ci/earthly/wasm/c AS wasm-c-ci diff --git a/wasm/wasi-hermes-component-adapter/Earthfile b/wasm/wasi-hermes-component-adapter/Earthfile index 65a8d75f9..d4a8500f9 100644 --- a/wasm/wasi-hermes-component-adapter/Earthfile +++ b/wasm/wasi-hermes-component-adapter/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.2.03 AS rust-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.2.15 AS rust-ci # Use when debugging cat-ci locally. # IMPORT ../../catalyst-ci/earthly/rust AS rust-ci From d2252d937270d10e64b11e53a053166fa4c033cb Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Tue, 8 Oct 2024 22:25:23 +0700 Subject: [PATCH 05/11] fix(hermes): Update rust toolchain version --- hermes/rust-toolchain.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hermes/rust-toolchain.toml b/hermes/rust-toolchain.toml index 20a42f2a9..f01d02df3 100644 --- a/hermes/rust-toolchain.toml +++ b/hermes/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.80" +channel = "1.81" profile = "default" \ No newline at end of file From de5e1ca9063a5857fa8d65ba93dbd82ddb9123e5 Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Tue, 8 Oct 2024 22:29:33 +0700 Subject: [PATCH 06/11] fix(hermes): lint issues --- .../runtime_extensions/hermes/cron/state.rs | 20 +++---------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/hermes/bin/src/runtime_extensions/hermes/cron/state.rs b/hermes/bin/src/runtime_extensions/hermes/cron/state.rs index 5340e364a..96fbfc5a6 100644 --- a/hermes/bin/src/runtime_extensions/hermes/cron/state.rs +++ b/hermes/bin/src/runtime_extensions/hermes/cron/state.rs @@ -84,12 +84,7 @@ impl InternalState { self.cron_queue .spawn_cron_job(CronJob::Add(app_name.clone(), crontab, cmd_tx)), ); - if let Ok(resp) = cmd_rx.blocking_recv() { - resp - } else { - // TODO (@saibatizoku): log error https://github.com/input-output-hk/hermes/issues/15 - false - } + cmd_rx.blocking_recv().unwrap_or(false) } /// Schedule a single cron event after a fixed delay. @@ -151,11 +146,7 @@ impl InternalState { .spawn_cron_job(CronJob::List(app_name.clone(), tag, cmd_tx)), ); // TODO (@@saibatizoku): log error https://github.com/input-output-hk/hermes/issues/15 - if let Ok(resp) = cmd_rx.blocking_recv() { - resp - } else { - vec![] - } + cmd_rx.blocking_recv().unwrap_or_default() } /// Remove the requested crontab. @@ -177,12 +168,7 @@ impl InternalState { self.cron_queue .spawn_cron_job(CronJob::Remove(app_name.clone(), entry, cmd_tx)), ); - if let Ok(resp) = cmd_rx.blocking_recv() { - resp - } else { - // TODO (@saibatizoku): log error https://github.com/input-output-hk/hermes/issues/15 - false - } + cmd_rx.blocking_recv().unwrap_or(false) } } From 7a0741553172b09074142ef020717acb5f413586 Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Wed, 9 Oct 2024 18:50:33 +0700 Subject: [PATCH 07/11] chore(hermes): Remove cbork, which is now located in catalyst-libs --- hermes/crates/cbork/.cargo/config.toml | 93 --------- hermes/crates/cbork/.config/nextest.toml | 49 ----- hermes/crates/cbork/Cargo.toml | 45 ----- hermes/crates/cbork/Earthfile | 50 ----- hermes/crates/cbork/README.md | 20 -- hermes/crates/cbork/abnf-parser/Cargo.toml | 17 -- .../abnf-parser/src/grammar/abnf_test.pest | 71 ------- .../abnf-parser/src/grammar/rfc_5234.pest | 89 --------- hermes/crates/cbork/abnf-parser/src/lib.rs | 93 --------- .../tests/abnf/invalid_abnf_sample_1.abnf | 1 - .../tests/abnf/valid_abnf_rfc3339.abnf | 14 -- .../tests/abnf/valid_abnf_rfc5234.abnf | 61 ------ .../tests/abnf/valid_abnf_rfc5234_core.abnf | 54 ----- .../tests/abnf/valid_abnf_rfc8610.abnf | 99 ---------- .../cbork/abnf-parser/tests/testsuite/abnf.rs | 52 ----- .../tests/testsuite/alternations.rs | 40 ---- .../tests/testsuite/character_sets.rs | 30 --- .../abnf-parser/tests/testsuite/comments.rs | 61 ------ .../abnf-parser/tests/testsuite/common/mod.rs | 17 -- .../abnf-parser/tests/testsuite/elements.rs | 44 ----- .../abnf-parser/tests/testsuite/groups.rs | 42 ---- .../tests/testsuite/identifiers.rs | 22 --- .../cbork/abnf-parser/tests/testsuite/main.rs | 11 -- .../tests/testsuite/repetitions.rs | 42 ---- .../abnf-parser/tests/testsuite/rules.rs | 50 ----- .../abnf-parser/tests/testsuite/values.rs | 149 -------------- hermes/crates/cbork/cddl-parser/Cargo.toml | 17 -- .../cddl-parser/src/grammar/cddl_modules.pest | 1 - .../cddl-parser/src/grammar/cddl_test.pest | 101 ---------- .../cddl-parser/src/grammar/postlude.cddl | 50 ----- .../cddl-parser/src/grammar/rfc_8610.pest | 186 ------------------ .../cddl-parser/src/grammar/rfc_9165.pest | 1 - hermes/crates/cbork/cddl-parser/src/lib.rs | 161 --------------- .../cbork/cddl-parser/tests/byte_sequences.rs | 24 --- hermes/crates/cbork/cddl-parser/tests/cddl.rs | 52 ----- .../tests/cddl/invalid_rfc8610_sample_1.cddl | 1 - .../tests/cddl/invalid_rfc8610_sample_2.cddl | 4 - .../tests/cddl/invalid_rfc8610_sample_3.cddl | 5 - .../tests/cddl/invalid_rfc8610_sample_4.cddl | 2 - .../tests/cddl/invalid_rfc8610_sample_5.cddl | 1 - .../tests/cddl/invalid_rfc8610_sample_6.cddl | 1 - .../tests/cddl/invalid_rfc8610_sample_7.cddl | 1 - .../tests/cddl/invalid_rfc8610_sample_8.cddl | 1 - .../tests/cddl/invalid_rfc8610_sample_9.cddl | 2 - .../tests/cddl/valid_rfc8610_arrays.cddl | 11 -- .../tests/cddl/valid_rfc8610_ctrl_bits.cddl | 19 -- .../tests/cddl/valid_rfc8610_ctrl_ord.cddl | 8 - .../tests/cddl/valid_rfc8610_ctrl_regexp.cddl | 7 - .../tests/cddl/valid_rfc8610_ctrl_size.cddl | 8 - .../cddl/valid_rfc8610_ctrl_within_and.cddl | 9 - .../cddl/valid_rfc8610_cuts_in_maps.cddl | 8 - .../valid_rfc8610_cuts_in_maps_alt_1.cddl | 8 - .../valid_rfc8610_cuts_in_maps_alt_2.cddl | 8 - .../valid_rfc8610_cuts_in_maps_alt_3.cddl | 8 - .../valid_rfc8610_example_array_object.cddl | 10 - .../valid_rfc8610_example_nested_object.cddl | 22 --- ...rfc8610_example_nested_object_compact.cddl | 12 -- .../tests/cddl/valid_rfc8610_generics.cddl | 4 - .../cddl/valid_rfc8610_group_to_choice.cddl | 13 -- ...valid_rfc8610_non_deterministic_order.cddl | 13 -- .../tests/cddl/valid_rfc8610_occurence.cddl | 7 - .../cddl/valid_rfc8610_op_precedence.cddl | 21 -- .../tests/cddl/valid_rfc8610_ranges.cddl | 16 -- .../valid_rfc8610_represenation_types.cddl | 12 -- .../cddl/valid_rfc8610_reputon_compact.cddl | 19 -- .../cddl/valid_rfc8610_reputon_full.cddl | 40 ---- .../tests/cddl/valid_rfc8610_simple_1.cddl | 9 - .../tests/cddl/valid_rfc8610_simple_2.cddl | 9 - .../tests/cddl/valid_rfc8610_simple_3.cddl | 13 -- .../tests/cddl/valid_rfc8610_simple_4.cddl | 9 - .../tests/cddl/valid_rfc8610_simple_5.cddl | 15 -- .../tests/cddl/valid_rfc8610_simple_6.cddl | 18 -- .../tests/cddl/valid_rfc8610_simple_7.cddl | 17 -- .../tests/cddl/valid_rfc8610_simple_8.cddl | 9 - .../tests/cddl/valid_rfc8610_simple_9.cddl | 9 - .../tests/cddl/valid_rfc8610_socket_plug.cddl | 15 -- .../cddl/valid_rfc8610_socket_plug_ext.cddl | 28 --- .../tests/cddl/valid_rfc8610_structs.cddl | 32 --- .../tests/cddl/valid_rfc8610_structs_alt.cddl | 18 -- .../tests/cddl/valid_rfc8610_tables.cddl | 10 - .../tests/cddl/valid_rfc8610_tags.cddl | 9 - .../tests/cddl/valid_rfc8610_unwrapping.cddl | 27 --- .../cddl/valid_rfc8610_unwrapping_alt.cddl | 12 -- .../cbork/cddl-parser/tests/character_sets.rs | 150 -------------- .../cbork/cddl-parser/tests/comments.rs | 21 -- .../tests/common/byte_sequences.rs | 49 ----- .../cddl-parser/tests/common/comments.rs | 20 -- .../tests/common/group_elements.rs | 114 ----------- .../cddl-parser/tests/common/identifiers.rs | 40 ---- .../tests/common/literal_values.rs | 106 ---------- .../cbork/cddl-parser/tests/common/mod.rs | 26 --- .../cbork/cddl-parser/tests/common/rules.rs | 59 ------ .../tests/common/text_sequences.rs | 6 - .../tests/common/type_declarations.rs | 112 ----------- .../cbork/cddl-parser/tests/group_elements.rs | 56 ------ .../cbork/cddl-parser/tests/identifiers.rs | 36 ---- .../cbork/cddl-parser/tests/literal_values.rs | 57 ------ .../crates/cbork/cddl-parser/tests/rules.rs | 87 -------- .../cbork/cddl-parser/tests/text_sequences.rs | 17 -- .../cddl-parser/tests/type_declarations.rs | 89 --------- hermes/crates/cbork/clippy.toml | 2 - hermes/crates/cbork/deny.toml | 117 ----------- hermes/crates/cbork/rust-toolchain.toml | 3 - hermes/crates/cbork/rustfmt.toml | 68 ------- 104 files changed, 3704 deletions(-) delete mode 100644 hermes/crates/cbork/.cargo/config.toml delete mode 100644 hermes/crates/cbork/.config/nextest.toml delete mode 100644 hermes/crates/cbork/Cargo.toml delete mode 100644 hermes/crates/cbork/Earthfile delete mode 100644 hermes/crates/cbork/README.md delete mode 100644 hermes/crates/cbork/abnf-parser/Cargo.toml delete mode 100644 hermes/crates/cbork/abnf-parser/src/grammar/abnf_test.pest delete mode 100644 hermes/crates/cbork/abnf-parser/src/grammar/rfc_5234.pest delete mode 100644 hermes/crates/cbork/abnf-parser/src/lib.rs delete mode 100644 hermes/crates/cbork/abnf-parser/tests/abnf/invalid_abnf_sample_1.abnf delete mode 100644 hermes/crates/cbork/abnf-parser/tests/abnf/valid_abnf_rfc3339.abnf delete mode 100644 hermes/crates/cbork/abnf-parser/tests/abnf/valid_abnf_rfc5234.abnf delete mode 100644 hermes/crates/cbork/abnf-parser/tests/abnf/valid_abnf_rfc5234_core.abnf delete mode 100644 hermes/crates/cbork/abnf-parser/tests/abnf/valid_abnf_rfc8610.abnf delete mode 100644 hermes/crates/cbork/abnf-parser/tests/testsuite/abnf.rs delete mode 100644 hermes/crates/cbork/abnf-parser/tests/testsuite/alternations.rs delete mode 100644 hermes/crates/cbork/abnf-parser/tests/testsuite/character_sets.rs delete mode 100644 hermes/crates/cbork/abnf-parser/tests/testsuite/comments.rs delete mode 100644 hermes/crates/cbork/abnf-parser/tests/testsuite/common/mod.rs delete mode 100644 hermes/crates/cbork/abnf-parser/tests/testsuite/elements.rs delete mode 100644 hermes/crates/cbork/abnf-parser/tests/testsuite/groups.rs delete mode 100644 hermes/crates/cbork/abnf-parser/tests/testsuite/identifiers.rs delete mode 100644 hermes/crates/cbork/abnf-parser/tests/testsuite/main.rs delete mode 100644 hermes/crates/cbork/abnf-parser/tests/testsuite/repetitions.rs delete mode 100644 hermes/crates/cbork/abnf-parser/tests/testsuite/rules.rs delete mode 100644 hermes/crates/cbork/abnf-parser/tests/testsuite/values.rs delete mode 100644 hermes/crates/cbork/cddl-parser/Cargo.toml delete mode 100644 hermes/crates/cbork/cddl-parser/src/grammar/cddl_modules.pest delete mode 100644 hermes/crates/cbork/cddl-parser/src/grammar/cddl_test.pest delete mode 100644 hermes/crates/cbork/cddl-parser/src/grammar/postlude.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/src/grammar/rfc_8610.pest delete mode 100644 hermes/crates/cbork/cddl-parser/src/grammar/rfc_9165.pest delete mode 100644 hermes/crates/cbork/cddl-parser/src/lib.rs delete mode 100644 hermes/crates/cbork/cddl-parser/tests/byte_sequences.rs delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl.rs delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/invalid_rfc8610_sample_1.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/invalid_rfc8610_sample_2.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/invalid_rfc8610_sample_3.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/invalid_rfc8610_sample_4.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/invalid_rfc8610_sample_5.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/invalid_rfc8610_sample_6.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/invalid_rfc8610_sample_7.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/invalid_rfc8610_sample_8.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/invalid_rfc8610_sample_9.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_arrays.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_ctrl_bits.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_ctrl_ord.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_ctrl_regexp.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_ctrl_size.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_ctrl_within_and.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_cuts_in_maps.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_cuts_in_maps_alt_1.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_cuts_in_maps_alt_2.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_cuts_in_maps_alt_3.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_example_array_object.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_example_nested_object.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_example_nested_object_compact.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_generics.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_group_to_choice.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_non_deterministic_order.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_occurence.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_op_precedence.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_ranges.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_represenation_types.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_reputon_compact.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_reputon_full.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_simple_1.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_simple_2.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_simple_3.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_simple_4.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_simple_5.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_simple_6.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_simple_7.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_simple_8.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_simple_9.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_socket_plug.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_socket_plug_ext.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_structs.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_structs_alt.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_tables.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_tags.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_unwrapping.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_unwrapping_alt.cddl delete mode 100644 hermes/crates/cbork/cddl-parser/tests/character_sets.rs delete mode 100644 hermes/crates/cbork/cddl-parser/tests/comments.rs delete mode 100644 hermes/crates/cbork/cddl-parser/tests/common/byte_sequences.rs delete mode 100644 hermes/crates/cbork/cddl-parser/tests/common/comments.rs delete mode 100644 hermes/crates/cbork/cddl-parser/tests/common/group_elements.rs delete mode 100644 hermes/crates/cbork/cddl-parser/tests/common/identifiers.rs delete mode 100644 hermes/crates/cbork/cddl-parser/tests/common/literal_values.rs delete mode 100644 hermes/crates/cbork/cddl-parser/tests/common/mod.rs delete mode 100644 hermes/crates/cbork/cddl-parser/tests/common/rules.rs delete mode 100644 hermes/crates/cbork/cddl-parser/tests/common/text_sequences.rs delete mode 100644 hermes/crates/cbork/cddl-parser/tests/common/type_declarations.rs delete mode 100644 hermes/crates/cbork/cddl-parser/tests/group_elements.rs delete mode 100644 hermes/crates/cbork/cddl-parser/tests/identifiers.rs delete mode 100644 hermes/crates/cbork/cddl-parser/tests/literal_values.rs delete mode 100644 hermes/crates/cbork/cddl-parser/tests/rules.rs delete mode 100644 hermes/crates/cbork/cddl-parser/tests/text_sequences.rs delete mode 100644 hermes/crates/cbork/cddl-parser/tests/type_declarations.rs delete mode 100644 hermes/crates/cbork/clippy.toml delete mode 100644 hermes/crates/cbork/deny.toml delete mode 100644 hermes/crates/cbork/rust-toolchain.toml delete mode 100644 hermes/crates/cbork/rustfmt.toml diff --git a/hermes/crates/cbork/.cargo/config.toml b/hermes/crates/cbork/.cargo/config.toml deleted file mode 100644 index 2764f1df4..000000000 --- a/hermes/crates/cbork/.cargo/config.toml +++ /dev/null @@ -1,93 +0,0 @@ -# Use MOLD linker where possible, but ONLY in CI applicable targets. - -# Configure how Docker container targets build. - -# If you want to customize these targets for a local build, then customize them in your: -# $CARGO_HOME/config.toml -# NOT in the project itself. -# These targets are ONLY the targets used by CI and inside docker builds. - -# DO NOT remove `"-C", "target-feature=+crt-static"` from the rustflags for these targets. - -# Should be the default to have fully static rust programs in CI -[target.x86_64-unknown-linux-musl] -linker = "clang" -rustflags = [ - "-C", "link-arg=-fuse-ld=/usr/bin/mold", - "-C", "target-feature=-crt-static" -] - -# Should be the default to have fully static rust programs in CI -[target.aarch64-unknown-linux-musl] -linker = "clang" -rustflags = [ - "-C", "link-arg=-fuse-ld=/usr/bin/mold", - "-C", "target-feature=-crt-static" -] - -[build] -rustflags = [] -rustdocflags = [ - "--enable-index-page", - "-Z", - "unstable-options", -] - -[profile.dev] -opt-level = 1 -debug = true -debug-assertions = true -overflow-checks = true -lto = false -panic = "unwind" -incremental = true -codegen-units = 256 - -[profile.release] -opt-level = 3 -debug = false -debug-assertions = false -overflow-checks = false -lto = "thin" -panic = "unwind" -incremental = false -codegen-units = 16 - -[profile.test] -opt-level = 3 -debug = true -lto = false -debug-assertions = true -incremental = true -codegen-units = 256 - -[profile.bench] -opt-level = 3 -debug = false -debug-assertions = false -overflow-checks = false -lto = "thin" -incremental = false -codegen-units = 16 - -[alias] -lint = "clippy --all-targets" -lintfix = "clippy --all-targets --fix --allow-dirty" -lint-vscode = "clippy --message-format=json-diagnostic-rendered-ansi --all-targets" - -docs = "doc --release --no-deps --document-private-items --bins --lib --examples" -# nightly docs build broken... when they are'nt we can enable these docs... --unit-graph --timings=html,json -Z unstable-options" -testunit = "nextest run --release --bins --lib --tests --benches --no-fail-fast -P ci" -testcov = "llvm-cov nextest --release --bins --lib --tests --benches --no-fail-fast -P ci" -testdocs = "test --doc --release" - -# Rust formatting, MUST be run with +nightly -fmtchk = "fmt -- --check -v --color=always" -fmtfix = "fmt -- -v" - -[term] -quiet = false # whether cargo output is quiet -verbose = false # whether cargo provides verbose output -color = "auto" # whether cargo colorizes output use `CARGO_TERM_COLOR="off"` to disable. -progress.when = "never" # whether cargo shows progress bar -progress.width = 80 # width of progress bar \ No newline at end of file diff --git a/hermes/crates/cbork/.config/nextest.toml b/hermes/crates/cbork/.config/nextest.toml deleted file mode 100644 index 5a36cc8fe..000000000 --- a/hermes/crates/cbork/.config/nextest.toml +++ /dev/null @@ -1,49 +0,0 @@ -# cspell: words scrollability -[store] -# The directory under the workspace root at which nextest-related files are -# written. Profile-specific storage is currently written to dir/. -# dir = "target/nextest" - -[profile.default] -# Print out output for failing tests as soon as they fail, and also at the end -# of the run (for easy scrollability). -failure-output = "immediate-final" - -# Do not cancel the test run on the first failure. -fail-fast = true - -status-level = "all" -final-status-level = "all" - -[profile.ci] -# Print out output for failing tests as soon as they fail, and also at the end -# of the run (for easy scrollability). -failure-output = "immediate-final" -# Do not cancel the test run on the first failure. -fail-fast = false - -status-level = "all" -final-status-level = "all" - - -[profile.ci.junit] -# Output a JUnit report into the given file inside 'store.dir/'. -# If unspecified, JUnit is not written out. - -path = "junit.xml" - -# The name of the top-level "report" element in JUnit report. If aggregating -# reports across different test runs, it may be useful to provide separate names -# for each report. -report-name = "nextest" - -# Whether standard output and standard error for passing tests should be stored in the JUnit report. -# Output is stored in the and elements of the element. -store-success-output = true - -# Whether standard output and standard error for failing tests should be stored in the JUnit report. -# Output is stored in the and elements of the element. -# -# Note that if a description can be extracted from the output, it is always stored in the -# element. -store-failure-output = true \ No newline at end of file diff --git a/hermes/crates/cbork/Cargo.toml b/hermes/crates/cbork/Cargo.toml deleted file mode 100644 index 12719c13a..000000000 --- a/hermes/crates/cbork/Cargo.toml +++ /dev/null @@ -1,45 +0,0 @@ -[workspace] -package.edition = "2021" -resolver = "2" -members = [ - "cddl-parser", - "abnf-parser", -] - -[workspace.lints.rust] -warnings = "deny" -missing_docs = "deny" -let_underscore_drop = "deny" -non_ascii_idents = "deny" -single_use_lifetimes = "deny" -trivial_casts = "deny" -trivial_numeric_casts = "deny" - -[workspace.lints.rustdoc] -broken_intra_doc_links = "deny" -invalid_codeblock_attributes = "deny" -invalid_html_tags = "deny" -invalid_rust_codeblocks = "deny" -bare_urls = "deny" -unescaped_backticks = "deny" - -[workspace.lints.clippy] -pedantic = { level = "deny", priority = -1 } -unwrap_used = "deny" -expect_used = "deny" -todo = "deny" -unimplemented = "deny" -exit = "deny" -get_unwrap = "deny" -index_refutable_slice = "deny" -indexing_slicing = "deny" -match_on_vec_items = "deny" -match_wild_err_arm = "deny" -missing_panics_doc = "deny" -panic = "deny" -string_slice = "deny" -unchecked_duration_subtraction = "deny" -unreachable = "deny" -missing_docs_in_private_items = "deny" - -[workspace.dependencies] diff --git a/hermes/crates/cbork/Earthfile b/hermes/crates/cbork/Earthfile deleted file mode 100644 index e4772fb87..000000000 --- a/hermes/crates/cbork/Earthfile +++ /dev/null @@ -1,50 +0,0 @@ -VERSION 0.8 - -IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.1.24 AS rust-ci -# Use when debugging cat-ci locally. -# IMPORT ../../catalyst-ci/earthly/rust AS rust-ci - -# Set up our target toolchains, and copy our files. -builder: - DO rust-ci+SETUP - - COPY --dir .cargo .config cddl-parser abnf-parser . - COPY Cargo.toml clippy.toml deny.toml rustfmt.toml . - - # RUN cargo generate-lockfile - -## ----------------------------------------------------------------------------- -## -## Standard CI targets. -## -## These targets are discovered and executed automatically by CI. - -# Run check using the most efficient host tooling -# CI Automated Entry point. -check: - FROM +builder - - DO rust-ci+EXECUTE --cmd="/scripts/std_checks.py" - -# Test which runs check with all supported host tooling. Needs qemu or rosetta to run. -# Only used to validate tooling is working across host toolsets. -all-hosts-check: - BUILD --platform=linux/amd64 --platform=linux/arm64 +check - -# Run build using the most efficient host tooling -# CI Automated Entry point. -build: - FROM +builder - - DO rust-ci+EXECUTE \ - --cmd="/scripts/std_build.py" \ - --args1="--libs=cddl-parser,abnf-parser" \ - --output="release/[^\./]+" \ - --docs="true" - - SAVE ARTIFACT target/$TARGETARCH/doc doc - -# Test which runs check with all supported host tooling. Needs qemu or rosetta to run. -# Only used to validate tooling is working across host toolsets. -build-all-hosts: - BUILD --platform=linux/amd64 --platform=linux/arm64 +build-hosted diff --git a/hermes/crates/cbork/README.md b/hermes/crates/cbork/README.md deleted file mode 100644 index 74e4e83f4..000000000 --- a/hermes/crates/cbork/README.md +++ /dev/null @@ -1,20 +0,0 @@ -# cbork - -CBOR Kit - -We need to support the parsing of CDDL in the following priority sequence. -Each needs to be complete before extending with the subsequent specification extension. -We do not need to handle choosing which extensions are enabled. - -1. CDDL Spec: -2. Errata to include: -3. Extensions: -4. Modules: and - -There are semantic rules about well formed CDDL files that are not enforced by the grammar. -The full parser will also need to validate those rules. -The primary rule is that the very first definition in the file is the base type. - -We should also be able to detect if there are orphaned definitions in the CDDL file. - -There may be other checks we need to perform on the parsed AST for validity. diff --git a/hermes/crates/cbork/abnf-parser/Cargo.toml b/hermes/crates/cbork/abnf-parser/Cargo.toml deleted file mode 100644 index d4fb94c56..000000000 --- a/hermes/crates/cbork/abnf-parser/Cargo.toml +++ /dev/null @@ -1,17 +0,0 @@ -#cspell: words memchr - -[package] -name = "abnf-parser" -version = "0.1.0" -edition.workspace = true -license = "MIT OR Apache-2.0" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[lints] -workspace = true - -[dependencies] -derive_more = "0.99.17" -pest = { version = "2.7.2", features = ["std", "pretty-print", "memchr", "const_prec_climber"] } -pest_derive = { version = "2.7.2", features = ["grammar-extras"] } diff --git a/hermes/crates/cbork/abnf-parser/src/grammar/abnf_test.pest b/hermes/crates/cbork/abnf-parser/src/grammar/abnf_test.pest deleted file mode 100644 index 9e57ff5a0..000000000 --- a/hermes/crates/cbork/abnf-parser/src/grammar/abnf_test.pest +++ /dev/null @@ -1,71 +0,0 @@ -// cspell: words VCHAR - -// ----------------------------------------------------------------------------- -// Test Expressions ONLY TO Be USED by Unit Tests. -// Extends `rfc_5234.pest` with rules needed to properly check sub-rules. - -/// Test Expression for the `rule` Rule. -rule_TEST = ${ SOI ~ rule ~ EOI } - -/// Test Expression for the `defined_as` Rule. -defined_as_TEST = ${ SOI ~ defined_as ~ EOI } - -/// Test Expression for the `elements` Rule. -elements_TEST = ${ SOI ~ elements ~ EOI } - -/// Test Expression for the `alternation` Rule. -alternation_TEST = ${ SOI ~ alternation ~ EOI } - -/// Test Expression for the `concatenation` Rule. -concatenation_TEST = ${ SOI ~ concatenation ~ EOI } - -/// Test Expression for the `repetition` Rule. -repetition_TEST = ${ SOI ~ repetition ~ EOI } - -/// Test Expression for the `repeat` Rule. -repeat_TEST = ${ SOI ~ repeat ~ EOI } - -/// Test Expression for the `element` Rule. -element_TEST = ${ SOI ~ element ~ EOI } - -/// Test Expression for the `group` Rule. -group_TEST = ${ SOI ~ group ~ EOI } - -/// Test Expression for the `option` Rule. -option_TEST = ${ SOI ~ option ~ EOI } - -/// Test Expression for the `char_val` Rule. -char_val_TEST = ${ SOI ~ char_val ~ EOI } - -/// Test Expression for the `num_val` Rule. -num_val_TEST = ${ SOI ~ num_val ~ EOI } - -/// Test Expression for the `bin_val` Rule. -bin_val_TEST = ${ SOI ~ bin_val ~ EOI } - -/// Test Expression for the `dec_val` Rule. -dec_val_TEST = ${ SOI ~ dec_val ~ EOI } - -/// Test Expression for the `hex_val` Rule. -hex_val_TEST = ${ SOI ~ hex_val ~ EOI } - -/// Test Expression for the `prose_val` Rule. -prose_val_TEST = ${ SOI ~ prose_val ~ EOI } - -/// Test Expression for the `c_wsp` Rule. -c_wsp_TEST = ${ SOI ~ c_wsp ~ EOI } - -/// Test Expression for the `c_nl` Rule. -c_nl_TEST = ${ SOI ~ c_nl ~ EOI } - -/// Test Expression for the `rulename` Rule. -rulename_TEST = ${ SOI ~ rulename ~ EOI } - -/// Test Expression for the `COMMENT` Rule. -COMMENT_TEST = { SOI ~ COMMENT* ~ EOI } - -/// Test Expression for the `WHITESPACE` Rule. -WHITESPACE_TEST = { SOI ~ WHITESPACE* ~ EOI } - -/// Test expression to the `VCHAR` Rule. -VCHAR_TEST = ${ SOI ~ VCHAR ~ EOI} diff --git a/hermes/crates/cbork/abnf-parser/src/grammar/rfc_5234.pest b/hermes/crates/cbork/abnf-parser/src/grammar/rfc_5234.pest deleted file mode 100644 index 47607c21f..000000000 --- a/hermes/crates/cbork/abnf-parser/src/grammar/rfc_5234.pest +++ /dev/null @@ -1,89 +0,0 @@ -//! ABNF Grammar adapted from RFC5234 Section 4 and Appendix B -//! https://datatracker.ietf.org/doc/html/rfc5234#section-4 -//! https://datatracker.ietf.org/doc/html/rfc5234#appendix-B.1 - -// cspell: words VCHAR DQUOTE ONEOF - -// correction: https://www.rfc-editor.org/errata/eid3076 -abnf = ${ - SOI - ~ (rule | (WHITESPACE* ~ c_nl))+ - ~ EOI -} - -// ----------------------------------------------------------------------------- -// Rules - -/// continues if next line starts with white space -rule = ${ rulename ~ defined_as ~ elements ~ c_nl } - -/// basic rules definition and incremental alternatives -defined_as = ${ c_wsp* ~ ("=/" | "=") ~ c_wsp* } - -/// correction: https://www.rfc-editor.org/errata/eid2968 -elements = ${ alternation ~ WHITESPACE* } - -// ----------------------------------------------------------------------------- -// Groups and Options - -group = ${ "(" ~ c_wsp* ~ alternation ~ c_wsp* ~ ")" } - -option = ${ "[" ~ c_wsp* ~ alternation ~ c_wsp* ~ "]" } - -// ----------------------------------------------------------------------------- -// Alternations - -alternation = ${ concatenation ~ (c_wsp* ~ "/" ~ c_wsp* ~ concatenation)* } - -concatenation = ${ repetition ~ (c_wsp+ ~ repetition)* } - -// ----------------------------------------------------------------------------- -// Repetitions - -repetition = ${ repeat? ~ element } - -repeat = ${ (ASCII_DIGIT* ~ "*" ~ ASCII_DIGIT*) | ASCII_DIGIT+ } - -// ----------------------------------------------------------------------------- -// Elements - -element = ${ rulename | group | option | char_val | num_val | prose_val } - -// ----------------------------------------------------------------------------- -// Values - -/// quoted string of SP and VCHAR without DQUOTE -char_val = ${ "\"" ~ ('\u{20}'..'\u{21}' | '\u{23}'..'\u{7E}')* ~ "\"" } - -num_val = ${ "%" ~ (bin_val | dec_val | hex_val) } - -/// series of concatenated bit values or single ONEOF range -bin_val = ${ "b" ~ ASCII_BIN_DIGIT+ ~ (("." ~ ASCII_BIN_DIGIT+)+ | ("-" ~ ASCII_BIN_DIGIT+))? } - -dec_val = ${ "d" ~ ASCII_DIGIT+ ~ (("." ~ ASCII_DIGIT+)+ | ("-" ~ ASCII_DIGIT+))? } - -hex_val = ${ "x" ~ ASCII_HEX_DIGIT+ ~ (("." ~ ASCII_HEX_DIGIT+)+ | ("-" ~ ASCII_HEX_DIGIT+))? } - -/// bracketed string of SP and VCHAR without ">" -/// prose description, to be used as last resort -/// correction: https://www.rfc-editor.org/errata/eid2914 -prose_val = ${ "<" ~ ('\u{20}'..'\u{3D}' | '\u{3F}'..'\u{7E}')* ~ ">" } - -// ----------------------------------------------------------------------------- -// Identifiers - -rulename = ${ ASCII_ALPHA ~ (ASCII_ALPHA | ASCII_DIGIT | "-" )* } - -// ----------------------------------------------------------------------------- -// Characters, Whitespace and Comments - -c_wsp = _{ WHITESPACE | (c_nl ~ WHITESPACE) } - -/// comment or newline -c_nl = _{ COMMENT | NEWLINE } - -COMMENT = { ";" ~ (VCHAR | WHITESPACE)* ~ NEWLINE } -WHITESPACE = _{ " " | "\t" } - -/// visible (printing) characters -VCHAR = _{ '\u{21}'..'\u{7E}' } diff --git a/hermes/crates/cbork/abnf-parser/src/lib.rs b/hermes/crates/cbork/abnf-parser/src/lib.rs deleted file mode 100644 index 691674843..000000000 --- a/hermes/crates/cbork/abnf-parser/src/lib.rs +++ /dev/null @@ -1,93 +0,0 @@ -// cspell: words Naur - -#![allow(missing_docs)] // TODO(apskhem): Temporary, to bo removed in a subsequent PR - -//! A parser for ABNF, utilized for parsing in accordance with RFC 5234. - -use std::fmt::Debug; - -use derive_more::{Display, From}; -pub use pest::Parser; -use pest::{error::Error, iterators::Pairs}; - -pub mod abnf { - pub use pest::Parser; - - #[derive(pest_derive::Parser)] - #[grammar = "grammar/rfc_5234.pest"] - pub struct ABNFParser; -} - -pub mod abnf_test { - pub use pest::Parser; - - #[derive(pest_derive::Parser)] - #[grammar = "grammar/rfc_5234.pest"] - #[grammar = "grammar/abnf_test.pest"] - pub struct ABNFTestParser; -} - -#[derive(Debug)] -#[allow(dead_code)] -/// Abstract Syntax Tree (AST) representing parsed ABNF syntax. -pub struct AST<'a>(Pairs<'a, abnf::Rule>); - -/// Represents an error that may occur during ABNF parsing. -#[derive(Display, Debug, From)] -/// Error type for ABNF parsing. -pub struct ABNFError(Error); - -/// Parses the input string containing ABNF (Augmented Backus-Naur Form) syntax and -/// returns the Abstract Syntax Tree (AST). -/// -/// # Arguments -/// -/// * `input` - A reference to a string slice containing the ABNF syntax to parse. -/// -/// # Returns -/// -/// Returns a `Result` where the successful variant contains the Abstract Syntax Tree -/// (AST) representing the parsed ABNF, and the error variant contains a boxed -/// `ABNFError`. -/// -/// # Errors -/// -/// This function may return an error in the following cases: -/// -/// - If there is an issue with parsing the ABNF input. -/// -/// # Examples -/// -/// ```rs -/// use abnf_parser::parse_abnf; -/// use std:fs; -/// -/// let input = fs::read_to_string("path/to/your/file.abnf").unwrap(); -/// let result = parse_abnf(&input); -/// ``` -pub fn parse_abnf(input: &str) -> Result, Box> { - let result: Result, _> = abnf::ABNFParser::parse(abnf::Rule::abnf, input) - .map(AST) - .map_err(ABNFError); - - result.map_err(Box::new) -} - -#[cfg(test)] -mod tests { - use crate::*; - - #[test] - fn it_works() { - let input = String::new(); - let result = parse_abnf(&input); - - match result { - Ok(c) => println!("{c:?}"), - Err(e) => { - println!("{e:?}"); - println!("{e}"); - }, - } - } -} diff --git a/hermes/crates/cbork/abnf-parser/tests/abnf/invalid_abnf_sample_1.abnf b/hermes/crates/cbork/abnf-parser/tests/abnf/invalid_abnf_sample_1.abnf deleted file mode 100644 index 3d8c0d46c..000000000 --- a/hermes/crates/cbork/abnf-parser/tests/abnf/invalid_abnf_sample_1.abnf +++ /dev/null @@ -1 +0,0 @@ -a = b ; without eol \ No newline at end of file diff --git a/hermes/crates/cbork/abnf-parser/tests/abnf/valid_abnf_rfc3339.abnf b/hermes/crates/cbork/abnf-parser/tests/abnf/valid_abnf_rfc3339.abnf deleted file mode 100644 index 2f033b8c6..000000000 --- a/hermes/crates/cbork/abnf-parser/tests/abnf/valid_abnf_rfc3339.abnf +++ /dev/null @@ -1,14 +0,0 @@ -date-full-year = 4DIGIT -date-month = 2DIGIT ; 01-12 -date-m-day = 2DIGIT ; 01-28, 01-29, 01-30, 01-31 based on month/year -time-hour = 2DIGIT ; 00-23 -time-minute = 2DIGIT ; 00-59 -time-second = 2DIGIT ; 00-58, 00-59, 00-60 based on leap sec rules -time-sub-second = "." 1*DIGIT -time-numeric-offset = ("+" / "-") time-hour ":" time-minute -time-offset = "Z" / time-numeric-offset -partial-time = time-hour ":" time-minute ":" time-second - [time-sub-second] -full-date = date-full-year "-" date-month "-" date-m-day -full-time = partial-time time-offset -date-time = full-date "T" full-time diff --git a/hermes/crates/cbork/abnf-parser/tests/abnf/valid_abnf_rfc5234.abnf b/hermes/crates/cbork/abnf-parser/tests/abnf/valid_abnf_rfc5234.abnf deleted file mode 100644 index 16e119027..000000000 --- a/hermes/crates/cbork/abnf-parser/tests/abnf/valid_abnf_rfc5234.abnf +++ /dev/null @@ -1,61 +0,0 @@ -; cspell: words VCHAR DQUOTE VCHAR ONEOF HEXDIG - -rulelist = 1*( rule / (*c-wsp c-nl) ) - -rule = rulename defined-as elements c-nl - ; continues if next line starts - ; with white space - -rulename = ALPHA *(ALPHA / DIGIT / "-") - -defined-as = *c-wsp ("=" / "=/") *c-wsp - ; basic rules definition and - ; incremental alternatives - -elements = alternation *c-wsp - -c-wsp = WSP / (c-nl WSP) - -c-nl = comment / CRLF - ; comment or newline - -comment = ";" *(WSP / VCHAR) CRLF - -alternation = concatenation - *(*c-wsp "/" *c-wsp concatenation) - -concatenation = repetition *(1*c-wsp repetition) - -repetition = [repeat] element - -repeat = 1*DIGIT / (*DIGIT "*" *DIGIT) - -element = rulename / group / option / - char-val / num-val / prose-val - -group = "(" *c-wsp alternation *c-wsp ")" - -option = "[" *c-wsp alternation *c-wsp "]" - -char-val = DQUOTE *(%x20-21 / %x23-7E) DQUOTE - ; quoted string of SP and VCHAR - ; without DQUOTE - -num-val = "%" (bin-val / dec-val / hex-val) - -bin-val = "b" 1*BIT - [ 1*("." 1*BIT) / ("-" 1*BIT) ] - ; series of concatenated bit values - ; or single ONEOF range - -dec-val = "d" 1*DIGIT - [ 1*("." 1*DIGIT) / ("-" 1*DIGIT) ] - -hex-val = "x" 1*HEXDIG - [ 1*("." 1*HEXDIG) / ("-" 1*HEXDIG) ] - -prose-val = "<" *(%x20-3D / %x3F-7E) ">" - ; bracketed string of SP and VCHAR - ; without angles - ; prose description, to be used as - ; last resort diff --git a/hermes/crates/cbork/abnf-parser/tests/abnf/valid_abnf_rfc5234_core.abnf b/hermes/crates/cbork/abnf-parser/tests/abnf/valid_abnf_rfc5234_core.abnf deleted file mode 100644 index b7fdda359..000000000 --- a/hermes/crates/cbork/abnf-parser/tests/abnf/valid_abnf_rfc5234_core.abnf +++ /dev/null @@ -1,54 +0,0 @@ -; cspell: words DQUOTE HEXDIG HTAB LWSP VCHAR - -ALPHA = %x41-5A / %x61-7A ; A-Z / a-z - -BIT = "0" / "1" - -CHAR = %x01-7F - ; any 7-bit US-ASCII character, - ; excluding NUL - -CR = %x0D - ; carriage return - -CRLF = CR LF - ; Internet standard newline - -CTL = %x00-1F / %x7F - ; controls - -DIGIT = %x30-39 - ; 0-9 - -DQUOTE = %x22 - ; " (Double Quote) - -HEXDIG = DIGIT / "A" / "B" / "C" / "D" / "E" / "F" - -HTAB = %x09 - ; horizontal tab - -LF = %x0A - ; linefeed - -LWSP = *(WSP / CRLF WSP) - ; Use of this linear-white-space rule - ; permits lines containing only white - ; space that are no longer legal in - ; mail headers and have caused - ; interoperability problems in other - ; contexts. - ; Do not use when defining mail - ; headers and use with caution in - ; other contexts. - -OCTET = %x00-FF - ; 8 bits of data - -SP = %x20 - -VCHAR = %x21-7E - ; visible (printing) characters - -WSP = SP / HTAB - ; white space diff --git a/hermes/crates/cbork/abnf-parser/tests/abnf/valid_abnf_rfc8610.abnf b/hermes/crates/cbork/abnf-parser/tests/abnf/valid_abnf_rfc8610.abnf deleted file mode 100644 index 6730511a8..000000000 --- a/hermes/crates/cbork/abnf-parser/tests/abnf/valid_abnf_rfc8610.abnf +++ /dev/null @@ -1,99 +0,0 @@ -; cspell: words genericparm genericarg assignt assigng groupname -; cspell: words memberkey rangeop ctlop grpchoice grpent optcom -; cspell: words bareword HEXDIG BINDIG hexfloat SCHAR FFFD SESC -; cspell: words bsqual BCHAR EALPHA PCHAR - -cddl = S 1*(rule S) -rule = typename [genericparm] S assignt S type - / groupname [genericparm] S assigng S grpent - -typename = id -groupname = id - -assignt = "=" / "/=" -assigng = "=" / "//=" - -genericparm = "<" S id S *("," S id S ) ">" -genericarg = "<" S type1 S *("," S type1 S ) ">" - -type = type1 *(S "/" S type1) - -type1 = type2 [S (rangeop / ctlop) S type2] -; space may be needed before the operator if type2 ends in a name - -type2 = value - / typename [genericarg] - / "(" S type S ")" - / "{" S group S "}" - / "[" S group S "]" - / "~" S typename [genericarg] - / "&" S "(" S group S ")" - / "&" S groupname [genericarg] - / "#" "6" ["." uint] "(" S type S ")" - / "#" DIGIT ["." uint] ; major/ai - / "#" ; any - -rangeop = "..." / ".." - -ctlop = "." id - -group = grpchoice *(S "//" S grpchoice) - -grpchoice = *(grpent optcom) - -grpent = [occur S] [memberkey S] type - / [occur S] groupname [genericarg] ; preempted by above - / [occur S] "(" S group S ")" - -memberkey = type1 S ["^" S] "=>" - / bareword S ":" - / value S ":" - -bareword = id - -optcom = S ["," S] - -occur = [uint] "*" [uint] - / "+" - / "?" - -uint = DIGIT1 *DIGIT - / "0x" 1*HEXDIG - / "0b" 1*BINDIG - / "0" - -value = number - / text - / bytes - -int = ["-"] uint - -; This is a float if it has fraction or exponent; int otherwise -number = hexfloat / (int ["." fraction] ["e" exponent ]) -hexfloat = ["-"] "0x" 1*HEXDIG ["." 1*HEXDIG] "p" exponent -fraction = 1*DIGIT -exponent = ["+"/"-"] 1*DIGIT - -text = %x22 *SCHAR %x22 -SCHAR = %x20-21 / %x23-5B / %x5D-7E / %x80-10FFFD / SESC -SESC = "\" (%x20-7E / %x80-10FFFD) - -bytes = [bsqual] %x27 *BCHAR %x27 -BCHAR = %x20-26 / %x28-5B / %x5D-10FFFD / SESC / CRLF -bsqual = "h" / "b64" - -id = EALPHA *(*("-" / ".") (EALPHA / DIGIT)) -ALPHA = %x41-5A / %x61-7A -EALPHA = ALPHA / "@" / "_" / "$" -DIGIT = %x30-39 -DIGIT1 = %x31-39 -HEXDIG = DIGIT / "A" / "B" / "C" / "D" / "E" / "F" -BINDIG = %x30-31 - -S = *WS -WS = SP / NL -SP = %x20 -NL = COMMENT / CRLF -COMMENT = ";" *PCHAR CRLF -PCHAR = %x20-7E / %x80-10FFFD -CRLF = %x0A / %x0D.0A diff --git a/hermes/crates/cbork/abnf-parser/tests/testsuite/abnf.rs b/hermes/crates/cbork/abnf-parser/tests/testsuite/abnf.rs deleted file mode 100644 index d397e781a..000000000 --- a/hermes/crates/cbork/abnf-parser/tests/testsuite/abnf.rs +++ /dev/null @@ -1,52 +0,0 @@ -use std::{ffi::OsStr, fs, io::Result}; - -use abnf_parser::parse_abnf; - -#[test] -/// # Panics -fn parse_abnf_files() { - let entries = fs::read_dir("tests/abnf").unwrap(); - - let mut file_paths: Vec<_> = entries - .filter_map(Result::ok) - .filter_map(|x| x.path().is_file().then_some(x.path())) - .collect(); - - file_paths.sort(); - - let valid_file_paths = file_paths.iter().filter(|p| { - p.file_name() - .and_then(OsStr::to_str) - .map(|p| p.starts_with("valid")) - .is_some_and(|p| p) - }); - let invalid_file_paths = file_paths.iter().filter(|p| { - p.file_name() - .and_then(OsStr::to_str) - .map(|p| p.starts_with("invalid")) - .is_some_and(|p| p) - }); - - // test for valid files - let mut err_messages = vec![]; - for file_path in valid_file_paths { - let content = fs::read_to_string(file_path).unwrap(); - - if let Err(e) = parse_abnf(&content) { - err_messages.push(format!("{}) {file_path:?} {e}", err_messages.len() + 1)); - } - } - - // test for invalid files - for file_path in invalid_file_paths { - let content = fs::read_to_string(file_path).unwrap(); - - let result = parse_abnf(&content); - - assert!(result.is_err(), "{:?} is expected to fail", &file_path); - } - - // summary - let err_msg = err_messages.join("\n\n"); - assert!(err_msg.is_empty(), "{err_msg}"); -} diff --git a/hermes/crates/cbork/abnf-parser/tests/testsuite/alternations.rs b/hermes/crates/cbork/abnf-parser/tests/testsuite/alternations.rs deleted file mode 100644 index e24bcb4a4..000000000 --- a/hermes/crates/cbork/abnf-parser/tests/testsuite/alternations.rs +++ /dev/null @@ -1,40 +0,0 @@ -use abnf_parser::{self, abnf_test::Rule}; - -use crate::common::*; - -pub(crate) const ALTERNATION_PASSES: &[&str] = &["foo / bar", "foo/bar", "foo/bar baz"]; - -pub(crate) const ALTERNATION_FAILS: &[&str] = &["foo /"]; - -pub(crate) const CONCATENATION_PASSES: &[&str] = &[ - "foo", - "foo bar", - "foo\tbar", - "foo bar baz", - "foo bar baz", - "foo - bar - baz", -]; - -pub(crate) const CONCATENATION_FAILS: &[&str] = &["foo\nbar\nbaz", "foo bar\nbaz"]; - -#[test] -/// Test if the `alternation` rule passes properly. -fn check_alternation() { - check_tests_rule( - Rule::alternation_TEST, - ALTERNATION_PASSES, - ALTERNATION_FAILS, - ); -} - -#[test] -/// Test if the `concatenation` rule passes properly. -fn check_concatenation() { - check_tests_rule( - Rule::concatenation_TEST, - CONCATENATION_PASSES, - CONCATENATION_FAILS, - ); -} diff --git a/hermes/crates/cbork/abnf-parser/tests/testsuite/character_sets.rs b/hermes/crates/cbork/abnf-parser/tests/testsuite/character_sets.rs deleted file mode 100644 index 74a591bb1..000000000 --- a/hermes/crates/cbork/abnf-parser/tests/testsuite/character_sets.rs +++ /dev/null @@ -1,30 +0,0 @@ -// cspell: words VCHAR vchar - -use abnf_parser::{self, abnf_test::Rule}; - -use crate::common::*; - -#[test] -/// Test if the `WHITESPACE` rule passes properly. -fn check_whitespace() { - let passes = vec![" ", "\t"]; - let fails = vec!["not", "\r", "\n", "\r\n"]; - - check_tests_rule(Rule::WHITESPACE_TEST, &passes, &fails); -} - -#[test] -/// Test if the `VCHAR` rule passes properly. -fn check_vchar() { - let passes: Vec<_> = (b'!'..=b'~').map(char::from).map(String::from).collect(); - let fails = vec!["\r", "\u{80}"]; - - check_tests_rule( - Rule::VCHAR_TEST, - &passes - .iter() - .map(std::string::String::as_str) - .collect::>(), - &fails, - ); -} diff --git a/hermes/crates/cbork/abnf-parser/tests/testsuite/comments.rs b/hermes/crates/cbork/abnf-parser/tests/testsuite/comments.rs deleted file mode 100644 index 3cce10349..000000000 --- a/hermes/crates/cbork/abnf-parser/tests/testsuite/comments.rs +++ /dev/null @@ -1,61 +0,0 @@ -use std::ops::Deref; - -use abnf_parser::{self, abnf_test::Rule}; - -use crate::common::*; - -pub(crate) const COMMENT_PASSES: &[&str] = &[ - ";\n", - "; a\n", - "; a\r\n", - ";;\n", - "; a87246h\t\t\r\n", - "; And another\r", -]; - -pub(crate) const COMMENT_FAILS: &[&str] = &[";", ";abc", "not a comment"]; - -pub(crate) const C_NL_PASSES: &[&str] = &["\r\n", "\r", "\n"]; - -pub(crate) const C_NL_FAILS: &[&str] = &[" "]; - -pub(crate) const C_WSP_PASSES: &[&str] = &[ - " ", - ";\n ", - "; a\n ", - "; a\r\n ", - ";;\n ", - "; a87246h\t\t\r\n ", - "; And another\r ", -]; - -pub(crate) const C_WSP_FAILS: &[&str] = &[";", ";abc", "not a comment", "; a\n "]; - -#[test] -/// Test if the `COMMENT` rule passes properly. -fn check_comment() { - check_tests_rule(Rule::COMMENT_TEST, COMMENT_PASSES, COMMENT_FAILS); -} - -#[test] -/// Test if the `c_nl` rule passes properly. -fn check_c_nl() { - let passes: Vec<_> = C_NL_PASSES - .iter() - .chain(COMMENT_PASSES) - .map(Deref::deref) - .collect(); - let fails: Vec<_> = C_NL_FAILS - .iter() - .chain(COMMENT_FAILS) - .map(Deref::deref) - .collect(); - - check_tests_rule(Rule::c_nl_TEST, &passes, &fails); -} - -#[test] -/// Test if the `c_wsp` rule passes properly. -fn check_c_wsp() { - check_tests_rule(Rule::c_wsp_TEST, C_WSP_PASSES, C_WSP_FAILS); -} diff --git a/hermes/crates/cbork/abnf-parser/tests/testsuite/common/mod.rs b/hermes/crates/cbork/abnf-parser/tests/testsuite/common/mod.rs deleted file mode 100644 index 8f6f077c4..000000000 --- a/hermes/crates/cbork/abnf-parser/tests/testsuite/common/mod.rs +++ /dev/null @@ -1,17 +0,0 @@ -use abnf_parser::{ - self, - abnf_test::{ABNFTestParser, Parser, Rule}, -}; - -/// # Panics -pub(crate) fn check_tests_rule(rule_type: Rule, passes: &[&str], fails: &[&str]) { - for test in passes { - let parse = ABNFTestParser::parse(rule_type, test); - assert!(parse.is_ok()); - } - - for test in fails { - let parse = ABNFTestParser::parse(rule_type, test); - assert!(parse.is_err()); - } -} diff --git a/hermes/crates/cbork/abnf-parser/tests/testsuite/elements.rs b/hermes/crates/cbork/abnf-parser/tests/testsuite/elements.rs deleted file mode 100644 index 33e25b824..000000000 --- a/hermes/crates/cbork/abnf-parser/tests/testsuite/elements.rs +++ /dev/null @@ -1,44 +0,0 @@ -use abnf_parser::{self, abnf_test::Rule}; - -use crate::{common::*, groups::*, identifiers::*, values::*}; - -pub(crate) const ELEMENT_PASSES: &[&str] = &[]; - -pub(crate) const ELEMENT_FAILS: &[&str] = &[]; - -#[test] -/// Test if the `element` rule passes properly. -fn check_element() { - let passes: Vec<_> = ELEMENT_PASSES - .iter() - .map(|x| (*x).to_string()) - .chain(RULENAME_PASSES.iter().map(|x| (*x).to_string())) - .chain(OPTION_PASSES.iter().map(|x| (*x).to_string())) - .chain(GROUP_PASSES.iter().map(|x| (*x).to_string())) - .chain(BIN_VAL_PASSES.iter().map(|x| format!("%{x}"))) - .chain(DEC_VAL_PASSES.iter().map(|x| format!("%{x}"))) - .chain(HEX_VAL_PASSES.iter().map(|x| format!("%{x}"))) - .collect(); - let fails: Vec<_> = ELEMENT_FAILS - .iter() - .map(|x| (*x).to_string()) - .chain(RULENAME_FAILS.iter().map(|x| (*x).to_string())) - .chain(OPTION_FAILS.iter().map(|x| (*x).to_string())) - .chain(GROUP_FAILS.iter().map(|x| (*x).to_string())) - .chain(BIN_VAL_FAILS.iter().map(|x| format!("%{x}"))) - .chain(DEC_VAL_FAILS.iter().map(|x| format!("%{x}"))) - .chain(HEX_VAL_FAILS.iter().map(|x| format!("%{x}"))) - .collect(); - - check_tests_rule( - Rule::element_TEST, - &passes - .iter() - .map(std::string::String::as_str) - .collect::>(), - &fails - .iter() - .map(std::string::String::as_str) - .collect::>(), - ); -} diff --git a/hermes/crates/cbork/abnf-parser/tests/testsuite/groups.rs b/hermes/crates/cbork/abnf-parser/tests/testsuite/groups.rs deleted file mode 100644 index 73370bf5c..000000000 --- a/hermes/crates/cbork/abnf-parser/tests/testsuite/groups.rs +++ /dev/null @@ -1,42 +0,0 @@ -use abnf_parser::{self, abnf_test::Rule}; - -use crate::common::*; - -pub(crate) const GROUP_PASSES: &[&str] = &[ - "(foo)", - "( foo )", - "(Rule1 Rule2)", - "(foo / bar)", - "(elem foo blat)", - "((elem) (foo) (blat))", - "(((((foo)))))", - "(((((foo / bar)))))", -]; - -pub(crate) const GROUP_FAILS: &[&str] = &["()", "((foo)", "(())", "())"]; - -pub(crate) const OPTION_PASSES: &[&str] = &[ - "[foo]", - "[(foo)]", - "[([(foo)])]", - "[ foo ]", - "[Rule1 Rule2]", - "[foo / bar]", - "[elem foo blat]", - "[[elem] [foo] [blat]]", - "[[[[[foo / bar]]]]]", -]; - -pub(crate) const OPTION_FAILS: &[&str] = &["[]", "[]]", "[]]"]; - -#[test] -/// Test if the `group` rule passes properly. -fn check_group() { - check_tests_rule(Rule::group_TEST, GROUP_PASSES, GROUP_FAILS); -} - -#[test] -/// Test if the `option` rule passes properly. -fn check_option() { - check_tests_rule(Rule::option_TEST, OPTION_PASSES, OPTION_FAILS); -} diff --git a/hermes/crates/cbork/abnf-parser/tests/testsuite/identifiers.rs b/hermes/crates/cbork/abnf-parser/tests/testsuite/identifiers.rs deleted file mode 100644 index 8045afba9..000000000 --- a/hermes/crates/cbork/abnf-parser/tests/testsuite/identifiers.rs +++ /dev/null @@ -1,22 +0,0 @@ -use abnf_parser::{self, abnf_test::Rule}; - -use crate::common::*; - -pub(crate) const RULENAME_PASSES: &[&str] = &[ - "ABCdef", - "ABC123def456", - "ABC-123-def-456", - "A", - "A1", - "A12345", -]; - -pub(crate) const RULENAME_FAILS: &[&str] = &[ - "ABC@def", "ABC def", "ABC_def", "$A12345", "_A12345", "123ABC", -]; - -#[test] -/// Test if the `rulename` rule passes properly. -fn check_rulename() { - check_tests_rule(Rule::rulename_TEST, RULENAME_PASSES, RULENAME_FAILS); -} diff --git a/hermes/crates/cbork/abnf-parser/tests/testsuite/main.rs b/hermes/crates/cbork/abnf-parser/tests/testsuite/main.rs deleted file mode 100644 index f84e27a70..000000000 --- a/hermes/crates/cbork/abnf-parser/tests/testsuite/main.rs +++ /dev/null @@ -1,11 +0,0 @@ -mod abnf; -mod alternations; -mod character_sets; -mod comments; -mod common; -mod elements; -mod groups; -mod identifiers; -mod repetitions; -mod rules; -mod values; diff --git a/hermes/crates/cbork/abnf-parser/tests/testsuite/repetitions.rs b/hermes/crates/cbork/abnf-parser/tests/testsuite/repetitions.rs deleted file mode 100644 index db57d32b0..000000000 --- a/hermes/crates/cbork/abnf-parser/tests/testsuite/repetitions.rs +++ /dev/null @@ -1,42 +0,0 @@ -use abnf_parser::{self, abnf_test::Rule}; - -use crate::common::*; - -pub(crate) const REPETITION_PASSES: &[&str] = &["1*1foo", "1foo", "1a", "1%b1", "*foo"]; - -pub(crate) const REPETITION_FAILS: &[&str] = &["1*1 foo", "1 foo", "* foo", "1", "1%", "1%b"]; - -pub(crate) const REPEAT_PASSES: &[&str] = &["*", "5*10", "*20", "5*10", "0*5", "5*", "*5", "0123"]; - -pub(crate) const REPEAT_FAILS: &[&str] = &[ - "+", - "?", - "0x1*", - "0b110*", - "5**10", - "5 * 10", - "5\t\n*\n10", - "0x1*0b110", - "0x1*0b110", - "++", - "??", - // Fail cases for uint - "0xG", // Invalid hex digit - "0b123", // Invalid binary digit - "0*5*", // Multiple '*' not allowed - "0x1*0b110*", - "0x", - "0b", -]; - -#[test] -/// Test if the `repetition` rule passes properly. -fn check_repetition() { - check_tests_rule(Rule::repetition_TEST, REPETITION_PASSES, REPETITION_FAILS); -} - -#[test] -/// Test if the `repeat` rule passes properly. -fn check_repeat() { - check_tests_rule(Rule::repeat_TEST, REPEAT_PASSES, REPEAT_FAILS); -} diff --git a/hermes/crates/cbork/abnf-parser/tests/testsuite/rules.rs b/hermes/crates/cbork/abnf-parser/tests/testsuite/rules.rs deleted file mode 100644 index d8d1f9bab..000000000 --- a/hermes/crates/cbork/abnf-parser/tests/testsuite/rules.rs +++ /dev/null @@ -1,50 +0,0 @@ -use abnf_parser::{self, abnf_test::Rule}; - -use crate::common::*; - -pub(crate) const RULE_PASSES: &[&str] = &[ - "a = b\n", - "a=b\n", - "CRLF = %d13.10 \n", - "command = \"command string\"\n", - "rulename = \"abc\"\n", - "rulename = %d97 %d98 %d99\n", - "rulelist = 1*( rule / (*c-wsp c-nl) )\n", -]; - -pub(crate) const RULE_FAILS: &[&str] = &["rulename = \"abc\"", "rulename = abc"]; - -pub(crate) const DEFINED_AS_PASSES: &[&str] = - &["= ", "=/ ", "= ", "=/ ", " =/ ", " = "]; - -pub(crate) const DEFINED_AS_FAILS: &[&str] = &["==", "=\\"]; - -pub(crate) const ELEMENTS_PASSES: &[&str] = &[ - "foo", - "foo bar baz", - "foo / bar", - "(foo / bar) baz", - "*(1*1foo / 2*bar) 012*baz", - "%b1", - "*%b1", -]; - -pub(crate) const ELEMENTS_FAILS: &[&str] = &["%", "=", "()", "[]"]; - -#[test] -/// Test if the `rule` rule passes properly. -fn check_rule() { - check_tests_rule(Rule::rule_TEST, RULE_PASSES, RULE_FAILS); -} - -#[test] -/// Test if the `defined_as` rule passes properly. -fn check_defined_as() { - check_tests_rule(Rule::defined_as_TEST, DEFINED_AS_PASSES, DEFINED_AS_FAILS); -} - -#[test] -/// Test if the `elements` rule passes properly. -fn check_elements() { - check_tests_rule(Rule::elements_TEST, ELEMENTS_PASSES, ELEMENTS_FAILS); -} diff --git a/hermes/crates/cbork/abnf-parser/tests/testsuite/values.rs b/hermes/crates/cbork/abnf-parser/tests/testsuite/values.rs deleted file mode 100644 index 79fdc92b3..000000000 --- a/hermes/crates/cbork/abnf-parser/tests/testsuite/values.rs +++ /dev/null @@ -1,149 +0,0 @@ -use abnf_parser::{self, abnf_test::Rule}; - -use crate::common::*; - -pub(crate) const PROSE_VAL_PASSES: &[&str] = &[ - "", - "", - "<12345>", - "", - "", - "", - "", - "<>", -]; - -pub(crate) const PROSE_VAL_FAILS: &[&str] = &[ - "<>>", - "<<>>", - "", - "", - "", -]; - -pub(crate) const HEX_VAL_PASSES: &[&str] = &["x1A", "xFF", "x0", "x1A.B2", "xFF.FF.FF", "x1A-FF"]; - -pub(crate) const HEX_VAL_FAILS: &[&str] = &[ - "x", - "X1A", - "x1A-FF-0D", - "xFF.FF.FF-FF", - "x.F", - "x-F", - "xG", - "x-FF", - "x1A-FF-0D.", - "x1A.0D-", - "x1A-FF-0D-", -]; - -pub(crate) const DEC_VAL_PASSES: &[&str] = &["d123", "d456.789", "d0", "d987.654.321", "d123-456"]; - -pub(crate) const DEC_VAL_FAILS: &[&str] = &[ - "d", - "D123", - "d123-456-789", - "d123.", - "d.456", - "d-789", - "dG", - "d-123", - "d123.", - "d456.789.", - "d123-", -]; - -pub(crate) const BIN_VAL_PASSES: &[&str] = - &["b101", "b1110.0101", "b0", "b1010.1010.1010", "b1101-1001"]; - -pub(crate) const BIN_VAL_FAILS: &[&str] = &[ - "b", - "B101", - "b101.", - "b.111", - "b-000", - "bG", - "b-101", - "b101.", - "b1110.0101.", - "b101-", -]; - -pub(crate) const NUM_VAL_PASSES: &[&str] = &[]; - -pub(crate) const NUM_VAL_FAILS: &[&str] = &["%", "%%"]; - -pub(crate) const CHAR_VAL_PASSES: &[&str] = &[ - "\"Valid string\"", - "\"Another valid string\"", - "\"1234\"", - "\"!@#$%^&*()\"", - "\"Quoted string with spaces\"", -]; - -pub(crate) const CHAR_VAL_FAILS: &[&str] = &[ - "\"Invalid string with newline\ncharacter\"", - "\"Invalid string with tab\tcharacter\"", - "\"Invalid string with control character at the end\u{1F}\"", -]; - -#[test] -/// Test if the `prose_val` rule passes properly. -fn check_prose_val() { - check_tests_rule(Rule::prose_val_TEST, PROSE_VAL_PASSES, PROSE_VAL_FAILS); -} - -#[test] -/// Test if the `hex_val` rule passes properly. -fn check_hex_val() { - check_tests_rule(Rule::hex_val_TEST, HEX_VAL_PASSES, HEX_VAL_FAILS); -} - -#[test] -/// Test if the `dec_val` rule passes properly. -fn check_dec_val() { - check_tests_rule(Rule::dec_val_TEST, DEC_VAL_PASSES, DEC_VAL_FAILS); -} - -#[test] -/// Test if the `bin_val` rule passes properly. -fn check_bin_val() { - check_tests_rule(Rule::bin_val_TEST, BIN_VAL_PASSES, BIN_VAL_FAILS); -} - -#[test] -/// Test if the `num_val` rule passes properly. -fn check_num_val() { - let passes: Vec<_> = NUM_VAL_PASSES - .iter() - .map(|x| (*x).to_string()) - .chain(BIN_VAL_PASSES.iter().map(|x| format!("%{x}"))) - .chain(DEC_VAL_PASSES.iter().map(|x| format!("%{x}"))) - .chain(HEX_VAL_PASSES.iter().map(|x| format!("%{x}"))) - .collect(); - let fails: Vec<_> = NUM_VAL_FAILS - .iter() - .map(|x| (*x).to_string()) - .chain(BIN_VAL_FAILS.iter().map(|x| format!("%{x}"))) - .chain(DEC_VAL_FAILS.iter().map(|x| format!("%{x}"))) - .chain(HEX_VAL_FAILS.iter().map(|x| format!("%{x}"))) - .collect(); - - check_tests_rule( - Rule::num_val_TEST, - &passes - .iter() - .map(std::string::String::as_str) - .collect::>(), - &fails - .iter() - .map(std::string::String::as_str) - .collect::>(), - ); -} - -#[test] -/// Test if the `char_val` rule passes properly. -fn check_char_val() { - check_tests_rule(Rule::char_val_TEST, CHAR_VAL_PASSES, CHAR_VAL_FAILS); -} diff --git a/hermes/crates/cbork/cddl-parser/Cargo.toml b/hermes/crates/cbork/cddl-parser/Cargo.toml deleted file mode 100644 index a693c65d9..000000000 --- a/hermes/crates/cbork/cddl-parser/Cargo.toml +++ /dev/null @@ -1,17 +0,0 @@ -#cspell: words memchr - -[package] -name = "cddl-parser" -version = "0.1.0" -edition.workspace = true -license = "MIT OR Apache-2.0" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[lints] -workspace = true - -[dependencies] -derive_more = "0.99.17" -pest = { version = "2.7.2", features = ["std", "pretty-print", "memchr", "const_prec_climber"] } -pest_derive = { version = "2.7.2", features = ["grammar-extras"] } diff --git a/hermes/crates/cbork/cddl-parser/src/grammar/cddl_modules.pest b/hermes/crates/cbork/cddl-parser/src/grammar/cddl_modules.pest deleted file mode 100644 index 908bc39a6..000000000 --- a/hermes/crates/cbork/cddl-parser/src/grammar/cddl_modules.pest +++ /dev/null @@ -1 +0,0 @@ -// working in progress \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/src/grammar/cddl_test.pest b/hermes/crates/cbork/cddl-parser/src/grammar/cddl_test.pest deleted file mode 100644 index 4eb04bda5..000000000 --- a/hermes/crates/cbork/cddl-parser/src/grammar/cddl_test.pest +++ /dev/null @@ -1,101 +0,0 @@ - -// ----------------------------------------------------------------------------- -// Test Expressions ONLY TO Be USED by Unit Tests. -// Extends `cddl.pest` with rules needed to properly check sub-rules. - -// cspell: words intfloat hexfloat groupname assignt -// cspell: words assigng genericparm genericarg rangeop ctlop -// cspell: words grpchoice grpent memberkey bareword optcom - -/// Test Expression for the `rule` Rule. -rule_TEST = ${ SOI ~ rule ~ EOI } - -/// Test Expression for the `typename` Rule. -typename_TEST = ${ SOI ~ typename ~ EOI } - -/// Test Expression for the `groupname` Rule. -groupname_TEST = ${ SOI ~ groupname ~ EOI } - -/// Test Expression for the `assignt` Rule. -assignt_TEST = ${ SOI ~ assignt ~ EOI } - -/// Test Expression for the `assigng` Rule. -assigng_TEST = ${ SOI ~ assigng ~ EOI } - -/// Test Expression for the `genericparm` Rule. -genericparm_TEST = ${ SOI ~ genericparm ~ EOI } - -/// Test Expression for the `genericarg` Rule. -genericarg_TEST = ${ SOI ~ genericarg ~ EOI } - -/// Test Expression for the `type` Rule. -type_TEST = ${ SOI ~ type ~ EOI } - -/// Test Expression for the `type1` Rule. -type1_TEST = ${ SOI ~ type1 ~ EOI } - -/// Test Expression for the `type2` Rule. -type2_TEST = ${ SOI ~ type2 ~ EOI } - -/// Test Expression for the `rangeop` Rule. -rangeop_TEST = ${ SOI ~ rangeop ~ EOI } - -/// Test Expression for the `ctlop` Rule. -ctlop_TEST = ${ SOI ~ ctlop ~ EOI } - -/// Test Expression for the `group` Rule. -group_TEST = ${ SOI ~ group ~ EOI } - -/// Test Expression for the `grpchoice` Rule. -grpchoice_TEST = ${ SOI ~ grpchoice ~ EOI } - -/// Test Expression for the `grpent` Rule. -grpent_TEST = ${ SOI ~ grpent ~ EOI } - -/// Test Expression for the `memberkey` Rule. -memberkey_TEST = ${ SOI ~ memberkey ~ EOI } - -/// Test Expression for the `bareword` Rule. -bareword_TEST = ${ SOI ~ bareword ~ EOI } - -/// Test Expression for the `optcom` Rule. -optcom_TEST = ${ SOI ~ optcom ~ EOI } - -/// Test Expression for the `occur` Rule. -occur_TEST = ${ SOI ~ occur ~ EOI } - -/// Test Expression for the `S` Rule. -S_TEST = ${ SOI ~ S ~ EOI } - -/// Test Expression for the `COMMENT` Rule. -COMMENT_TEST = { SOI ~ COMMENT* ~ EOI } - -/// Test expression for the URL_BASE64 Rule. -URL_BASE64_TEST = { SOI ~ URL_BASE64 ~ EOI } - -/// Test expression to the `id` Rule. -id_TEST = ${ SOI ~ id ~ EOI} - -/// Test expression to the `bytes` Rule. -bytes_TEST = ${ SOI ~ bytes ~ EOI} - -/// Test expression to the `text` Rule. -text_TEST = ${ SOI ~ text ~ EOI} - -/// Test expression to the `uint` Rule. -uint_TEST = ${ SOI ~ uint ~ EOI} - -/// Test expression to the `int` Rule. -int_TEST = ${ SOI ~ int ~ EOI} - -/// Test expression to the `intfloat` Rule. -intfloat_TEST = ${ SOI ~ intfloat ~ EOI} - -/// Test expression to the `hexfloat` Rule. -hexfloat_TEST = ${ SOI ~ hexfloat ~ EOI} - -/// Test expression to the `number` Rule. -number_TEST = ${ SOI ~ number ~ EOI} - -/// Test expression to the `value` Rule. -value_TEST = ${ SOI ~ value ~ EOI} \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/src/grammar/postlude.cddl b/hermes/crates/cbork/cddl-parser/src/grammar/postlude.cddl deleted file mode 100644 index ebdd5cadf..000000000 --- a/hermes/crates/cbork/cddl-parser/src/grammar/postlude.cddl +++ /dev/null @@ -1,50 +0,0 @@ -; CDDL Standard Postlude as defined by Appendix D of RFC8610 -; https://www.rfc-editor.org/rfc/rfc8610#appendix-D - -; cspell: words nint tstr tdate biguint decfrac bigfloat cbor bignint - -any = # - -uint = #0 -nint = #1 -int = uint / nint - -bstr = #2 -bytes = bstr -tstr = #3 -text = tstr - -tdate = #6.0(tstr) -time = #6.1(number) -number = int / float -biguint = #6.2(bstr) -bignint = #6.3(bstr) -bigint = biguint / bignint -integer = int / bigint -unsigned = uint / biguint -decfrac = #6.4([e10: int, m: integer]) -bigfloat = #6.5([e2: int, m: integer]) -eb64url = #6.21(any) -eb64legacy = #6.22(any) -eb16 = #6.23(any) -encoded-cbor = #6.24(bstr) -uri = #6.32(tstr) -b64url = #6.33(tstr) -b64legacy = #6.34(tstr) -regexp = #6.35(tstr) -mime-message = #6.36(tstr) -cbor-any = #6.55799(any) - -float16 = #7.25 -float32 = #7.26 -float64 = #7.27 -float16-32 = float16 / float32 -float32-64 = float32 / float64 -float = float16-32 / float64 - -false = #7.20 -true = #7.21 -bool = false / true -nil = #7.22 -null = nil -undefined = #7.23 \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/src/grammar/rfc_8610.pest b/hermes/crates/cbork/cddl-parser/src/grammar/rfc_8610.pest deleted file mode 100644 index 4a609ca51..000000000 --- a/hermes/crates/cbork/cddl-parser/src/grammar/rfc_8610.pest +++ /dev/null @@ -1,186 +0,0 @@ -//! CDDL Grammar adapted from RFC8610 Appendix B -//! https://www.rfc-editor.org/rfc/rfc8610#appendix-B - -// cspell: words assignt groupname grpent genericparm assigng optcom -// cspell: words genericarg rangeop ctlop grpchoice memberkey bareword hexfloat intfloat -// cspell: words SCHAR BCHAR PCHAR SESC FFFD Characterset Visiable - -cddl = ${ - SOI - ~ S ~ (rule ~ S)+ - ~ EOI -} - -// ----------------------------------------------------------------------------- -// Rules -rule = ${ - (typename ~ genericparm? ~ S ~ assignt ~ S ~ type) - | (groupname ~ genericparm? ~ S ~ assigng ~ S ~ grpent) -} - -typename = { id } -groupname = { id } - -assignt = { "=" | "/=" } -assigng = { "=" | "//=" } - -genericparm = ${ "<" ~ S ~ id ~ S ~ ("," ~ S ~ id ~ S)* ~ ">" } -genericarg = ${ "<" ~ S ~ type1 ~ S ~ ("," ~ S ~ type1 ~ S)* ~ ">" } - -// ----------------------------------------------------------------------------- -// Type Declaration -type = ${ type1 ~ (S ~ "/" ~ S ~ type1)* } - -type1 = ${ type2 ~ (S ~ (rangeop | ctlop) ~ S ~ type2)? } - -type2 = ${ - value - | typename ~ genericarg? - | ("(" ~ S ~ type ~ S ~ ")") - | ("{" ~ S ~ group ~ S ~ "}") - | ("[" ~ S ~ group ~ S ~ "]") - | ("~" ~ S ~ typename ~ genericarg?) - | ("&" ~ S ~ "(" ~ S ~ group ~ S ~ ")") - | ("&" ~ S ~ groupname ~ genericarg?) - | ("#" ~ "6" ~ ("." ~ uint)? ~ "(" ~ S ~ type ~ S ~ ")") - | ("#" ~ ASCII_DIGIT ~ ("." ~ uint)?) - | "#" -} - -rangeop = { "..." | ".." } -ctlop = ${ "." ~ id } - -// ----------------------------------------------------------------------------- -// Group Elements -group = ${ grpchoice ~ (S ~ "//" ~ S ~ grpchoice)* } - -grpchoice = ${ (grpent ~ optcom)* } - -grpent = ${ - ((occur ~ S)? ~ (memberkey ~ S)? ~ type) - | ((occur ~ S)? ~ groupname ~ genericarg?) - | ((occur ~ S)? ~ "(" ~ S ~ group ~ S ~ ")") -} - -memberkey = ${ - (type1 ~ S ~ ("^" ~ S)? ~ "=>") - | ((value | bareword) ~ S ~ ":") -} - -bareword = { id } - -/// Optional Comma - Note eligible for producing pairs as this might be useful for linting -optcom = { S ~ ("," ~ S)? } - -occur = { - (uint? ~ "*" ~ uint?) - | "+" - | "?" -} - -// ----------------------------------------------------------------------------- -// Literal Values - -/// All Literal Values -value = { number | text | bytes } - -/// Literal Numbers - A float if it has fraction or exponent; int otherwise -number = { hexfloat | intfloat } - -/// Hex floats of the form -0x123.abc0p+12 -hexfloat = ${ "-"? ~ "0x" ~ ASCII_HEX_DIGIT+ ~ ("." ~ ASCII_HEX_DIGIT+)? ~ "p" ~ exponent } - -/// Ints or Int floats -intfloat = ${ int ~ ("." ~ fraction)? ~ ("e" ~ exponent)? } - -/// Fractional part of a number -fraction = ${ ASCII_DIGIT+ } - -/// Exponent for a number -exponent = ${ ("+" | "-") ~ ASCII_DIGIT+ } - -/// All integers, singed and unsigned -int = ${ "-"? ~ uint } - - -/// Unsigned Integers -uint = ${ - (ASCII_NONZERO_DIGIT ~ ASCII_DIGIT*) - | ("0x" ~ ASCII_HEX_DIGIT+) - | ("0b" ~ ASCII_BIN_DIGIT+) - | "0" -} - -/// Literal Text -text = ${ "\"" ~ SCHAR* ~ "\"" } - -/// Literal Bytes. -bytes = ${ bytes_hex | bytes_b64 | bytes_text } -bytes_hex = ${ "h" ~ "'" ~ HEX_PAIR* ~ "'" } -bytes_b64 = ${ "b64" ~ "'" ~ URL_BASE64 ~ "'" } -bytes_text = ${ "'" ~ BCHAR* ~ "'" } - -// ----------------------------------------------------------------------------- -// Simple multiple character sequences - -/// identifier, called the `name` in the CDDL spec. -id = ${ group_socket | type_socket | name } -/// Special form of a name that represents a Group Socket. -group_socket = ${ "$$" ~ ( ( "-" | "." )* ~ NAME_END )* } -/// Special form of a name that represents a Type Socket. -type_socket = ${ "$" ~ ( ( "-" | "." )* ~ NAME_END )* } -/// General form of a name. -name = ${ NAME_START ~ ( ( "-" | "." )* ~ NAME_END )* } - -/// A pair of hex digits. (Must always have even numbers of hex digits.) -HEX_PAIR = _{ S ~ ASCII_HEX_DIGIT ~ S ~ ASCII_HEX_DIGIT ~ S } - -/// Whitespace is allowed and is ignored. -/// This token will keep the whitespace, so it will need to handled when converted to binary. -URL_BASE64 = _{ S ~ ( URL_BASE64_ALPHA ~ S)* ~ URL_BASE64_PAD? } - - -// ----------------------------------------------------------------------------- -// Characters, Whitespace and Comments - -S = _{ (COMMENT | WHITESPACE)* } -WHITESPACE = _{ " " | "\t" | NEWLINE } -COMMENT = { ";" ~ (PCHAR | "\t")* ~ NEWLINE } - -URL_BASE64_ALPHA = _{ ASCII_ALPHA | ASCII_DIGIT | "-" | "_" } -// Optional Padding that goes at the end of Base64. -URL_BASE64_PAD = _{ "~" } - -// Identifier Name Character sets. - -/// A name can start with an alphabetic character (including "@", "_", "$") -/// The body of the name can consist of any of the characters from the set -/// {"A" to "Z", "a" to "z", "0" to "9", "_", "-", "@", ".", "$"} -// NAME_BODY = _{ NAME_END | "-" | "." } -- Unused Rule -NAME_START = _{ ASCII_ALPHA | "@" | "_" | "$" } -/// A name can end with an alphabetic character (including "@", "_", "$") or a digit. -NAME_END = _{ NAME_START | ASCII_DIGIT } - -/// All Visible characters. -PCHAR = _{ ASCII_VISIBLE | UNICODE_CHAR } - -/// The set of characters valid for a text string. -SCHAR = _{ SCHAR_ASCII_VISIBLE | UNICODE_CHAR | SESC } - -/// The set of characters valid for a byte string. -BCHAR = _{ BCHAR_ASCII_VISIBLE | UNICODE_CHAR | SESC | NEWLINE } - -/// Escaping code to allow invalid characters to be used in text or byte strings. -SESC = ${ "\\" ~ (ASCII_VISIBLE | UNICODE_CHAR) } - -/// All Visible Ascii characters. -ASCII_VISIBLE = _{ ' '..'~' } - -/// Ascii subset valid for text strings. -SCHAR_ASCII_VISIBLE = _{ ' '..'!' | '#'..'[' | ']'..'~' } - -/// Ascii subset valid for byte text strings. -BCHAR_ASCII_VISIBLE = _{ ' '..'&' | '('..'[' | ']'..'~' } - -/// Valid non ascii unicode Characters -UNICODE_CHAR = _{ '\u{80}'..'\u{10FFFD}' } \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/src/grammar/rfc_9165.pest b/hermes/crates/cbork/cddl-parser/src/grammar/rfc_9165.pest deleted file mode 100644 index c9aaec9b2..000000000 --- a/hermes/crates/cbork/cddl-parser/src/grammar/rfc_9165.pest +++ /dev/null @@ -1 +0,0 @@ -// working in progress diff --git a/hermes/crates/cbork/cddl-parser/src/lib.rs b/hermes/crates/cbork/cddl-parser/src/lib.rs deleted file mode 100644 index b452c87ea..000000000 --- a/hermes/crates/cbork/cddl-parser/src/lib.rs +++ /dev/null @@ -1,161 +0,0 @@ -#![allow(missing_docs)] // TODO(apskhem): Temporary, to bo removed in a subsequent PR - -//! A parser for CDDL, utilized for parsing in accordance with RFC 8610. - -use std::fmt::Debug; - -use derive_more::{Display, From}; -pub use pest::Parser; -use pest::{error::Error, iterators::Pairs}; - -pub mod rfc_8610 { - pub use pest::Parser; - - #[derive(pest_derive::Parser)] - #[grammar = "grammar/rfc_8610.pest"] - pub struct RFC8610Parser; -} - -pub mod rfc_9165 { - pub use pest::Parser; - - #[derive(pest_derive::Parser)] - #[grammar = "grammar/rfc_8610.pest"] - #[grammar = "grammar/rfc_9165.pest"] - pub struct RFC8610Parser; -} - -pub mod cddl { - pub use pest::Parser; - - #[derive(pest_derive::Parser)] - #[grammar = "grammar/rfc_8610.pest"] - #[grammar = "grammar/rfc_9165.pest"] - #[grammar = "grammar/cddl_modules.pest"] - pub struct RFC8610Parser; -} - -pub mod cddl_test { - pub use pest::Parser; - - // Parser with DEBUG rules. These rules are only used in tests. - #[derive(pest_derive::Parser)] - #[grammar = "grammar/rfc_8610.pest"] - #[grammar = "grammar/rfc_9165.pest"] - #[grammar = "grammar/cddl_modules.pest"] - #[grammar = "grammar/cddl_test.pest"] // Ideally this would only be used in tests. - pub struct CDDLTestParser; -} - -/// Represents different parser extensions for handling CDDL specifications. -pub enum Extension { - /// RFC8610 ONLY limited parser. - RFC8610Parser, - /// RFC8610 and RFC9165 limited parser. - RFC9165Parser, - /// RFC8610, RFC9165, and CDDL modules. - CDDLParser, -} - -// CDDL Standard Postlude - read from an external file -pub const POSTLUDE: &str = include_str!("grammar/postlude.cddl"); - -// TODO: this is temporary. need to add more pragmatic nodes -#[derive(Debug)] -/// Abstract Syntax Tree (AST) representing parsed CDDL syntax. -pub enum AST<'a> { - /// Represents the AST for RFC 8610 CDDL rules. - RFC8610(Pairs<'a, rfc_8610::Rule>), - /// Represents the AST for RFC 9165 CDDL rules. - RFC9165(Pairs<'a, rfc_9165::Rule>), - /// Represents the AST for CDDL Modules rules. - CDDL(Pairs<'a, cddl::Rule>), -} - -/// Represents different types of errors related to different types of extension. -#[derive(Display, Debug)] -pub enum CDDLErrorType { - /// An error related to RFC 8610 extension. - RFC8610(Error), - /// An error related to RFC 9165 extension. - RFC9165(Error), - /// An error related to CDDL modules extension. - CDDL(Error), -} - -/// Represents an error that may occur during CDDL parsing. -#[derive(Display, Debug, From)] -pub struct CDDLError(CDDLErrorType); - -/// Parses and checks semantically a CDDL input string. -/// -/// # Arguments -/// -/// * `input` - A string containing the CDDL input to be parsed. -/// -/// # Returns -/// -/// Returns `Ok(())` if parsing is successful, otherwise returns an `Err` containing -/// a boxed `CDDLError` indicating the parsing error. -/// -/// # Errors -/// -/// This function may return an error in the following cases: -/// -/// - If there is an issue with parsing the CDDL input. -/// -/// # Examples -/// -/// ```rs -/// use cddl_parser::{parse_cddl, Extension}; -/// use std:fs; -/// -/// let mut input = fs::read_to_string("path/to/your/file.cddl").unwrap(); -/// let result = parse_cddl(&mut input, &Extension::CDDLParser); -/// assert!(result.is_ok()); -/// ``` -pub fn parse_cddl<'a>( - input: &'a mut String, extension: &Extension, -) -> Result, Box> { - input.push_str("\n\n"); - input.push_str(POSTLUDE); - - let result = match extension { - Extension::RFC8610Parser => { - rfc_8610::RFC8610Parser::parse(rfc_8610::Rule::cddl, input) - .map(AST::RFC8610) - .map_err(CDDLErrorType::RFC8610) - }, - Extension::RFC9165Parser => { - rfc_9165::RFC8610Parser::parse(rfc_9165::Rule::cddl, input) - .map(AST::RFC9165) - .map_err(CDDLErrorType::RFC9165) - }, - Extension::CDDLParser => { - cddl::RFC8610Parser::parse(cddl::Rule::cddl, input) - .map(AST::CDDL) - .map_err(CDDLErrorType::CDDL) - }, - }; - - result.map_err(|e| Box::new(CDDLError::from(e))) -} - -#[cfg(test)] -mod tests { - use crate::*; - - #[test] - fn it_works() { - let mut input = String::new(); - let result = parse_cddl(&mut input, &Extension::CDDLParser); - - match result { - Ok(c) => println!("{c:?}"), - Err(e) => { - println!("{e:?}"); - println!("{e}"); - }, - } - } -} diff --git a/hermes/crates/cbork/cddl-parser/tests/byte_sequences.rs b/hermes/crates/cbork/cddl-parser/tests/byte_sequences.rs deleted file mode 100644 index 5df53da86..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/byte_sequences.rs +++ /dev/null @@ -1,24 +0,0 @@ -// cspell: words hexpair rstuvw abcdefghijklmnopqrstuvwyz rstuvw Xhhb Bhcm - -use cddl_parser::cddl_test::Rule; - -mod common; -use common::byte_sequences::*; - -#[test] -/// Test if the `HEX_PAIR` rule passes properly. -fn check_hexpair() { - common::check_tests_rule(Rule::HEX_PAIR, HEXPAIR_PASSES, HEXPAIR_FAILS); -} - -#[test] -/// Test if the `URL_BASE64` rule passes properly. -fn check_url_base64() { - common::check_tests_rule(Rule::URL_BASE64_TEST, URL_BASE64_PASSES, URL_BASE64_FAILS); -} - -#[test] -/// Test if the `bytes` rule passes properly. -fn check_bytes() { - common::check_tests_rule(Rule::bytes_TEST, BYTES_PASSES, BYTES_FAILS); -} diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl.rs b/hermes/crates/cbork/cddl-parser/tests/cddl.rs deleted file mode 100644 index b2e9f525c..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl.rs +++ /dev/null @@ -1,52 +0,0 @@ -use std::{ffi::OsStr, fs, io::Result}; - -use cddl_parser::{parse_cddl, Extension}; - -#[test] -/// # Panics -fn parse_cddl_files() { - let entries = fs::read_dir("tests/cddl").unwrap(); - - let mut file_paths: Vec<_> = entries - .filter_map(Result::ok) - .filter_map(|x| x.path().is_file().then_some(x.path())) - .collect(); - - file_paths.sort(); - - let valid_file_paths = file_paths.iter().filter(|p| { - p.file_name() - .and_then(OsStr::to_str) - .map(|p| p.starts_with("valid")) - .is_some_and(|p| p) - }); - let invalid_file_paths = file_paths.iter().filter(|p| { - p.file_name() - .and_then(OsStr::to_str) - .map(|p| p.starts_with("invalid")) - .is_some_and(|p| p) - }); - - // test for valid files - let mut err_messages = vec![]; - for file_path in valid_file_paths { - let mut content = fs::read_to_string(file_path).unwrap(); - - if let Err(e) = parse_cddl(&mut content, &Extension::CDDLParser) { - err_messages.push(format!("{}) {file_path:?} {e}", err_messages.len() + 1)); - } - } - - // test for invalid files - for file_path in invalid_file_paths { - let mut content = fs::read_to_string(file_path).unwrap(); - - let result = parse_cddl(&mut content, &Extension::CDDLParser); - - assert!(result.is_err(), "{:?} is expected to fail", &file_path); - } - - // summary - let err_msg = err_messages.join("\n\n"); - assert!(err_msg.is_empty(), "{err_msg}"); -} diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/invalid_rfc8610_sample_1.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/invalid_rfc8610_sample_1.cddl deleted file mode 100644 index f0b22f1e4..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/invalid_rfc8610_sample_1.cddl +++ /dev/null @@ -1 +0,0 @@ -parentheses_mismatch = ( int \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/invalid_rfc8610_sample_2.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/invalid_rfc8610_sample_2.cddl deleted file mode 100644 index e05f50fdf..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/invalid_rfc8610_sample_2.cddl +++ /dev/null @@ -1,4 +0,0 @@ -; cspell: words tstr - -sample = { - tstr => tstr \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/invalid_rfc8610_sample_3.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/invalid_rfc8610_sample_3.cddl deleted file mode 100644 index cc09425d0..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/invalid_rfc8610_sample_3.cddl +++ /dev/null @@ -1,5 +0,0 @@ -; cspell: words tstr - -sample = ; comment here { - tstr => tstr -} \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/invalid_rfc8610_sample_4.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/invalid_rfc8610_sample_4.cddl deleted file mode 100644 index 615c9c7f3..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/invalid_rfc8610_sample_4.cddl +++ /dev/null @@ -1,2 +0,0 @@ -outer = { inner: int } -incorrectly_nested = outer inner: int \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/invalid_rfc8610_sample_5.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/invalid_rfc8610_sample_5.cddl deleted file mode 100644 index 494d46c73..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/invalid_rfc8610_sample_5.cddl +++ /dev/null @@ -1 +0,0 @@ -missing_definition \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/invalid_rfc8610_sample_6.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/invalid_rfc8610_sample_6.cddl deleted file mode 100644 index 6120ddd74..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/invalid_rfc8610_sample_6.cddl +++ /dev/null @@ -1 +0,0 @@ -invalid_char = int & \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/invalid_rfc8610_sample_7.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/invalid_rfc8610_sample_7.cddl deleted file mode 100644 index a89f99313..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/invalid_rfc8610_sample_7.cddl +++ /dev/null @@ -1 +0,0 @@ -empty_rule = \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/invalid_rfc8610_sample_8.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/invalid_rfc8610_sample_8.cddl deleted file mode 100644 index 0ad76396f..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/invalid_rfc8610_sample_8.cddl +++ /dev/null @@ -1 +0,0 @@ -unexpected_token = % \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/invalid_rfc8610_sample_9.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/invalid_rfc8610_sample_9.cddl deleted file mode 100644 index ebad7d015..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/invalid_rfc8610_sample_9.cddl +++ /dev/null @@ -1,2 +0,0 @@ -missing_group_open int -missing_group_close = int \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_arrays.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_arrays.cddl deleted file mode 100644 index 04465a589..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_arrays.cddl +++ /dev/null @@ -1,11 +0,0 @@ -; 3.4. Arrays - -; cspell: words tstr - -unlimited-people = [* person] -one-or-two-people = [1*2 person] -at-least-two-people = [2* person] -person = ( - name: tstr, - age: uint, -) \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_ctrl_bits.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_ctrl_bits.cddl deleted file mode 100644 index 096b876e7..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_ctrl_bits.cddl +++ /dev/null @@ -1,19 +0,0 @@ -; 3.8.2. Control Operator .bits - -; cspell: words tcpflagbytes rwxbits - -tcpflagbytes = bstr .bits flags -flags = &( - fin: 8, - syn: 9, - rst: 10, - psh: 11, - ack: 12, - urg: 13, - ece: 14, - cwr: 15, - ns: 0, -) / (4..7) ; data offset bits - -rwxbits = uint .bits rwx -rwx = &(r: 2, w: 1, x: 0) \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_ctrl_ord.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_ctrl_ord.cddl deleted file mode 100644 index 3cc737c91..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_ctrl_ord.cddl +++ /dev/null @@ -1,8 +0,0 @@ -; 3.8.6. Control Operators .lt, .le, .gt, .ge, .eq, .ne, and .default - -speed = number .ge 0 ; unit: m/s - -timer = { - time: uint, - ? displayed-step: (number .gt 0) .default 1 -} \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_ctrl_regexp.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_ctrl_regexp.cddl deleted file mode 100644 index 04c4f6a61..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_ctrl_regexp.cddl +++ /dev/null @@ -1,7 +0,0 @@ -; 3.8.3. Control Operator .regexp - -; cspell: words tstr - -nai = tstr .regexp "[A-Za-z0-9]+@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)+" - -; "N1@CH57HF.4Znqe0.dYJRN.igjf" should pass this regexp \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_ctrl_size.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_ctrl_size.cddl deleted file mode 100644 index 6a2b27601..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_ctrl_size.cddl +++ /dev/null @@ -1,8 +0,0 @@ -; 3.8.1. Control Operator .size - -full-address = [[+ label], ip4, ip6] -ip4 = bstr .size 4 -ip6 = bstr .size 16 -label = bstr .size (1..63) - -audio_sample = uint .size 3 ; 24-bit, equivalent to 0...16777216 \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_ctrl_within_and.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_ctrl_within_and.cddl deleted file mode 100644 index d34003df0..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_ctrl_within_and.cddl +++ /dev/null @@ -1,9 +0,0 @@ -; 3.8.5. Control Operators .within and .and - -message = $message .within message-structure -message-structure = [message_type, *message_option] -message_type = 0..255 -message_option = any - -$message /= [3, dough: text, topping: [* text]] -$message /= [4, noodles: text, sauce: text, parmesan: bool] \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_cuts_in_maps.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_cuts_in_maps.cddl deleted file mode 100644 index e2b49c184..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_cuts_in_maps.cddl +++ /dev/null @@ -1,8 +0,0 @@ -; 3.5.4. Cuts in Maps - -; cspell: words tstr - -extensible-map-example = { - ? "optional-key" => int, - * tstr => any -} \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_cuts_in_maps_alt_1.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_cuts_in_maps_alt_1.cddl deleted file mode 100644 index ac73c3649..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_cuts_in_maps_alt_1.cddl +++ /dev/null @@ -1,8 +0,0 @@ -; 3.5.4. Cuts in Maps - -; cspell: words tstr - -extensible-map-example = { - ? "optional-key" ^ => int, - * tstr => any -} \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_cuts_in_maps_alt_2.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_cuts_in_maps_alt_2.cddl deleted file mode 100644 index 1283a7c7d..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_cuts_in_maps_alt_2.cddl +++ /dev/null @@ -1,8 +0,0 @@ -; 3.5.4. Cuts in Maps - -; cspell: words tstr - -extensible-map-example = { - ? "optional-key": int, - * tstr => any -} \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_cuts_in_maps_alt_3.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_cuts_in_maps_alt_3.cddl deleted file mode 100644 index f8e239051..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_cuts_in_maps_alt_3.cddl +++ /dev/null @@ -1,8 +0,0 @@ -; 3.5.4. Cuts in Maps - -; cspell: words tstr - -extensible-map-example = { - ? optional-key: int, - * tstr => any -} \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_example_array_object.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_example_array_object.cddl deleted file mode 100644 index 0590259b7..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_example_array_object.cddl +++ /dev/null @@ -1,10 +0,0 @@ -root = [2*2 { - precision: text, - Latitude: float, - Longitude: float, - Address: text, - City: text, - State: text, - Zip: text, - Country: text -}] \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_example_nested_object.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_example_nested_object.cddl deleted file mode 100644 index 6f36f7942..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_example_nested_object.cddl +++ /dev/null @@ -1,22 +0,0 @@ -root = { image } - -image = ( - Image: { - size, - Title: text, - thumbnail, - IDs: [* int] - } -) - -size = ( - Width: 0..1280 - Height: 0..1024 -) - -thumbnail = ( - Thumbnail: { - size, - Url: ~uri - } -) \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_example_nested_object_compact.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_example_nested_object_compact.cddl deleted file mode 100644 index 1b00b80bb..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_example_nested_object_compact.cddl +++ /dev/null @@ -1,12 +0,0 @@ -root = { - Image: { - size, Title: text, - Thumbnail: { size, Url: ~uri }, - IDs: [* int] - } -} - -size = ( - Width: 0..1280, - Height: 0..1024, -) \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_generics.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_generics.cddl deleted file mode 100644 index a541cd121..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_generics.cddl +++ /dev/null @@ -1,4 +0,0 @@ -; 3.10. Generics - -messages = message<"reboot", "now"> / message<"sleep", 1..100> -message = {type: t, value: v} \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_group_to_choice.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_group_to_choice.cddl deleted file mode 100644 index e172f919f..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_group_to_choice.cddl +++ /dev/null @@ -1,13 +0,0 @@ -; 2.2.2.2. Turning a Group into a Choice - -; cspell: words basecolors - -terminal-color = &basecolors -basecolors = ( - black: 0, red: 1, green: 2, yellow: 3, - blue: 4, magenta: 5, cyan: 6, white: 7, -) -extended-color = &( - basecolors, - orange: 8, pink: 9, purple: 10, brown: 11, -) \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_non_deterministic_order.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_non_deterministic_order.cddl deleted file mode 100644 index 9c8738ba3..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_non_deterministic_order.cddl +++ /dev/null @@ -1,13 +0,0 @@ -; 3.5.3. Non-deterministic Order - -labeled-values = { - ? fritz: number, - * label => value -} -label = text -value = number - -do-not-do-this = { - int => int, - int => 6, -} \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_occurence.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_occurence.cddl deleted file mode 100644 index 10327de08..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_occurence.cddl +++ /dev/null @@ -1,7 +0,0 @@ -; 3.2. Occurrence - -apartment = { - kitchen: size, - * bedroom: size, -} -size = float ; in m2 \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_op_precedence.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_op_precedence.cddl deleted file mode 100644 index 39c494fc8..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_op_precedence.cddl +++ /dev/null @@ -1,21 +0,0 @@ -; 3.11. Operator Precedence - -t = [group1] -group1 = (a / b // c / d) -a = 1 b = 2 c = 3 d = 4 - -t = {group2} -group2 = (? ab: a / b // cd: c / d) -a = 1 b = 2 c = 3 d = 4 - -t = [group3] -group3 = (+ a / b / c) -a = 1 b = 2 c = 3 - -t = [group4] -group4 = (+ a // b / c) -a = 1 b = 2 c = 3 - -t = [group4a] -group4a = ((+ a) // (b / c)) -a = 1 b = 2 c = 3 \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_ranges.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_ranges.cddl deleted file mode 100644 index f7190a325..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_ranges.cddl +++ /dev/null @@ -1,16 +0,0 @@ -; 2.2.2.1. Ranges - -device-address = byte -max-byte = 255 -byte = 0..max-byte ; inclusive range -first-non-byte = 256 -byte1 = 0...first-non-byte ; byte1 is equivalent to byte - -int-range = 0..10 ; only integers match -float-range = 0.0..10.0 ; only floats match -BAD-range1 = 0..10.0 ; NOT DEFINED -BAD-range2 = 0.0..10 ; NOT DEFINED -numeric-range = int-range / float-range - -non-range-expression = min..max -range-expression = min .. max \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_represenation_types.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_represenation_types.cddl deleted file mode 100644 index dfd0f4069..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_represenation_types.cddl +++ /dev/null @@ -1,12 +0,0 @@ -; 2.2.3. Representation Types - -; cspell: words cbor tstr - -my_breakfast = #6.55799(breakfast) ; cbor-any is too general! -breakfast = cereal / porridge -cereal = #6.998(tstr) -porridge = #6.999([liquid, solid]) -liquid = milk / water -milk = 0 -water = 1 -solid = tstr \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_reputon_compact.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_reputon_compact.cddl deleted file mode 100644 index 350acd521..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_reputon_compact.cddl +++ /dev/null @@ -1,19 +0,0 @@ -; cspell: words reputons reputon - -reputation-object = { - application: text - reputons: [* reputon] -} - -reputon = { - rater: text - assertion: text - rated: text - rating: float16 - ? confidence: float16 - ? normal-rating: float16 - ? sample-size: uint - ? generated: uint - ? expires: uint - * text => any -} \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_reputon_full.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_reputon_full.cddl deleted file mode 100644 index 9fdf25462..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_reputon_full.cddl +++ /dev/null @@ -1,40 +0,0 @@ -; cspell: words reputons reputon - -reputation-object = { - reputation-context, - reputon-list -} - -reputation-context = ( - application: text -) - -reputon-list = ( - reputons: reputon-array -) - -reputon-array = [* reputon] - -reputon = { - rater-value, - assertion-value, - rated-value, - rating-value, - ? conf-value, - ? normal-value, - ? sample-value, - ? gen-value, - ? expire-value, - * ext-value, -} - -rater-value = ( rater: text ) -assertion-value = ( assertion: text ) -rated-value = ( rated: text ) -rating-value = ( rating: float16 ) -conf-value = ( confidence: float16 ) -normal-value = ( normal-rating: float16 ) -sample-value = ( sample-size: uint ) -gen-value = ( generated: uint ) -expire-value = ( expires: uint ) -ext-value = ( text => any ) diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_simple_1.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_simple_1.cddl deleted file mode 100644 index a3a5a0160..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_simple_1.cddl +++ /dev/null @@ -1,9 +0,0 @@ -; Figure 1: Using a Group Directly in a Map - -; cspell: words tstr - -person = { - age: int, - name: tstr, - employer: tstr, -} \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_simple_2.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_simple_2.cddl deleted file mode 100644 index 73da918a3..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_simple_2.cddl +++ /dev/null @@ -1,9 +0,0 @@ -; Figure 2: A Basic Group - -; cspell: words tstr - -pii = ( - age: int, - name: tstr, - employer: tstr, -) \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_simple_3.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_simple_3.cddl deleted file mode 100644 index cb53425a1..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_simple_3.cddl +++ /dev/null @@ -1,13 +0,0 @@ -; Figure 3: Using a Group by Name - -; cspell: words tstr - -person = { - pii -} - -pii = ( - age: int, - name: tstr, - employer: tstr, -) \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_simple_4.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_simple_4.cddl deleted file mode 100644 index d787a8838..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_simple_4.cddl +++ /dev/null @@ -1,9 +0,0 @@ -; Figure 4: Using a Parenthesized Group in a Map - -; cspell: words tstr - -person = {( - age: int, - name: tstr, - employer: tstr, -)} \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_simple_5.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_simple_5.cddl deleted file mode 100644 index deae51f7e..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_simple_5.cddl +++ /dev/null @@ -1,15 +0,0 @@ -; Figure 5: Maps with Copy/Paste - -; cspell: words tstr - -person = { - age: int, - name: tstr, - employer: tstr, -} - -dog = { - age: int, - name: tstr, - leash-length: float, -} \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_simple_6.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_simple_6.cddl deleted file mode 100644 index 1be65c13e..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_simple_6.cddl +++ /dev/null @@ -1,18 +0,0 @@ -; Figure 6: Using a Group for Factorization - -; cspell: words tstr - -person = { - identity, - employer: tstr, -} - -dog = { - identity, - leash-length: float, -} - -identity = ( - age: int, - name: tstr, -) \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_simple_7.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_simple_7.cddl deleted file mode 100644 index 0bf9dba22..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_simple_7.cddl +++ /dev/null @@ -1,17 +0,0 @@ -; 2.2.2. Choices - -; cspell: words tstr - -attire = "bow tie" / "necktie" / "Internet attire" -protocol = 6 / 17 - -address = { delivery } - -delivery = ( -street: tstr, ? number: uint, city // -po-box: uint, city // -per-pickup: true ) - -city = ( -name: tstr, zip-code: uint -) \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_simple_8.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_simple_8.cddl deleted file mode 100644 index d55779ca6..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_simple_8.cddl +++ /dev/null @@ -1,9 +0,0 @@ -; 2.2.2. Choices - -; cspell: words tstr - -attire /= "swimwear" - -delivery //= ( -lat: float, long: float, drone-type: tstr -) \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_simple_9.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_simple_9.cddl deleted file mode 100644 index 517e44c45..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_simple_9.cddl +++ /dev/null @@ -1,9 +0,0 @@ -; cspell: words tstr bareword - -; This is a comment -person = { g } - -g = ( - "name": tstr, - age: int, ; "age" is a bareword -) \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_socket_plug.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_socket_plug.cddl deleted file mode 100644 index e42eac779..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_socket_plug.cddl +++ /dev/null @@ -1,15 +0,0 @@ -; 3.9. Socket/Plug - -tcp-header = {seq: uint, ack: uint, * $$tcp-option} - -; later, in a different file - -$$tcp-option //= ( -sack: [+(left: uint, right: uint)] -) - -; and, maybe in another file - -$$tcp-option //= ( - sack-permitted: true -) \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_socket_plug_ext.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_socket_plug_ext.cddl deleted file mode 100644 index 70d981cc1..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_socket_plug_ext.cddl +++ /dev/null @@ -1,28 +0,0 @@ -; 3.9. Socket/Plug - -; cspell: words tstr personaldata shoesize - -PersonalData = { - ? displayName: tstr, - NameComponents, - ? age: uint, - * $$personaldata-extensions -} - -NameComponents = ( - ? firstName: tstr, - ? familyName: tstr, -) - -; The above already works as is. -; But then, we can add later: - -$$personaldata-extensions //= ( - favorite-salsa: tstr, -) - -; and again, somewhere else: - -$$personaldata-extensions //= ( - shoesize: uint, -) \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_structs.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_structs.cddl deleted file mode 100644 index f58d9f46a..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_structs.cddl +++ /dev/null @@ -1,32 +0,0 @@ -; 3.5.1. Structs - -; cspell: words tstr - -Geography = [ - city : tstr, - gpsCoordinates : GpsCoordinates, -] - -GpsCoordinates = { - longitude : uint, ; degrees, scaled by 10^7 - latitude : uint, ; degrees, scaled by 10^7 -} - -located-samples = { - sample-point: int, - samples: [+ float], - * equipment-type => equipment-tolerances, -} -equipment-type = [name: tstr, manufacturer: tstr] -equipment-tolerances = [+ [float, float]] - -PersonalData = { - ? displayName: tstr, - NameComponents, - ? age: uint, -} - -NameComponents = ( - ? firstName: tstr, - ? familyName: tstr, -) \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_structs_alt.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_structs_alt.cddl deleted file mode 100644 index 4787b9674..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_structs_alt.cddl +++ /dev/null @@ -1,18 +0,0 @@ -; 3.5.1. Structs - -; cspell: words tstr - -Geography = [ - city : tstr, - gpsCoordinates : GpsCoordinates, -] - -GpsCoordinates = { - longitude : uint, ; degrees, scaled by 10^7 - latitude : uint, ; degrees, scaled by 10^7 -} - -located-samples = { - "sample-point" => int, - "samples" => [+ float], -} \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_tables.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_tables.cddl deleted file mode 100644 index bce2eab8c..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_tables.cddl +++ /dev/null @@ -1,10 +0,0 @@ -; 3.5.2. Tables - -; cspell: words tstr tostring mynumber - -square-roots = {* x => y} -x = int -y = float - -tostring = {* mynumber => tstr} -mynumber = int / float \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_tags.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_tags.cddl deleted file mode 100644 index 471f76cd8..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_tags.cddl +++ /dev/null @@ -1,9 +0,0 @@ -; 3.6. Tags - -; cspell: words biguint buuid tstr - -biguint = #6.2(bstr) - -buuid = #6.37(bstr) - -my_uri = #6.32(tstr) / tstr \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_unwrapping.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_unwrapping.cddl deleted file mode 100644 index 0d7fe9aaa..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_unwrapping.cddl +++ /dev/null @@ -1,27 +0,0 @@ -; 3.7. Unwrapping - -basic-header-group = ( - field1: int, - field2: text, -) - -basic-header = [ basic-header-group ] - -advanced-header = [ - basic-header-group, - field3: bytes, - field4: number, ; as in the tagged type "time" -] - -; Unwrapping simplifies this to: - -basic-header = [ - field1: int, - field2: text, -] - -advanced-header = [ - ~basic-header, - field3: bytes, - field4: ~time, -] \ No newline at end of file diff --git a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_unwrapping_alt.cddl b/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_unwrapping_alt.cddl deleted file mode 100644 index 24813ddb7..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/cddl/valid_rfc8610_unwrapping_alt.cddl +++ /dev/null @@ -1,12 +0,0 @@ -; Unwrapping simplifies this to: - -basic-header = [ - field1: int, - field2: text, -] - -advanced-header = [ - ~basic-header, - field3: bytes, - field4: ~time, -] diff --git a/hermes/crates/cbork/cddl-parser/tests/character_sets.rs b/hermes/crates/cbork/cddl-parser/tests/character_sets.rs deleted file mode 100644 index 77b4682ec..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/character_sets.rs +++ /dev/null @@ -1,150 +0,0 @@ -// cspell: words PCHAR pchar BCHAR bchar SESC sesc SCHAR schar fffd fffe - -use cddl_parser::{ - self, - cddl_test::{CDDLTestParser, Parser, Rule}, -}; - -#[test] -/// Test if the `WHITESPACE` rule passes properly. -fn check_whitespace() { - let whitespace = vec![" ", "\t", "\r", "\n", "\r\n"]; - - let not_whitespace = "not"; - - for ws in whitespace { - let parse = CDDLTestParser::parse(Rule::WHITESPACE, ws); - assert!(parse.is_ok()); - } - - let parse = CDDLTestParser::parse(Rule::WHITESPACE, not_whitespace); - assert!(parse.is_err()); -} - -#[test] -/// Test if the `PCHAR` rule passes properly. -fn check_pchar() { - for x in ('\u{0}'..='\u{ff}').map(char::from) { - let test = format!("{x}"); - let parse = CDDLTestParser::parse(Rule::PCHAR, &test); - if x < ' ' || x == '\u{7f}' { - assert!(parse.is_err()); - } else { - assert!(parse.is_ok()); - } - } - - let parse = CDDLTestParser::parse(Rule::ASCII_VISIBLE, "\r"); - assert!(parse.is_err()); -} - -#[test] -/// Test if the `BCHAR` rule passes properly. -fn check_bchar() { - for x in ('\u{0}'..='\u{ff}').map(char::from) { - let test = format!("{x}"); - let parse = CDDLTestParser::parse(Rule::BCHAR, &test); - if !matches!(x, '\n' | '\r') && x < ' ' || matches!(x, '\t' | '\'' | '\\' | '\u{7f}') { - assert!(parse.is_err()); - } else { - assert!(parse.is_ok()); - } - } - - let parse = CDDLTestParser::parse(Rule::ASCII_VISIBLE, "\r"); - assert!(parse.is_err()); -} - -#[test] -/// Test if the `SESC` rule passes properly. -fn check_sesc() { - for x in (' '..='\u{ff}').map(char::from) { - let test = format!("\\{x}"); - let parse = CDDLTestParser::parse(Rule::SESC, &test); - if x == '\u{7f}' { - assert!(parse.is_err()); - } else { - assert!(parse.is_ok()); - } - } - - let parse = CDDLTestParser::parse(Rule::ASCII_VISIBLE, "\r"); - assert!(parse.is_err()); -} - -#[test] -/// Test if the `ASCII_VISIBLE` rule passes properly. -fn check_ascii_visible() { - for x in (b' '..=b'~').map(char::from) { - let test = x.to_string(); - let parse = CDDLTestParser::parse(Rule::ASCII_VISIBLE, &test); - assert!(parse.is_ok()); - } - - let parse = CDDLTestParser::parse(Rule::ASCII_VISIBLE, "\r"); - assert!(parse.is_err()); - - let parse = CDDLTestParser::parse(Rule::ASCII_VISIBLE, "\u{80}"); - assert!(parse.is_err()); -} - -#[test] -/// Test if the `SCHAR_ASCII_VISIBLE` rule passes properly. -fn check_schar_ascii_visible() { - let invalids = "\"\\"; - for x in (b' '..=b'~').map(char::from) { - let test = x.to_string(); - let parse = CDDLTestParser::parse(Rule::SCHAR_ASCII_VISIBLE, &test); - if invalids.contains(x) { - assert!(parse.is_err()); - } else { - assert!(parse.is_ok()); - } - } - - let parse = CDDLTestParser::parse(Rule::SCHAR_ASCII_VISIBLE, "\r"); - assert!(parse.is_err()); - - let parse = CDDLTestParser::parse(Rule::SCHAR_ASCII_VISIBLE, "\u{80}"); - assert!(parse.is_err()); -} - -#[test] -/// Test if the `BCHAR_ASCII_VISIBLE` rule passes properly. -fn check_bchar_ascii_visible() { - let invalids = "'\\"; - for x in (b' '..=b'~').map(char::from) { - let test = x.to_string(); - let parse = CDDLTestParser::parse(Rule::BCHAR_ASCII_VISIBLE, &test); - if invalids.contains(x) { - assert!(parse.is_err()); - } else { - assert!(parse.is_ok()); - } - } - - let parse = CDDLTestParser::parse(Rule::BCHAR_ASCII_VISIBLE, "\r"); - assert!(parse.is_err()); - - let parse = CDDLTestParser::parse(Rule::BCHAR_ASCII_VISIBLE, "\u{80}"); - assert!(parse.is_err()); -} - -#[test] -/// Test if the `UNICODE_CHAR` rule passes properly. -fn check_unicode() { - let parse = CDDLTestParser::parse(Rule::UNICODE_CHAR, "\r"); - assert!(parse.is_err()); - - let parse = CDDLTestParser::parse(Rule::UNICODE_CHAR, "\u{80}"); - assert!(parse.is_ok()); - - let parse = CDDLTestParser::parse(Rule::UNICODE_CHAR, "\u{10fffd}"); - assert!(parse.is_ok()); - - let parse = CDDLTestParser::parse(Rule::UNICODE_CHAR, "\u{7ffff}"); - assert!(parse.is_ok()); - - let parse = CDDLTestParser::parse(Rule::UNICODE_CHAR, "\u{10fffe}"); - assert!(parse.is_err()); -} diff --git a/hermes/crates/cbork/cddl-parser/tests/comments.rs b/hermes/crates/cbork/cddl-parser/tests/comments.rs deleted file mode 100644 index f819072ab..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/comments.rs +++ /dev/null @@ -1,21 +0,0 @@ -use cddl_parser::{self, cddl_test::Rule}; - -mod common; -use common::comments::*; - -#[test] -/// Test if the `COMMENT` rule passes properly. -fn check_comment() { - common::check_tests_rule(Rule::COMMENT_TEST, COMMENT_PASSES, COMMENT_FAILS); -} - -#[test] -/// Test if the `COMMENT` rule passes properly with whitespace. -/// This uses a special rule in the Grammar to test whitespace exhaustively. -fn check_whitespace_comments() { - common::check_tests_rule( - Rule::COMMENT_TEST, - WHITESPACE_COMMENT_PASSES, - WHITESPACE_COMMENT_FAILS, - ); -} diff --git a/hermes/crates/cbork/cddl-parser/tests/common/byte_sequences.rs b/hermes/crates/cbork/cddl-parser/tests/common/byte_sequences.rs deleted file mode 100644 index afd944b15..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/common/byte_sequences.rs +++ /dev/null @@ -1,49 +0,0 @@ -// cspell: words HEXPAIR rstuvw abcdefghijklmnopqrstuvwyz Xhhb Bhcm - -#![allow(dead_code)] // TODO: find a way to remove this. - -pub(crate) const HEXPAIR_PASSES: &[&str] = &["00", "ab", "de", "0f", "f0"]; - -pub(crate) const HEXPAIR_FAILS: &[&str] = &["0", " 0", "0 ", "az", "0p"]; - -pub(crate) const URL_BASE64_PASSES: &[&str] = &[ - "abcdefghijklmnopq rstuvw yz01\t23456789-_ABCDEFGHIJKLMNOPQRSTUVWXYZ~", - "abcdefghijklmnopqrstuvwyz0123456789-_ABCDEFGHIJKLMNOPQRSTUVWXYZ", -]; - -pub(crate) const URL_BASE64_FAILS: &[&str] = &[ - "abcdefghijklmnopq # rstuvw yz01\t23456789-_ABCDEFGHIJKLMNOPQRSTUVWXYZ~ ", - "abcdefghijklmnopq $ rstuvw yz01\t23456789-_ABCDEFGHIJKLMNOPQRSTUVWXYZ~\t", - "abcdefghijklmnopq % rstuvw yz01\t23456789-_ABCDEFGHIJKLMNOPQRSTUVWXYZ~\n", - "abcdefghijklmnopq ^ rstuvw yz01\t23456789-_ABCDEFGHIJKLMNOPQRSTUVWXYZ~\r", - "abcdefghijklmnopq & rstuvw yz01\t23456789-_ABCDEFGHIJKLMNOPQRSTUVWXYZ~\r\n", -]; - -pub(crate) const BYTES_PASSES: &[&str] = &[ - "h''", - "b64''", - "''", - "h'00'", - "h'63666F6FF6'", - "h'68656c6c6f20776f726c64'", - "h'4 86 56c 6c6f'", - "h' 20776 f726c64'", - "h'00112233445566778899aabbccddeeff0123456789abcdef'", - "h'0 1 2 3 4 5 6 7 8 9 a b c d e f'", - "h' 0 1 2 3 4 5\r 6 7 \n 8 9 a\r\n\t b c d e f'", - "h'0 \n\n\r f'", - "b64'aHR0cHM6Ly93d3cuZXhhbXBsZS5jb20vcGFnZT9wYXJhbTE9dmFsdWUxJnBhcmFtMj12YWx1ZTI~'", - "'text\n that gets converted \\\' into a byte string...'", -]; - -pub(crate) const BYTES_FAILS: &[&str] = &[ - "h64", - "b64", - "\"\"", - "h ''", - "b64 ''", - "h'001'", - "b64'abcdefghijklmnopq # rstuvw yz01\t23456789-_ABCDEFGHIJKLMNOPQRSTUVWXYZ~'", - "b64'abcdefghijklmnopq & rstuvw yz01\t23456789-_ABCDEFGHIJKLMNOPQRSTUVWXYZ'", - "'\u{7}'", -]; diff --git a/hermes/crates/cbork/cddl-parser/tests/common/comments.rs b/hermes/crates/cbork/cddl-parser/tests/common/comments.rs deleted file mode 100644 index 7ffcaad81..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/common/comments.rs +++ /dev/null @@ -1,20 +0,0 @@ -#![allow(dead_code)] // TODO: find a way to remove this. - -pub(crate) const COMMENT_PASSES: &[&str] = &["; A Comment \n", "; And another\r", ";more\r\n"]; - -pub(crate) const COMMENT_FAILS: &[&str] = &["not a comment\n"]; - -pub(crate) const WHITESPACE_COMMENT_PASSES: &[&str] = &[ - " ", - " ", - " \t \t", - " \t \r \n \r\n ", - "; A Comment\r", - " \t ; A Comment \n", - "; One Comment\n; Two Comments\n", - "; One Comment \n; Two Comments\r; Another Comment\r\n", - "\t; One Comment \n\t; Two Comments\r; Another Comment\r\n", - "\t; A Comment \n ; Another Comment \t \r\n \t ; A Final Comment \r\n", -]; - -pub(crate) const WHITESPACE_COMMENT_FAILS: &[&str] = &["not a comment"]; diff --git a/hermes/crates/cbork/cddl-parser/tests/common/group_elements.rs b/hermes/crates/cbork/cddl-parser/tests/common/group_elements.rs deleted file mode 100644 index e6fa05672..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/common/group_elements.rs +++ /dev/null @@ -1,114 +0,0 @@ -// cspell: words OPTCOM MEMBERKEY bareword tstr GRPENT GRPCHOICE - -#![allow(dead_code)] // TODO: find a way to remove this. - -pub(crate) const OCCUR_PASSES: &[&str] = &[ - "*", - "+", - "?", - "5*10", - "0x1*0b110", - "*20", - "5*10", - "0x1*0b110", - "0*5", - "5*", - "*5", - "0b110*", - "0x1*", -]; - -pub(crate) const OCCUR_FAILS: &[&str] = &[ - "5**10", - "5 * 10", - "5\t\n*\n10", - "++", - "??", - // Fail cases for uint - "0123", // Leading zero is not allowed for decimal - "0xG", // Invalid hex digit - "0b123", // Invalid binary digit - "0*5*", // Multiple '*' not allowed - "0x1*0b110*", - "0x", - "0b", -]; - -pub(crate) const OPTCOM_PASSES: &[&str] = &["", ",", " ,", " , ", "\n,\n", "\n"]; - -pub(crate) const OPTCOM_FAILS: &[&str] = &[",,"]; - -pub(crate) const MEMBERKEY_PASSES: &[&str] = &[ - // bareword - "foo:", - "foo-bar:", - "foo_bar:", - "foo :", - // values - "\"foo\":", - "1:", - "0x123:", - "1.1:", - "-1:", - "b64'1234':", - "h'1234':", - "h'12 34\n':", - // type1 - "tstr =>", - "id =>", - "# =>", - "1..2 =>", - "1...2 =>", - "\"foo\" =>", - "\"foo\" ^=>", - "\"foo\"^ =>", - "\"foo\" ^ =>", - "1 =>", - "0x123 =>", - "1.1 =>", - "-1 =>", - "b64'1234' =>", - "h'1234' =>", - "h'12 34\n' =>", -]; - -pub(crate) const MEMBERKEY_FAILS: &[&str] = &["#:", "foo::"]; - -pub(crate) const GRPENT_PASSES: &[&str] = &[ - "foo: 1", - "foo: 1", - "foo-bar:\t\n1", - "foo :\n1", - "foo: #", - "tstr => any", - "tstr => { foo: bar }", - "tstr => { foo: bar, baz }", - "tstr => [foo: bar, baz]", -]; - -pub(crate) const GRPENT_FAILS: &[&str] = &["tstr => (foo: bar)"]; - -pub(crate) const GRPCHOICE_PASSES: &[&str] = &[ - "foo: 1", - "foo: 1, bar: 2", - "foo: 1, bar: 2,", - "foo: 1\nbar: 2", - "foo: 1 bar: 2", - "foo => 1 bar: 2", - "foo => 1, bar => 2", - "foo => 1, bar: 2", - "foo => 1bar: 2", -]; - -pub(crate) const GRPCHOICE_FAILS: &[&str] = &["foo: ,", "foo:", "foo: bar: 2", "foo => bar: 2"]; - -pub(crate) const GROUP_PASSES: &[&str] = &[ - "(foo: 1)", - "(foo: 1) // (bar: 2)", - "(foo: 1) // (bar: 2)", - "(street: tstr, ? number: uint, city // po-box: uint, city // per-pickup: true)", - "(+ a // b / c)", - "((+ a) // (b / c))", -]; - -pub(crate) const GROUP_FAILS: &[&str] = &["(foo: 1) / (bar: 2)"]; diff --git a/hermes/crates/cbork/cddl-parser/tests/common/identifiers.rs b/hermes/crates/cbork/cddl-parser/tests/common/identifiers.rs deleted file mode 100644 index 65e186bb6..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/common/identifiers.rs +++ /dev/null @@ -1,40 +0,0 @@ -// cspell: words aname groupsocket typesocket - -#![allow(dead_code)] // TODO: find a way to remove this. - -pub(crate) const ID_PASSES: &[&str] = &[ - "$", - "@", - "_", - "a", - "z", - "A", - "Z", - "$$", - "@@", - "__", - "a$", - "a@", - "a_", - "$0", - "@9", - "_a", - "abc", - "aname", - "@aname", - "_aname", - "$aname", - "a$name", - "a.name", - "@a.name", - "$a.name", - "_a.name", - "$$", - "$$groupsocket", - "$", - "$typesocket", -]; - -pub(crate) const ID_FAILS: &[&str] = &[ - "aname.", "aname-", "aname%", "a%name4", "a^name5", "a name", "", -]; diff --git a/hermes/crates/cbork/cddl-parser/tests/common/literal_values.rs b/hermes/crates/cbork/cddl-parser/tests/common/literal_values.rs deleted file mode 100644 index 2289ed8d9..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/common/literal_values.rs +++ /dev/null @@ -1,106 +0,0 @@ -// cspell: words xdog INTFLOAT HEXFLOAT xabcp defp - -#![allow(dead_code)] // TODO: find a way to remove this. - -pub(crate) const UINT_PASSES: &[&str] = &[ - "10", - "101", - "2034", - "30456", - "123456789", - "0x123456789abcdefABCDEF", - "0b0001110101010101", - "0", -]; - -pub(crate) const UINT_FAILS: &[&str] = &[" a ", "zz", "0123zzz", "0xdog", "0b777"]; - -pub(crate) const INT_PASSES: &[&str] = &[ - "10", - "101", - "2034", - "30456", - "123456789", - "0x123456789abcdefABCDEF", - "0b0001110101010101", - "0", - "-10", - "-101", - "-2034", - "-30456", - "-123456789", - "-0x123456789abcdefABCDEF", - "-0b0001110101010101", - "-0", -]; - -pub(crate) const INT_FAILS: &[&str] = &[" a ", "zz", "0123zzz", "0xdog", "0b777"]; - -pub(crate) const INTFLOAT_PASSES: &[&str] = &[ - "10", - "101", - "2034", - "30456", - "123456789", - "0", - "-10", - "-101", - "-2034", - "-30456", - "-123456789", - "123.456", - "123.456", - "123e+789", - "123e-789", - "123.456e+789", - "123.456e-789", -]; - -pub(crate) const INTFLOAT_FAILS: &[&str] = &[" a ", "zz", "0123zzz", "0xdog", "0b777"]; - -pub(crate) const HEXFLOAT_PASSES: &[&str] = &[ - "0xabcp+123", - "-0xabcp+123", - "0xabcp-123", - "-0xabcp-123", - "0xabc.defp+123", - "-0xabc.defp+123", - "0xabc.defp-123", - "-0xabc.defp-123", -]; - -pub(crate) const HEXFLOAT_FAILS: &[&str] = &[" a ", "zz", "0123zzz", "0xdog", "0b777"]; - -pub(crate) const NUMBER_PASSES: &[&str] = &[ - "0xabcp+123", - "-0xabcp+123", - "0xabcp-123", - "-0xabcp-123", - "0xabc.defp+123", - "-0xabc.defp+123", - "0xabc.defp-123", - "-0xabc.defp-123", - "10", - "101", - "2034", - "30456", - "123456789", - "0", - "-10", - "-101", - "-2034", - "-30456", - "-123456789", - "123.456", - "123.456", - "123e+789", - "123e-789", - "123.456e+789", - "123.456e-789", -]; - -pub(crate) const NUMBER_FAILS: &[&str] = &[" a ", "zz", "0123zzz", "0xdog", "0b777"]; - -pub(crate) const VALUE_PASSES: &[&str] = &[]; - -pub(crate) const VALUE_FAILS: &[&str] = &[]; diff --git a/hermes/crates/cbork/cddl-parser/tests/common/mod.rs b/hermes/crates/cbork/cddl-parser/tests/common/mod.rs deleted file mode 100644 index fd6dbb23e..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/common/mod.rs +++ /dev/null @@ -1,26 +0,0 @@ -use cddl_parser::{ - self, - cddl_test::{CDDLTestParser, Parser, Rule}, -}; - -pub(crate) mod byte_sequences; -pub(crate) mod comments; -pub(crate) mod group_elements; -pub(crate) mod identifiers; -pub(crate) mod literal_values; -pub(crate) mod rules; -pub(crate) mod text_sequences; -pub(crate) mod type_declarations; - -/// # Panics -pub(crate) fn check_tests_rule(rule_type: Rule, passes: &[&str], fails: &[&str]) { - for test in passes { - let parse = CDDLTestParser::parse(rule_type, test); - assert!(parse.is_ok()); - } - - for test in fails { - let parse = CDDLTestParser::parse(rule_type, test); - assert!(parse.is_err()); - } -} diff --git a/hermes/crates/cbork/cddl-parser/tests/common/rules.rs b/hermes/crates/cbork/cddl-parser/tests/common/rules.rs deleted file mode 100644 index c8eeb071c..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/common/rules.rs +++ /dev/null @@ -1,59 +0,0 @@ -// cspell: words GENERICARG bigfloat GENERICPARM ASSIGNG ASSIGNT GROUPNAME tstr - -#![allow(dead_code)] // TODO: find a way to remove this. - -use super::identifiers::{ID_FAILS, ID_PASSES}; - -pub(crate) const GENERICARG_PASSES: &[&str] = &[ - "", - "<{ foo: bar }>", - "<{ h'1234': uint }>", - "<1...10>", - "<\n1...10\t>", - "<{ foo: bar }, { foo: baz }>", - "<{ foo: bar }, 1..10>", -]; - -pub(crate) const GENERICARG_FAILS: &[&str] = - &["", "<>", "", "<( foo: bar )>", ""]; - -pub(crate) const GENERICPARM_PASSES: &[&str] = - &["", "", "", ""]; - -pub(crate) const GENERICPARM_FAILS: &[&str] = &[ - "", - "<>", - "", - "<{ foo: bar }>", - "<{ h'1234': uint }>", - "<1...10>", - "<\n1...10\t>", -]; - -pub(crate) const ASSIGNG_PASSES: &[&str] = &["=", "//="]; - -pub(crate) const ASSIGNG_FAILS: &[&str] = &["==", "/="]; - -pub(crate) const ASSIGNT_PASSES: &[&str] = &["=", "/="]; - -pub(crate) const ASSIGNT_FAILS: &[&str] = &["==", "//="]; - -pub(crate) const TYPENAME_PASSES: &[&str] = ID_PASSES; - -pub(crate) const TYPENAME_FAILS: &[&str] = ID_FAILS; - -pub(crate) const GROUPNAME_PASSES: &[&str] = ID_PASSES; - -pub(crate) const GROUPNAME_FAILS: &[&str] = ID_FAILS; - -pub(crate) const RULE_GROUP_PASSES: &[&str] = &[ - "foo = (bar: baz)", - "t //= (foo: bar)", - "t //= foo", - "t //= foo", - "t //= foo: bar", - "t //= 2*2 foo: bar", - "delivery //= ( lat: float, long: float, drone-type: tstr )", -]; - -pub(crate) const RULE_GROUP_FAILS: &[&str] = &["foo = bar: baz", "t /= (foo: bar)"]; diff --git a/hermes/crates/cbork/cddl-parser/tests/common/text_sequences.rs b/hermes/crates/cbork/cddl-parser/tests/common/text_sequences.rs deleted file mode 100644 index b38ae82f5..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/common/text_sequences.rs +++ /dev/null @@ -1,6 +0,0 @@ -#![allow(dead_code)] // TODO: find a way to remove this. - -pub(crate) const S_PASSES: &[&str] = &[" ", " ", " \t \t", " \t \r \n \r\n "]; -pub(crate) const S_FAILS: &[&str] = &[" a ", "zz", " \t d \t", " \t \r \n \t \r\n x"]; -pub(crate) const TEXT_PASSES: &[&str] = &[r#""""#, r#""abc""#, "\"abc\\n\""]; -pub(crate) const TEXT_FAILS: &[&str] = &["", "''", "\"abc\n\""]; diff --git a/hermes/crates/cbork/cddl-parser/tests/common/type_declarations.rs b/hermes/crates/cbork/cddl-parser/tests/common/type_declarations.rs deleted file mode 100644 index 5b77dd881..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/common/type_declarations.rs +++ /dev/null @@ -1,112 +0,0 @@ -// cspell: words CTLOP aname groupsocket typesocket RANGEOP tstr - -#![allow(dead_code)] // TODO: find a way to remove this. - -pub(crate) const CTLOP_PASSES: &[&str] = &[ - ".$", - ".@", - "._", - ".a", - ".z", - ".A", - ".Z", - ".$$", - ".@@", - ".__", - ".a$", - ".a@", - ".a_", - ".$0", - ".@9", - "._a", - ".abc", - ".aname", - ".@aname", - "._aname", - ".$aname", - ".a$name", - ".a.name", - ".@a.name", - ".$a.name", - "._a.name", - ".$$", - ".$$groupsocket", - ".$", - ".$typesocket", -]; - -pub(crate) const CTLOP_FAILS: &[&str] = &[ - "aname.", ".", "..", "aname.", "aname-", "aname%", "a%name4", "a^name5", "a name", "", -]; - -pub(crate) const RANGEOP_PASSES: &[&str] = &["..", "..."]; - -pub(crate) const RANGEOP_FAILS: &[&str] = &[".", "", "....", ".. .", ". .."]; - -pub(crate) const TYPE2_PASSES: &[&str] = &[ - "#", - "#1", - "#1.1", - "#1.1", - "#6", - "#6.11", - "#6.11(tstr)", - "#6.11(\tstr\n)", - "#6.11({ foo })", - "#6.11([ foo ])", - "#6.11(#3.1)", - "&foo", - "& foo", - "&((+ a) // (b / c))", - "&\t( foo: bar )", - "~foo", - "~ foo", - "foo", - "[ foo bar ]", - "{ foo bar }", - "(a)", - "(a / b)", - "(#)", - "((a))", - "1", - "h'1111'", - "true", - "foo", -]; - -pub(crate) const TYPE2_FAILS: &[&str] = &[ - "", - "##", - "#1.", - "#6.11 (tstr)", - "#6.11(( foo: uint ))", - "&", - "& foo ", - "(foo bar)", -]; - -pub(crate) const TYPE1_PASSES: &[&str] = &[ - "1..2", - "1 .. 2", - "1\t..\n2", - "1...2", - "0..10.0", // BAD range 1 - "0.0..10", // BAD range 2 - "0..max-byte", - "min-type..max-byte", - "1.0..2.0", - "1.0...2.0", - "foo.bar", -]; - -pub(crate) const TYPE1_FAILS: &[&str] = &[""]; - -pub(crate) const TYPE_PASSES: &[&str] = &[ - "1 / 2", - "1\n/\t2", - "1 / 2 / 3 / 4", - "1 / (2 / (3 / 4))", - "# / #", -]; - -pub(crate) const TYPE_FAILS: &[&str] = &["", "1 \\ 2", "1 // 2", "1 2", "1 / 2 3"]; diff --git a/hermes/crates/cbork/cddl-parser/tests/group_elements.rs b/hermes/crates/cbork/cddl-parser/tests/group_elements.rs deleted file mode 100644 index 0fa4296de..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/group_elements.rs +++ /dev/null @@ -1,56 +0,0 @@ -// cspell: words OPTCOM MEMBERKEY bareword tstr GRPENT GRPCHOICE -// cspell: words optcom memberkey grpent grpchoice - -use cddl_parser::{self, cddl_test::Rule}; - -mod common; -use common::{group_elements::*, identifiers::*}; - -#[test] -/// Test if the `occur` rule passes properly. -/// This uses a special rule in the Grammar to test `occur` exhaustively. -fn check_occur() { - common::check_tests_rule(Rule::occur_TEST, OCCUR_PASSES, OCCUR_FAILS); -} - -#[test] -/// Test if the `bareword` rule passes properly. -/// This uses a special rule in the Grammar to test `bareword` exhaustively. -fn check_bareword() { - common::check_tests_rule(Rule::bareword_TEST, ID_PASSES, ID_FAILS); -} - -#[test] -/// Test if the `optcom` rule passes properly. -/// This uses a special rule in the Grammar to test `optcom` exhaustively. -fn check_optcom() { - common::check_tests_rule(Rule::optcom_TEST, OPTCOM_PASSES, OPTCOM_FAILS); -} - -#[test] -/// Test if the `memberkey` rule passes properly. -/// This uses a special rule in the Grammar to test `memberkey` exhaustively. -fn check_memberkey() { - common::check_tests_rule(Rule::memberkey_TEST, MEMBERKEY_PASSES, MEMBERKEY_FAILS); -} - -#[test] -/// Test if the `grpent` rule passes properly. -/// This uses a special rule in the Grammar to test `grpent` exhaustively. -fn check_grpent() { - common::check_tests_rule(Rule::grpent_TEST, GRPENT_PASSES, GRPENT_FAILS); -} - -#[test] -/// Test if the `grpchoice` rule passes properly. -/// This uses a special rule in the Grammar to test `grpchoice` exhaustively. -fn check_grpchoice() { - common::check_tests_rule(Rule::grpchoice_TEST, GRPCHOICE_PASSES, GRPCHOICE_FAILS); -} - -#[test] -/// Test if the `group` rule passes properly. -/// This uses a special rule in the Grammar to test `group` exhaustively. -fn check_group() { - common::check_tests_rule(Rule::group_TEST, GROUP_PASSES, GROUP_FAILS); -} diff --git a/hermes/crates/cbork/cddl-parser/tests/identifiers.rs b/hermes/crates/cbork/cddl-parser/tests/identifiers.rs deleted file mode 100644 index c4f3e7dfa..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/identifiers.rs +++ /dev/null @@ -1,36 +0,0 @@ -// cspell: words aname groupsocket typesocket groupsocket - -use cddl_parser::{ - self, - cddl_test::{CDDLTestParser, Parser, Rule}, -}; - -mod common; -use common::identifiers::*; - -#[test] -/// Check if the name components pass properly. -fn check_name_characters() { - for x in ('\u{0}'..='\u{ff}').map(char::from) { - let test = format!("{x}"); - let parse_start = CDDLTestParser::parse(Rule::NAME_START, &test); - let parse_end = CDDLTestParser::parse(Rule::NAME_END, &test); - - if x.is_ascii_alphabetic() || matches!(x, '@' | '_' | '$') { - assert!(parse_start.is_ok()); - assert!(parse_end.is_ok()); - } else if x.is_ascii_digit() { - assert!(parse_start.is_err()); - assert!(parse_end.is_ok()); - } else { - assert!(parse_start.is_err()); - assert!(parse_end.is_err()); - } - } -} - -#[test] -/// Test if the `id` rule passes properly. -fn check_id() { - common::check_tests_rule(Rule::id_TEST, ID_PASSES, ID_FAILS); -} diff --git a/hermes/crates/cbork/cddl-parser/tests/literal_values.rs b/hermes/crates/cbork/cddl-parser/tests/literal_values.rs deleted file mode 100644 index c29fcedeb..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/literal_values.rs +++ /dev/null @@ -1,57 +0,0 @@ -// cspell: words xdog intfloat hexfloat xabcp defp rstuvw - -use std::ops::Deref; - -use cddl_parser::{self, cddl_test::Rule}; - -mod common; -use common::{byte_sequences::*, literal_values::*, text_sequences::*}; - -#[test] -/// Test if the `uint` rule passes properly. -fn check_uint() { - common::check_tests_rule(Rule::uint_TEST, UINT_PASSES, UINT_FAILS); -} - -#[test] -/// Test if the `uint` rule passes properly. -fn check_int() { - common::check_tests_rule(Rule::int_TEST, INT_PASSES, INT_FAILS); -} - -#[test] -/// Test if the `uint` rule passes properly. -fn check_intfloat() { - common::check_tests_rule(Rule::intfloat_TEST, INTFLOAT_PASSES, INTFLOAT_FAILS); -} - -#[test] -/// Test if the `uint` rule passes properly. -fn check_hexfloat() { - common::check_tests_rule(Rule::hexfloat_TEST, HEXFLOAT_PASSES, HEXFLOAT_FAILS); -} - -#[test] -/// Test if the `number` rule passes properly. -fn check_number() { - common::check_tests_rule(Rule::number_TEST, NUMBER_PASSES, NUMBER_FAILS); -} - -#[test] -/// Test if the `uint` rule passes properly. -fn check_value() { - let passes: Vec<_> = VALUE_PASSES - .iter() - .chain(NUMBER_PASSES) - .chain(BYTES_PASSES) - .chain(TEXT_PASSES) - .map(Deref::deref) - .collect(); - let fails: Vec<_> = VALUE_FAILS - .iter() - .chain(NUMBER_FAILS) - .map(Deref::deref) - .collect(); - - common::check_tests_rule(Rule::value_TEST, &passes, &fails); -} diff --git a/hermes/crates/cbork/cddl-parser/tests/rules.rs b/hermes/crates/cbork/cddl-parser/tests/rules.rs deleted file mode 100644 index 79a999e63..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/rules.rs +++ /dev/null @@ -1,87 +0,0 @@ -// cspell: words GENERICARG bigfloat ASSIGNG GROUPNAME tstr genericarg GENERICARG -// cspell: words assigng assignt ASSIGNT GENERICPARM genericparm - -use cddl_parser::{ - self, - cddl_test::{CDDLTestParser, Parser, Rule}, -}; - -mod common; -use common::{rules::*, type_declarations::*}; - -#[test] -/// Test if the `genericarg` rule passes properly. -/// This uses a special rule in the Grammar to test `genericarg` exhaustively. -fn check_genericarg() { - common::check_tests_rule(Rule::genericarg_TEST, GENERICARG_PASSES, GENERICARG_FAILS); -} - -#[test] -/// Test if the `genericparm` rule passes properly. -/// This uses a special rule in the Grammar to test `genericparm` exhaustively. -fn check_genericparm() { - common::check_tests_rule( - Rule::genericparm_TEST, - GENERICPARM_PASSES, - GENERICPARM_FAILS, - ); -} - -#[test] -/// Test if the `assigng` rule passes properly. -/// This uses a special rule in the Grammar to test `assigng` exhaustively. -fn check_assigng() { - common::check_tests_rule(Rule::assigng_TEST, ASSIGNG_PASSES, ASSIGNG_FAILS); -} - -#[test] -/// Test if the `assignt` rule passes properly. -/// This uses a special rule in the Grammar to test `assignt` exhaustively. -fn check_assignt() { - common::check_tests_rule(Rule::assignt_TEST, ASSIGNT_PASSES, ASSIGNT_FAILS); -} - -#[test] -/// Test if the `typename` rule passes properly. -/// This uses a special rule in the Grammar to test `typename` exhaustively. -fn check_typename() { - common::check_tests_rule(Rule::typename_TEST, TYPENAME_PASSES, TYPENAME_FAILS); -} - -#[test] -/// Test if the `groupname` rule passes properly. -/// This uses a special rule in the Grammar to test `groupname` exhaustively. -fn check_groupname() { - common::check_tests_rule(Rule::groupname_TEST, GROUPNAME_PASSES, GROUPNAME_FAILS); -} - -#[test] -/// Test if the `rule` rule passes properly for type variant. -fn check_rule_type_composition() { - for (i, test_i) in [TYPENAME_PASSES, TYPENAME_FAILS] - .into_iter() - .flatten() - .enumerate() - { - for (j, test_j) in [ASSIGNT_PASSES].into_iter().flatten().enumerate() { - for (k, test_k) in [TYPE_PASSES, TYPE_FAILS].into_iter().flatten().enumerate() { - let input = [test_i.to_owned(), test_j.to_owned(), test_k.to_owned()].join(" "); - let parse = CDDLTestParser::parse(Rule::rule_TEST, &input); - if (0..TYPENAME_PASSES.len()).contains(&i) - && (0..ASSIGNT_PASSES.len()).contains(&j) - && (0..TYPE_PASSES.len()).contains(&k) - { - assert!(parse.is_ok()); - } else { - assert!(parse.is_err()); - } - } - } - } -} - -#[test] -/// Test if the `rule` rule passes properly for group variant. -fn check_rule_group() { - common::check_tests_rule(Rule::rule_TEST, RULE_GROUP_PASSES, RULE_GROUP_FAILS); -} diff --git a/hermes/crates/cbork/cddl-parser/tests/text_sequences.rs b/hermes/crates/cbork/cddl-parser/tests/text_sequences.rs deleted file mode 100644 index bd96aa657..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/text_sequences.rs +++ /dev/null @@ -1,17 +0,0 @@ -use cddl_parser::{self, cddl_test::Rule}; - -mod common; -use common::text_sequences::*; - -#[test] -/// Test if the `S` rule passes properly. -/// This uses a special rule in the Grammar to test whitespace exhaustively. -fn check_s() { - common::check_tests_rule(Rule::S_TEST, S_PASSES, S_FAILS); -} - -#[test] -/// Test if the `text` rule passes properly. -fn check_text() { - common::check_tests_rule(Rule::text_TEST, TEXT_PASSES, TEXT_FAILS); -} diff --git a/hermes/crates/cbork/cddl-parser/tests/type_declarations.rs b/hermes/crates/cbork/cddl-parser/tests/type_declarations.rs deleted file mode 100644 index 571b95621..000000000 --- a/hermes/crates/cbork/cddl-parser/tests/type_declarations.rs +++ /dev/null @@ -1,89 +0,0 @@ -// cspell: words CTLOP aname groupsocket typesocket RANGEOP tstr ctlop -// cspell: words rangeop RANGEOP - -use cddl_parser::{ - self, - cddl_test::{CDDLTestParser, Parser, Rule}, -}; - -mod common; -use common::type_declarations::*; - -#[test] -/// Test if the `ctlop` rule passes properly. -/// This uses a special rule in the Grammar to test `ctlop` exhaustively. -fn check_ctlop() { - common::check_tests_rule(Rule::ctlop_TEST, CTLOP_PASSES, CTLOP_FAILS); -} - -#[test] -/// Test if the `rangeop` rule passes properly. -/// This uses a special rule in the Grammar to test `rangeop` exhaustively. -fn check_rangeop() { - common::check_tests_rule(Rule::rangeop_TEST, RANGEOP_PASSES, RANGEOP_FAILS); -} - -#[test] -/// Test if the `type2` rule passes properly. -/// This uses a special rule in the Grammar to test `type2` exhaustively. -fn check_type2() { - common::check_tests_rule(Rule::type2_TEST, TYPE2_PASSES, TYPE2_FAILS); -} - -#[test] -/// Test if the `type1` rule passes properly. -/// This uses a special rule in the Grammar to test `type1` exhaustively. -fn check_type1() { - common::check_tests_rule(Rule::type1_TEST, TYPE1_PASSES, TYPE1_FAILS); -} - -#[test] -/// Test if the `type1` rule passes properly based on composition of type2 test cases. -fn check_type1_composition() { - let j_len = CTLOP_PASSES.len() + RANGEOP_PASSES.len(); - for (i, test_i) in [TYPE2_PASSES, TYPE_FAILS].into_iter().flatten().enumerate() { - for (j, test_j) in [CTLOP_PASSES, RANGEOP_PASSES] - .into_iter() - .flatten() - .enumerate() - { - for (k, test_k) in [TYPE2_PASSES, TYPE_FAILS].into_iter().flatten().enumerate() { - let input = [test_i.to_owned(), test_j.to_owned(), test_k.to_owned()].join(" "); - let parse = CDDLTestParser::parse(Rule::type1_TEST, &input); - if (0..TYPE2_PASSES.len()).contains(&i) - && (0..j_len).contains(&j) - && (0..TYPE2_PASSES.len()).contains(&k) - { - assert!(parse.is_ok()); - } else { - assert!(parse.is_err()); - } - } - } - } -} - -#[test] -/// Test if the `type` rule passes properly. -/// This uses a special rule in the Grammar to test `type` exhaustively. -fn check_type() { - common::check_tests_rule(Rule::type_TEST, TYPE_PASSES, TYPE_FAILS); -} - -#[test] -/// Test if the `type` rule passes properly based on composition of type2 test cases. -fn check_type_composition() { - // type2 composition testing - for (i, test_i) in [TYPE2_PASSES, TYPE_FAILS].into_iter().flatten().enumerate() { - for (j, test_j) in [TYPE2_PASSES, TYPE_FAILS].into_iter().flatten().enumerate() { - let input = [test_i.to_owned(), "/", test_j.to_owned()].join(" "); - let parse = CDDLTestParser::parse(Rule::type_TEST, &input); - - if (0..TYPE2_PASSES.len()).contains(&i) && (0..TYPE2_PASSES.len()).contains(&j) { - assert!(parse.is_ok()); - } else { - assert!(parse.is_err()); - } - } - } -} diff --git a/hermes/crates/cbork/clippy.toml b/hermes/crates/cbork/clippy.toml deleted file mode 100644 index 72db4f0ab..000000000 --- a/hermes/crates/cbork/clippy.toml +++ /dev/null @@ -1,2 +0,0 @@ -allow-unwrap-in-tests = true -allow-expect-in-tests = true \ No newline at end of file diff --git a/hermes/crates/cbork/deny.toml b/hermes/crates/cbork/deny.toml deleted file mode 100644 index 921f1eb3c..000000000 --- a/hermes/crates/cbork/deny.toml +++ /dev/null @@ -1,117 +0,0 @@ -# cspell: words msvc, wasip, RUSTSEC, rustls, libssh, reqwest, tinyvec, Leay, webpki - -[graph] -# cargo-deny is really only ever intended to run on the "normal" tier-1 targets -targets = [ - "x86_64-unknown-linux-gnu", - "aarch64-unknown-linux-gnu", - "x86_64-unknown-linux-musl", - "aarch64-apple-darwin", - "x86_64-apple-darwin", - "x86_64-pc-windows-msvc", - "wasm32-unknown-unknown", - "wasm32-wasip1", - "wasm32-wasip2", -] - -[advisories] -version = 2 -ignore = [ - { id = "RUSTSEC-2020-0168", reason = "`mach` is used by wasmtime and we have no control over that." }, - { id = "RUSTSEC-2021-0145", reason = "we don't target windows, and don;t use a custom global allocator." }, -] - -[bans] -multiple-versions = "warn" -wildcards = 'deny' -deny = [ - # { crate = "git2", use-instead = "gix" }, - { crate = "openssl", use-instead = "rustls" }, - { crate = "openssl-sys", use-instead = "rustls" }, - "libssh2-sys", - # { crate = "cmake", use-instead = "cc" }, - # { crate = "windows", reason = "bloated and unnecessary", use-instead = "ideally inline bindings, practically, windows-sys" }, -] -skip = [ - # { crate = "bitflags@1.3.2", reason = "https://github.com/seanmonstar/reqwest/pull/2130 should be in the next version" }, - # { crate = "winnow@0.5.40", reason = "gix 0.59 was yanked, see https://github.com/Byron/gitoxide/issues/1309" }, - # { crate = "heck@0.4.1", reason = "strum_macros uses this old version" }, - # { crate = "base64@0.21.7", reason = "gix-transport pulls in this old version, as well as a newer version via reqwest" }, - # { crate = "byte-array-literalsase64@0.21.7", reason = "gix-transport pulls in this old version, as well as a newer version via reqwest" }, -] -skip-tree = [ - { crate = "windows-sys@0.48.0", reason = "a foundational crate for many that bumps far too frequently to ever have a shared version" }, -] - -[sources] -unknown-registry = "deny" -unknown-git = "deny" - -# List of URLs for allowed Git repositories -allow-git = [ - "https://github.com/input-output-hk/hermes.git", - "https://github.com/input-output-hk/catalyst-pallas.git", - "https://github.com/bytecodealliance/wasmtime", - "https://github.com/aldanor/hdf5-rust", -] - -[licenses] -version = 2 -# Don't warn if a listed license isn't found -unused-allowed-license="allow" -# We want really high confidence when inferring licenses from text -confidence-threshold = 0.93 -allow = [ - "MIT", - "Apache-2.0", - "Unicode-DFS-2016", - "BSD-3-Clause", - "BSD-2-Clause", - "BlueOak-1.0.0", - "Apache-2.0 WITH LLVM-exception", - "CC0-1.0", - "ISC", - "Unicode-3.0", - "MPL-2.0", -] -exceptions = [ - #{ allow = ["Zlib"], crate = "tinyvec" }, - #{ allow = ["Unicode-DFS-2016"], crate = "unicode-ident" }, - #{ allow = ["OpenSSL"], crate = "ring" }, -] - -[[licenses.clarify]] -crate = "byte-array-literals" -expression = "Apache-2.0 WITH LLVM-exception" -license-files = [{ path = "../../../LICENSE", hash = 0x001c7e6c }] - -[[licenses.clarify]] -crate = "hdf5-src" -expression = "MIT" -license-files = [{ path = "../LICENSE-MIT", hash = 0x001c7e6c }] - -[[licenses.clarify]] -crate = "ring" -expression = "MIT" -license-files = [{ path = "LICENSE", hash = 0xbd0eed23 }] - -# SPDX considers OpenSSL to encompass both the OpenSSL and SSLeay licenses -# https://spdx.org/licenses/OpenSSL.html -# ISC - Both BoringSSL and ring use this for their new files -# MIT - "Files in third_party/ have their own licenses, as described therein. The MIT -# license, for third_party/fiat, which, unlike other third_party directories, is -# compiled into non-test libraries, is included below." -# OpenSSL - Obviously -#expression = "ISC AND MIT AND OpenSSL" -#license-files = [{ path = "LICENSE", hash = 0xbd0eed23 }] - -#[[licenses.clarify]] -#crate = "webpki" -#expression = "ISC" -#license-files = [{ path = "LICENSE", hash = 0x001c7e6c }] - -# Actually "ISC-style" -#[[licenses.clarify]] -#crate = "rustls-webpki" -#expression = "ISC" -#license-files = [{ path = "LICENSE", hash = 0x001c7e6c }] diff --git a/hermes/crates/cbork/rust-toolchain.toml b/hermes/crates/cbork/rust-toolchain.toml deleted file mode 100644 index 08feed89d..000000000 --- a/hermes/crates/cbork/rust-toolchain.toml +++ /dev/null @@ -1,3 +0,0 @@ -[toolchain] -channel = "1.78" -profile = "default" \ No newline at end of file diff --git a/hermes/crates/cbork/rustfmt.toml b/hermes/crates/cbork/rustfmt.toml deleted file mode 100644 index 1a0573b22..000000000 --- a/hermes/crates/cbork/rustfmt.toml +++ /dev/null @@ -1,68 +0,0 @@ -# Enable unstable features: -# * imports_indent -# * imports_layout -# * imports_granularity -# * group_imports -# * reorder_impl_items -# * trailing_comma -# * where_single_line -# * wrap_comments -# * comment_width -# * blank_lines_upper_bound -# * condense_wildcard_suffixes -# * force_multiline_blocks -# * format_code_in_doc_comments -# * format_generated_files -# * hex_literal_case -# * inline_attribute_width -# * normalize_comments -# * normalize_doc_attributes -# * overflow_delimited_expr -unstable_features = true - -# Compatibility: -edition = "2021" - -# Tabs & spaces - Defaults, listed for clarity -tab_spaces = 4 -hard_tabs = false - -# Commas. -trailing_comma = "Vertical" -match_block_trailing_comma = true - -# General width constraints. -max_width = 100 - -# Comments: -normalize_comments = true -normalize_doc_attributes = true -wrap_comments = true -comment_width = 90 # small excess is okay but prefer 80 -format_code_in_doc_comments = true -format_generated_files = false - -# Imports. -imports_indent = "Block" -imports_layout = "Mixed" -group_imports = "StdExternalCrate" -reorder_imports = true -imports_granularity = "Crate" - -# Arguments: -use_small_heuristics = "Default" -fn_params_layout = "Compressed" -overflow_delimited_expr = true -where_single_line = true - -# Misc: -inline_attribute_width = 0 -blank_lines_upper_bound = 1 -reorder_impl_items = true -use_field_init_shorthand = true -force_multiline_blocks = true -condense_wildcard_suffixes = true -hex_literal_case = "Upper" - -# Ignored files: -ignore = [] \ No newline at end of file From 9b8a585fa4c28be7b668fd66ad96866178580b5e Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Wed, 9 Oct 2024 19:27:54 +0700 Subject: [PATCH 08/11] fix(hermes): Remove workspace dependencies --- hermes/Cargo.toml | 61 ---------- hermes/bin/Cargo.toml | 109 ++++++++++-------- .../crates/cardano-chain-follower/Cargo.toml | 16 +-- 3 files changed, 68 insertions(+), 118 deletions(-) diff --git a/hermes/Cargo.toml b/hermes/Cargo.toml index 274882983..35b9b6bc1 100644 --- a/hermes/Cargo.toml +++ b/hermes/Cargo.toml @@ -3,7 +3,6 @@ resolver = "2" members = [ "bin", "crates/cardano-chain-follower", - "crates/hermes-ipfs", ] [workspace.package] @@ -52,63 +51,3 @@ unchecked_duration_subtraction = "deny" unreachable = "deny" missing_docs_in_private_items = "deny" -[workspace.dependencies] -# specific commit from the `catalyst` branch -pallas = { git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "709acb19c52c6b789279ecc4bc8793b5d8b5abe9", version = "0.25.0" } -# specific commit from the `catalyst` branch -pallas-hardano = { git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "709acb19c52c6b789279ecc4bc8793b5d8b5abe9", version = "0.25.0" } - -cardano-chain-follower = { path = "crates/cardano-chain-follower", version = "0.0.1" } - -hermes-ipfs = { path = "crates/hermes-ipfs", version = "0.0.1" } - -wasmtime = "20.0.2" -rusty_ulid = "2.0.0" -anyhow = "1.0.71" -hex-literal = "0.4.1" -thiserror = "1.0.56" -hex = "0.4.3" -tracing = "0.1.40" -tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } -criterion = "0.5.1" -libtest-mimic = "0.7.0" -crossbeam-queue = "0.3.11" -bip39 = "2.0.0" -iana-time-zone = "0.1.60" -rand = "0.8.5" -bip32 = "0.5.1" -ed25519-bip32 = "0.4.1" -dashmap = "6.0.1" -once_cell = "1.19.0" -clap = "4.5.3" -build-info = "0.0.37" -build-info-build = "0.0.37" -derive_more = "0.99.17" -chrono = "0.4.35" -chrono-tz = "0.9.0" -saffron = "0.1.0" -tokio = "1.36.0" -libsqlite3-sys = "0.29.0" -stringzilla = "3.8.4" -serial_test = { version = "3.1.1", features = ["file_locks"] } -temp-dir = "0.1.13" -hdf5 = { git="https://github.com/aldanor/hdf5-rust.git", rev="694e900972fbf5ffbdd1a2294f57a2cc3a91c994", version="0.8.1", features = [ "static", "blosc" ]} -# needs to enable blosc compression functionality for hdf5 crate -blosc-src = { version = "0.3.0", features = ["lz4", "zlib", "zstd"] } -num_cpus = "1.16.0" -console = "0.15.8" -serde = "1.0" -serde_json = "1.0" -jsonschema = "0.18.0" -hmac = "0.12.1" -pbkdf2 = "0.12.2" -blake2b_simd = "1.0.2" -sha2 = "0.10" -ed25519-dalek = "2.1.1" -x509-cert = "0.2.5" -coset = "0.3.7" -libipld = "0.16.0" -rust-ipfs = "0.11.21" -rustyline-async = "0.4.2" -dirs = "5.0.1" -lipsum = "0.9.1" diff --git a/hermes/bin/Cargo.toml b/hermes/bin/Cargo.toml index 6bddc1f6f..48dc525b4 100644 --- a/hermes/bin/Cargo.toml +++ b/hermes/bin/Cargo.toml @@ -26,63 +26,72 @@ path = "tests/wasm-integration/main.rs" harness = false [dependencies] -cardano-chain-follower = { workspace = true } -wasmtime = { workspace = true, features = ["component-model"] } -rusty_ulid = { workspace = true } -anyhow = { workspace = true } -hex-literal = { workspace = true } -thiserror = { workspace = true } -criterion = { workspace = true, optional = true } -libtest-mimic = { workspace = true } -crossbeam-queue = { workspace = true } -bip39 = { workspace = true, features = ["chinese-simplified", "chinese-traditional", "czech", "french", "italian", "japanese", "korean", "spanish" ] } -rand = { workspace = true } -bip32 = { workspace = true } -ed25519-bip32 = { workspace = true } -dashmap = { workspace = true } -once_cell = { workspace = true } -clap = { workspace = true, features = ["derive", "env"] } -tracing = { workspace = true, features = ["log"] } -tracing-subscriber = { workspace = true, features = ["fmt", "json", "time"] } -build-info = { workspace = true } -derive_more = { workspace = true } -chrono = { workspace = true, features = ["now"] } -chrono-tz = { workspace = true } -iana-time-zone = { workspace = true } -tokio = { workspace = true, features = ["rt", "sync", "time"] } -pallas = { workspace = true } -saffron = { workspace = true } -libsqlite3-sys = { workspace = true, features = ["bundled"] } -stringzilla = { workspace = true } -hdf5 = { workspace = true } -blosc-src = { workspace = true } -num_cpus = { workspace = true } -console = { workspace = true } -serde = { workspace = true, features = ["derive"] } -serde_json = { workspace = true } -hyper = { version = "0.14.10", features = ["full"] } -dirs = { workspace = true } +# specific commit from the `catalyst` branch +pallas = { git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "709acb19c52c6b789279ecc4bc8793b5d8b5abe9", version = "0.25.0" } + +# HDF5 is consumed using a git tag, because the latest release is very old, but the code is much more advanced. +hdf5 = { git="https://github.com/aldanor/hdf5-rust.git", rev="694e900972fbf5ffbdd1a2294f57a2cc3a91c994", version="0.8.1", features = [ "static", "blosc" ]} +# needs to enable blosc compression functionality for hdf5 crate +blosc-src = { version = "0.3.0", features = ["lz4", "zlib", "zstd"] } + +criterion = {version = "0.5.1", optional=true} + +cardano-chain-follower = { path = "../crates/cardano-chain-follower", version = "0.0.1" } +hermes-ipfs = { version = "0.0.3", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "v0.0.3" } -jsonschema = { workspace = true } -hex = { workspace = true } -hmac = { workspace = true } -pbkdf2 = { workspace = true } -blake2b_simd = { workspace = true } -sha2 = { workspace = true } -ed25519-dalek = { workspace = true, features = ["pem"] } -x509-cert = { workspace = true, features = ["pem"] } -coset = { workspace = true } -hermes-ipfs = { workspace = true } +wasmtime = {version="20.0.2", features = ["component-model"] } +rusty_ulid = "2.0.0" +anyhow = "1.0.71" +hex-literal = "0.4.1" +thiserror = "1.0.56" +hex = "0.4.3" +tracing = {version="0.1.40", features = ["log"] } +tracing-subscriber = { version = "0.3.18", features = ["fmt", "json", "time", "env-filter"] } +libtest-mimic = "0.7.0" +crossbeam-queue = "0.3.11" +bip39 = { version="2.0.0", features = ["chinese-simplified", "chinese-traditional", "czech", "french", "italian", "japanese", "korean", "spanish" ] } +iana-time-zone = "0.1.60" +rand = "0.8.5" +bip32 = "0.5.1" +ed25519-bip32 = "0.4.1" +dashmap = "6.0.1" +once_cell = "1.19.0" +clap = "4.5.3" +build-info = "0.0.39" +derive_more = "0.99.17" +chrono = { version = "0.4.35", features = ["now"] } +chrono-tz = "0.9.0" +saffron = "0.1.0" +tokio = "1.36.0" +libsqlite3-sys = {version="0.30.1", features = ["bundled"] } +stringzilla = "3.8.4" temp-dir = "0.1.13" +num_cpus = "1.16.0" +console = "0.15.8" +serde = { version="1.0.210", features = ["derive"] } +serde_json = "1.0" +jsonschema = "0.18.0" +hyper = { version = "0.14.10", features = ["full"] } +hmac = "0.12.1" +pbkdf2 = "0.12.2" +blake2b_simd = "1.0.2" +sha2 = "0.10" +ed25519-dalek = { version="2.1.1", features = ["pem"] } +x509-cert = { version="0.2.5", features = ["pem"] } +coset = "0.3.7" +rust-ipfs = "0.12.1" +dirs = "5.0.1" regex = "1.10.5" [build-dependencies] -build-info-build = { workspace = true } +build-info-build = "0.0.39" [dev-dependencies] -tracing-subscriber = { workspace = true } -serial_test = { workspace = true } -temp-dir = { workspace = true } +serial_test = { version = "3.1.1", features = ["file_locks"] } [package.metadata.cargo-machete] +# This is required for HDF5. ignored = ["blosc-src"] + + + diff --git a/hermes/crates/cardano-chain-follower/Cargo.toml b/hermes/crates/cardano-chain-follower/Cargo.toml index 0c0ee4a19..58422d974 100644 --- a/hermes/crates/cardano-chain-follower/Cargo.toml +++ b/hermes/crates/cardano-chain-follower/Cargo.toml @@ -11,12 +11,14 @@ license.workspace = true workspace = true [dependencies] -pallas.workspace = true -pallas-hardano.workspace = true -thiserror.workspace = true -tokio = { workspace = true, features = ["macros", "rt", "net", "rt-multi-thread"] } -tracing.workspace = true +# specific commit from the `catalyst` branch +pallas = { git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "709acb19c52c6b789279ecc4bc8793b5d8b5abe9", version = "0.25.0" } +# specific commit from the `catalyst` branch +pallas-hardano = { git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "709acb19c52c6b789279ecc4bc8793b5d8b5abe9", version = "0.25.0" } +thiserror = "1.0.56" +tokio = "1.36.0" +tracing = "0.1.40" [dev-dependencies] -hex.workspace = true -tracing-subscriber = { workspace = true, features = ["env-filter"] } +hex = "0.4.3" +tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } From 387e78ff934bf8621e0f36f05250713d1280ceea Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Wed, 9 Oct 2024 19:28:32 +0700 Subject: [PATCH 09/11] chore(hermes): Hermes IPFS has moved to catalyst-libs --- hermes/crates/hermes-ipfs/.gitignore | 11 - hermes/crates/hermes-ipfs/Cargo.toml | 27 - .../examples/add-file-with-pinning.rs | 78 --- .../hermes-ipfs/examples/hermes-ipfs-cli.rs | 89 --- .../examples/provide-content-dht.rs | 111 ---- hermes/crates/hermes-ipfs/examples/pubsub.rs | 161 ----- .../hermes-ipfs/examples/put-get-dht.rs | 63 -- hermes/crates/hermes-ipfs/src/lib.rs | 603 ------------------ 8 files changed, 1143 deletions(-) delete mode 100644 hermes/crates/hermes-ipfs/.gitignore delete mode 100644 hermes/crates/hermes-ipfs/Cargo.toml delete mode 100644 hermes/crates/hermes-ipfs/examples/add-file-with-pinning.rs delete mode 100644 hermes/crates/hermes-ipfs/examples/hermes-ipfs-cli.rs delete mode 100644 hermes/crates/hermes-ipfs/examples/provide-content-dht.rs delete mode 100644 hermes/crates/hermes-ipfs/examples/pubsub.rs delete mode 100644 hermes/crates/hermes-ipfs/examples/put-get-dht.rs delete mode 100644 hermes/crates/hermes-ipfs/src/lib.rs diff --git a/hermes/crates/hermes-ipfs/.gitignore b/hermes/crates/hermes-ipfs/.gitignore deleted file mode 100644 index 8afaf0c8e..000000000 --- a/hermes/crates/hermes-ipfs/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -### Rust ### -# Generated by Cargo -# will have compiled files and executables -debug/ -target/ - -# These are backup files generated by rustfmt -**/*.rs.bk - -# MSVC Windows builds of rustc generate these, which store debugging information -*.pdb diff --git a/hermes/crates/hermes-ipfs/Cargo.toml b/hermes/crates/hermes-ipfs/Cargo.toml deleted file mode 100644 index c3b09f7e1..000000000 --- a/hermes/crates/hermes-ipfs/Cargo.toml +++ /dev/null @@ -1,27 +0,0 @@ -[package] -name = "hermes-ipfs" -edition.workspace = true -version.workspace = true -authors.workspace = true -homepage.workspace = true -repository.workspace = true -license.workspace = true - -[lints] -workspace = true - -[dependencies] -anyhow.workspace = true -derive_more.workspace = true -libipld.workspace = true -rust-ipfs.workspace = true -tokio.workspace = true - -[dev-dependencies] -# Dependencies used by examples -clap = { workspace = true, features = ["derive"] } -dirs.workspace = true -lipsum.workspace = true -rand.workspace = true -rustyline-async.workspace = true -tracing-subscriber.workspace = true diff --git a/hermes/crates/hermes-ipfs/examples/add-file-with-pinning.rs b/hermes/crates/hermes-ipfs/examples/add-file-with-pinning.rs deleted file mode 100644 index 53a924b3e..000000000 --- a/hermes/crates/hermes-ipfs/examples/add-file-with-pinning.rs +++ /dev/null @@ -1,78 +0,0 @@ -//! Hermes IPFS File Publishing and Pinning - -use hermes_ipfs::{Cid, HermesIpfs}; - -/// Print helper -async fn print_cid_pinned(hermes_ipfs: &HermesIpfs, cid: &Cid) -> anyhow::Result<()> { - let is_pinned = hermes_ipfs.is_pinned(cid).await?; - println!("* Is CID pinned?: {is_pinned:?}"); - Ok(()) -} - -/// Example application. -#[tokio::main] -#[allow(clippy::println_empty_string)] -async fn main() -> anyhow::Result<()> { - let hermes_ipfs = HermesIpfs::start().await?; - println!("***************************************"); - println!("* Hermes IPFS node has started."); - println!("***************************************"); - println!(""); - println!("***************************************"); - println!("* Adding file to IPFS:"); - println!(""); - let ipfs_file = b"This is a demo file that is stored in IPFS.".to_vec(); - let ipfs_path = hermes_ipfs.add_ipfs_file(ipfs_file.into()).await?; - println!("* IPFS file published at {ipfs_path}"); - let cid = ipfs_path.root().cid().ok_or(anyhow::anyhow!( - "ERROR! Could not extract CID from IPFS path." - ))?; - println!("* CID: {cid}"); - println!("* CID Version: {:?}", cid.version()); - print_cid_pinned(&hermes_ipfs, cid).await?; - println!("***************************************"); - println!(""); - println!("***************************************"); - println!("* CID Pinning:"); - println!(""); - if let Err(e) = hermes_ipfs.insert_pin(cid).await { - if e.to_string().contains("already pinned recursively") { - println!("{cid} is already pinned"); - } else { - println!("AN ERROR OCCURRED: {e}"); - } - }; - println!("* Removing pin."); - hermes_ipfs.remove_pin(cid).await?; - print_cid_pinned(&hermes_ipfs, cid).await?; - println!(""); - println!("* Re-pinning CID:."); - if let Err(e) = hermes_ipfs.insert_pin(cid).await { - if e.to_string().contains("already pinned recursively") { - println!("{cid} is already pinned"); - } else { - println!("AN ERROR OCCURRED: {e}"); - } - }; - print_cid_pinned(&hermes_ipfs, cid).await?; - println!("***************************************"); - println!(""); - println!("***************************************"); - println!("* Get file from IPFS:"); - println!(""); - println!("* Retrieving from {ipfs_path}"); - let get_file_bytes = hermes_ipfs.get_ipfs_file(ipfs_path.into()).await?; - println!("* Got file, {} bytes:", get_file_bytes.len()); - let get_file = String::from_utf8(get_file_bytes)?; - println!("* FILE CONTENTS:"); - println!(""); - println!("{get_file}"); - println!(""); - println!("***************************************"); - println!(""); - hermes_ipfs.stop().await; - println!("***************************************"); - println!("* Hermes IPFS node has stopped."); - println!("***************************************"); - Ok(()) -} diff --git a/hermes/crates/hermes-ipfs/examples/hermes-ipfs-cli.rs b/hermes/crates/hermes-ipfs/examples/hermes-ipfs-cli.rs deleted file mode 100644 index 4ecc52281..000000000 --- a/hermes/crates/hermes-ipfs/examples/hermes-ipfs-cli.rs +++ /dev/null @@ -1,89 +0,0 @@ -//! Hermes IPFS VFS compatibility - -use clap::{Parser, Subcommand}; -use hermes_ipfs::{HermesIpfs, IpfsBuilder}; -use lipsum::lipsum_with_rng; -use rand::thread_rng; -use rust_ipfs::IpfsPath; - -/// CLI for a virtual filesystem. -#[derive(Debug, Parser)] // requires `derive` feature -#[command(name = "hermes-ipfs-cli")] -#[command(about = "Hermes IPFS Virtual File Manager", long_about = None)] -struct Cli { - /// CLI commands - #[command(subcommand)] - command: Commands, -} - -/// Commands for the CLI. -#[derive(Debug, Subcommand)] -enum Commands { - /// List Files - #[command(name = "ls")] - ListFiles, - /// Add a file with random content to IPFS - #[command(name = "add")] - AddFile, - /// Print the contents from a file in IPFS - #[command(name = "cat")] - GetFile { - /// IPFS Path - ipfs_path_str: String, - }, - /// Remove the file from being listed (will be garbage collected) - #[command(name = "rm")] - UnPinFile { - /// IPFS Path - ipfs_path_str: String, - }, -} - -/// Example application. -#[tokio::main] -async fn main() -> anyhow::Result<()> { - let args = Cli::parse(); - let base_dir = dirs::data_dir().unwrap_or_else(|| std::path::PathBuf::from(".")); - let ipfs_data_path = base_dir.as_path().join("hermes/ipfs"); - let builder = IpfsBuilder::new() - .with_default() - .set_default_listener() - .set_disk_storage(ipfs_data_path); - let hermes_node: HermesIpfs = builder.start().await?.into(); - match args.command { - Commands::ListFiles => { - println!("Listing files"); - let cids = hermes_node.list_pins().await?; - for cid in &cids { - println!("{}", IpfsPath::from(cid)); - } - }, - Commands::AddFile => { - println!("Adding file"); - let contents = lipsum_with_rng(thread_rng(), 42); - let ipfs_path = hermes_node - .add_ipfs_file(contents.into_bytes().into()) - .await?; - println!("Added file: {ipfs_path}"); - }, - Commands::GetFile { ipfs_path_str } => { - println!("Getting file"); - let ipfs_path: IpfsPath = ipfs_path_str.parse()?; - let get_file_bytes = hermes_node.get_ipfs_file(ipfs_path.into()).await?; - println!("* Got file, {} bytes:", get_file_bytes.len()); - let get_file = String::from_utf8(get_file_bytes)?; - println!("* FILE CONTENTS:"); - println!("{get_file}\n"); - }, - Commands::UnPinFile { ipfs_path_str } => { - println!("Un-pinning file {ipfs_path_str}"); - let ipfs_path: IpfsPath = ipfs_path_str.parse()?; - let cid = ipfs_path.root().cid().ok_or(anyhow::anyhow!( - "ERROR! Could not extract CID from IPFS path." - ))?; - hermes_node.remove_pin(cid).await?; - }, - } - hermes_node.stop().await; - Ok(()) -} diff --git a/hermes/crates/hermes-ipfs/examples/provide-content-dht.rs b/hermes/crates/hermes-ipfs/examples/provide-content-dht.rs deleted file mode 100644 index 63cf97475..000000000 --- a/hermes/crates/hermes-ipfs/examples/provide-content-dht.rs +++ /dev/null @@ -1,111 +0,0 @@ -//! Use Hermes IPFS to distribute content using DHT -#![allow(clippy::println_empty_string)] - -use hermes_ipfs::{HermesIpfs, IpfsPath}; - -/// Connect Node A, upload file and provide CID by adding to DHT -async fn connect_node_a_upload_and_provide( - file_content: Vec, -) -> anyhow::Result<(HermesIpfs, IpfsPath)> { - let hermes_ipfs = HermesIpfs::start().await?; - println!("***************************************"); - println!("* Hermes IPFS node A has started."); - println!(""); - let peer_id_a = hermes_ipfs.identity(None).await?; - let addresses = hermes_ipfs.listening_addresses().await?; - println!("* Peer ID: {peer_id_a}"); - for addr in addresses { - println!(" * {addr}"); - } - println!("***************************************"); - println!(""); - println!("***************************************"); - println!("* Adding file to IPFS:"); - println!(""); - let ipfs_path = hermes_ipfs.add_ipfs_file(file_content.into()).await?; - println!("* IPFS file published at {ipfs_path}"); - let cid = ipfs_path.root().cid().ok_or(anyhow::anyhow!( - "ERROR! Could not extract CID from IPFS path." - ))?; - println!("* CID: {cid}"); - println!("* CID Version: {:?}", cid.version()); - println!("***************************************"); - println!(""); - println!("***************************************"); - println!("* Providing content to DHT:"); - println!(""); - println!("* Providing {cid} as peer {peer_id_a}"); - println!("***************************************"); - println!(""); - Ok((hermes_ipfs, ipfs_path)) -} - -/// Connect Node A, upload file and provide CID by adding to DHT -async fn connect_node_b_to_node_a(node_a: &HermesIpfs) -> anyhow::Result { - let hermes_ipfs_b = HermesIpfs::start().await?; - println!("***************************************"); - println!("* Hermes IPFS node B has started."); - println!(""); - let peer_id_b = hermes_ipfs_b.identity(None).await?; - // node_b.connect(peer_id_a).await?; - println!("* Peer ID: {peer_id_b}"); - println!("* Listening addresses:"); - let addresses = hermes_ipfs_b.listening_addresses().await?; - for addr in addresses { - println!(" * {addr}"); - } - println!("***************************************"); - println!(""); - println!("***************************************"); - println!("* Connecting Node B to Node A:"); - println!(""); - println!("* Adding peer listening addresses from Node A:"); - let node_a_addresses = node_a.listening_addresses().await?; - let peer_a = node_a.identity(None).await?; - for addr in node_a_addresses { - hermes_ipfs_b.add_peer(peer_a, addr.clone()).await?; - println!(" * {addr} - CONNECTED"); - } - println!("***************************************"); - println!(""); - Ok(hermes_ipfs_b) -} - -/// Example application. -#[tokio::main] -async fn main() -> anyhow::Result<()> { - // File to be uploaded - let ipfs_file = b"DEMO FILE DISTRIBUTED WITH IPFS".to_vec(); - // Start Node A, publish file, and make node provider for CID - let (hermes_ipfs_a, ipfs_path) = connect_node_a_upload_and_provide(ipfs_file.clone()).await?; - // Start Node B, add listening addresses from Node A, and - // connect to Node A's peer ID. - let hermes_ipfs_b = connect_node_b_to_node_a(&hermes_ipfs_a).await?; - - println!("***************************************"); - println!("* Get content from IPFS path {ipfs_path}"); - println!(""); - // For illustration, the `ipfs_path` can be obtained from a known CID - let ipfs_path_string = format!("{ipfs_path}"); - - // Fetch the content from the `ipfs_path`. - let fetched_bytes = hermes_ipfs_b - .get_ipfs_file(ipfs_path_string.parse()?) - .await?; - assert_eq!(ipfs_file, fetched_bytes); - let fetched_file = String::from_utf8(fetched_bytes)?; - println!("* Fetched: {fetched_file:?}"); - println!("***************************************"); - println!(""); - // Stop the nodes and exit. - hermes_ipfs_a.stop().await; - println!("***************************************"); - println!("* Hermes IPFS node A has stopped."); - println!("***************************************"); - hermes_ipfs_b.stop().await; - println!(""); - println!("***************************************"); - println!("* Hermes IPFS node B has stopped."); - println!("***************************************"); - Ok(()) -} diff --git a/hermes/crates/hermes-ipfs/examples/pubsub.rs b/hermes/crates/hermes-ipfs/examples/pubsub.rs deleted file mode 100644 index 2e3696ef8..000000000 --- a/hermes/crates/hermes-ipfs/examples/pubsub.rs +++ /dev/null @@ -1,161 +0,0 @@ -//! `PubSub` example -//! -//! This example starts two bootstrapped Hermes IPFS Nodes and subscribes them to the -//! `ipfs-chat` topic, creating an async stream for incoming topic publications for each -//! node. Another set of async streams are created for swarm pubsub events related to the -//! topic. -//! -//! The example then spawns different async tasks that run in a loop. -//! -//! * The task that reads from the topic stream for Node A -//! * The task that reads from the topic stream for Node B -//! * The task that reads from the topic swarm events for Node A -//! * The task that reads from the topic swarm events for Node B -//! * The task that reads lines from stdin and publishes them as either node. -use std::io::Write; - -use hermes_ipfs::{pin_mut, FutureExt, HermesIpfs, StreamExt}; -use rust_ipfs::PubsubEvent; -use rustyline_async::Readline; - -#[allow(clippy::indexing_slicing)] -/// Connect Node A, upload file and provide CID by adding to DHT -async fn start_bootstrapped_nodes() -> anyhow::Result<(HermesIpfs, HermesIpfs)> { - let hermes_a = HermesIpfs::start().await?; - println!("***************************************"); - println!("* Hermes IPFS node A has started."); - let peer_id_a = hermes_a.identity(None).await?; - println!(" Peer ID: {peer_id_a}"); - let addresses = hermes_a.listening_addresses().await?; - let a_address = addresses[0].clone(); - let a_p2p = a_address.with(rust_ipfs::Protocol::P2p(peer_id_a)); - println!(" P2P addr: {a_p2p}"); - println!("***************************************"); - println!("* Hermes IPFS node B has started."); - let hermes_b = HermesIpfs::start().await?; - let peer_id_b = hermes_b.identity(None).await?; - println!(" Peer ID: {peer_id_b}"); - let addresses = hermes_b.listening_addresses().await?; - let b_address = addresses[0].clone(); - let b_p2p = b_address.with(rust_ipfs::Protocol::P2p(peer_id_b)); - println!(" P2P addr: {b_p2p}"); - println!("***************************************"); - println!("* Bootstrapping node A."); - hermes_a.dht_mode(rust_ipfs::DhtMode::Server).await?; - hermes_a.add_bootstrap(b_p2p).await?; - hermes_a.bootstrap().await?; - println!("***************************************"); - println!("* Bootstrapping node B."); - hermes_b.dht_mode(rust_ipfs::DhtMode::Server).await?; - hermes_b.add_bootstrap(a_p2p).await?; - hermes_b.bootstrap().await?; - println!("***************************************"); - Ok((hermes_a, hermes_b)) -} - -#[tokio::main] -/// Main function -async fn main() -> anyhow::Result<()> { - let topic = String::from("ipfs-chat"); - - // Initialize the repo and start a daemon - let (hermes_a, hermes_b) = start_bootstrapped_nodes().await?; - let (mut rl, mut stdout) = Readline::new(format!("{} > ", "Write message to publish"))?; - - let mut event_stream = hermes_a.pubsub_events(&topic).await?; - let mut event_stream_b = hermes_b.pubsub_events(&topic).await?; - - let stream = hermes_a.pubsub_subscribe(topic.to_string()).await?; - let stream_b = hermes_b.pubsub_subscribe(topic.to_string()).await?; - - pin_mut!(stream); - pin_mut!(stream_b); - - tokio::task::yield_now().await; - - let mut peer_line = PeerLine::A; - loop { - tokio::select! { - data = stream.next() => { - if let Some(msg) = data { - writeln!(stdout, "NODE A RECV: {}", String::from_utf8_lossy(&msg.data))?; - } - } - data = stream_b.next() => { - if let Some(msg) = data { - writeln!(stdout, "NODE B RECV: {}", String::from_utf8_lossy(&msg.data))?; - } - } - Some(event) = event_stream.next() => { - match event { - PubsubEvent::Subscribe { peer_id } => writeln!(stdout, "{peer_id} subscribed")?, - PubsubEvent::Unsubscribe { peer_id } => writeln!(stdout, "{peer_id} unsubscribed")?, - } - } - Some(event) = event_stream_b.next() => { - match event { - PubsubEvent::Subscribe { peer_id } => writeln!(stdout, "{peer_id} subscribed")?, - PubsubEvent::Unsubscribe { peer_id } => writeln!(stdout, "{peer_id} unsubscribed")?, - } - } - line = rl.readline().fuse() => match line { - Ok(rustyline_async::ReadlineEvent::Line(line)) => { - let line_bytes = line.as_bytes().to_vec(); - let topic = topic.clone(); - match peer_line { - PeerLine::A => { - if let Err(e) = hermes_a.pubsub_publish(topic, line_bytes).await { - writeln!(stdout, "Error publishing message: {e}")?; - continue; - } - } - PeerLine::B => { - if let Err(e) = hermes_b.pubsub_publish(topic, line_bytes).await { - writeln!(stdout, "Error publishing message: {e}")?; - continue; - } - } - } - writeln!(stdout, "{peer_line} SEND: {line}")?; - peer_line.toggle(); - } - Ok(rustyline_async::ReadlineEvent::Eof | rustyline_async::ReadlineEvent::Interrupted) => { - break - }, - Err(e) => { - writeln!(stdout, "Error: {e}")?; - writeln!(stdout, "Exiting...")?; - break - }, - } - } - } - // Exit - hermes_a.stop().await; - Ok(()) -} - -#[derive(Debug)] -/// Helpful enum for toggling which peer reads lines from stdin -enum PeerLine { - /// Node A - A, - /// Node B - B, -} - -impl PeerLine { - /// Toggle peers - fn toggle(&mut self) { - *self = match self { - PeerLine::A => PeerLine::B, - PeerLine::B => PeerLine::A, - }; - } -} - -impl std::fmt::Display for PeerLine { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "NODE {self:?}") - } -} diff --git a/hermes/crates/hermes-ipfs/examples/put-get-dht.rs b/hermes/crates/hermes-ipfs/examples/put-get-dht.rs deleted file mode 100644 index 3cfacc9f5..000000000 --- a/hermes/crates/hermes-ipfs/examples/put-get-dht.rs +++ /dev/null @@ -1,63 +0,0 @@ -//! Use Hermes IPFS to distribute content using DHT -#![allow(clippy::println_empty_string)] - -use hermes_ipfs::HermesIpfs; - -#[allow(clippy::indexing_slicing)] -/// Connect Node A, upload file and provide CID by adding to DHT -async fn start_bootstrapped_nodes() -> anyhow::Result<(HermesIpfs, HermesIpfs)> { - let hermes_a = HermesIpfs::start().await?; - println!("***************************************"); - println!("* Hermes IPFS node A has started."); - let peer_id_a = hermes_a.identity(None).await?; - println!(" Peer ID: {peer_id_a}"); - let addresses = hermes_a.listening_addresses().await?; - let a_address = addresses[0].clone(); - let a_p2p = a_address.with(rust_ipfs::Protocol::P2p(peer_id_a)); - println!(" P2P addr: {a_p2p}"); - println!("***************************************"); - println!("* Hermes IPFS node B has started."); - let hermes_b = HermesIpfs::start().await?; - let peer_id_b = hermes_b.identity(None).await?; - println!(" Peer ID: {peer_id_b}"); - let addresses = hermes_b.listening_addresses().await?; - let b_address = addresses[0].clone(); - let b_p2p = b_address.with(rust_ipfs::Protocol::P2p(peer_id_b)); - println!(" P2P addr: {b_p2p}"); - println!("***************************************"); - println!("* Bootstrapping node A."); - hermes_a.dht_mode(rust_ipfs::DhtMode::Server).await?; - hermes_a.add_bootstrap(b_p2p).await?; - hermes_a.bootstrap().await?; - println!("***************************************"); - println!("* Bootstrapping node B."); - hermes_b.dht_mode(rust_ipfs::DhtMode::Server).await?; - hermes_b.add_bootstrap(a_p2p).await?; - hermes_b.bootstrap().await?; - println!("***************************************"); - Ok((hermes_a, hermes_b)) -} - -/// Example application. -#[tokio::main] -async fn main() -> anyhow::Result<()> { - // File to be uploaded - let ipfs_file = b"DEMO FILE DISTRIBUTED WITH DHT".to_vec(); - // Start Node A, publish file, and make node provider for CID - let (hermes_ipfs_a, hermes_ipfs_b) = start_bootstrapped_nodes().await?; - println!("* Hermes IPFS node A is publishing 'my_key' to DHT."); - hermes_ipfs_a.dht_put(b"my_key", ipfs_file).await?; - println!("* Hermes IPFS node B is getting 'my_key' from DHT."); - let data_retrieved = hermes_ipfs_b.dht_get(b"my_key").await?; - let data = String::from_utf8(data_retrieved)?; - println!(" Got data: {data:?}"); - // Stop the nodes and exit. - hermes_ipfs_a.stop().await; - println!("***************************************"); - println!("* Hermes IPFS node A has stopped."); - println!("***************************************"); - hermes_ipfs_b.stop().await; - println!("* Hermes IPFS node B has stopped."); - println!("***************************************"); - Ok(()) -} diff --git a/hermes/crates/hermes-ipfs/src/lib.rs b/hermes/crates/hermes-ipfs/src/lib.rs deleted file mode 100644 index fe8f46b63..000000000 --- a/hermes/crates/hermes-ipfs/src/lib.rs +++ /dev/null @@ -1,603 +0,0 @@ -//! Hermes IPFS -//! -//! Provides support for storage, and `PubSub` functionality. - -use std::str::FromStr; - -use derive_more::{Display, From, Into}; -/// IPFS Content Identifier. -pub use libipld::Cid; -/// IPLD -pub use libipld::Ipld; -/// `rust_ipfs` re-export. -pub use rust_ipfs; -/// libp2p re-exports. -pub use rust_ipfs::libp2p::futures::{pin_mut, stream::BoxStream, FutureExt, StreamExt}; -/// Peer Info type. -pub use rust_ipfs::p2p::PeerInfo; -/// Enum for specifying paths in IPFS. -pub use rust_ipfs::path::IpfsPath; -/// Server, Client, or Auto mode -pub use rust_ipfs::DhtMode; -/// Server, Client, or Auto mode -pub use rust_ipfs::Ipfs; -/// Multiaddr type. -pub use rust_ipfs::Multiaddr; -/// Peer ID type. -pub use rust_ipfs::PeerId; -/// Storage type for IPFS node. -pub use rust_ipfs::StorageType; -/// Stream for `PubSub` Topic Subscriptions. -pub use rust_ipfs::SubscriptionStream; -/// Builder type for IPFS Node configuration. -use rust_ipfs::UninitializedIpfsNoop; -use rust_ipfs::{ - dag::ResolveError, - libp2p::gossipsub::{Message as PubsubMessage, MessageId as PubsubMessageId}, - unixfs::AddOpt, - PubsubEvent, Quorum, -}; - -#[derive(Debug, Display, From, Into)] -/// `PubSub` Message ID. -pub struct MessageId(pub PubsubMessageId); - -/// Builder type for IPFS Node configuration. -pub struct IpfsBuilder(UninitializedIpfsNoop); - -impl IpfsBuilder { - #[must_use] - /// Create a new` IpfsBuilder`. - pub fn new() -> Self { - Self(UninitializedIpfsNoop::new()) - } - - #[must_use] - /// Set the default configuration for the IPFS node. - pub fn with_default(self) -> Self { - Self(self.0.with_default()) - } - - #[must_use] - /// Set the default listener for the IPFS node. - pub fn set_default_listener(self) -> Self { - Self(self.0.set_default_listener()) - } - - #[must_use] - /// Set the storage type for the IPFS node to local disk. - /// - /// ## Parameters - pub fn set_disk_storage>(self, storage_path: T) -> Self { - Self( - self.0 - .set_storage_type(rust_ipfs::StorageType::Disk(storage_path.into())), - ) - } - - #[must_use] - /// Set the transport configuration for the IPFS node. - pub fn set_transport_configuration(self, transport: rust_ipfs::p2p::TransportConfig) -> Self { - Self(self.0.set_transport_configuration(transport)) - } - - #[must_use] - /// Disable TLS for the IPFS node. - pub fn disable_tls(self) -> Self { - let transport = rust_ipfs::p2p::TransportConfig { - enable_quic: false, - enable_secure_websocket: false, - ..Default::default() - }; - Self(self.0.set_transport_configuration(transport)) - } - - /// Start the IPFS node. - /// - /// ## Errors - /// Returns an error if the IPFS daemon fails to start. - pub async fn start(self) -> anyhow::Result { - self.0.start().await - } -} - -impl Default for IpfsBuilder { - fn default() -> Self { - Self::new() - } -} - -/// Hermes IPFS Node. -pub struct HermesIpfs { - /// IPFS node - node: Ipfs, -} - -impl HermesIpfs { - /// Start a new node. - /// - /// ## Returns - /// - /// * `HermesIpfs` - /// - /// ## Errors - /// - /// Returns an error if the IPFS daemon fails to start. - pub async fn start() -> anyhow::Result { - let node: Ipfs = IpfsBuilder::new() - .with_default() - .set_default_listener() - .start() - .await?; - Ok(HermesIpfs { node }) - } - - /// Add a file to IPFS. - /// - /// ## Parameters - /// - /// * `file_path` The `file_path` can be specified as a type that converts into - /// `std::path::PathBuf`. - /// - /// ## Returns - /// - /// * A result with `IpfsPath` - /// - /// ## Errors - /// - /// Returns an error if the file fails to upload. - pub async fn add_ipfs_file(&self, ipfs_file: AddIpfsFile) -> anyhow::Result { - let ipfs_path = self.node.add_unixfs(ipfs_file).await?; - Ok(ipfs_path) - } - - /// Get a file from IPFS - /// - /// ## Parameters - /// - /// * `ipfs_path` - `GetIpfsFile(IpfsPath)` Path used to get the file from IPFS. - /// - /// ## Returns - /// - /// * `A result with Vec`. - /// - /// ## Errors - /// - /// Returns an error if the file fails to download. - pub async fn get_ipfs_file(&self, ipfs_path: GetIpfsFile) -> anyhow::Result> { - let stream_bytes = self.node.cat_unixfs(ipfs_path).await?; - Ok(stream_bytes.to_vec()) - } - - /// Pin content to IPFS. - /// - /// ## Parameters - /// - /// * `cid` - `Cid` Content identifier to be pinned. - /// - /// ## Errors - /// - /// Returns an error if pinning fails. - pub async fn insert_pin(&self, cid: &Cid) -> anyhow::Result<()> { - self.node.insert_pin(cid).await - } - - /// Checks whether a given block is pinned. - /// - /// # Crash unsafety - /// - /// Cannot currently detect partially written recursive pins. Those can happen if - /// [`HermesIpfs::insert_pin`] is interrupted by a crash for example. - /// - /// Works correctly only under no-crash situations. Workaround for hitting a crash is - /// to re-pin any existing recursive pins. - /// - /// ## Parameters - /// - /// * `cid` - `Cid` Content identifier to be pinned. - /// - /// ## Returns - /// `true` if the block is pinned, `false` if not. See Crash unsafety notes for the - /// false response. - /// - /// ## Errors - /// - /// Returns an error if checking pin fails. - pub async fn is_pinned(&self, cid: &Cid) -> anyhow::Result { - self.node.is_pinned(cid).await - } - - /// List all pins in the IPFS node. - /// - /// ## Parameters - /// * `cid` - `Option` Optional content identifier to list pins. If `None`, lists - /// all pins. - /// - /// ## Errors - /// Returns an error if listing pins fails. - pub async fn list_pins(&self) -> anyhow::Result> { - // List all kinds of pins by setting `None` as the argument. - let pins_stream = self.node.list_pins(None).await; - pin_mut!(pins_stream); - let mut pins = vec![]; - while let Some(pinned) = pins_stream.next().await { - pins.push(pinned?.0); - } - Ok(pins) - } - - /// Remove pinned content from IPFS. - /// - /// ## Parameters - /// - /// * `cid` - `Cid` Content identifier to be un-pinned. - /// - /// ## Errors - /// - /// Returns an error if removing pin fails. - pub async fn remove_pin(&self, cid: &Cid) -> anyhow::Result<()> { - self.node.remove_pin(cid).recursive().await - } - - /// Stop and exit the IPFS node daemon. - pub async fn stop(self) { - self.node.exit_daemon().await; - } - - /// Returns the peer identity information. If no peer id is supplied the local node - /// identity is used. - /// - /// ## Parameters - /// - /// * `peer_id` - `Option` - /// - /// ## Errors - /// - /// Returns error if peer info cannot be retrieved. - pub async fn identity(&self, peer_id: Option) -> anyhow::Result { - self.node.identity(peer_id).await.map(|p| p.peer_id) - } - - /// Add peer to address book. - /// - /// ## Parameters - /// - /// * `peer_id` - `PeerId` - /// * `addr` - `Multiaddr` - /// - /// ## Errors - /// - /// Returns error if unable to add peer. - pub async fn add_peer(&self, peer_id: PeerId, addr: Multiaddr) -> anyhow::Result<()> { - self.node.add_peer(peer_id, addr).await - } - - /// List of local listening addresses - /// - /// ## Returns - /// - /// * `Result>` - /// - /// ## Errors - /// - /// Returns error if listening addresses cannot be retrieved. - pub async fn listening_addresses(&self) -> anyhow::Result> { - self.node.listening_addresses().await - } - - /// Sets DHT mode in the IPFS node. - /// - /// ## Parameters - /// - /// * `mode` - `DhtMode` - /// - /// ## Returns - /// - /// * `Result<()>` - /// - /// ## Errors - /// - /// Returns error if unable to set DHT mode - pub async fn dht_mode(&self, mode: DhtMode) -> anyhow::Result<()> { - self.node.dht_mode(mode).await - } - - /// Add DAG data to IPFS. - /// - /// ## Parameters - /// - /// * `ipld` - `Ipld` - /// - /// ## Returns - /// - /// * `Result` - /// - /// ## Errors - /// - /// Returns error if unable to add DAG content. - pub async fn dag_put(&self, ipld: Ipld) -> anyhow::Result { - self.node.put_dag(ipld).await - } - - /// Get DAG data from IPFS. - /// - /// ## Parameters - /// - /// * `path` - `impl Into` - /// - /// ## Returns - /// - /// * `Result` - /// - /// ## Errors - /// - /// Returns error if unable to get DAG content. - pub async fn dag_get>(&self, path: T) -> Result { - self.node.get_dag(path).await - } - - /// Add content to DHT. - /// - /// ## Parameters - /// - /// * `key` - `impl AsRef<[u8]>` - /// * `value` - `impl Into>` - /// - /// ## Returns - /// - /// * `Result<()>` - /// - /// ## Errors - /// - /// Returns error if unable to add content to DHT - pub async fn dht_put( - &self, key: impl AsRef<[u8]>, value: impl Into>, - ) -> anyhow::Result<()> { - self.node.dht_put(key, value, Quorum::One).await - } - - /// Get content from DHT. - /// - /// ## Parameters - /// - /// * `key` - `impl AsRef<[u8]>` - /// - /// ## Returns - /// - /// * `Result>` - /// - /// ## Errors - /// - /// Returns error if unable to get content from DHT - pub async fn dht_get(&self, key: impl AsRef<[u8]>) -> anyhow::Result> { - let record_stream = self.node.dht_get(key).await?; - pin_mut!(record_stream); - let record = record_stream - .next() - .await - .ok_or(anyhow::anyhow!("No record found"))?; - Ok(record.value) - } - - /// Add address to bootstrap nodes. - /// - /// ## Parameters - /// - /// * `address` - `Multiaddr` - /// - /// ## Returns - /// - /// * `Result` - /// - /// ## Errors - /// - /// Returns error if unable to add address to bootstrap nodes - pub async fn add_bootstrap(&self, address: Multiaddr) -> anyhow::Result { - self.node.add_bootstrap(address).await - } - - /// Bootstrap the IPFS node. - /// - /// ## Returns - /// - /// * `Result<()>` - /// - /// ## Errors - /// - /// Returns error if unable to retrieve bootstrap the node. - pub async fn bootstrap(&self) -> anyhow::Result<()> { - self.node.bootstrap().await - } - - /// Returns a stream of pubsub swarm events for a topic. - /// - /// ## Parameters - /// - /// * `topic` - `impl Into` - /// - /// ## Returns - /// - /// * A result with `BoxStream<'static, PubsubEvent>` - /// - /// ## Errors - /// - /// Returns error if unable to retrieve pubsub swarm events. - pub async fn pubsub_events( - &self, topic: impl Into, - ) -> anyhow::Result> { - self.node.pubsub_events(topic).await - } - - /// Subscribes to a pubsub topic. - /// - /// ## Parameters - /// - /// * `topic` - `impl Into` - /// - /// ## Returns - /// - /// * `SubscriptionStream` - /// - /// ## Errors - /// - /// Returns error if unable to subscribe to pubsub topic. - pub async fn pubsub_subscribe( - &self, topic: impl Into, - ) -> anyhow::Result { - self.node.pubsub_subscribe(topic).await - } - - /// Unsubscribes from a pubsub topic. - /// - /// ## Parameters - /// - /// * `topic` - `impl Into` - /// - /// ## Returns - /// - /// * `bool` - /// - /// ## Errors - /// - /// Returns error if unable to unsubscribe from pubsub topic. - pub async fn pubsub_unsubscribe(&self, topic: impl Into) -> anyhow::Result { - self.node.pubsub_unsubscribe(topic).await - } - - /// Publishes a message to a pubsub topic. - /// - /// ## Parameters - /// - /// * `topic` - `impl Into` - /// * `message` - `Vec` - /// - /// ## Returns - /// - /// * `Result` - /// - /// ## Errors - /// - /// Returns error if unable to publish to a pubsub topic. - pub async fn pubsub_publish( - &self, topic: impl Into, message: Vec, - ) -> anyhow::Result { - self.node - .pubsub_publish(topic, message) - .await - .map(std::convert::Into::into) - } - - /// Ban peer from node. - /// - /// ## Parameters - /// - /// * `peer` - `PeerId` - /// - /// ## Returns - /// - /// * `Result<()>` - /// - /// ## Errors - /// - /// Returns error if unable to ban peer. - pub async fn ban_peer(&self, peer: PeerId) -> anyhow::Result<()> { - self.node.ban_peer(peer).await - } -} - -impl From for HermesIpfs { - fn from(node: Ipfs) -> Self { - Self { node } - } -} - -/// File that will be added to IPFS -pub enum AddIpfsFile { - /// Path in local disk storage to the file. - Path(std::path::PathBuf), - /// Stream of file bytes, with an optional name. - /// **NOTE** current implementation of `rust-ipfs` does not add names to published - /// files. - Stream((Option, Vec)), -} - -impl From for AddOpt { - fn from(value: AddIpfsFile) -> Self { - match value { - AddIpfsFile::Path(file_path) => file_path.into(), - AddIpfsFile::Stream((None, bytes)) => bytes.into(), - AddIpfsFile::Stream((Some(name), bytes)) => (name, bytes).into(), - } - } -} - -impl From for AddIpfsFile { - fn from(value: String) -> Self { - Self::Path(value.into()) - } -} - -impl From for AddIpfsFile { - fn from(value: std::path::PathBuf) -> Self { - Self::Path(value) - } -} - -impl From> for AddIpfsFile { - fn from(value: Vec) -> Self { - Self::Stream((None, value)) - } -} - -impl From<(String, Vec)> for AddIpfsFile { - fn from((name, stream): (String, Vec)) -> Self { - Self::Stream((Some(name), stream)) - } -} - -impl From<(Option, Vec)> for AddIpfsFile { - fn from(value: (Option, Vec)) -> Self { - Self::Stream(value) - } -} - -/// Path to get the file from IPFS -pub struct GetIpfsFile(IpfsPath); - -impl From for GetIpfsFile { - fn from(value: Cid) -> Self { - GetIpfsFile(value.into()) - } -} - -impl From for GetIpfsFile { - fn from(value: IpfsPath) -> Self { - GetIpfsFile(value) - } -} - -impl From for IpfsPath { - fn from(value: GetIpfsFile) -> Self { - value.0 - } -} - -impl FromStr for GetIpfsFile { - type Err = anyhow::Error; - - fn from_str(s: &str) -> Result { - Ok(GetIpfsFile(s.parse()?)) - } -} - -/// Handle stream of messages from the IPFS pubsub topic -pub fn subscription_stream_task( - stream: SubscriptionStream, handler: fn(PubsubMessage), -) -> tokio::task::JoinHandle<()> { - tokio::spawn(async move { - pin_mut!(stream); - while let Some(msg) = stream.next().await { - handler(msg); - } - }) -} From c461a870c3262a058c70433615ce592c11e674df Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Wed, 9 Oct 2024 20:08:27 +0700 Subject: [PATCH 10/11] fix(hermes): Bump every crate version that its straight forward to bump --- hermes/bin/Cargo.toml | 46 +++++++++---------- hermes/bin/src/logger.rs | 10 ++-- hermes/bin/src/packaging/schema_validation.rs | 8 ++-- .../crates/cardano-chain-follower/Cargo.toml | 4 +- 4 files changed, 34 insertions(+), 34 deletions(-) diff --git a/hermes/bin/Cargo.toml b/hermes/bin/Cargo.toml index 48dc525b4..94c975b39 100644 --- a/hermes/bin/Cargo.toml +++ b/hermes/bin/Cargo.toml @@ -30,9 +30,9 @@ harness = false pallas = { git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "709acb19c52c6b789279ecc4bc8793b5d8b5abe9", version = "0.25.0" } # HDF5 is consumed using a git tag, because the latest release is very old, but the code is much more advanced. -hdf5 = { git="https://github.com/aldanor/hdf5-rust.git", rev="694e900972fbf5ffbdd1a2294f57a2cc3a91c994", version="0.8.1", features = [ "static", "blosc" ]} +hdf5 = { package = "hdf5-metno", version = "0.9.2", features = [ "static", "blosc" ] } # needs to enable blosc compression functionality for hdf5 crate -blosc-src = { version = "0.3.0", features = ["lz4", "zlib", "zstd"] } +blosc-src = { version = "0.3.4", features = ["lz4", "zlib", "zstd"] } criterion = {version = "0.5.1", optional=true} @@ -41,47 +41,47 @@ hermes-ipfs = { version = "0.0.3", git = "https://github.com/input-output-hk/cat wasmtime = {version="20.0.2", features = ["component-model"] } rusty_ulid = "2.0.0" -anyhow = "1.0.71" +anyhow = "1.0.89" hex-literal = "0.4.1" -thiserror = "1.0.56" +thiserror = "1.0.64" hex = "0.4.3" tracing = {version="0.1.40", features = ["log"] } tracing-subscriber = { version = "0.3.18", features = ["fmt", "json", "time", "env-filter"] } -libtest-mimic = "0.7.0" +libtest-mimic = "0.8.1" crossbeam-queue = "0.3.11" -bip39 = { version="2.0.0", features = ["chinese-simplified", "chinese-traditional", "czech", "french", "italian", "japanese", "korean", "spanish" ] } -iana-time-zone = "0.1.60" +bip39 = { version="2.1.0", features = ["chinese-simplified", "chinese-traditional", "czech", "french", "italian", "japanese", "korean", "spanish" ] } +iana-time-zone = "0.1.61" rand = "0.8.5" -bip32 = "0.5.1" +bip32 = "0.5.2" ed25519-bip32 = "0.4.1" -dashmap = "6.0.1" -once_cell = "1.19.0" -clap = "4.5.3" +dashmap = "6.1.0" +once_cell = "1.20.2" +clap = "4.5.20" build-info = "0.0.39" -derive_more = "0.99.17" -chrono = { version = "0.4.35", features = ["now"] } -chrono-tz = "0.9.0" +derive_more = "1.0.0" +chrono = { version = "0.4.38", features = ["now"] } +chrono-tz = "0.10.0" saffron = "0.1.0" -tokio = "1.36.0" +tokio = "1.40.0" libsqlite3-sys = {version="0.30.1", features = ["bundled"] } -stringzilla = "3.8.4" -temp-dir = "0.1.13" +stringzilla = "3.9.8" +temp-dir = "0.1.14" num_cpus = "1.16.0" console = "0.15.8" serde = { version="1.0.210", features = ["derive"] } -serde_json = "1.0" -jsonschema = "0.18.0" -hyper = { version = "0.14.10", features = ["full"] } +serde_json = "1.0.128" +jsonschema = "0.22.3" +hyper = { version = "0.14.30", features = ["full"] } hmac = "0.12.1" pbkdf2 = "0.12.2" blake2b_simd = "1.0.2" -sha2 = "0.10" +sha2 = "0.10.8" ed25519-dalek = { version="2.1.1", features = ["pem"] } x509-cert = { version="0.2.5", features = ["pem"] } -coset = "0.3.7" +coset = "0.3.8" rust-ipfs = "0.12.1" dirs = "5.0.1" -regex = "1.10.5" +regex = "1.11.0" [build-dependencies] build-info-build = "0.0.39" diff --git a/hermes/bin/src/logger.rs b/hermes/bin/src/logger.rs index e34627344..78c33b4a4 100644 --- a/hermes/bin/src/logger.rs +++ b/hermes/bin/src/logger.rs @@ -16,20 +16,20 @@ use crate::runtime_extensions::bindings::hermes::logging; #[allow(dead_code)] pub(crate) enum LogLevel { /// Errors - #[display(fmt = "Error")] + #[display("Error")] Error, /// Warnings - #[display(fmt = "Warn")] + #[display("Warn")] Warn, /// Informational Messages #[default] - #[display(fmt = "Info")] + #[display("Info")] Info, /// Debug messages - #[display(fmt = "Debug")] + #[display("Debug")] Debug, /// Tracing - #[display(fmt = "Trace")] + #[display("Trace")] Trace, } diff --git a/hermes/bin/src/packaging/schema_validation.rs b/hermes/bin/src/packaging/schema_validation.rs index d75b624ba..f58005285 100644 --- a/hermes/bin/src/packaging/schema_validation.rs +++ b/hermes/bin/src/packaging/schema_validation.rs @@ -2,7 +2,7 @@ use std::io::Read; -use jsonschema::{Draft, JSONSchema}; +use jsonschema::{Draft, Validator}; use serde::de::DeserializeOwned; use crate::errors::Errors; @@ -11,7 +11,7 @@ use crate::errors::Errors; #[derive(Debug)] pub(crate) struct SchemaValidator { /// JSON schema validator instance. - schema: JSONSchema, + schema: Validator, } impl SchemaValidator { @@ -30,9 +30,9 @@ impl SchemaValidator { /// Create a new json schema validator from JSON value. pub(crate) fn from_json(json: &serde_json::Value) -> anyhow::Result { - let schema = JSONSchema::options() + let schema = Validator::options() .with_draft(Draft::Draft7) - .compile(json) + .build(json) .map_err(|err| anyhow::anyhow!("Invalid draft 7 JSON schema:\n {err}"))?; Ok(Self { schema }) diff --git a/hermes/crates/cardano-chain-follower/Cargo.toml b/hermes/crates/cardano-chain-follower/Cargo.toml index 58422d974..bd7186215 100644 --- a/hermes/crates/cardano-chain-follower/Cargo.toml +++ b/hermes/crates/cardano-chain-follower/Cargo.toml @@ -15,8 +15,8 @@ workspace = true pallas = { git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "709acb19c52c6b789279ecc4bc8793b5d8b5abe9", version = "0.25.0" } # specific commit from the `catalyst` branch pallas-hardano = { git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "709acb19c52c6b789279ecc4bc8793b5d8b5abe9", version = "0.25.0" } -thiserror = "1.0.56" -tokio = "1.36.0" +thiserror = "1.0.64" +tokio = "1.40.0" tracing = "0.1.40" [dev-dependencies] From f117af70be1aa0497d1f0a06d41f406acf52a250 Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Thu, 10 Oct 2024 00:33:41 +0700 Subject: [PATCH 11/11] fix(hermes): spelling --- .config/dictionaries/project.dic | 1 + .earthlyignore | 2 ++ Earthfile | 14 ++------------ cspell.json | 2 ++ wasm/wasi-hermes-component-adapter/build.rs | 2 ++ .../src/descriptors.rs | 2 +- wasm/wasi-hermes-component-adapter/src/lib.rs | 2 +- 7 files changed, 11 insertions(+), 14 deletions(-) create mode 100644 .earthlyignore diff --git a/.config/dictionaries/project.dic b/.config/dictionaries/project.dic index d5f2a2527..8aed91b0d 100644 --- a/.config/dictionaries/project.dic +++ b/.config/dictionaries/project.dic @@ -104,6 +104,7 @@ maindbname mapref mdlint mdns +metno miniprotocol miniprotocols mithril diff --git a/.earthlyignore b/.earthlyignore new file mode 100644 index 000000000..77f6e2cd7 --- /dev/null +++ b/.earthlyignore @@ -0,0 +1,2 @@ +.git +**/target \ No newline at end of file diff --git a/Earthfile b/Earthfile index 6e6ddaa60..7afb765b4 100644 --- a/Earthfile +++ b/Earthfile @@ -3,10 +3,8 @@ VERSION 0.8 IMPORT github.com/input-output-hk/catalyst-ci/earthly/mdlint:v3.2.15 AS mdlint-ci IMPORT github.com/input-output-hk/catalyst-ci/earthly/cspell:v3.2.15 AS cspell-ci -FROM debian:stable-slim - # cspell: words livedocs sitedocs - + # check-markdown : markdown check using catalyst-ci. check-markdown: DO mdlint-ci+CHECK @@ -19,21 +17,13 @@ markdown-check-fix: # clean-spelling-list : Make sure the project dictionary is properly sorted. clean-spelling-list: + FROM debian:stable-slim DO cspell-ci+CLEAN # check-spelling : Check spelling in this repo inside a container. check-spelling: DO cspell-ci+CHECK -# spell-list-words : List words in a dictionary -spell-list-words: - FROM ghcr.io/streetsidesoftware/cspell:8.0.0 - WORKDIR /work - - COPY . . - - RUN cspell-cli --words-only --unique "wasm/**" | sort -f - # repo-docs : target to store the documentation from the root of the repo. repo-docs: # Create artifacts of extra files we embed inside the documentation when its built. diff --git a/cspell.json b/cspell.json index 5fa6208b6..904209897 100644 --- a/cspell.json +++ b/cspell.json @@ -141,12 +141,14 @@ // "dotnet", // "elixir", "filetypes", + "flutter", "fonts", // "fsharp", "fullstack", // "gaming-terms", "git", // "golang", + // "google", // "haskell", "html", "html-symbol-entities", diff --git a/wasm/wasi-hermes-component-adapter/build.rs b/wasm/wasi-hermes-component-adapter/build.rs index 96d644ccf..14913ef9d 100644 --- a/wasm/wasi-hermes-component-adapter/build.rs +++ b/wasm/wasi-hermes-component-adapter/build.rs @@ -237,6 +237,8 @@ fn build_raw_intrinsics() -> Vec { module.finish() } +// cspell: words libfoo + /// This function produces the output of `llvm-ar crus libfoo.a foo.o` given /// the object file above as input. The archive is what's eventually fed to /// LLD. diff --git a/wasm/wasi-hermes-component-adapter/src/descriptors.rs b/wasm/wasi-hermes-component-adapter/src/descriptors.rs index 4271297f5..1ebc7773d 100644 --- a/wasm/wasi-hermes-component-adapter/src/descriptors.rs +++ b/wasm/wasi-hermes-component-adapter/src/descriptors.rs @@ -290,7 +290,7 @@ impl Descriptors { Descriptor::Closed(next) => *next, _ => unreachable!("impossible: freelist points to a closed descriptor"), }; - // Write descriptor to the entry at the nead of the list + // Write descriptor to the entry at the head of the list *freelist_desc = d; // Point closed to the following item self.closed = next_closed; diff --git a/wasm/wasi-hermes-component-adapter/src/lib.rs b/wasm/wasi-hermes-component-adapter/src/lib.rs index 7e324a094..a54062eaa 100644 --- a/wasm/wasi-hermes-component-adapter/src/lib.rs +++ b/wasm/wasi-hermes-component-adapter/src/lib.rs @@ -116,7 +116,7 @@ macro_rules! cfg_filesystem_available { // The unwrap/expect methods in std pull panic when they fail, which pulls // in unwinding machinery that we can't use in the adapter. Instead, use this -// extension trait to get postfixed upwrap on Option and Result. +// extension trait to get postfixed unwrap on Option and Result. #[allow(clippy::missing_docs_in_private_items)] trait TrappingUnwrap { fn trapping_unwrap(self) -> T;