Skip to content

fix: factor out test_utils, clean-up test code #181

fix: factor out test_utils, clean-up test code

fix: factor out test_utils, clean-up test code #181

Workflow file for this run

name: 'Code tests'
on:
pull_request:
types:
- opened
- edited
- reopened
- synchronize
- labeled
merge_group:
types: [checks_requested]
branches:
- main
env:
# When getting Rust dependencies, retry on network error:
CARGO_NET_RETRY: 10
# Use the local .curlrc
CURL_HOME: .
jobs:
rust_test:
name: 'rust-tests:required'
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@v3
- name: 'Test cargo crates'
run: cargo test
motoko_tests:
name: 'motoko-tests:required'
runs-on: ubuntu-latest
steps:
- name: 'Checkout code'
uses: actions/checkout@v4
- name: Setup DFX
uses: dfinity/setup-dfx@main
with:
dfx-version: 'auto'
- name: 'Start DFX'
run: dfx start --background
- name: 'Test cns_root canister'
run: |
dfx deploy --no-wallet cns_root_test
echo "Calling runTests on canister cns_root_test..."
dfx canister call cns_root_test runTests "()"
- name: 'Test tld_operator canister'
# NOTE: The functionality of tld_operator depends on whehter the caller is a controller or not,
# so we proceed in two steps. Initially the test canister (i.e. tld_operator_test) is not a controller,
# so we test the behaviour for non-controller callers. Afterwards we make the test canister
# a controller of tld_operator, and test the behaviour for controller callers.
run: |
dfx deploy --no-wallet tld_operator_test
echo "Calling runTestsIfNotController on canister tld_operator_test ..."
dfx canister call tld_operator_test runTestsIfNotController "()"
echo "Adding tld_operator_test-canister as a controller of tld_operator-canister..."
dfx canister update-settings tld_operator --add-controller `dfx canister id tld_operator_test`
echo "Calling runTests on canister tld_operator_test..."
dfx canister call tld_operator_test runTests "()"
- name: 'Test tld_operator canister if not controller'
run: |
dfx deploy --no-wallet tld_operator_test_not_controller
- name: 'Stop DFX'
run: dfx stop