feat: add multi wallet support #91
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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-nd", | |
"hd-to-distributed", | |
] | |
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: | | |
echo "::debug:: Getting passwords from ./${{matrix.type}}/pass.txt" | |
passphrases=$(cat "./${{matrix.type}}/pass.txt"|tr '\n' ',') | |
echo "::debug:: password string is $passphrases" | |
echo "::debug:: Getting input type for wallet" | |
input_type=$(echo ${{ matrix.type }} | awk -F'-' '{print $1}') | |
echo "::debug:: Input type for wallet is $input_type" | |
echo "::debug:: Getting input path for wallet" | |
input_path="./${{ matrix.type }}/$input_type" | |
echo "::debug:: Input path for wallet is $input_path" | |
echo "::debug:: Getting output type for wallet" | |
output_type=$(echo ${{ matrix.type }} | awk -F'-' '{print $3}') | |
echo "::debug:: Output type for wallet is $output_type" | |
echo "::debug:: Getting output path for wallet" | |
output_path="./${{ matrix.type }}/$output_type" | |
echo "::debug:: Output path for wallet is $output_path" | |
echo -e "Generating Input And Output Paths: ${green}OK${nc}" | |
echo "::debug:: Getting input grep command" | |
input_grep="Public key:" | |
echo "::debug:: Input grep command is $input_grep" | |
echo "::debug:: Getting output grep command" | |
output_grep="Public key:" | |
echo "::debug:: Output grep command is $output_grep" | |
echo -e "Generating Input Grep Command: ${green}OK${nc}" | |
echo "::debug:: Chaning input path and input grep command if input wallet is distributed" | |
if echo "${input_type}" | grep -q "distributed"; then | |
input_path="$input_path/test1" | |
input_grep="Composite public key:" | |
fi | |
echo "::debug:: Chaning output path and output grep command if output wallet is distributed" | |
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 "::debug:: Adding all variables to GITHUB EVN" | |
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: | | |
echo "::debug:: Getting Wallets List from $input_path" | |
wallets_list=$(ethdo wallet list --base-dir "$input_path" | tr '\n' ' ') | |
echo "::debug:: Wallets List is $wallets_list" | |
echo -e "Getting Wallets: ${green}OK${nc}" | |
echo "::debug:: Iterate over Wallets List" | |
for w in $wallets_list; do | |
echo "::debug:: Current wallet is $w" | |
echo "::debug:: Gettting Accounts List for wallet $w" | |
accounts=$(ethdo wallet --base-dir "$input_path" accounts --wallet="$w" | tr '\n' ' ') | |
echo "::debug:: Accounts List for wallet $w is $accounts" | |
echo "::debug:: Iterate over Accounts List" | |
for a in $accounts; do | |
echo "::debug:: Current account is $a" | |
echo "::debug:: Getting input key for account $a" | |
input_key=$(ethdo account --base-dir "$input_path" info --account "$w/$a" | grep -i "$input_grep" | awk '{print $NF}') | |
echo "::debug:: Input key for account $a is $input_key" | |
echo "::debug:: Getting output key for account $a" | |
output_key=$(ethdo account --base-dir "$output_path" info --account "$w/$a" | grep -i "$output_grep" | awk '{print $NF}') | |
echo "::debug:: Output key for account $a is $output_key" | |
echo "::debug:: Compare input key and output key" | |
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() { | |
echo "::debug:: Check input wallet type $input_type" | |
case $input_type in | |
"distributed") | |
echo "::debug:: Input wallet is distirbuted" | |
echo "::debug:: Get local input path" | |
local _input_path="./${{ matrix.type }}/$input_type" | |
echo "::debug:: Local input path is $_input_path" | |
echo "::debug:: Get local sig1" | |
local _sig1=$(ethdo signature sign --base-dir "$_input_path/test1" --account "$w/$a" --data "${sign_data}" --passphrase "${passphrases}") | |
echo "::debug:: Local sig1 is $_sig1" | |
echo "::debug:: Get local sig2" | |
local _sig2=$(ethdo signature sign --base-dir "$_input_path/test2" --account "$w/$a" --data "${sign_data}" --passphrase "${passphrases}") | |
echo "::debug:: Local sig2 is $_sig2" | |
echo "::debug:: Get input signature" | |
input_signature=$(ethdo signature aggregate --signature "10:$_sig1" --signature "20:$_sig2" --data "${sign_data}") | |
echo "::debug:: Input signature is $input_signature" | |
;; | |
*) | |
echo "::debug:: Input wallet is not distirbuted" | |
echo "::debug:: Get input signature" | |
input_signature=$(ethdo signature sign --base-dir "$input_path" --account "$w/$a" --data "${sign_data}" --passphrase "${passphrases}") | |
echo "::debug:: Input signature is $input_signature" | |
;; | |
esac | |
echo "::debug:: Check output wallet type $output_type" | |
case $output_type in | |
"distributed") | |
echo "::debug:: Output wallet is distirbuted" | |
echo "::debug:: Get local output path" | |
local _output_path="./${{ matrix.type }}/$output_type" | |
echo "::debug:: Local local output path is $_output_path" | |
echo "::debug:: Get local sig1" | |
local _sig1=$(ethdo signature sign --base-dir "$_output_path/test1" --account "$w/$a" --data "${sign_data}" --passphrase "${passphrases}") | |
echo "::debug:: Local sig1 is $_sig1" | |
echo "::debug:: Get local sig2" | |
local _sig2=$(ethdo signature sign --base-dir "$_output_path/test2" --account "$w/$a" --data "${sign_data}" --passphrase "${passphrases}") | |
echo "::debug:: Local sig1 is $_sig2" | |
echo "::debug:: Get output signature" | |
output_signature=$(ethdo signature aggregate --signature "10:$_sig1" --signature "20:$_sig2" --data "${sign_data}") | |
echo "::debug:: Output signature is $input_signature" | |
;; | |
*) | |
echo "::debug:: Output wallet is not distirbuted" | |
echo "::debug:: Get output signature" | |
output_signature=$(ethdo signature sign --base-dir "$output_path" --account "$w/$a" --data "${sign_data}" --passphrase "${passphrases}") | |
echo "::debug:: Output signature is $input_signature" | |
;; | |
esac | |
} | |
echo "::debug:: Getting Wallets List from $input_path" | |
wallets_list=$(ethdo wallet list --base-dir "$input_path" | tr '\n' ' ') | |
echo "::debug:: Wallets List is $wallets_list" | |
echo -e "Getting Wallets: ${green}OK${nc}" | |
echo "::debug:: Iterate over Wallets List" | |
for w in $wallets_list; do | |
echo "::debug:: Current wallet is $w" | |
echo "::debug:: Gettting Accounts List for wallet $w" | |
accounts=$(ethdo wallet --base-dir "$input_path" accounts --wallet="$w" | tr '\n' ' ') | |
echo "::debug:: Accounts List for wallet $w is $accounts" | |
echo "::debug:: Iterate over Accounts List" | |
for a in $accounts; do | |
echo "::debug:: Current account is $a" | |
echo "::debug:: Run get_signatures function" | |
get_signatures | |
echo "::debug:: Return from get_signatures function" | |
echo "::debug:: Input signature is $input_signature" | |
echo "::debug:: Output signature is $output_signature" | |
echo "::debug:: Compare input signature and output signature" | |
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' |