diff --git a/HACKING.md b/HACKING.md index d1266f7981..90a6860ce0 100644 --- a/HACKING.md +++ b/HACKING.md @@ -10,11 +10,11 @@ This document explains how to build the Wasm module of the Internet Identity can The build requires the following dependencies: -* [`dfx`](https://github.com/dfinity/sdk/releases/latest) version 0.10.0 or later -* Rustup with target `wasm32-unknown-unknown` (see [rustup instructions](https://rust-lang.github.io/rustup/cross-compilation.html)), which can be installed by running [./scripts/bootstrap](./scripts/bootstrap) -* CMake -* [`ic-wasm`](https://github.com/dfinity/ic-wasm), which can be installed by running [./scripts/bootstrap](./scripts/bootstrap) -* Node.js v16+ +- [`dfx`](https://github.com/dfinity/sdk/releases/latest) version 0.10.0 or later +- Rustup with target `wasm32-unknown-unknown` (see [rustup instructions](https://rust-lang.github.io/rustup/cross-compilation.html)), which can be installed by running [./scripts/bootstrap](./scripts/bootstrap) +- CMake +- [`ic-wasm`](https://github.com/dfinity/ic-wasm), which can be installed by running [./scripts/bootstrap](./scripts/bootstrap) +- Node.js v16+ > NOTE! If you're only going to hack on the HTML and CSS code, see the [showcase](#showcase) section. @@ -38,7 +38,6 @@ dfx deploy internet_identity --no-wallet > `II_DUMMY_CAPTCHA` to `0`:\ > `II_DUMMY_CAPTCHA=0 dfx deploy internet_identity --no-wallet` - Then the canister can be used as ```bash @@ -56,7 +55,7 @@ The `dfx` executable can proxy queries to the canister. To view it, run the foll echo "http://$(dfx canister id internet_identity).localhost:4943" ``` -*Note: The URL doesn't work for safari.* +_Note: The URL doesn't work for safari._ ### Building the frontend @@ -95,6 +94,7 @@ into the following issues: #### Test suites We have a set of Selenium tests that run through the various flows. To set up a local deployment follow these steps: + 1. Start a local replica with `dfx start` 1. Deploy II and the other test canisters with `dfx deploy --no-wallet` 1. Start the vite dev server with TLS enabled: `TLS_DEV_SERVER=1 npm run dev` @@ -112,6 +112,15 @@ If you open a PR that isn't formatted according to `prettier`, CI will automatic We use `eslint` to check the frontend code. You can run it with `npm run lint`. +#### Canisters tests + +There are plenty of unit and integration tests that cover the different canisters of this repository which cover all the functionality that Internet Identity offer. + +To run the canister tests, run the following command from the root directory: + +```bash +./scripts.test.canisters.sh +``` ### Building the backend @@ -138,21 +147,26 @@ This will produce `./internet_identity.wasm.gz`. ## Attribute Sharing / Verifiable Credentials To experiment with Attribute Sharing / Verifiable Credentials feature, one can start a demo VC-issuer by running + ```bash dfx deploy issuer ``` + This will deploy also `internet_identity`, and provision the issuer for the testing environment. See [VC issuer documentation](./demos/vc_issuer/README.md) for details. Our [`test-app`](./demos/test-app) offers a simple relying party functionality and can be deployed using + ```bash dfx deploy test_app ``` Afterward one can serve the frontends locally via: + ```bash npm run dev ``` + and access the issuer FE at http://issuer.localhost:5173/, and the test-app at http://test_app.localhost:5173/ (the relying party is functionality is at the bottom of the page). @@ -160,18 +174,17 @@ and access the issuer FE at http://issuer.localhost:5173/, and the test-app at h The simplest way to make visual changes (HTML & CSS, and non-flow JS) is to start the showcase: -``` bash +```bash npm run showcase ``` This will start a webserver showcasing most II pages & components. The showcase can also be built: -``` bash +```bash npm run build:showcase [--base 'some-base/'] npm run preview:showcase [--base 'some-base/'] ``` - [releases]: https://github.com/dfinity/internet-identity/releases [docker-build]: ./README.md#building-with-docker [features-and-flavors]: ./README.md#build-features-and-flavors diff --git a/scripts/test.canisters.sh b/scripts/test.canisters.sh new file mode 100755 index 0000000000..bf578e90de --- /dev/null +++ b/scripts/test.canisters.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +POCKET_IC_SERVER_VERSION=6.0.0 +POCKET_IC_SERVER_PATH="pocket-ic" +PREVIOUS_II_WASM_PATH="internet_identity_previous.wasm.gz" +PREVIOUS_ARCHIVE_WASM_PATH="archive_previous.wasm.gz" + +if [[ $OSTYPE == "linux-gnu"* ]] || [[ $RUNNER_OS == "Linux" ]]; then + PLATFORM=linux +elif [[ $OSTYPE == "darwin"* ]] || [[ $RUNNER_OS == "macOS" ]]; then + PLATFORM=darwin +else + echo "OS not supported: ${OSTYPE:-$RUNNER_OS}" + exit 1 +fi + +if [ -f "./$PREVIOUS_II_WASM_PATH" ]; then + echo "Using previous II wasm." +else + echo "Downloading previous II wasm." +curl -sSL https://github.com/dfinity/internet-identity/releases/latest/download/internet_identity_test.wasm.gz -o ${PREVIOUS_II_WASM_PATH} +fi + +if [ -f "./$PREVIOUS_ARCHIVE_WASM_PATH" ]; then + echo "Using previous Archive wasm." +else + echo "Downloading previous Archive wasm." + curl -sSL https://github.com/dfinity/internet-identity/releases/latest/download/archive.wasm.gz -o ${PREVIOUS_ARCHIVE_WASM_PATH} +fi + +if [ ! -f "$POCKET_IC_SERVER_PATH" ]; then + echo "Downloading PocketIC." + curl -sSL https://github.com/dfinity/pocketic/releases/download/${POCKET_IC_SERVER_VERSION}/pocket-ic-x86_64-${PLATFORM}.gz -o ${POCKET_IC_SERVER_PATH}.gz + gunzip ${POCKET_IC_SERVER_PATH}.gz + chmod +x ${POCKET_IC_SERVER_PATH} +else + echo "PocketIC server already exists, skipping download." +fi + +# Build II +II_FETCH_ROOT_KEY=1 II_DUMMY_CAPTCHA=1 ./scripts/build --internet-identity + +# Build Archive +./scripts/build --archive + +# Run tests + +echo "Running integration tests." +cargo test "${@}" \ No newline at end of file diff --git a/src/internet_identity/tests/README.md b/src/internet_identity/tests/README.md index b5cf8cfcaf..d6e380d988 100644 --- a/src/internet_identity/tests/README.md +++ b/src/internet_identity/tests/README.md @@ -2,21 +2,8 @@ This is a test suite for the Internet Identity canister. To run the tests: -``` bash -# Make sure II is built with the "test" flavor -II_FETCH_ROOT_KEY=1 II_DUMMY_CAPTCHA=1 ./scripts/build - -# Build the archive canister -./scripts/build --archive - -# Make sure you have a copy of the latest release of II -curl -SL https://github.com/dfinity/internet-identity/releases/latest/download/internet_identity_test.wasm -o internet_identity_previous.wasm - -# Make sure you have a copy of the latest release of the archive -curl -SL https://github.com/dfinity/internet-identity/releases/latest/download/archive.wasm -o archive_previous.wasm - -# Run the tests -cargo test -p internet_identity +```bash +./scripts.test.canisters.sh -p internet_identity ``` _NOTE: you can also run the tests with `cargo test -p internet_identity --release` which takes much longer to build, but the tests are then orders of magnitude faster._