-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsynpress-envsetter.sh
59 lines (50 loc) · 2.03 KB
/
synpress-envsetter.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
#!/bin/bash
# this small scripts sets all the required environment variables for Synpress
# For ropsten
#
# It reads the private key from a file called SYNPRESS_PRIVATEKEY
# If you're a developer don't forget to put the file SYNPRESS_PRIVATEKEY in your .gitignore !
#
# Web-app uses Synpress (a wrapper around Cypress) to run full end-to-end tests
# On Linux environment this scripts must be called using ". ./synpress-env.sh"
unset PRIVATE_KEY
unset NETWORK_NAME
unset RPC_URL
unset CHAIN_ID
unset BLOCK_EXPLORER
unset IS_TESTNET
sourced=0
if [ -n "$ZSH_EVAL_CONTEXT" ]; then
case $ZSH_EVAL_CONTEXT in *:file) sourced=1;; esac
elif [ -n "$KSH_VERSION" ]; then
[ "$(cd $(dirname -- $0) && pwd -P)/$(basename -- $0)" != "$(cd $(dirname -- ${.sh.file}) && pwd -P)/$(basename -- ${.sh.file})" ] && sourced=1
elif [ -n "$BASH_VERSION" ]; then
(return 0 2>/dev/null) && sourced=1
else # All other shells: examine $0 for known shell binary filenames
# Detects `sh` and `dash`; add additional shell filenames as needed.
case ${0##*/} in sh|dash) sourced=1;; esac
fi
{
if [ $sourced -eq 0 ]; then
echo "You need to run this script using the 'source' command in order for the environment variables being set in your calling shell. "
echo "Example: source $0"
return 1 2>/dev/null
exit 1
fi
}
{
if [ ! -f ./SYNPRESS_PRIVATEKEY ]; then
echo "File SYNPRESS_PRIVATEKEY not found. Put the private key of your test wallet into this file in the same directory where this script is located and try again."
return 1 2>/dev/null
exit 1
fi
}
PRIVATE_KEY=$(cat "./SYNPRESS_PRIVATEKEY")
#export SECRET_WORDS='does,not,work,use,private,key' running synpress with seedphrase doesnt work as synpress sets up metamask with secret words once set. However, this leads to an error that crashes the test.
export PRIVATE_KEY=$PRIVATE_KEY
export NETWORK_NAME=Localhost
export RPC_URL=http://127.0.0.1:8545
export CHAIN_ID=1337
export BLOCK_EXPLORER=http://127.0.0.1:8545
export IS_TESTNET=true
echo "Environment variables set to run Web-app tests using Synpress!"