-
Notifications
You must be signed in to change notification settings - Fork 3
119 lines (103 loc) · 4.52 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
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
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
- name: 'Preparing Variables For ${{matrix.type}}'
run: |
echo -e "# Comparing Accounts Public Keys"
passphrases=$(cat "./${{matrix.type}}/pass.txt"|tr '\n' ',')
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]"
echo "passphrases=$passphrases" >> $GITHUB_ENV
echo "input_path=$input_path" >> $GITHUB_ENV
echo "input_grep=$input_grep" >> $GITHUB_ENV
echo "output_path=$output_path" >> $GITHUB_ENV
echo "output_grep=$output_grep" >> $GITHUB_ENV
- name: 'Checking PubKeys For ${{matrix.type}}'
run: |
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;
- name: 'Checking Signatures For ${{matrix.type}}'
run: |
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
signature=$(ethdo signature sign --base-dir "$input_path" --account "$w/$a" --data "${data}" --passphrase "${passphrases}")
if ! $(ethdo signature verify --base-dir "$output_path" --account "$w/$a" --data "${data}" --passphrase "${passphrases}" --signature "${signature}"); then
echo -e "Failed To Verify Signature For Account [$w/$a]: ${red}Fail${nc}"
exit 1
echo -e "Checking Signature For Account [$w/$a]: ${green}OK${nc}"
done;
done;
env:
red: '\033[0;31m'
green: '\033[0;32m'
yellow: '\033[0;33m'
nc: '\033[0m'
sign_data: '0x000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f'