forked from CryptoLions/EOS-Test-Cave
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from EOS-BP-Developers/msig
Add msig test script
- Loading branch information
Showing
18 changed files
with
265 additions
and
8 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +0,0 @@ | ||
04323 | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
31517 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/home/vagrant/Code/EOS-Test-Cave/producing-nodes/start.sh: line 26: /usr/local/bin/nodeos: No such file or directory |
File renamed without changes.
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
TEST_NAME="Create msig account for multisig test" | ||
|
||
. ../runner.sh | ||
|
||
accounts=( testmultisig msigconfirm1 msigconfirm2 msigconfirm3 ); | ||
|
||
#---------------------- | ||
PUB_KEY=$( cat $GLOBALPATH/log/wallet_name_testwallet_key.dat | cut -d' ' -f1) | ||
for NAME in "${accounts[@]}"; do | ||
CMD=$( $GLOBALPATH/bin/cleos.sh system newaccount eosio $NAME $PUB_KEY --stake-net "1000.0000 EOS" --stake-cpu "1000.0000 EOS" --buy-ram "1.0000 EOS" --transfer 2>$tpm_stderr ) | ||
|
||
ERR=$(cat $tpm_stderr) | ||
if [[ $ERR != *"executed transaction"* ]]; then | ||
failed "$ERR" | ||
rm $tpm_stderr; | ||
exit 1 | ||
fi | ||
|
||
sleep 2 | ||
|
||
CMD=$( $GLOBALPATH/bin/cleos.sh transfer eosio $NAME "1000.0000 EOS" "msig test tokens" -p eosio 2>$tpm_stderr ) | ||
ERR=$(cat $tpm_stderr) | ||
if [[ $ERR != *"executed transaction"* ]]; then | ||
failed "$ERR" | ||
rm $tpm_stderr; | ||
exit 1; | ||
fi | ||
done | ||
echo "1:$TEST_NAME" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
TEST_NAME="Import msig account private key in wallet" | ||
|
||
. ../runner.sh | ||
|
||
accounts=( testmultisig msigconfirm1 msigconfirm2 msigconfirm3 ); | ||
|
||
#---------------------- | ||
PUB_KEY=$( cat $GLOBALPATH/log/wallet_name_testwallet_key.dat | cut -d' ' -f1) | ||
PRIV_KEY=$( cat $GLOBALPATH/log/wallet_name_testwallet_key.dat | cut -d' ' -f2) | ||
|
||
for NAME in "${accounts[@]}"; do | ||
# Check Wallet | ||
CMD=$( $GLOBALPATH/bin/cleos.sh wallet create -n $NAME 2> $tpm_stderr ) | ||
ERR=$(cat $tpm_stderr) | ||
if [[ $ERR != "" ]]; then | ||
failed "$ERR" | ||
rm $tpm_stderr; | ||
exit 1 | ||
else | ||
WALLET_PASS=$(echo $CMD | awk -F\" '{ print $2 }') | ||
echo $WALLET_PASS > "$GLOBALPATH/log/wallet_name_"$NAME"_password.dat" | ||
fi | ||
|
||
CMD=$( $GLOBALPATH/bin/cleos.sh wallet import -n $NAME $PRIV_KEY 2> $tpm_stderr ) | ||
ERR=$(cat $tpm_stderr) | ||
CHK_KEY=$(echo $CMD | awk '{print $5}') | ||
if [[ $ERR != "" ]]; then | ||
failed "$ERR" | ||
rm $tpm_stderr; | ||
exit 1 | ||
elif [[ $CHK_KEY != $PUB_KEY ]]; then | ||
failed "$ERR" | ||
echo "$CHK_KEY / $PUB_KEY" | ||
rm $tpm_stderr; | ||
exit 1 | ||
fi | ||
done | ||
echo "1:$TEST_NAME" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
TEST_NAME="Set Multisig Active Permission" | ||
|
||
. ../runner.sh | ||
|
||
|
||
#---------------------- | ||
# Usage : cleos set account permission [OPTIONS] account permission authority [parent] | ||
|
||
# generate json for active multisig | ||
accounts=( testmultisig msigconfirm1 msigconfirm2 msigconfirm3 ); | ||
msig_json="$GLOBALPATH/log/tmp_msig.json" | ||
NAME=${accounts[0]} | ||
|
||
echo '{"threshold":2,"keys":[],"accounts":[' > $msig_json | ||
for ((x=1;x<=3;x++)); do | ||
if [ $x -eq 3 ]; then | ||
echo '{"permission":{"actor":"'${accounts[$x]}'","permission":"active"},"weight":1}' >> $msig_json | ||
else | ||
echo '{"permission":{"actor":"'${accounts[$x]}'","permission":"active"},"weight":1},' >> $msig_json | ||
fi | ||
done | ||
echo '], "waits":[]}' >> $msig_json | ||
|
||
CMD=$( $GLOBALPATH/bin/cleos.sh set account permission ${NAME} active "$(cat $msig_json)" owner -p ${NAME}@owner 2>${tpm_stderr}) | ||
|
||
ERR=$(cat $tpm_stderr) | ||
if [[ $ERR != *"executed transaction"* ]]; then | ||
failed "$ERR" | ||
rm $tpm_stderr; | ||
exit 1; | ||
fi | ||
|
||
echo "1:$TEST_NAME" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
TEST_NAME="Set Multisig Owner Permission" | ||
|
||
. ../runner.sh | ||
|
||
#---------------------- | ||
# Usage : cleos set account permission [OPTIONS] account permission authority [parent] | ||
|
||
# generate json for owner multisig | ||
accounts=( testmultisig msigconfirm1 msigconfirm2 msigconfirm3 ); | ||
msig_json="$GLOBALPATH/log/tmp_msig.json" | ||
NAME=${accounts[0]} | ||
|
||
echo '{"threshold":2,"keys":[],"accounts":[' > $msig_json | ||
for ((x=1;x<=3;x++)); do | ||
if [ $x -eq 3 ]; then | ||
echo '{"permission":{"actor":"'${accounts[$x]}'","permission":"owner"},"weight":1}' >> $msig_json | ||
else | ||
echo '{"permission":{"actor":"'${accounts[$x]}'","permission":"owner"},"weight":1},' >> $msig_json | ||
fi | ||
done | ||
echo '], "waits":[]}' >> $msig_json | ||
|
||
CMD=$( $GLOBALPATH/bin/cleos.sh set account permission ${NAME} owner "$(cat $msig_json)" -p ${NAME}@owner 2>${tpm_stderr}) | ||
|
||
ERR=$(cat $tpm_stderr) | ||
if [[ $ERR != *"executed transaction"* ]]; then | ||
failed "$ERR" | ||
rm $tpm_stderr; | ||
exit 1; | ||
fi | ||
echo "1:$TEST_NAME" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
TEST_NAME="Simple Transfer Multi Signature Propose" | ||
|
||
. ../runner.sh | ||
|
||
# multisig propose [OPTIONS] proposal_name requested_permissions trx_permissions contract action data [proposer] [proposal_expiration] | ||
|
||
accounts=( testmultisig msigconfirm1 msigconfirm2 msigconfirm3 ); | ||
NAME=${accounts[0]} | ||
msig_json="$GLOBALPATH/log/tmp_msig.json" | ||
echo '[' > $msig_json | ||
#---------------------- | ||
for((x=1;x<=3;x++)); do | ||
CONFIRMER=${accounts[$x]} | ||
if [ $x -eq 3 ]; then | ||
echo ' {"actor":"'$CONFIRMER'","permission":"active"}]' >> $msig_json | ||
else | ||
echo ' {"actor":"'$CONFIRMER'","permission":"active"},' >> $msig_json | ||
fi | ||
done | ||
|
||
CMD=$( $GLOBALPATH/bin/cleos.sh multisig propose testmultisig "$(cat $msig_json)" '[{"actor": "'$NAME'", "permission": "active"}]' eosio.token transfer '{"from":"'$NAME'", "to":"'$CONFIRMER'", "quantity":"25.0000 EOS", "memo":"transfer test with multi signature confirm"}' -p ${CONFIRMER}@active 2> ${tpm_stderr} ) | ||
|
||
ERR=$(cat $tpm_stderr) | ||
if [[ $ERR != *"executed transaction"* ]]; then | ||
failed "$ERR" | ||
rm $tpm_stderr; | ||
exit 1; | ||
fi | ||
echo "1:$TEST_NAME" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
TEST_NAME="Multisig Propose Review" | ||
|
||
. ../runner.sh | ||
|
||
# Usage: cleos multisig review [OPTIONS] proposer proposal_name | ||
accounts=( testmultisig msigconfirm1 msigconfirm2 msigconfirm3 ); | ||
NAME=${accounts[0]} | ||
#---------------------- | ||
# get variable on end of accounts array | ||
proposer=${accounts[${#accounts[@]}-1]} | ||
sleep 1; | ||
CMD=$( $GLOBALPATH/bin/cleos.sh multisig review ${proposer} $NAME 2> $tpm_stderr | jq -r .proposal_name ) | ||
ERR=$(cat $tpm_stderr) | ||
if [[ $CMD != "$NAME" ]]; then | ||
failed "$ERR" | ||
rm $tpm_stderr | ||
exit 1; | ||
fi | ||
echo "1:$TEST_NAME" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
TEST_NAME="Multisig Propose Approve sign" | ||
|
||
. ../runner.sh | ||
|
||
# Usage: cleos multisig approve [OPTIONS] proposer proposal_name permissions | ||
#../../bin/cleos.sh multisig approve msigconfirm3 testmultisig '{"actor":"msigconfirm1", "permission":"active"}' -p msigconfirm1@active | ||
|
||
accounts=( testmultisig msigconfirm1 msigconfirm2 msigconfirm3 ); | ||
NAME=${accounts[0]} | ||
proposer=${accounts[${#accounts[@]}-1]} | ||
|
||
for((x=1;x<${#accounts[@]};x++)); do | ||
CMD=$( $GLOBALPATH/bin/cleos.sh multisig approve $proposer $NAME '{"actor":"'${accounts[$x]}'","permission":"active"}' -p ${accounts[$x]}@active 2>$tpm_stderr ) | ||
ERR=$(cat $tpm_stderr) | ||
if [[ $ERR != *"executed transaction"* ]]; then | ||
failed "${accounts[$x]} - $ERR" | ||
rm $tpm_stderr; | ||
exit 1; | ||
fi | ||
done | ||
echo "1:$TEST_NAME" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
TEST_NAME="Multisig Propose unapprove sign" | ||
|
||
. ../runner.sh | ||
|
||
# Usage: cleos multisig approve [OPTIONS] proposer proposal_name permissions | ||
#../../bin/cleos.sh multisig approve msigconfirm3 testmultisig '{"actor":"msigconfirm1", "permission":"active"}' -p msigconfirm1@active | ||
sleep 1 | ||
accounts=( testmultisig msigconfirm1 msigconfirm2 msigconfirm3 ); | ||
NAME=${accounts[0]} | ||
proposer=${accounts[${#accounts[@]}-1]} | ||
unapprove=${accounts[2]} | ||
|
||
CMD=$( $GLOBALPATH/bin/cleos.sh multisig unapprove $proposer $NAME '{"actor":"'${unapprove}'","permission":"active"}' -p ${unapprove}@active 2> $tpm_stderr ) | ||
ERR=$(cat $tpm_stderr) | ||
if [[ $ERR != *"executed transaction"* ]]; then | ||
failed "$ERR" | ||
rm $tpm_stderr; | ||
exit 1; | ||
fi | ||
echo "1:$TEST_NAME" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
TEST_NAME="Execute Approved Multisign Transation" | ||
|
||
. ../runner.sh | ||
|
||
# Usage: cleos multisig exec [OPTIONS] proposer proposal_name [executer] | ||
|
||
accounts=( testmultisig msigconfirm1 msigconfirm2 msigconfirm3 ); | ||
NAME=${accounts[0]} | ||
proposer=${accounts[${#accounts[@]}-1]} | ||
executer=${accounts[1]} | ||
|
||
CMD=$( $GLOBALPATH/bin/cleos.sh multisig exec $proposer $NAME -p ${executer}@active 2> $tpm_stderr ) | ||
ERR=$(cat $tpm_stderr) | ||
if [[ $ERR != *"executed transaction"* ]]; then | ||
failed "$ERR" | ||
rm $tpm_stderr; | ||
exit 1; | ||
fi | ||
sleep 1; | ||
CMD=$( $GLOBALPATH/bin/cleos.sh get currency balance eosio.token msigconfirm3 EOS | awk '{print $1}' | sed "s/\.//g" 2> $tpm_stderr ) | ||
ERR=$(cat $tpm_stderr) | ||
if [[ $ERR != "" ]]; then | ||
failed "$ERR" | ||
rm $tpm_stderr; | ||
exit 1; | ||
elif [[ $CMD -ne 10250000 ]]; then | ||
failed "msigconfirm3 account balance is not right. maybe multisig execute is not work." | ||
rm $tpm_stderr; | ||
exit 1; | ||
fi | ||
|
||
echo "1:$TEST_NAME" |
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