Skip to content

feat: add multi wallet support #51

feat: add multi wallet support

feat: add multi wallet support #51

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",
"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 "# Generating Input And Output Paths"
input_path="./${{ matrix.type }}/$(echo ${{ matrix.type }} | awk -F'-' '{print $1}')"
output_path="./${{ matrix.type }}/$(echo ${{ matrix.type }} | awk -F'-' '{print $3}')"
echo -e "# Generating Input Grep Command"
input_grep="Public key:"
ouput_grep="Public key:"
echo -e "# Updating Paths And Grep Command If Wallet Is Distributed"
if $(echo $input_path | grep "distributed"); then
input_path="$input_path/test1"
input_grep="Composite public key:"
fi
if $(echo $output_path | grep "distributed"); then
output_path="$output_path/test1"
ouput_grep="Composite public key:"
fi
echo -e "# $input_path"
echo -e "# $output_path"
echo -e "# Checking Public Keys"
wallets_list=$(ethdo wallet --base-dir "$input_path" | tr '\n' ' ')
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 "Account [$w/$a]: ${green}OK${nc}"
done;
echo -e "Account [$w]: ${green}OK${nc}"
done;
env:
red: '\033[0;31m'
green: '\033[0;32m'
nc: '\033[0m'