Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
aterga committed Dec 4, 2024
1 parent 587785a commit 2d57876
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 86 deletions.
39 changes: 7 additions & 32 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ The `sns-testing` solution is based on Docker; however, there are subtle issues
This should print the dashboard URL:

```
Dashboard: http://localhost:8000/_/dashboard
Replica API running on 0.0.0.0:8000
```

5. Open another Bash console:
Expand Down
6 changes: 3 additions & 3 deletions deploy_dapp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ export ARG="${3:-()}"

. ./constants.sh normal

dfx --provisional-create-canister-effective-canister-id jrlun-jiaaa-aaaab-aaaaa-cai canister create "${NAME}" --network "${NETWORK}" --no-wallet
./bin/dfx --provisional-create-canister-effective-canister-id jrlun-jiaaa-aaaab-aaaaa-cai canister create "${NAME}" --network "${NETWORK}" --no-wallet

if [[ -z "${WASM}" ]]
then
export WASM=".dfx/${DX_NETWORK}/canisters/${NAME}/${NAME}.wasm"
dfx build --network "${NETWORK}" "${NAME}"
./bin/dfx build --network "${NETWORK}" "${NAME}"
fi

dfx canister install "${NAME}" --network "${NETWORK}" --argument "${ARG}" --argument-type idl --wasm "${WASM}"
./bin/dfx canister install "${NAME}" --network "${NETWORK}" --argument "${ARG}" --argument-type idl --wasm "${WASM}"
2 changes: 1 addition & 1 deletion example_sns_init.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ Distribution:
# as the treasury. This is initialized in a special sub-account, as the
# main account of Governance is the minting account of the SNS Ledger.
# This field is specified as a token. For instance, "1 token".
treasury: 2_000_000 tokens
governance: 2_000_000 tokens

# The initial SNS token balance of the Swap canister is what will be
# available for the decentralization swap. These tokens will be swapped
Expand Down
6 changes: 3 additions & 3 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ chmod +x dfx

if [[ "${OS}" == "linux" ]]
then
export QUILL="linux"
export QUILL_PLATFORM="linux"
elif [[ "${OS}" == "darwin" ]]
then
export QUILL="macos"
export QUILL_PLATFORM="macos"
else
echo "Unknown OS!"
exit 1
fi

curl --fail -L "https://github.com/dfinity/quill/releases/download/v0.4.2/quill-${QUILL}-x86_64" -o quill
curl --fail -L "https://github.com/dfinity/quill/releases/download/v${QUILL_VERSION}/quill-${QUILL_PLATFORM}-x86_64" -o quill
chmod +x quill

if [[ "${OS}" == "linux" ]]
Expand Down
8 changes: 4 additions & 4 deletions participate_sns_swap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ do
export PEM_FILE="$(readlink -f ~/.config/dfx/identity/${NEW_DX_IDENT}/identity.pem)"

# Get the ticket
quill sns new-sale-ticket --amount-icp-e8s "${ICP_PER_PARTICIPANT_E8S}" --canister-ids-file ./sns_canister_ids.json --pem-file "${PEM_FILE}" > msg.json
RESPONSE="$(quill --insecure-local-dev-mode send --yes msg.json)"
./bin/quill sns new-sale-ticket --amount-icp-e8s "${ICP_PER_PARTICIPANT_E8S}" --canister-ids-file ./sns_canister_ids.json --pem-file "${PEM_FILE}" > msg.json
RESPONSE="$(./bin/quill --insecure-local-dev-mode send --yes msg.json)"
if [[ "${RESPONSE}" == *"invalid_user_amount"* ]]
then
echo "ERROR: invalid_user_amount error; see full output from quill below this line"
Expand All @@ -53,8 +53,8 @@ do
fi

# Use the ticket
quill sns pay --amount-icp-e8s "${ICP_PER_PARTICIPANT_E8S}" --ticket-creation-time "${TICKET_CREATION_TIME}" --ticket-id "${TICKET_ID}" --canister-ids-file ./sns_canister_ids.json --pem-file "${PEM_FILE}" > msg.json
quill --insecure-local-dev-mode send --yes msg.json
./bin/quill sns pay --amount-icp-e8s "${ICP_PER_PARTICIPANT_E8S}" --ticket-creation-time "${TICKET_CREATION_TIME}" --ticket-id "${TICKET_ID}" --canister-ids-file ./sns_canister_ids.json --pem-file "${PEM_FILE}" > msg.json
./bin/quill --insecure-local-dev-mode send --yes msg.json

done

Expand Down
49 changes: 26 additions & 23 deletions run_basic_scenario.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,32 +47,35 @@ done
# Participate in SNS swap
./participate_sns_swap.sh

# Await Swap lifecycle to be in state 2 (OPEN).
# Await Swap lifecycle to be in state 3 (COMMITTED).
# See https://github.com/dfinity/ic/blob/master/rs/sns/swap/proto/ic_sns_swap/pb/v1/swap.proto#L17
while [ "$(./get_sns_swap_state.sh | ./bin/idl2json | jq -r '.swap[0].lifecycle')" != "3" ]; do sleep 1; done

# Upgrade test canister (II)
./upgrade_test_canister.sh Welcome
# We expect that the canister has not been changed yet as we have now decentralized
# so we don't hold the majority of the voting power.
[ "$(./bin/dfx canister call test greet "M")" == '("Hello, M!")' ] && echo "OK" || exit 1

# Collect votes by the SNS developer neuron submitting the upgrade proposal and total number of votes.
YES="$(./get_last_sns_proposal.sh | ./bin/idl2json | jq -r '.proposals[0].latest_tally[0].yes')"
TOTAL="$(./get_last_sns_proposal.sh | ./bin/idl2json | jq -r '.proposals[0].latest_tally[0].total')"

