Commit d5e55584 authored by QM's avatar QM

update shell

parent ee762cca
...@@ -7,6 +7,8 @@ set +e ...@@ -7,6 +7,8 @@ set +e
# 主要在平行链上测试 # 主要在平行链上测试
source "./mainPubilcRelayerTest.sh" source "./mainPubilcRelayerTest.sh"
Yellow="\[\033[0;33m\]"
le8=100000000
function start_docker_ebrelayerProxy() { function start_docker_ebrelayerProxy() {
updata_toml proxy updata_toml proxy
...@@ -38,19 +40,115 @@ function setWithdraw() { ...@@ -38,19 +40,115 @@ function setWithdraw() {
function TestETH2Chain33Assets_proxy() { function TestETH2Chain33Assets_proxy() {
echo -e "${GRE}=========== $FUNCNAME begin ===========${NOC}" echo -e "${GRE}=========== $FUNCNAME begin ===========${NOC}"
echo -e "${GRE}=========== eth to chain33 在以太坊上锁定 ETH 资产,然后在 chain33 上 burn ===========${NOC}" echo -e "${GRE}=========== eth to chain33 在以太坊上锁定 ETH 资产,然后在 chain33 上 burn ===========${NOC}"
echo -e "${Yellow} lockAmount1 ${NOC}"
local lockAmount1=$1
echo -e "${Yellow} ethBridgeBank 初始金额 ${NOC}"
# shellcheck disable=SC2154
ethBridgeBankBalancebf=$(${CLIA} ethereum balance -o "${ethBridgeBank}" | jq -r ".balance")
echo -e "${Yellow} chain33ReceiverAddr chain33 端 lock 后接收地址初始金额 ${NOC}"
# shellcheck disable=SC2154
chain33RBalancebf=$(${Chain33Cli} evm query -a "${chain33EthBridgeTokenAddr}" -c "${chain33DeployAddr}" -b "balanceOf(${chain33ReceiverAddr})")
echo -e "${Yellow} chain33Validatorsp chain33 代理地址初始金额 ${NOC}"
chain33VspBalancebf=$(${Chain33Cli} evm query -a "${chain33EthBridgeTokenAddr}" -c "${chain33DeployAddr}" -b "balanceOf(${chain33Validatorsp})")
echo -e "${Yellow} lock ${NOC}"
# shellcheck disable=SC2154
result=$(${CLIA} ethereum lock -m "${lockAmount1}" -k "${ethTestAddrKey1}" -r "${chain33ReceiverAddr}")
cli_ret "${result}" "lock"
# eth 等待 2 个区块
sleep 4
echo -e "${Yellow} ethBridgeBank lock 后金额 ${NOC}"
result=$(${CLIA} ethereum balance -o "${ethBridgeBank}")
# shellcheck disable=SC2219
let ethBridgeBankBalanceEnd=${ethBridgeBankBalancebf}+${lockAmount1}
cli_ret "${result}" "balance" ".balance" "${ethBridgeBankBalanceEnd}"
# shellcheck disable=SC2086
sleep "${maturityDegree}"
# chain33 chain33EthBridgeTokenAddr(ETH合约中)查询 lock 金额
echo -e "${Yellow} chain33ReceiverAddr chain33 端 lock 后接收地址 lock 后金额 ${NOC}"
# shellcheck disable=SC2154
result=$(${Chain33Cli} evm query -a "${chain33EthBridgeTokenAddr}" -c "${chain33DeployAddr}" -b "balanceOf(${chain33ReceiverAddr})")
# shellcheck disable=SC2219
let chain33RBalancelock=${lockAmount1}*${le8}+${chain33RBalancebf}
# is_equal "${result}" "${chain33RBalancelock}"
echo -e "${Yellow} chain33Validatorsp chain33 代理地址 lock 后金额 ${NOC}"
result=$(${Chain33Cli} evm query -a "${chain33EthBridgeTokenAddr}" -c "${chain33DeployAddr}" -b "balanceOf(${chain33Validatorsp})")
# is_equal "${result}" "${chain33VspBalancebf}"
echo -e "${Yellow} ethTestAddr2 ethereum withdraw 接收地址初始金额 ${NOC}"
# shellcheck disable=SC2154
ethT2Balancebf=$(${CLIA} ethereum balance -o "${ethTestAddr2}" | jq -r ".balance")
echo -e "${Yellow} ethValidatorAddrp ethereum 代理地址初始金额 ${NOC}"
# shellcheck disable=SC2154
ethPBalancebf=$(${CLIA} ethereum balance -o "${ethValidatorAddrp}" | jq -r ".balance")
echo -e "${Yellow} withdraw ${NOC}"
# shellcheck disable=SC2154
result=$(${CLIA} chain33 withdraw -m "${lockAmount1}" -k "${chain33ReceiverAddrKey}" -r "${ethTestAddr2}" -t "${chain33EthBridgeTokenAddr}")
cli_ret "${result}" "withdraw"
sleep "${maturityDegree}"
# 查询 ETH 这端 bridgeBank 地址 0
result=$(${CLIA} ethereum balance -o "${ethBridgeBank}")
cli_ret "${result}" "balance" ".balance" "${ethBridgeBankBalanceEnd}"
echo -e "${Yellow} chain33ReceiverAddr chain33 端 lock 后接收地址 withdraw 后金额 ${NOC}"
result=$(${Chain33Cli} evm query -a "${chain33EthBridgeTokenAddr}" -c "${chain33DeployAddr}" -b "balanceOf(${chain33ReceiverAddr})")
# is_equal "${result}" "${chain33RBalancebf}"
echo -e "${Yellow} chain33Validatorsp chain33 代理地址 withdraw 后金额 ${NOC}"
result=$(${Chain33Cli} evm query -a "${chain33EthBridgeTokenAddr}" -c "${chain33DeployAddr}" -b "balanceOf(${chain33Validatorsp})")
# shellcheck disable=SC2219
let chain33VspBalancewithdraw=${lockAmount1}*${le8}+${chain33VspBalancebf}
# is_equal "${result}" "${chain33VspBalancewithdraw}"
echo -e "${Yellow} ethTestAddr2 ethereum withdraw 接收地址 withdraw 后金额 ${NOC}"
result=$(${CLIA} ethereum balance -o "${ethTestAddr2}" | jq -r ".balance")
# shellcheck disable=SC2219
let ethT2BalanceEnd=${ethT2Balancebf}+${lockAmount1}-1
# is_equal "${result}" "${ethT2BalanceEnd}"
echo -e "${Yellow} ethValidatorAddrp ethereum 代理地址 withdraw 后金额 ${NOC}"
result=$(${CLIA} ethereum balance -o "${ethValidatorAddrp}" | jq -r ".balance")
# shellcheck disable=SC2219
let ethPBalanceEnd=${ethPBalancebf}-${lockAmount1}+1-${result}
if [ $ethPBalanceEnd -gt 1 ]
then echo "error $ethPBalanceEnd 大于 1"
else echo "ok"
fi
echo -e "${GRE}=========== $FUNCNAME end ===========${NOC}"
}
# eth to chain33 在以太坊上锁定 ETH 资产,然后在 chain33 上 burn
function TestETH2Chain33Assets_proxy_excess() {
echo -e "${GRE}=========== $FUNCNAME begin ===========${NOC}"
echo -e "${GRE}=========== eth to chain33 在以太坊上锁定 ETH 资产,然后在 chain33 上 burn ===========${NOC}"
# shellcheck disable=SC2154 # shellcheck disable=SC2154
result=$(${CLIA} ethereum balance -o "${ethBridgeBank}") result=$(${CLIA} ethereum balance -o "${ethBridgeBank}")
cli_ret "${result}" "balance" ".balance" "0" cli_ret "${result}" "balance" ".balance" "0"
local lockAmount1=20
# shellcheck disable=SC2154 # shellcheck disable=SC2154
result=$(${CLIA} ethereum lock -m 20 -k "${ethTestAddrKey1}" -r "${chain33ReceiverAddr}") result=$(${CLIA} ethereum lock -m ${lockAmount1} -k "${ethTestAddrKey1}" -r "${chain33ReceiverAddr}")
cli_ret "${result}" "lock" cli_ret "${result}" "lock"
# eth 等待 2 个区块 # eth 等待 2 个区块
sleep 4 sleep 4
result=$(${CLIA} ethereum balance -o "${ethBridgeBank}") result=$(${CLIA} ethereum balance -o "${ethBridgeBank}")
cli_ret "${result}" "balance" ".balance" "20" cli_ret "${result}" "balance" ".balance" "${lockAmount1}"
# shellcheck disable=SC2086 # shellcheck disable=SC2086
sleep "${maturityDegree}" sleep "${maturityDegree}"
...@@ -58,38 +156,38 @@ function TestETH2Chain33Assets_proxy() { ...@@ -58,38 +156,38 @@ function TestETH2Chain33Assets_proxy() {
# chain33 chain33EthBridgeTokenAddr(ETH合约中)查询 lock 金额 # chain33 chain33EthBridgeTokenAddr(ETH合约中)查询 lock 金额
# shellcheck disable=SC2154 # shellcheck disable=SC2154
result=$(${Chain33Cli} evm query -a "${chain33EthBridgeTokenAddr}" -c "${chain33DeployAddr}" -b "balanceOf(${chain33ReceiverAddr})") result=$(${Chain33Cli} evm query -a "${chain33EthBridgeTokenAddr}" -c "${chain33DeployAddr}" -b "balanceOf(${chain33ReceiverAddr})")
is_equal "${result}" "2000000000" is_equal "${result}" "${lockAmount1}00000000"
result=$(${Chain33Cli} evm query -a "${chain33EthBridgeTokenAddr}" -c "${chain33DeployAddr}" -b "balanceOf(${chain33Validatorsp})") result=$(${Chain33Cli} evm query -a "${chain33EthBridgeTokenAddr}" -c "${chain33DeployAddr}" -b "balanceOf(${chain33Validatorsp})")
is_equal "${result}" "0" is_equal "${result}" "0"
# 原来的数额 # 原来的数额
# shellcheck disable=SC2154 # shellcheck disable=SC2154
result=$(${CLIA} ethereum balance -o "${ethTestAddr2}") ethT2Balance=$(${CLIA} ethereum balance -o "${ethTestAddr2}" | jq -r ".balance")
cli_ret "${result}" "balance" ".balance" "1000"
# shellcheck disable=SC2154 # shellcheck disable=SC2154
result=$(${CLIA} ethereum balance -o "${ethValidatorAddrp}") result=$(${CLIA} ethereum balance -o "${ethValidatorAddrp}")
echo '#5.burn ETH from Chain33 ETH(Chain33)-----> Ethereum' echo '#5.burn ETH from Chain33 ETH(Chain33)-----> Ethereum'
# shellcheck disable=SC2154 # shellcheck disable=SC2154
result=$(${CLIA} chain33 withdraw -m 20 -k "${chain33ReceiverAddrKey}" -r "${ethTestAddr2}" -t "${chain33EthBridgeTokenAddr}") result=$(${CLIA} chain33 withdraw -m ${lockAmount1} -k "${chain33ReceiverAddrKey}" -r "${ethTestAddr2}" -t "${chain33EthBridgeTokenAddr}")
cli_ret "${result}" "withdraw" cli_ret "${result}" "withdraw"
sleep "${maturityDegree}" sleep "${maturityDegree}"
# 查询 ETH 这端 bridgeBank 地址 0 # 查询 ETH 这端 bridgeBank 地址 0
result=$(${CLIA} ethereum balance -o "${ethBridgeBank}") result=$(${CLIA} ethereum balance -o "${ethBridgeBank}")
cli_ret "${result}" "balance" ".balance" "20" cli_ret "${result}" "balance" ".balance" "${lockAmount1}"
echo "check the balance on chain33" echo "check the balance on chain33"
result=$(${Chain33Cli} evm query -a "${chain33EthBridgeTokenAddr}" -c "${chain33DeployAddr}" -b "balanceOf(${chain33ReceiverAddr})") result=$(${Chain33Cli} evm query -a "${chain33EthBridgeTokenAddr}" -c "${chain33DeployAddr}" -b "balanceOf(${chain33ReceiverAddr})")
is_equal "${result}" "0" is_equal "${result}" "0"
result=$(${Chain33Cli} evm query -a "${chain33EthBridgeTokenAddr}" -c "${chain33DeployAddr}" -b "balanceOf(${chain33Validatorsp})") result=$(${Chain33Cli} evm query -a "${chain33EthBridgeTokenAddr}" -c "${chain33DeployAddr}" -b "balanceOf(${chain33Validatorsp})")
is_equal "${result}" "2000000000" is_equal "${result}" "${lockAmount1}00000000"
result=$(${CLIA} ethereum balance -o "${ethTestAddr2}") result=$(${CLIA} ethereum balance -o "${ethTestAddr2}")
cli_ret "${result}" "balance" ".balance" "1019" let ethT2BalanceEnd=${ethT2Balance}+${lockAmount1}-1
cli_ret "${result}" "balance" ".balance" "${ethT2BalanceEnd}"
result=$(${CLIA} ethereum balance -o "${ethValidatorAddrp}") result=$(${CLIA} ethereum balance -o "${ethValidatorAddrp}")
...@@ -195,6 +293,8 @@ function TestETH2Chain33USDT_proxy() { ...@@ -195,6 +293,8 @@ function TestETH2Chain33USDT_proxy() {
result=$(${CLIA} ethereum lock -m 100 -k "${ethTestAddrKey1}" -r "${chain33ReceiverAddr}" -t "${ethereumUSDTERC20TokenAddr}") result=$(${CLIA} ethereum lock -m 100 -k "${ethTestAddrKey1}" -r "${chain33ReceiverAddr}" -t "${ethereumUSDTERC20TokenAddr}")
cli_ret "${result}" "lock" cli_ret "${result}" "lock"
sleep "${maturityDegree}"
result=$(${Chain33Cli} evm query -a "${chain33USDTBridgeTokenAddr}" -c "${chain33TestAddr1}" -b "balanceOf(${chain33ReceiverAddr})") result=$(${Chain33Cli} evm query -a "${chain33USDTBridgeTokenAddr}" -c "${chain33TestAddr1}" -b "balanceOf(${chain33ReceiverAddr})")
# 结果是 12 * le8 # 结果是 12 * le8
# is_equal "${result}" "1200000000" # is_equal "${result}" "1200000000"
...@@ -239,8 +339,10 @@ function TestRelayerProxy() { ...@@ -239,8 +339,10 @@ function TestRelayerProxy() {
start_docker_ebrelayerProxy start_docker_ebrelayerProxy
setWithdraw setWithdraw
TestETH2Chain33Assets_proxy TestETH2Chain33Assets_proxy 20
TestETH2Chain33USDT_proxy # TestETH2Chain33Assets_proxy 30
# TestETH2Chain33Assets_proxy_excess 60
# TestETH2Chain33USDT_proxy
} }
function AllRelayerMainTest() { function AllRelayerMainTest() {
......
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