-
Notifications
You must be signed in to change notification settings - Fork 3
88 lines (78 loc) · 3.05 KB
/
func-tests.yaml
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
name: Functional Tests
on:
push:
tags: ['v*']
pull_request:
branches: ['main']
workflow_dispatch:
jobs:
functional-tests:
strategy:
matrix:
type: [
"distributed-to-nd",
"nd-to-distributed",
"hd-to-distributed",
"hd-to-nd",
]
defaults:
run:
working-directory: './.github/examples/'
shell: bash
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: 'Build dkc script'
uses: actions/setup-go@v4
with:
go-version-file: './go.mod'
- run: go build ../../
- name: 'Install ethdo'
run: |
go install "github.com/wealdtech/ethdo@$ethdo_version"
env:
ethdo_version: 'v1.28.5'
- name: 'Converting ${{matrix.type}}'
run: |
#FIXME set -e is the default bash flag(this is not obvious btw need to fix)
echo -e "# Running DKC"
./dkc convert --config ${{matrix.type}}.yaml
echo -e "# Comparing Accounts Public Keys"
input_type=$(echo ${{ matrix.type }} | awk -F'-' '{print $1}')
input_path="./${{ matrix.type }}/$input_type"
output_type=$(echo ${{ matrix.type }} | awk -F'-' '{print $3}')
output_path="./${{ matrix.type }}/$output_type"
echo -e "Generating Input And Output Paths: ${green}OK${nc}"
input_grep="Public key:"
ouput_grep="Public key:"
echo -e "Generating Input Grep Command: ${green}OK${nc}"
if echo "${input_type}" | grep -q "distributed"; then
input_path="$input_path/test1"
input_grep="Composite public key:"
fi
if echo "${output_type}" | grep -q "distributed"; then
output_path="$output_path/test1"
output_grep="Composite public key:"
fi
echo -e "Updating Paths And Grep Command If Wallet Is Distributed: ${green}OK${nc}"
echo -e "${green}Input Path | Input Grep:${nc} [$input_path] [$input_grep]"
echo -e "${green}Output Path | Output Grep:${nc} [$output_path] [$output_grep]"
wallets_list=$(ethdo wallet list --base-dir "$input_path" | tr '\n' ' ')
echo -e "Getting Wallets: ${green}OK${nc}"
for w in $wallets_list; do
accounts=$(ethdo wallet --base-dir "$input_path" accounts --wallet="$w" | tr '\n' ' ')
for a in $accounts; do
input_key=$(ethdo account --base-dir "$input_path" info --account "$w/$a" | grep -i "$input_grep" | awk '{print $NF}')
output_key=$(ethdo account --base-dir "$output_path" info --account "$w/$a" | grep -i "$output_grep" | awk '{print $NF}')
if [[ $input_key != $output_key ]]; then
echo -e "Account [$w/$a]: ${red}Fail${nc} ($input_key != $output_key)"
exit 1
fi
echo -e "Checking Account [$w/$a]: ${green}OK${nc}"
done;
done;
env:
red: '\033[0;31m'
green: '\033[0;32m'
yellow: '\033[0;33m'
nc: '\033[0m'