Commit 80796322 authored by QM's avatar QM Committed by 33cn

export x2eth logs

parent 5f158371
......@@ -12,6 +12,26 @@ RED='\033[1;31m'
GRE='\033[1;32m'
NOC='\033[0m'
# 出错退出前拷贝日志文件
function exit_cp_file() {
ls
# shellcheck disable=SC2116
dirNameFa=$( echo ~ )
dirName="$dirNameFa/x2ethereumlogs"
if [ ! -d "${dirName}" ]; then
# shellcheck disable=SC2086
mkdir -p ${dirName}
fi
for name in A B C D; do
cp "./$name/ebrelayer.log" "$dirName/ebrelayer$name.log"
done
docker cp "${NODE3}":/root/logs/chain33.log "$dirName/chain33.log"
exit 1
}
function kill_all_ebrelayer() {
for name in A B C D; do
local ebrelayer="./../build/$name/ebrelayer"
......@@ -24,13 +44,13 @@ function cli_ret() {
set +x
if [[ $# -lt 2 ]]; then
echo -e "${RED}wrong parameter${NOC}"
exit 1
exit_cp_file
fi
ok=$(echo "${1}" | jq -r .isOK)
if [[ ${ok} != "true" ]]; then
echo -e "${RED}failed to ${2}${NOC}"
exit 1
exit_cp_file
fi
local jqMsg=".msg"
......@@ -42,7 +62,7 @@ function cli_ret() {
if [[ $# -eq 4 ]]; then
if [ "$(echo "$msg < $4" | bc)" -eq 1 ] || [ "$(echo "$msg > $4" | bc)" -eq 1 ]; then
echo -e "${RED}The balance is not correct${NOC}"
exit 1
exit_cp_file
fi
fi
......@@ -55,13 +75,13 @@ function balance_ret() {
set +x
if [[ $# -lt 2 ]]; then
echo -e "${RED}wrong parameter${NOC}"
exit 1
exit_cp_file
fi
local balance=$(echo "${1}" | jq -r ".balance")
if [ "$(echo "$balance < $2" | bc)" -eq 1 ] || [ "$(echo "$balance > $2" | bc)" -eq 1 ]; then
echo -e "${RED}The balance is not correct${NOC}"
exit 1
exit_cp_file
fi
set -x
......@@ -75,7 +95,7 @@ function cli_ret_err() {
echo "${ok}"
if [[ ${ok} == "true" ]]; then
echo -e "${RED}isOK is true${NOC}"
exit 1
exit_cp_file
fi
#set -x
}
......@@ -103,13 +123,13 @@ function start_ebrelayer() {
# 参数如果小于 2 直接报错
if [[ $# -lt 2 ]]; then
echo -e "${RED}wrong parameter${NOC}"
exit 1
exit_cp_file
fi
# 判断可执行文件是否存在
if [ ! -x "${1}" ]; then
echo -e "${RED}${1} not exist${NOC}"
exit 1
exit_cp_file
fi
# 后台启动程序
......@@ -126,7 +146,7 @@ function start_ebrelayer() {
count=$((count + 1))
if [[ ${count} -ge 20 ]]; then
echo -e "${RED}start ${1} failed${NOC}"
exit 1
exit_cp_file
fi
# shellcheck disable=SC2009
......@@ -150,7 +170,7 @@ function start_ebrelayer_and_unlock() {
count=$((count + 1))
if [[ ${count} == 5 ]]; then
echo -e "${RED}failed to unlock${NOC}"
exit 1
exit_cp_file
fi
sleep 1
......@@ -173,7 +193,7 @@ function start_ebrelayer_and_setpwd_unlock() {
count=$((count + 1))
if [[ ${count} == 5 ]]; then
echo -e "${RED}failed to set_pwd${NOC}"
exit 1
exit_cp_file
fi
sleep 1
......@@ -189,7 +209,7 @@ function start_ebrelayer_and_setpwd_unlock() {
count=$((count + 1))
if [[ ${count} == 5 ]]; then
echo -e "${RED}failed to unlock${NOC}"
exit 1
exit_cp_file
fi
sleep 1
......@@ -222,7 +242,7 @@ function block_wait() {
if [[ $# -lt 1 ]]; then
echo -e "${RED}wrong block_wait parameter${NOC}"
exit 1
exit_cp_file
fi
local cur_height=$(${CLI} block last_header | jq ".height")
......@@ -250,12 +270,12 @@ function check_tx() {
if [[ $# -lt 2 ]]; then
echo -e "${RED}wrong check_tx parameters${NOC}"
exit 1
exit_cp_file
fi
if [[ ${2} == "" ]]; then
echo -e "${RED}wrong check_tx txHash is empty${NOC}"
exit 1
exit_cp_file
fi
local count=0
......@@ -279,19 +299,19 @@ function check_tx() {
ty=$(${CLI} tx query -s "${2}" | jq .receipt.ty)
if [[ ${ty} != 2 ]]; then
echo -e "${RED}check tx error, hash is ${2}${NOC}"
exit 1
exit_cp_file
fi
}
function check_number() {
if [[ $# -lt 2 ]]; then
echo -e "${RED}wrong check number parameters${NOC}"
exit 1
exit_cp_file
fi
if [ "$(echo "$1 < $2" | bc)" -eq 1 ] || [ "$(echo "$1 > $2" | bc)" -eq 1 ]; then
echo -e "${RED}error number, expect ${1}, get ${2}${NOC}"
exit 1
exit_cp_file
fi
}
......@@ -299,13 +319,13 @@ function check_number() {
function check_addr() {
if [[ $# -lt 2 ]]; then
echo -e "${RED}wrong check number parameters${NOC}"
exit 1
exit_cp_file
fi
addr=$(echo "${1}" | jq -r ".acc.addr")
if [[ ${addr} != "${2}" ]]; then
echo -e "${RED}error addr, expect ${1}, get ${2}${NOC}"
exit 1
exit_cp_file
fi
}
......@@ -319,7 +339,7 @@ function updata_relayer_toml() {
local chain33Host=$(docker inspect "${NODE3}" | jq ".[].NetworkSettings.Networks" | grep "IPAddress" | awk '{ print $2}' | sed 's/\"//g' | sed 's/,//g')
if [[ ${chain33Host} == "" ]]; then
echo -e "${RED}chain33Host is empty${NOC}"
exit 1
exit_cp_file
fi
local pushHost=$(ifconfig wlp2s0 | grep "inet " | awk '{ print $2}' | awk -F: '{print $2}')
......@@ -339,7 +359,7 @@ function updata_relayer_toml() {
if [[ ${pushHost} == "" ]]; then
echo -e "${RED}pushHost is empty${NOC}"
exit 1
exit_cp_file
fi
local line=$(delete_line_show "${file}" "chain33Host")
......@@ -447,7 +467,7 @@ function wait_prophecy_finish() {
count=$((count + 1))
if [[ ${count} == 30 ]]; then
echo -e "${RED}failed to get balance${NOC}"
exit 1
exit_cp_file
fi
sleep 1
......@@ -460,7 +480,7 @@ function eth_block_wait() {
set +x
if [[ $# -lt 0 ]]; then
echo -e "${RED}wrong block_wait parameter${NOC}"
exit 1
exit_cp_file
fi
local cur_height=""
......
......@@ -14,7 +14,7 @@ function x2ethereum() {
echo "========================== x2ethereum test =========================="
set +e
set -x
AllRelayerMainTest 1
AllRelayerMainTest 10
perf_test_main 10
echo "========================== x2ethereum test end =========================="
fi
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment