From 058b217bf24c35ee6a1dfa921d7c71563739abf7 Mon Sep 17 00:00:00 2001 From: Martin Fraga Date: Thu, 6 Jun 2024 17:07:08 -0300 Subject: [PATCH] tooling: swap out cargo-make for make (#359) * swap out cargo-make for make * feat: add self documented Makefile targets * refactor: use single default profile for both local and CI tests * docs: make command fail if there are warnings * ci: split test and lint workflows * address review comments * ci: try defining lint and test as reusable jobs * ci: remove workflow dependency and run ci on merges on next and main * ci: make targets consistent with miden-base * docs: fixes to documentation * make: add fix target for makefile * ci: remove rust-toolchain from test and lint workflows * lint: fix clippy issues * make: reorder sections to be the same as miden base * make: restrict separators to 100 chars width * ci: remove rustup update on mkdocs job * make: add targets to build and install --- .config/nextest.toml | 4 -- .github/workflows/ci.yml | 104 ----------------------------- .github/workflows/lint.yml | 58 ++++++++++++++++ .github/workflows/test.yml | 39 +++++++++++ CHANGELOG.md | 2 + CONTRIBUTING.md | 6 +- Makefile | 99 +++++++++++++++++++++++++++ Makefile.toml | 107 ------------------------------ README.md | 10 ++- src/cli/mod.rs | 12 ++-- src/cli/utils.rs | 2 +- src/client/store_authenticator.rs | 2 +- src/client/sync.rs | 2 +- src/store/mod.rs | 2 +- src/store/sqlite_store/mod.rs | 10 +-- tests/README.md | 47 ++++++------- 16 files changed, 245 insertions(+), 261 deletions(-) delete mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/test.yml create mode 100644 Makefile delete mode 100644 Makefile.toml diff --git a/.config/nextest.toml b/.config/nextest.toml index 2d4913185..e2e6c2ec3 100644 --- a/.config/nextest.toml +++ b/.config/nextest.toml @@ -1,8 +1,4 @@ [profile.default] -retries = 0 -slow-timeout = { period = "5m"} - -[profile.ci-default] retries = { backoff = "exponential", count = 2, delay = "1s", jitter = true, max-delay = "10s"} status-level = "skip" failure-output = "immediate-final" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 8a6cc1d6b..000000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,104 +0,0 @@ -name: CI -on: - push: - branches: - - main - pull_request: - types: [opened, repoened, synchronize] - -jobs: - test: - name: Test Rust ${{matrix.toolchain}} on ${{matrix.os}} - runs-on: ${{matrix.os}}-latest - strategy: - fail-fast: false - matrix: - toolchain: [stable, nightly] - os: [ubuntu] - steps: - - uses: actions/checkout@main - - name: Install rust - uses: dtolnay/rust-toolchain@master - with: - toolchain: ${{matrix.toolchain}} - - name: Install cargo make - run: cargo install cargo-make - - uses: taiki-e/install-action@nextest - - name: cargo make - test - run: cargo make ci-test - - clippy: - name: Clippy - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@main - - name: Install minimal stable with clippy - uses: dtolnay/rust-toolchain@master - with: - components: clippy - toolchain: stable - - name: Install cargo make - run: cargo install cargo-make - - name: cargo make - clippy-all - run: cargo make clippy-all - - rustfmt: - name: rustfmt - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@main - - name: Install minimal nightly with rustfmt - uses: dtolnay/rust-toolchain@nightly - with: - components: rustfmt - - name: Install cargo make - run: cargo install cargo-make - - name: cargo make - format - run: cargo make format - - integration_tests: - name: integration_tests - runs-on: ubuntu-latest - needs: [clippy, rustfmt] - steps: - - uses: actions/checkout@main - - name: Install minimal stable with rustfmt - uses: dtolnay/rust-toolchain@stable - with: - components: rustfmt - - name: Install cargo make - run: cargo install cargo-make - - uses: taiki-e/install-action@nextest - - run: cargo make reset - - run: cargo make node - - run: cargo make start-node > /dev/null & - - run: cargo make integration-test-full - - name: Kill miden-node - if: always() - run: cargo make kill-node - - docs: - name: build mkdocs - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Install minimal stable with rustfmt - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - components: rustfmt - override: true - - name: Install cargo make - run: cargo install cargo-make - - uses: actions/setup-python@v5 - with: - python-version: 3.x - - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV - - uses: actions/cache@v4 - with: - key: mkdocs-material-${{ env.cache_id }} - path: .cache - restore-keys: | - mkdocs-material- - - run: cargo make build-docs diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 000000000..45bba65d2 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,58 @@ +name: Lint +on: + push: + branches: [main, next] + pull_request: + types: [opened, repoened, synchronize] + +jobs: + clippy: + name: Clippy + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@main + - name: Install Rust with clippy + run: | + rustup update --no-self-update nightly + rustup +nightly component add clippy + - name: make - clippy + run: make clippy + + rustfmt: + name: rustfmt + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@main + - name: Install Rust with rustfmt + run: | + rustup update --no-self-update nightly + rustup +nightly component add rustfmt + - name: make - format-check + run: make format-check + + mkdocs: + name: build mkdocs + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@main + - uses: actions/setup-python@v5 + with: + python-version: 3.x + - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV + - uses: actions/cache@v4 + with: + key: mkdocs-material-${{ env.cache_id }} + path: .cache + restore-keys: | + mkdocs-material- + - run: make doc-build + + rustdocs: + name: build rust documentation + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@main + - name: Install Rust + run: rustup update --no-self-update + - name: make - doc + run: make doc diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..588110a1f --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,39 @@ +name: Test +on: + push: + branches: [main, next] + pull_request: + types: [opened, repoened, synchronize] + +jobs: + test: + name: Test Rust ${{matrix.toolchain}} on ${{matrix.os}} + runs-on: ${{matrix.os}}-latest + strategy: + fail-fast: false + matrix: + toolchain: [stable, nightly] + os: [ubuntu] + steps: + - uses: actions/checkout@main + - name: Install Rust with ${{matrix.toolchain}} toolchain + run: rustup update --no-self-update ${{ matrix.toolchain }} + - uses: taiki-e/install-action@nextest + - name: make - test + run: make test + + integration_tests: + name: integration_tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@main + - name: Install Rust + run: rustup update --no-self-update + - uses: taiki-e/install-action@nextest + - run: make clean-node + - run: make node + - run: make start-node > /dev/null & + - run: make integration-test-full + - name: Kill miden-node + if: always() + run: make kill-node diff --git a/CHANGELOG.md b/CHANGELOG.md index db8a0e19d..385492199 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog +* Changed `cargo-make` usage for `make` and `Makefile.toml` for a regular `Makefile` (#359). +* Added integration tests using the CLI (#353). * Added a new check on account creation / import on the CLI to set the account as the default one if none is set (#372). * Fixed bug when exporting a note into a file (#368). * Simplified and separated the `notes --list` table (#356). diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9c93a6f97..ab9d6b6e8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -71,13 +71,13 @@ For example, a new change to the `miden-node-store` crate might have the followi // ================================================================================ ``` -- [Rustfmt](https://github.com/rust-lang/rustfmt), [Clippy](https://github.com/rust-lang/rust-clippy) and [Rustdoc](https://doc.rust-lang.org/rustdoc/index.html) linting is included in CI pipeline. Anyways it's preferable to run linting locally before push. To simplify running these commands in a reproducible manner we use [cargo-make](https://github.com/sagiegurari/cargo-make), you can run: +- [Rustfmt](https://github.com/rust-lang/rustfmt), [Clippy](https://github.com/rust-lang/rust-clippy) and [Rustdoc](https://doc.rust-lang.org/rustdoc/index.html) linting is included in CI pipeline. Anyways it's preferable to run linting locally before push. To simplify running these commands in a reproducible manner we use `make`, you can run: ``` - cargo make lint + make lint ``` -You can find more information about the `cargo make` commands in the [Makefile](Makefile.toml) +You can find more information about other `make` commands in the [Makefile](Makefile) ### Versioning We use [semver](https://semver.org/) naming convention. diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..73ddacbd1 --- /dev/null +++ b/Makefile @@ -0,0 +1,99 @@ +.DEFAULT_GOAL := help + +.PHONY: help +help: ## Show description of all commands + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' + +# --- Variables ----------------------------------------------------------------------------------- + +FEATURES_INTEGRATION_TESTING="integration" +FEATURES_CLI="testing,concurrent" +NODE_FEATURES_TESTING="testing" +WARNINGS=RUSTDOCFLAGS="-D warnings" + +# --- Linting ------------------------------------------------------------------------------------- + +.PHONY: clippy +clippy: ## Runs clippy on all targets with config + cargo +nightly clippy --workspace --tests --all-targets --all-features -- -D clippy::all -D warnings + +.PHONY: fix +fix: ## Runs Fix with configs + cargo +nightly fix --allow-staged --allow-dirty --all-targets --all-features + +.PHONY: format +format: ## Runs format using nightly toolchain + cargo +nightly fmt --all + +.PHONY: format-check +format-check: ## Runs format using nightly toolchain but only in check mode + cargo +nightly fmt --all --check + +.PHONY: lint +lint: format fix clippy ## Runs all linting tasks at once (clippy, fixing, formatting) + +# --- Documentation site -------------------------------------------------------------------------- + +.PHONY: doc-deps +doc-deps: ## Install dependencies to build and serve documentation site + pip3 install -r scripts/docs_requirements.txt + +.PHONY: doc-build +doc-build: doc-deps ## Build documentation site + mkdocs build + +.PHONY: doc-serve +doc-serve: doc-deps ## Serve documentation site + mkdocs serve + +# --- Rust documentation -------------------------------------------------------------------------- + +.PHONY: doc +doc: ## Generates & checks rust documentation + $(WARNINGS) cargo doc --all-features --keep-going --release + +# --- Testing ------------------------------------------------------------------------------------- + +.PHONY: test +test: ## Run tests + cargo nextest run --release --workspace + +# --- Integration testing ------------------------------------------------------------------------- + +.PHONY: integration-test +integration-test: ## Run integration tests + cargo nextest run --release --test=integration --features $(FEATURES_INTEGRATION_TESTING) + +.PHONY: integration-test-full +integration-test-full: ## Run the integration test binary with ignored tests included + cargo nextest run --release --test=integration --features $(FEATURES_INTEGRATION_TESTING) + cargo nextest run --release --test=integration --features $(FEATURES_INTEGRATION_TESTING) --run-ignored ignored-only -- test_import_genesis_accounts_can_be_used_for_transactions + +.PHONY: kill-node +kill-node: ## Kill node process + pkill miden-node || echo 'process not running' + +.PHONY: clean-node +clean-node: ## Clean node directory + rm -rf miden-node + +.PHONY: node +node: ## Setup node + if [ -d miden-node ]; then cd miden-node ; else git clone https://github.com/0xPolygonMiden/miden-node.git && cd miden-node; fi + cd miden-node && git checkout main && git pull origin main && cargo update + cd miden-node && rm -rf miden-store.sqlite3* + cd miden-node && cargo run --bin miden-node --features $(NODE_FEATURES_TESTING) -- make-genesis --inputs-path ../tests/config/genesis.toml --force + +.PHONY: start-node +start-node: ## Run node + cd miden-node && cargo run --bin miden-node --features $(NODE_FEATURES_TESTING) -- start --config ../tests/config/miden-node.toml node + +# --- Installing ---------------------------------------------------------------------------------- + +install: ## Installs the CLI binary using the current dir + cargo install --features $(FEATURES_CLI) --path . + +# --- Building ------------------------------------------------------------------------------------ + +build: ## Builds the CLI binary and client library in release mode + cargo build --release --features $(FEATURES_CLI) diff --git a/Makefile.toml b/Makefile.toml deleted file mode 100644 index aa8c3d3b1..000000000 --- a/Makefile.toml +++ /dev/null @@ -1,107 +0,0 @@ -# Cargo Makefile - -[env] -FEATURES_INTEGRATION_TESTING="integration" -NODE_FEATURES_TESTING="testing" - -[tasks.format] -toolchain = "nightly" -command = "cargo" -args = ["fmt", "--all"] - -[tasks.check-format] -toolchain = "nightly" -command = "cargo" -args = ["fmt", "--all", "--", "--check"] - -[tasks.clippy-all] -dependencies = [ - "clippy", - "clippy-integration-tests" -] - -[tasks.clippy] -command = "cargo" -args = ["clippy","--workspace", "--all-targets", "--", "-D", "clippy::all", "-D", "warnings"] - -[tasks.clippy-integration-tests] -command = "cargo" -args = ["clippy","--workspace", "--tests", "--features", "integration", "--", "-D", "clippy::all", "-D", "warnings"] - -[tasks.docs] -env = { "RUSTDOCFLAGS" = "-D warnings" } -command = "cargo" -args = ["doc", "--all-features", "--keep-going", "--release"] - -[tasks.test] -description = "Run the client testing suite" -command = "cargo" -args = ["nextest", "run", "--release", "--workspace"] - -[tasks.integration-test] -description = "Run the integration test binary. Requires a node to connect to." -command = "cargo" -args = ["nextest", "run", "--release", "--test=integration", "--features", "${FEATURES_INTEGRATION_TESTING}"] - -# Same commands as above but using ci profile for nextest -[tasks.ci-test] -description = "Run the client testing suite" -command = "cargo" -args = ["nextest", "run", "--profile", "ci-default", "--release", "--workspace"] - -[tasks.integration-test-full] -description = "Run the integration test binary with ignored tests included" -script_runner = "bash" -script = [ - 'cargo nextest run --profile ci-default --release --test=integration --features $FEATURES_INTEGRATION_TESTING', - 'cargo nextest run --profile ci-default --release --test=integration --features $FEATURES_INTEGRATION_TESTING --run-ignored ignored-only -- test_import_genesis_accounts_can_be_used_for_transactions' -] - -[tasks.lint] -dependencies = [ - "check-format", - "clippy-all", - "docs" -] - -[tasks.kill-node] -description = "Kill the miden-node process" -script = "pkill miden-node || echo 'process not running'" - -[tasks.reset] -description = "Remove the miden-node directory" -command = "rm" -args = ["-rf", "miden-node"] - -[tasks.node] -description = "Clone or update miden-node repository and clean up files" -script_runner = "bash" -script = [ - 'if [ -d miden-node ]; then cd miden-node ; else git clone https://github.com/0xPolygonMiden/miden-node.git && cd miden-node; fi', - 'git checkout main && git pull origin main && cargo update', - 'rm -rf miden-store.sqlite3 miden-store.sqlite3-wal miden-store.sqlite3-shm', - 'cargo run --bin miden-node --features $NODE_FEATURES_TESTING -- make-genesis --inputs-path ../tests/config/genesis.toml --force', -] - -[tasks.start-node] -description = "Start the miden-node" -script_runner = "bash" -cwd = "./miden-node" -script = "cargo run --bin miden-node --features $NODE_FEATURES_TESTING -- start --config ../tests/config/miden-node.toml node" - -[tasks.docs-deps] -description = "Install documentation dependencies" -command = "pip3" -args = ["install", "-r", "scripts/docs_requirements.txt"] - -[tasks.build-docs] -description = "Build documentation" -dependencies = ["docs-deps"] -command = "mkdocs" -args = ["build"] - -[tasks.serve-docs] -description = "Serve documentation locally" -dependencies = ["docs-deps"] -command = "mkdocs" -args = ["serve"] diff --git a/README.md b/README.md index 7a96d2b76..773196798 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # Miden client [![LICENSE](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/0xPolygonMiden/miden-client/blob/main/LICENSE) -[![CI](https://github.com/0xPolygonMiden/miden-client/actions/workflows/ci.yml/badge.svg)](https://github.com/0xPolygonMiden/miden-clinet/actions/workflows/ci.yml) -[![RUST_VERSION](https://img.shields.io/badge/rustc-1.78+-lightgray.svg)]() +[![test](https://github.com/0xPolygonMiden/miden-client/actions/workflows/test.yml/badge.svg)](https://github.com/0xPolygonMiden/miden-clinet/actions/workflows/test.yml) +[![RUST_VERSION](https://img.shields.io/badge/rustc-1.78+-lightgray.svg)](https://www.rust-lang.org/tools/install) [![crates.io](https://img.shields.io/crates/v/miden-client)](https://crates.io/crates/miden-client) This repository contains the Miden client, which provides a way to execute and prove transactions, facilitating the interaction with the Miden rollup. @@ -64,7 +64,11 @@ cargo install miden-client ### Makefile -As mentioned before, we use [cargo-make](https://github.com/sagiegurari/cargo-make) to encapsulate some tasks, such as running lints and tests. You can check out [Makefile.toml](./Makefile.toml) for all available tasks. +As mentioned before, we use `make` to encapsulate some tasks, such as running lints and tests. You can check out [Makefile](./Makefile) for all available tasks or just run the following command: + +```bash +make +``` ## Testing diff --git a/src/cli/mod.rs b/src/cli/mod.rs index d8184f0fa..af18ebb3f 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -166,9 +166,9 @@ pub fn create_dynamic_table(headers: &[&str]) -> Table { /// # Errors /// /// - Returns [IdPrefixFetchError::NoMatch] if we were unable to find any note where -/// `note_id_prefix` is a prefix of its id. +/// `note_id_prefix` is a prefix of its id. /// - Returns [IdPrefixFetchError::MultipleMatches] if there were more than one note found -/// where `note_id_prefix` is a prefix of its id. +/// where `note_id_prefix` is a prefix of its id. pub(crate) fn get_input_note_with_id_prefix< N: NodeRpcClient, R: FeltRng, @@ -218,9 +218,9 @@ pub(crate) fn get_input_note_with_id_prefix< /// # Errors /// /// - Returns [IdPrefixFetchError::NoMatch] if we were unable to find any note where -/// `note_id_prefix` is a prefix of its id. +/// `note_id_prefix` is a prefix of its id. /// - Returns [IdPrefixFetchError::MultipleMatches] if there were more than one note found -/// where `note_id_prefix` is a prefix of its id. +/// where `note_id_prefix` is a prefix of its id. pub(crate) fn get_output_note_with_id_prefix< N: NodeRpcClient, R: FeltRng, @@ -270,9 +270,9 @@ pub(crate) fn get_output_note_with_id_prefix< /// # Errors /// /// - Returns [IdPrefixFetchError::NoMatch] if we were unable to find any account where -/// `account_id_prefix` is a prefix of its id. +/// `account_id_prefix` is a prefix of its id. /// - Returns [IdPrefixFetchError::MultipleMatches] if there were more than one account found -/// where `account_id_prefix` is a prefix of its id. +/// where `account_id_prefix` is a prefix of its id. fn get_account_with_id_prefix< N: NodeRpcClient, R: FeltRng, diff --git a/src/cli/utils.rs b/src/cli/utils.rs index 0130c3405..27deb7c45 100644 --- a/src/cli/utils.rs +++ b/src/cli/utils.rs @@ -60,7 +60,7 @@ pub(crate) fn get_input_acc_id_by_prefix_or_default< /// # Errors /// /// - Will return a `IdPrefixFetchError` if the provided account id string can't be parsed as an -/// `AccountId` and does not correspond to an account tracked by the client either. +/// `AccountId` and does not correspond to an account tracked by the client either. pub(crate) fn parse_account_id< N: NodeRpcClient, R: FeltRng, diff --git a/src/client/store_authenticator.rs b/src/client/store_authenticator.rs index e6976af82..83c905cd9 100644 --- a/src/client/store_authenticator.rs +++ b/src/client/store_authenticator.rs @@ -62,7 +62,7 @@ impl TransactionAuthenticator for StoreAuthenticator { /// 2. The expanded public key represented as the coefficients of a polynomial of degree < 512. /// 3. The signature represented as the coefficients of a polynomial of degree < 512. /// 4. The product of the above two polynomials in the ring of polynomials with coefficients -/// in the Miden field. +/// in the Miden field. /// /// # Errors /// Will return an error if either: diff --git a/src/client/sync.rs b/src/client/sync.rs index c471ed750..63c4be54b 100644 --- a/src/client/sync.rs +++ b/src/client/sync.rs @@ -724,7 +724,7 @@ fn apply_mmr_changes( /// /// - All of the transaction's output notes are committed /// - All of the transaction's input notes are consumed, which means we got their nullifiers as -/// part of the update +/// part of the update /// - The account corresponding to the transaction hash matches the transaction's // final_account_state fn get_transactions_to_commit( diff --git a/src/store/mod.rs b/src/store/mod.rs index 14e8764b4..45684b5cb 100644 --- a/src/store/mod.rs +++ b/src/store/mod.rs @@ -236,7 +236,7 @@ pub trait Store { /// - Updating the notes, marking them as `committed` or `consumed` based on incoming /// inclusion proofs and nullifiers /// - Updating transactions in the store, marking as `committed` the ones provided with - /// `committed_transactions` + /// `committed_transactions` /// - Storing new MMR authentication nodes fn apply_state_sync(&self, state_sync_update: StateSyncUpdate) -> Result<(), StoreError>; } diff --git a/src/store/sqlite_store/mod.rs b/src/store/sqlite_store/mod.rs index 9794ce28f..4a03f88a1 100644 --- a/src/store/sqlite_store/mod.rs +++ b/src/store/sqlite_store/mod.rs @@ -39,7 +39,7 @@ mod transactions; /// In the case of json, some caveats must be taken: /// /// - To insert json values you must use sqlite's `json` function in the query alongside named -/// parameters, and the provided parameter must be a valid json. That is: +/// parameters, and the provided parameter must be a valid json. That is: /// /// ```sql /// INSERT INTO SOME_TABLE @@ -54,14 +54,14 @@ mod transactions; /// (Using raw string literals for the jsons is encouraged if possible) /// /// - To get data from any of the json fields you can use the `json_extract` function (in some -/// cases you'll need to do some explicit type casting to help rusqlite figure out types): +/// cases you'll need to do some explicit type casting to help rusqlite figure out types): /// /// ```sql /// SELECT CAST(json_extract(some_json_col, '$.some_json_field') AS TEXT) from some_table /// ``` /// /// - For some datatypes you'll need to do some manual serialization/deserialization. For example, -/// suppose one of your json fields is an array of digests. Then you'll need to +/// suppose one of your json fields is an array of digests. Then you'll need to /// - Create the json with an array of strings representing the digests: /// /// ```ignore @@ -79,7 +79,7 @@ mod transactions; /// ``` /// /// - When deserializing, handling the extra symbols (`[`, `]`, `,`, `"`). For that you can use -/// the `parse_json_array` function: +/// the `parse_json_array` function: /// /// ```ignore /// let some_array = parse_json_array(some_array_field) @@ -88,7 +88,7 @@ mod transactions; /// .collect::, _>>()?; /// ``` /// - Thus, if needed you can create a struct representing the json values and use serde_json to -/// simplify all of the serialization/deserialization logic +/// simplify all of the serialization/deserialization logic pub struct SqliteStore { pub(crate) db: RefCell, } diff --git a/tests/README.md b/tests/README.md index 09714c0df..7c89c7a03 100644 --- a/tests/README.md +++ b/tests/README.md @@ -4,43 +4,43 @@ This document describes the current state of the organization of integration tes ## Running integration tests -There are commands provided in the `Makefile.toml` to make running them easier. To run the current integration test, you should run: +There are commands provided in the `Makefile` to make running them easier. To run the current integration test, you should run: ```bash # This will ensure we start from a clean node and client -cargo make reset -# This command will clone the node's repo and generate the accounts and genesis files and lastly start the node -cargo make node -# This command will run the node on background -cargo make start-node & +make clean-node +# This command will clone the node's repo and generate the accounts and genesis files +make node +# This command will run the node +make start-node +``` + +And on a second terminal do: + +```bash # This will run the integration test -cargo make integration-test-full +make integration-test-full ``` +Note that in order to run this as part of a CI/CD workflow (at least on github), you'll need to use `make start-node &` instead so the process keeps running on background. + ## Integration Test Flow -The integration test goes through a series of supported flows such as minting -and transferring assets which runs against a running node. +The integration test goes through a series of supported flows such as minting and transferring assets which runs against a running node. ### Setup -Before running the tests though, there is a setup we need to perform to have a -node up and running. This is accomplished with the `node` command from the -`Makefile.toml` and what it does is: +Before running the tests though, there is a setup we need to perform to have a node up and running. This is accomplished with the `node` command from the `Makefile` and what it does is: - Clone the node repo if it doesn't exist. - Delete previously existing data. - Generate genesis and account data with `cargo run --release --bin miden-node --features testing -- make-genesis --inputs-path node/genesis.toml`. -After that we can start the node, again done in the `start-node` command from -the `Makefile.toml`. Killing the node process after running the test is also -the user's responsibilty. +After that we can start the node, again done in the `start-node` command from the `Makefile`. Killing the node process after running the test is also the user's responsibilty. ### Test Run -To run the integration test you just need to run `cargo make integration-test`. -It'll run the integration tests as a cargo test using the `integration` feature -which is used to separate regular tests from integration tests. +To run the integration test you just need to run `make integration-test`. It'll run the integration tests as a cargo test using the `integration` feature which is used to separate regular tests from integration tests. ### Ignored Tests @@ -49,23 +49,20 @@ from the node it is running against which might not always be possible. You can run it manually by doing: ```bash -cargo nextest run --profile ci-default --release --test=integration --features integration --run-ignored ignored-only -- test_import_genesis_accounts_can_be_used_for_transactions +cargo nextest run --release --test=integration --features integration --run-ignored ignored-only -- test_import_genesis_accounts_can_be_used_for_transactions ``` -Or run `cargo make integration-test-full` to run all integration tests with +Or run `make integration-test-full` to run all integration tests with that included. On the other hand, if you want to run integration tests without that one you can just instead do: ```bash -cargo make integration-test +make integration-test ``` ### Running tests against a remote node -You can run the integration tests against a remote node by overwriting the rpc -section of the configuration file at `./config/miden-client.toml`. Note that -the store configuration part of the file is ignored as each test creates its -own database. +You can run the integration tests against a remote node by overwriting the rpc section of the configuration file at `./config/miden-client.toml`. Note that the store configuration part of the file is ignored as each test creates its own database. ## CI integration