Skip to content

feat: add multi wallet support #89

feat: add multi wallet support

feat: add multi wallet support #89

Workflow file for this run

name: Functional Tests
on:
push:
tags: ['v*']
pull_request:
branches: ['main']
workflow_dispatch:
jobs:
functional-tests:
strategy:
matrix:
type: [
"distributed-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.33.2'
- name: 'Converting ${{matrix.type}}'
run: |
./dkc convert --config ${{matrix.type}}.yaml
- name: 'Preparing Variables For ${{matrix.type}}'
run: |
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:"
output_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 "input_type=$input_type" >> $GITHUB_ENV
echo "output_path=$output_path" >> $GITHUB_ENV
echo "output_grep=$output_grep" >> $GITHUB_ENV
echo "output_type=$output_type" >> $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: |
get_signatures() {
case $input_type in
"distributed")
local _input_path="./${{ matrix.type }}/$input_type"
local _sig1=$(ethdo signature sign --base-dir "$_input_path/test1" --account "$w/$a" --data "${sign_data}" --passphrase "${passphrases}")
local _sig2=$(ethdo signature sign --base-dir "$_input_path/test2" --account "$w/$a" --data "${sign_data}" --passphrase "${passphrases}")
input_signature=$(ethdo signature aggregate --signature "10:$_sig1" --signature "20:$_sig2" --data "${sign_data}")
;;
*)
input_signature=$(ethdo signature sign --base-dir "$input_path" --account "$w/$a" --data "${sign_data}" --passphrase "${passphrases}")
;;
esac
case $output_type in
"distributed")
local _output_path="./${{ matrix.type }}/$output_type"
local sig1=$(ethdo signature sign --base-dir "$_output_path/test1" --account "$w/$a" --data "${sign_data}" --passphrase "${passphrases}")
local sig2=$(ethdo signature sign --base-dir "$_output_path/test2" --account "$w/$a" --data "${sign_data}" --passphrase "${passphrases}")
output_signature=$(ethdo signature aggregate --signature "10:$_sig1" --signature "20:$_sig2" --data "${sign_data}")
;;
*)
output_signature=$(ethdo signature sign --base-dir "$output_path" --account "$w/$a" --data "${sign_data}" --passphrase "${passphrases}")
;;
esac
}
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
get_signatures
if [[ "$input_signature" != "$output_signature" ]]; then
echo -e "Failed To Verify Signature For Account [$w/$a]: ${red}Fail${nc}"
exit 1
fi
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'