Skip to main content

Crate my_canister_dapp_test

Crate my_canister_dapp_test 

Source
Expand description

§My Canister Dapp Test

Crates.io Documentation Build Status License: MIT

Acceptance suite for user-owned dapps built with my-canister-dashboard.

Validates that a WASM module correctly implements every endpoint in the dashboard interface:

  • http_request — certified asset serving (dashboard HTML/JS/CSS, 404 handling, CSP headers)
  • wasm_status — dapp metadata (name, version, memo)
  • manage_ii_principal — Internet Identity principal CRUD + controller guard
  • manage_alternative_origins — II alternative origins CRUD + origin validation
  • manage_top_up_rule — auto top-up rule CRUD + timer-driven ICP→cycles minting

Each WASM is installed into a fresh PocketIC canister with ICP Ledger and CMC system canisters for end-to-end top-up testing.

§Usage

my-canister-dapp-test path/to/my-dapp.wasm.gz

Or via cargo:

cargo run -p my-canister-dapp-test -- path/to/my-dapp.wasm.gz

§License

MIT

Structs§

AssetHashes
Hashes of the three dashboard frontend assets, for verification and debugging.

Constants§

CMC_CANISTER_ID_TEXT
Cycles Minting Canister (CMC) ID.
ICP_INDEX_CANISTER_ID_TEXT
ICP Index canister ID.
ICP_LEDGER_CANISTER_ID_TEXT
ICP Ledger canister ID.
II_CANISTER_ID_TEXT
Internet Identity canister ID.
LEDGER_INIT_TRANSFER_FEE_E8S
ICP ledger transfer fee in e8s (0.0001 ICP).
LEDGER_PREFUND_E8S
Amount of ICP (in e8s) pre-funded to the canister for top-up tests (200 ICP).
MIN_CANISTER_CREATION_BALANCE
Minimum cycles required to create a canister on PocketIC.

Functions§

compute_asset_hash
SHA-256 hash of data, returned as a lowercase hex string.
compute_frontend_asset_hashes
Computes SHA-256 hashes for the three main dashboard assets.
ii_principal_at_installer_app
Principal simulating the installer app (the initial controller that installs the dapp WASM).
ii_principal_at_user_controlled_dapp
Principal simulating the dapp owner (the II-authenticated end user).
run_acceptance_suite
Runs the full acceptance suite against a single dapp WASM.
stranger_principal
Principal simulating an unauthorized caller (should be rejected by all guards).
validate_css_structure
Validates that CSS content is non-empty, valid UTF-8, and contains at least one style rule.
validate_frontend_assets
Validates all three main dashboard assets and returns their SHA-256 hashes.
validate_html_structure
Validates that HTML content has the expected structure for a canister dashboard page.
validate_js_structure
Validates that JavaScript content is non-empty, reasonably sized, and valid UTF-8.
verify_asset_hashes_match_known_version
Verifies that the given asset hashes match at least one entry in asset-hashes.json.