# Assert that the SNS developer neuron no longer holds voting majority after the SNS swap is completed.
[ "$((2 * ${YES}))" -lt "${TOTAL}" ] && echo "OK" || exit 1

# TODO[dfinity/sns-testing/issues/83]: Re-enable upgrading dapp canisters via SNS proposals.
#
# # Upgrade test canister (II)
# ./upgrade_test_canister.sh Welcome
#
# # We expect that the canister has not been changed yet as we have now decentralized
# # so we don't hold the majority of the voting power.
# [ "$(./bin/dfx canister call test greet "M")" == '("Hello, M!")' ] && echo "OK" || exit 1
#
# # Collect votes by the SNS developer neuron submitting the upgrade proposal and total number of votes.
# YES="$(./get_last_sns_proposal.sh | ./bin/idl2json | jq -r '.proposals[0].latest_tally[0].yes')"
# TOTAL="$(./get_last_sns_proposal.sh | ./bin/idl2json | jq -r '.proposals[0].latest_tally[0].total')"
#
# # Assert that the SNS developer neuron no longer holds voting majority after the SNS swap is completed.
# [ "$((2 * ${YES}))" -lt "${TOTAL}" ] && echo "OK" || exit 1
#
# Vote on upgrade canister SNS proposal
./vote_on_sns_proposal.sh \
61 `# Simulate this number of SNS users' votes. TODO: determine the smallest possible value that will work here` \
2 `# Proposal ID` \
y `# Vote to adopt this proposal`
./wait_for_last_sns_proposal.sh
./wait_for_canister_running.sh "$(./bin/dfx canister id test)"

# Assert the new greeting text
[ "$(./bin/dfx canister call test greet "M")" == '("Welcome, M!")' ] && echo "OK" || exit 1
#./vote_on_sns_proposal.sh \
# 61 `# Simulate this number of SNS users' votes. TODO: determine the smallest possible value that will work here` \
# 2 `# Proposal ID` \
# y `# Vote to adopt this proposal`
#./wait_for_last_sns_proposal.sh
#./wait_for_canister_running.sh "$(./bin/dfx canister id test)"
#
# # Assert the new greeting text
# [ "$(./bin/dfx canister call test greet "M")" == '("Welcome, M!")' ] && echo "OK" || exit 1

echo "Basic scenario has successfully finished."
6 changes: 4 additions & 2 deletions settings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ export SNS_AGGREGATOR_RELEASE="proposal-129614-agg"
# $ ./gitlab-ci/src/artifacts/newest_sha_with_disk_image.sh origin/master
# from the IC monorepo: https://github.com/dfinity/ic
# if you change IC_COMMIT, then you need to rerun `source install.sh`
export IC_COMMIT="ce465b8bd96f7706b9480fdfc10cda0a67f5f0f7"
export IC_COMMIT="6a4eeb97fd93a5fc93d50b0e01ab24c6a7e72fae"

export TESTNET="local"

export DFX_VERSION="0.22.0"
export DFX_VERSION="0.24.2"
export DFX_SNS_VERSION="0.4.1"
export DFX_NNS_VERSION="0.4.1"

export QUILL_VERSION="0.5.1"
3 changes: 1 addition & 2 deletions test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ crate-type = ["cdylib"]

[dependencies]
candid = "0.10.7"
ic-cdk = "0.16.0"
ic-cdk = "0.17.0"
serde = "1"
wee_alloc = "0.4.3"
lazy_static = "1.4.0"
32 changes: 17 additions & 15 deletions upgrade_dapp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export ARG="${3:-()}"

. ./constants.sh normal

export DEVELOPER_NEURON_ID="$(dfx canister \
export DEVELOPER_NEURON_ID="$(./bin/dfx canister \
--network "${NETWORK}" \
call "${SNS_GOVERNANCE_CANISTER_ID}" \
list_neurons "(record {of_principal = opt principal\"${DX_PRINCIPAL}\"; limit = 1})" \
Expand All @@ -33,22 +33,24 @@ fi

if [[ -z "${WASM}" ]]
then
dfx build --network "${NETWORK}" "${NAME}"
export WASM=".dfx/${DX_NETWORK}/canisters/${NAME}/${NAME}.wasm"
./bin/dfx build --network "${NETWORK}" "${NAME}"
WASM=".dfx/${DX_NETWORK}/canisters/${NAME}/${NAME}"
ic-wasm "${WASM}.wasm" -o "${WASM}-s.wasm" shrink
gzip "${WASM}-s.wasm"
export WASM="${WASM}-s.wasm.gz"
fi

export CID="$(dfx canister --network "${NETWORK}" id "${NAME}")"
quill sns \
--canister-ids-file "${REPODIR}/sns_canister_ids.json" \
--pem-file "${PEM_FILE}" \
make-upgrade-canister-proposal \
--summary "This proposal upgrades test canister" \
--title "Upgrade test canister" \
--url "https://example.com/" \
--target-canister-id "${CID}" \
--wasm-path "${WASM}" \
"${ARGFLAG}" "${ARG}" \
export CID="$(./bin/dfx canister --network "${NETWORK}" id "${NAME}")"
./bin/quill sns \
--canister-ids-file "${REPODIR}/sns_canister_ids.json" \
--pem-file "${PEM_FILE}" \
make-upgrade-canister-proposal \
--target-canister-id "${CID}" \
--mode upgrade \
--wasm-path "${WASM}" \
"${ARGFLAG}" "${ARG}" \
"${DEVELOPER_NEURON_ID}" > msg.json
quill send \

./bin/quill send \
--insecure-local-dev-mode \
--yes msg.json | grep -v "new_canister_wasm"

0 comments on commit 2d57876

Please sign in to comment.