Skip to content

Commit 26b2332

Browse files
atergaArshavir Ter-Gabrielyan
authored andcommitted
first
1 parent af69209 commit 26b2332

File tree

2 files changed

+98
-0
lines changed

2 files changed

+98
-0
lines changed

.github/workflows/e2e.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ jobs:
5353
if: matrix.extension == 'sns'
5454
- name: run test
5555
run: timeout 2400 e2e/bats/bin/bats extensions/${{ matrix.extension }}/e2e/tests/*.bash
56+
- name: run sns tests
57+
run: timeout 2400 e2e/launch-simple-sns.sh
5658

5759
aggregate:
5860
name: e2e:required

e2e/launch-simple-sns.sh

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Tested with dfx 0.20.1
4+
5+
set -euo pipefail
6+
7+
# This ID corresponds to TEST_NEURON_1
8+
NEURON_ID="449479075714955186"
9+
10+
dfx start --clean --background
11+
12+
dfx identity use default
13+
cargo run --bin nns install --dfx-cache-path="$(dfx cache show)"
14+
15+
# Ensure we have a powerful neuron
16+
cat <<EOF >ident-1.pem
17+
-----BEGIN EC PRIVATE KEY-----
18+
MHQCAQEEICJxApEbuZznKFpV+VKACRK30i6+7u5Z13/DOl18cIC+oAcGBSuBBAAK
19+
oUQDQgAEPas6Iag4TUx+Uop+3NhE6s3FlayFtbwdhRVjvOar0kPTfE/N8N6btRnd
20+
74ly5xXEBNSXiENyxhEuzOZrIWMCNQ==
21+
-----END EC PRIVATE KEY-----
22+
EOF
23+
dfx identity import --force --storage-mode=plaintext ident-1 ident-1.pem
24+
dfx identity use ident-1
25+
PRINCIPAL_ID=$(dfx identity get-principal)
26+
27+
# Hack
28+
sleep 15s
29+
30+
# Top-up the SNS-W canister
31+
dfx ledger fabricate-cycles --canister qaa6y-5yaaa-aaaaa-aaafa-cai --t 2345
32+
33+
dfx canister call "rrkah-fqaaa-aaaaa-aaaaq-cai" update_neuron '(
34+
record {
35+
id = opt record { id = '${NEURON_ID}' : nat64 };
36+
staked_maturity_e8s_equivalent = null;
37+
controller = opt principal "'${PRINCIPAL_ID}'";
38+
recent_ballots = vec {};
39+
kyc_verified = true;
40+
neuron_type = null;
41+
not_for_profit = false;
42+
maturity_e8s_equivalent = 1_000_000 : nat64;
43+
cached_neuron_stake_e8s = 1_000_000_000_000_000 : nat64;
44+
created_timestamp_seconds = 123 : nat64;
45+
auto_stake_maturity = opt true;
46+
aging_since_timestamp_seconds = 456 : nat64;
47+
hot_keys = vec {};
48+
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";
49+
joined_community_fund_timestamp_seconds = opt (1 : nat64);
50+
dissolve_state = opt variant {
51+
DissolveDelaySeconds = 252_460_800 : nat64
52+
};
53+
followees = vec {};
54+
neuron_fees_e8s = 0 : nat64;
55+
transfer = null;
56+
known_neuron_data = null;
57+
spawn_at_timestamp_seconds = null;
58+
},
59+
)'
60+
61+
curl https://raw.githubusercontent.com/dfinity/sns-testing/main/example_sns_init.yaml \
62+
| sed "s/YOUR_PRINCIPAL_ID/${PRINCIPAL_ID}/" \
63+
| sed "s/- YOUR_CANISTER_ID//" > sns_init.yaml
64+
65+
touch logo.png
66+
67+
cargo run --bin sns propose --neuron-id "${NEURON_ID}" sns_init.yaml
68+
69+
# Check that the CreateServiceNervousSystem propsoal was executed
70+
PROPOSAL_DATA=$(dfx canister \
71+
call "rrkah-fqaaa-aaaaa-aaaaq-cai" \
72+
list_proposals '(
73+
record {
74+
include_reward_status = vec {};
75+
before_proposal = null;
76+
limit = 1;
77+
exclude_topic = vec {};
78+
include_status = vec {};
79+
}
80+
)' | idl2json)
81+
82+
while [ "$(echo "${PROPOSAL_DATA}" | jq -r '.proposal_info[0].executed_timestamp_seconds')" == "0" ]
83+
do
84+
FAILURE_REASON=$(echo "${PROPOSAL_DATA}" | jq -c -r '.proposal_info[0].failure_reason?')
85+
if [ "$FAILURE_REASON" = "null" ]; then
86+
printf "."
87+
sleep 1
88+
else
89+
echo "CreateServiceNervousSystem proposal FAILED: ${FAILURE_REASON}"
90+
dfx stop
91+
exit 1
92+
fi
93+
done
94+
95+
echo "CreateServiceNervousSystem proposal SUCCEEDED!"
96+
echo "Run `dfx stop` when you're done testing."

0 commit comments

Comments
 (0)