forked from trezor/trezor-suite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-connect-test.sh
executable file
·146 lines (127 loc) · 3.76 KB
/
docker-connect-test.sh
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/usr/bin/env bash
# This script runs @trezor/connect tests.
# It spins up trezor-user-env and sets required evironment variables.
set -euo pipefail
# Running standalone instance of trezor-user-env
# docker run -it -e SDL_VIDEODRIVER="dummy" -p "9001:9001" -p "21326:21326" -p "21325:21326" registry.gitlab.com/satoshilabs/trezor/trezor-user-env/trezor-user-env
# Tweaking trezor-user-env locally
# docker run -it -e SDL_VIDEODRIVER="dummy" -p "9001:9001" -p "21326:21326" -p "21325:21326" registry.gitlab.com/satoshilabs/trezor/trezor-user-env/trezor-user-env nix-shell
# do your changes using `vi` and run:
# [nix-shell:/trezor-user-env]# ./run.sh
# Ports
# 9001 - websocket server, communication test case > user-env (setup etc...)
# 21326 - trezord proxy. beacuse of trezord CORS check
# 21325 - original trezord port redirected to trezor-user-env proxy
ENVIRONMENT=$1
if [[ "$ENVIRONMENT" != "web" && "$ENVIRONMENT" != "node" ]];
then
echo "either 'web' or 'node' must be specified as the first argument"
exit 1
fi
show_usage() {
echo "Usage: run [OPTIONS] [ARGS]"
echo ""
echo "Options:"
echo " -c Disable backend cache. default: enabled"
echo " -d Disable docker. Useful when running own instance of trezor-user-env. default: enabled"
echo " -D PATH Set path to docker executable. Can be replaced with \`podman\`. default: docker"
echo " -e All methods except excluded, example: applySettings,signTransaction"
echo " -p Test pattern"
echo " -f Use specific firmware version, example: 2.1.4, 1.8.0 default: 2-main"
echo " -i Included methods only, example: applySettings,signTransaction"
echo " -s actual test script. default: 'yarn test:integration'"
echo " -u Firmware url"
echo " -m Firmware model, example: R'"
}
# default options
FIRMWARE=""
FIRMWARE_URL=""
INCLUDED_METHODS=""
EXCLUDED_METHODS=""
DOCKER=true
# TODO: DOCKER_PATH appears unused. Remove or export?
DOCKER_PATH="docker"
USE_TX_CACHE=true
USE_WS_CACHE=true
PATTERN=""
FIRMWARE_MODEL=""
# user options
OPTIND=2
while getopts ":p:i:e:f:u:m:D:hdc" opt; do
case $opt in
d)
DOCKER=false
;;
D)
DOCKER_PATH="$OPTARG"
;;
c)
USE_TX_CACHE=false
USE_WS_CACHE=false
;;
f)
FIRMWARE=$OPTARG
;;
u)
FIRMWARE_URL=$OPTARG
;;
i)
INCLUDED_METHODS=$OPTARG
;;
e)
EXCLUDED_METHODS=$OPTARG
;;
p)
PATTERN=$OPTARG
;;
m)
FIRMWARE_MODEL=$OPTARG
;;
h) # Script usage
show_usage
exit 0
;;
\?)
echo "invalid option $OPTARG"
exit 1
;;
esac
done
shift $((OPTIND - 1))
export DOCKER_PATH
if [[ $ENVIRONMENT == "node" ]];
then
SCRIPT="yarn workspace @trezor/connect test:e2e:node"
else
SCRIPT="yarn workspace @trezor/connect test:e2e:web"
fi
# export essential process.env variables
export TESTS_FIRMWARE=$FIRMWARE
export TESTS_INCLUDED_METHODS=$INCLUDED_METHODS
export TESTS_EXCLUDED_METHODS=$EXCLUDED_METHODS
export TESTS_USE_TX_CACHE=$USE_TX_CACHE
export TESTS_USE_WS_CACHE=$USE_WS_CACHE
export TESTS_PATTERN=$PATTERN
export TESTS_SCRIPT=$SCRIPT
export TESTS_FIRMWARE_URL=$FIRMWARE_URL
export TESTS_FIRMWARE_MODEL=$FIRMWARE_MODEL
runDocker() {
docker compose -f ./docker/docker-compose.connect-test.yml up --abort-on-container-exit
}
run() {
echo "Testing env: ${ENVIRONMENT}. Using: ${SCRIPT} ${PATTERN}"
echo " Firmware: ${TESTS_FIRMWARE}"
echo " Firmware model: ${TESTS_FIRMWARE_MODEL}"
echo " Firmware from url: ${FIRMWARE_URL}"
echo " Test pattern: $PATTERN"
echo " Included methods: ${INCLUDED_METHODS}"
echo " Excluded methods: ${EXCLUDED_METHODS}"
echo " TxCache: ${USE_TX_CACHE}"
echo " WsCache: ${USE_WS_CACHE}"
if [ $DOCKER = true ]; then
runDocker
else
$SCRIPT "$PATTERN"
fi
}
run