forked from dfinity/nns-dapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.test
executable file
·55 lines (50 loc) · 1.69 KB
/
config.test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env bash
set -euo pipefail
JSON_CONFIG="deployment-config.json"
ENV_CONFIG="frontend/.env"
arg_config() {
echo "nns-dapp-arg-${DFX_NETWORK}.did"
}
clean_config() {
ALL_CONFIG=("$JSON_CONFIG" "$ENV_CONFIG" "$(arg_config)")
rm -f "${ALL_CONFIG[@]}"
}
(
echo "Compare generated config against expected values for specific networks"
./scripts/nns-dapp/test-config
)
# TODO: Updating golden files is broken for this test. Fix it.
# (
# echo "Compare generated config with local deployments"
# # Note: Unlike on mainnet, canister IDs can change. The test will adapt the expected values with the actual canister ID.
# # We will deploy twice to make sure that the local canister ID changes.
# dfx start --clean --background
# for ((i = 0; i < 2; i++)); do
# dfx canister create nns-dapp
# scripts/nns-dapp/test-config --network local
# dfx canister delete nns-dapp --yes
# done
# )
(
echo "Network parameter is in config"
for DFX_NETWORK in mainnet local; do
clean_config
DFX_NETWORK="$DFX_NETWORK" ./config.sh
: "Check value in JSON"
JSON_NETWORK="$(jq -r .DFX_NETWORK "$JSON_CONFIG")"
[[ "$DFX_NETWORK" == "$JSON_NETWORK" ]] || {
printf "ERROR: %s\n" "Unexpected DFX_NETWORK value in $JSON_CONFIG:" \
"Expected: $DFX_NETWORK" \
"Actual: $JSON_NETWORK"
exit 1
} >&2
: "Check value in arg"
ARG_NETWORK="$(idl2json <"$(arg_config)" | jq -r '.[0].args[]|select(.["0"] == "DFX_NETWORK")|.["1"]')"
[[ "$DFX_NETWORK" == "$ARG_NETWORK" ]] || {
printf "ERROR: %s\n" "Unexpected DFX_NETWORK value in $(arg_config):" \
"Expected: $DFX_NETWORK" \
"Actual: $ARG_NETWORK"
exit 1
} >&2
done
)