-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add CI test that checks an SNS can be launched using dfx nns / dfx sns #131
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Tested with dfx 0.20.1 | ||
|
||
set -euo pipefail | ||
|
||
# This ID corresponds to TEST_NEURON_1 | ||
NEURON_ID="449479075714955186" | ||
|
||
dfx start --clean --background | ||
|
||
dfx identity use default | ||
cargo run --bin nns install --dfx-cache-path="$(dfx cache show)" | ||
|
||
# Ensure we have a powerful neuron | ||
cat <<EOF >ident-1.pem | ||
-----BEGIN EC PRIVATE KEY----- | ||
MHQCAQEEICJxApEbuZznKFpV+VKACRK30i6+7u5Z13/DOl18cIC+oAcGBSuBBAAK | ||
oUQDQgAEPas6Iag4TUx+Uop+3NhE6s3FlayFtbwdhRVjvOar0kPTfE/N8N6btRnd | ||
74ly5xXEBNSXiENyxhEuzOZrIWMCNQ== | ||
-----END EC PRIVATE KEY----- | ||
EOF | ||
dfx identity import --force --storage-mode=plaintext ident-1 ident-1.pem | ||
dfx identity use ident-1 | ||
PRINCIPAL_ID=$(dfx identity get-principal) | ||
|
||
# Hack | ||
sleep 15s | ||
|
||
# Top-up the SNS-W canister | ||
dfx ledger fabricate-cycles --canister qaa6y-5yaaa-aaaaa-aaafa-cai --t 2345 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about using variables for the canister IDs? Also below. |
||
|
||
dfx canister call "rrkah-fqaaa-aaaaa-aaaaq-cai" update_neuron '( | ||
record { | ||
id = opt record { id = '${NEURON_ID}' : nat64 }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was super confused about why the variable expansion works with the single quotes. But then I realized you actually end the single quote string, concatenate the variable and then open a new string. Is that intentional or did it work by accident? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was intentional, but I'm no Bash expert — maybe there's a better way. |
||
staked_maturity_e8s_equivalent = null; | ||
controller = opt principal "'${PRINCIPAL_ID}'"; | ||
recent_ballots = vec {}; | ||
kyc_verified = true; | ||
neuron_type = null; | ||
not_for_profit = false; | ||
maturity_e8s_equivalent = 1_000_000 : nat64; | ||
cached_neuron_stake_e8s = 1_000_000_000_000_000 : nat64; | ||
created_timestamp_seconds = 123 : nat64; | ||
auto_stake_maturity = opt true; | ||
aging_since_timestamp_seconds = 456 : nat64; | ||
hot_keys = vec {}; | ||
account = blob "3\8fZ\9fn\af]\a9\17\be\ea\14yA\f3\b3\00\16\af[\ae\1cq\c0\a0\dd\1d?\d8\e7\a96"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where does this blob come from? |
||
joined_community_fund_timestamp_seconds = opt (1 : nat64); | ||
dissolve_state = opt variant { | ||
DissolveDelaySeconds = 252_460_800 : nat64 | ||
}; | ||
followees = vec {}; | ||
neuron_fees_e8s = 0 : nat64; | ||
transfer = null; | ||
known_neuron_data = null; | ||
spawn_at_timestamp_seconds = null; | ||
}, | ||
)' | ||
|
||
curl https://raw.githubusercontent.com/dfinity/sns-testing/main/example_sns_init.yaml \ | ||
| sed "s/YOUR_PRINCIPAL_ID/${PRINCIPAL_ID}/" \ | ||
| sed "s/- YOUR_CANISTER_ID//" > sns_init.yaml | ||
|
||
touch logo.png | ||
|
||
cargo run --bin sns propose --neuron-id "${NEURON_ID}" sns_init.yaml | ||
|
||
# Check that the CreateServiceNervousSystem propsoal was executed | ||
PROPOSAL_DATA=$(dfx canister \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NCR: shellcheck would require double quotes around the |
||
call "rrkah-fqaaa-aaaaa-aaaaq-cai" \ | ||
list_proposals '( | ||
record { | ||
include_reward_status = vec {}; | ||
before_proposal = null; | ||
limit = 1; | ||
exclude_topic = vec {}; | ||
include_status = vec {}; | ||
} | ||
)' | idl2json) | ||
|
||
while [ "$(echo "${PROPOSAL_DATA}" | jq -r '.proposal_info[0].executed_timestamp_seconds')" == "0" ] | ||
do | ||
FAILURE_REASON=$(echo "${PROPOSAL_DATA}" | jq -c -r '.proposal_info[0].failure_reason?') | ||
if [ "$FAILURE_REASON" = "null" ]; then | ||
printf "." | ||
sleep 1 | ||
else | ||
echo "CreateServiceNervousSystem proposal FAILED: ${FAILURE_REASON}" | ||
dfx stop | ||
exit 1 | ||
fi | ||
done | ||
|
||
echo "CreateServiceNervousSystem proposal SUCCEEDED!" | ||
echo "Run `dfx stop` when you're done testing." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you say more about why this hack is needed?