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

Update downgrade-upgrade test #3315

Merged
merged 4 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .config/spellcheck.dic
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ ICP
schemas
WASM
Wasm
Wasms
bitdivine marked this conversation as resolved.
Show resolved Hide resolved
OWASP
<
>
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG-Nns-Dapp.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ The NNS Dapp is released through proposals in the Network Nervous System. Theref

#### Changed
* Specify the `snsdemo` version in `dfx.json`.
* Support using the nns-dapp downgrade-upgrade test with Wasms other than prod.

#### Deprecated
#### Removed
Expand Down
21 changes: 15 additions & 6 deletions scripts/nns-dapp/downgrade-upgrade-test
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ set -euo pipefail
SOURCE_DIR="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
PATH="$SOURCE_DIR:$PATH"

PROD_WASM="nns-dapp-prod.wasm.gz" # TODO: Switch to a test build, when available for the prod tag.

help_text() {
cat <<-EOF
Tests:
Expand All @@ -17,6 +15,7 @@ help_text() {
source "$SOURCE_DIR/../clap.bash"
# Define options
clap.define short=w long=wasm desc="The wasm built from the local code." variable=CURRENT_WASM default=""
clap.define short=p long=prod desc="A test build of the production wasm" variable=PROD_WASM default=""
clap.define short=a long=accounts desc="Accounts will be created until there are at least this many." variable=NUM_TOY_ACCOUNTS default="200000"
clap.define short=c long=chunk desc="The accounts are created in chunks of this size." variable=TOY_ACCOUNT_CHUNK_SIZE default="10000"
# Source the output file ----------------------------------------------------------
Expand All @@ -32,9 +31,16 @@ get_current_wasm() {
}

get_prod_wasm() {
# TODO: Use the test build once available for the prod release.
# Note: Using the test build allows us to get arbitrary test accounts from the canister.
curl -sL https://github.com/dfinity/nns-dapp/releases/download/prod/nns-dapp.wasm.gz >"$PROD_WASM"
if test -n "${PROD_WASM:-}"; then
test -f "${PROD_WASM}" || {
bitdivine marked this conversation as resolved.
Show resolved Hide resolved
echo "ERROR: The specified production wasm file does not exist at: '$PROD_WASM'"
exit 1
} >&2
else
PROD_WASM="$(mktemp nns-dapp-prod-XXXXXX --suffix .wasm.gz)"
curl -sL https://github.com/dfinity/nns-dapp/releases/download/prod/nns-dapp_test.wasm.gz >"$PROD_WASM"
fi
}

# Gets the number of transactions; this list may be pruned so is not invariant.
Expand All @@ -47,13 +53,16 @@ get_upgrade_invariant_stats() {
}
# Gets some sample accounts
sample_toy_accounts() {
echo "Sample accounts will be available once the production commit has a test wasm with get_toy_account()."
# seq 0 "$TOY_ACCOUNT_CHUNK_SIZE" "$((NUM_TOY_ACCOUNTS - 1))" | xargs -I{} dfx canister call nns-dapp get_toy_account "({})" --query
seq 0 "$TOY_ACCOUNT_CHUNK_SIZE" "$((NUM_TOY_ACCOUNTS - 1))" | xargs -I{} dfx canister call nns-dapp get_toy_account "({})" --query
}
# Gets data that should be invariant across upgrades
get_upgrade_invariants() {
echo "==== UPGRADE INVARIANT STATS ===="
get_upgrade_invariant_stats
echo "==== END ===="
echo "==== SAMPLE INVARIANT STATS ===="
sample_toy_accounts
echo "==== END ===="
}

# Verifies that the state is at least as large as expected.
Expand Down