Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support clients from multiple Gateways #3

Merged
merged 27 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
77d6c7c
wip: multiple gateways + unit tests
massimoalbarello Nov 10, 2023
d417100
message nonce for each gateway
massimoalbarello Nov 10, 2023
c1cb3d1
fix: create message queue for each authorized gateway during init
massimoalbarello Nov 10, 2023
620fbe0
fix: integration tests
massimoalbarello Nov 10, 2023
f76a462
chore: update readme tests docs
ilbertt Nov 14, 2023
aebef67
perf: unneeded pub visibility
ilbertt Nov 14, 2023
1ead87e
perf: remove expects, variables names, references
ilbertt Nov 15, 2023
920840f
perf: unneeded results, removed todos
ilbertt Nov 15, 2023
672c992
feat: gateway data in one map, unit_tests folder
ilbertt Nov 15, 2023
f55b0b4
chore: update unit tests path in readme
ilbertt Nov 15, 2023
daf4e24
fix: rename gateway principal in did
ilbertt Nov 15, 2023
8b450e6
feat: TEST_ENV mutex
ilbertt Nov 15, 2023
b071bea
feat: multiple gateways integration tests
ilbertt Nov 15, 2023
b1becf1
chore: test docs
ilbertt Nov 15, 2023
e56a6b2
perf: proptest strategies
ilbertt Nov 15, 2023
15c63ba
perf: destructure CanisterOutputCertifiedMessages
ilbertt Nov 15, 2023
17d6d28
perf: typos
ilbertt Nov 15, 2023
a6f21fc
perf: ClientPrincipal for ws_send
ilbertt Nov 15, 2023
6f20810
feat: prop tests in integration tests
ilbertt Nov 15, 2023
3984056
perf: functions visibility
ilbertt Nov 15, 2023
426d5d0
feat: load test canister wasm also from path
ilbertt Nov 15, 2023
4cb928c
chore: update to checkout@v4 action
ilbertt Nov 15, 2023
a2d952e
perf: unneeded methods
ilbertt Nov 15, 2023
4e573e3
fix: send a valid but wrong candid
ilbertt Nov 15, 2023
3f02452
chore: enable tests on pull request
ilbertt Nov 16, 2023
7e12d38
chore: rename test script
ilbertt Nov 17, 2023
969d767
style: typo
ilbertt Nov 17, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
outputs:
version: ${{ steps.cargo-publish.outputs.version }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: "stable"
Expand All @@ -41,7 +41,7 @@ jobs:
version: ${{ steps.tag_version.outputs.new_tag }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/[email protected]
Expand All @@ -54,7 +54,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Release
uses: softprops/action-gh-release@v1
with:
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ on:
push:
branches:
- main
pull_request:

jobs:
unit-and-integration-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: "stable"
Expand All @@ -19,6 +20,9 @@ jobs:
cache-on-failure: "true"
- name: Run unit tests
run: cargo test --package ic-websocket-cdk --lib -- tests::unit_tests
- name: Run doc tests
run: cargo test --package ic-websocket-cdk --doc
# the following steps are replicated in the scripts/test.sh file
- name: Prepare environment for integration tests
run: |
rustup target add wasm32-unknown-unknown
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,17 @@ The **ic-websocket-cdk** library implementation can be found in the [src/ic-webs
### Testing

There are two types of tests available:
- **Unit tests**: tests for CDK functions, written in Rust.
- **Integration tests**: for these tests a local IC replica is set up and the CDK is deployed to a [test canister](./tests/src/lib.rs). Tests are written in Node.js and are available in the [tests](./tests/integration/) folder.
- **Unit tests**: tests for CDK functions, written in Rust and available in the [unit_tests](./src/ic-websocket-cdk/src/tests/unit_tests/) folder.
- **Integration tests**: for these tests the CDK is deployed to a [test canister](./src/test_canister/). These tests are written in Rust and use [PocketIC](https://github.com/dfinity/pocketic) under the hood. They are available in the [integration_tests](./src/ic-websocket-cdk/src/tests/integration_tests/) folder.

There's a script that runs all the tests together, taking care of setting up the replica and deploying the canister. To run the script, execute the following command:
There's a script that runs all the tests together, taking care of setting up the environment (Linux only!) and deploying the canister. To run the script, execute the following command:

```bash
./scripts/test_canister.sh
./scripts/test.sh
```

> If you're on **macOS**, you have to manually download the PocketIC binary ([guide](https://github.com/dfinity/pocketic#download)) and place it in the [bin](./bin/) folder.

## License

MIT License. See [LICENSE](./LICENSE).
Expand Down
15 changes: 15 additions & 0 deletions scripts/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

set -e

# unit tests
cargo test --package ic-websocket-cdk --lib -- tests::unit_tests
# doc tests
cargo test --package ic-websocket-cdk --doc

# integration tests
./scripts/download-pocket-ic.sh

./scripts/build-test-canister.sh

POCKET_IC_BIN="$(pwd)/bin/pocket-ic" RUST_BACKTRACE=1 cargo test --package ic-websocket-cdk --lib -- tests::integration_tests --test-threads 1
13 changes: 0 additions & 13 deletions scripts/test_canister.sh

This file was deleted.

Loading
Loading