Unverified Commit 53a3f129 authored by 33cn's avatar 33cn Committed by GitHub

Merge pull request #635 from jpeng-go/master

#484 update rpc_test
parents babba433 fa1b1ba6
......@@ -37,9 +37,9 @@ chain33_BlockWait() {
break
fi
count=$((count + 1))
sleep 1
sleep 0.1
done
echo "wait new block $count s, cur height=$expect,old=$cur_height"
echo "wait new block $count/10 s, cur height=$expect,old=$cur_height"
}
chain33_QueryTx() {
......
......@@ -10,9 +10,7 @@ function dapp_test_rpc() {
if [ -d dapptest ]; then
cp $DAPP_TEST_COMMON dapptest/
cd dapptest || return
dir=$(find . -maxdepth 1 -type d ! -name dapptest ! -name evm ! -name game ! -name guess ! -name hashlock ! -name ticket ! -name lottery ! -name pokerbull ! -name token ! -name trade ! -name . | sed 's/^\.\///' | sort)
dir=$(find . -maxdepth 1 -type d ! -name dapptest ! -name ticket ! -name . | sed 's/^\.\///' | sort)
echo "dapps list: $dir"
for app in $dir; do
echo "=========== # $app rpc test ============="
......@@ -20,8 +18,8 @@ function dapp_test_rpc() {
echo "=========== # $app rpc end ============="
done
##ticket用例最后执行
./ticket/"${RPC_TESTFILE}" "$ip"
fi
echo "============ # dapp rpc test end ============="
}
#dapp_test_rpc $1
......@@ -80,6 +80,7 @@ function base_init() {
sed -i $sedfix 's/^powLimitBits=.*/powLimitBits="0x1f2fffff"/g' chain33.toml
sed -i $sedfix 's/^targetTimePerBlock=.*/targetTimePerBlock=1/g' chain33.toml
sed -i $sedfix 's/^targetTimespan=.*/targetTimespan=10000000/g' chain33.toml
# p2p
sed -i $sedfix 's/^seeds=.*/seeds=["chain33:13802","chain32:13802","chain31:13802"]/g' chain33.toml
......@@ -131,13 +132,13 @@ function start() {
${CLI} net info
${CLI} net peer_info
local count=100
local count=1000
while [ $count -gt 0 ]; do
peersCount=$(${CLI} net peer_info | jq '.[] | length')
if [ "${peersCount}" -ge 2 ]; then
break
fi
sleep 5
sleep 1
((count--))
echo "peers error: peersCount=${peersCount}"
done
......@@ -212,10 +213,10 @@ function miner() {
sleep 1
echo "=========== # close auto mining ============="
result=$(${1} wallet auto_mine -f 1 | jq ".isok")
if [ "${result}" = "false" ]; then
exit 1
fi
#result=$(${1} wallet auto_mine -f 0 | jq ".isok")
#if [ "${result}" = "false" ]; then
# exit 1
#fi
}
function block_wait() {
......@@ -232,9 +233,9 @@ function block_wait() {
break
fi
count=$((count + 1))
sleep 1
sleep 0.1
done
echo "wait new block $count s, cur height=$expect,old=$cur_height"
echo "wait new block $count/10 s, cur height=$expect,old=$cur_height"
}
function block_wait2height() {
......@@ -257,9 +258,9 @@ function block_wait2height() {
break
fi
count=$((count + 1))
sleep 1
sleep 0.1
done
echo "wait new block $count s, cur_height=$new_height,expect=$expect"
echo "wait new block $count/10 s, cur_height=$new_height,expect=$expect"
}
function check_docker_status() {
......
......@@ -108,7 +108,7 @@ futureBlockTime = 16
ticketFrozenTime = 5 #5s only for test
ticketWithdrawTime = 10 #10s only for test
ticketMinerWaitTime = 2 #2s only for test
targetTimespan = 2304
targetTimespan=2304
targetTimePerBlock=16
[mver.consensus.ticket.ForkChainParamV1]
......@@ -116,14 +116,14 @@ futureBlockTime = 15
ticketFrozenTime = 43200
ticketWithdrawTime = 172800
ticketMinerWaitTime = 7200
targetTimespan = 2160
targetTimePerBlock = 15
targetTimespan=2160
targetTimePerBlock=15
[mver.consensus.ticket.ForkChainParamV2]
coinReward = 5
coinDevFund = 3
targetTimespan = 720
targetTimePerBlock = 5
targetTimespan=720
targetTimePerBlock=5
ticketPrice = 3000
......
......@@ -168,7 +168,7 @@ func DposPerf() {
dposClient := cs.(*Client)
dposClient.csState.QueryCycleBoundaryInfo(task.Cycle)
dposClient.csState.GetCBInfoByCircle(task.Cycle)
//dposClient.csState.GetCBInfoByCircle(task.Cycle)
dposClient.csState.QueryVrf(pubkey, task.Cycle)
dposClient.csState.QueryVrfs(dposClient.csState.validatorMgr.Validators, task.Cycle)
dposClient.csState.GetVrfInfoByCircle(task.Cycle, VrfQueryTypeM)
......@@ -200,12 +200,12 @@ func DposPerf() {
fmt.Println("Verify CB failed.")
}
fmt.Println("=======start GetCBInfoByCircle!=======")
//first time, not hit
dposClient.csState.GetCBInfoByCircle(task.Cycle)
time.Sleep(1 * time.Second)
//second time, hit cache
dposClient.csState.GetCBInfoByCircle(task.Cycle)
//fmt.Println("=======start GetCBInfoByCircle!=======")
////first time, not hit
//dposClient.csState.GetCBInfoByCircle(task.Cycle)
//time.Sleep(1 * time.Second)
////second time, hit cache
//dposClient.csState.GetCBInfoByCircle(task.Cycle)
fmt.Println("=======start VoteVerify!=======")
vote := generateVote(dposClient.csState)
......
......@@ -13,7 +13,7 @@ func TestTicker(t *testing.T) {
ticker.Start()
ti := timeoutInfo{
Duration: time.Second * time.Duration(2),
Duration: time.Second * time.Duration(3),
State: InitStateType,
}
fmt.Println("timeoutInfo:", ti.String())
......
This diff is collapsed.
......@@ -3,17 +3,14 @@
set -e
set -o pipefail
# shellcheck source=/dev/null
source ../dapp-test-common.sh
MAIN_HTTP=""
GAME_ID=""
PASSWD="ABCD"
HASH_VALUE=$(echo -n "ABCD1" | sha256sum | awk '{print $1}')
ACCOUNT_A="1PUiGcbsccfxW3zuvHXZBJfznziph5miAo"
PRIVA_A="56942AD84CCF4788ED6DACBC005A1D0C4F91B63BCF0C99A02BE03C8DEAE71138"
ACCOUNT_B="1EDnnePAZN48aC2hiTDzhkczfF39g1pZZX"
PRIVA_B="2116459C0EC8ED01AA0EEAE35CAC5C96F94473F7816F114873291217303F6989"
EXECTOR=""
# shellcheck source=/dev/null
......@@ -142,9 +139,44 @@ function init() {
fi
echo "gameAddr=${game_addr}"
chain33_SendToAddress "${ACCOUNT_B}" "$game_addr" 5000000000 "${MAIN_HTTP}"
local main_ip=${MAIN_HTTP//8901/8801}
#main chain import pri key
#16Z3haNPQd9wrnFDw19rtpbgnN2xynNT9f
chain33_ImportPrivkey "0xfa21dc33a6144c546537580d28d894355d1e9af7292be175808b0f5737c30849" "16Z3haNPQd9wrnFDw19rtpbgnN2xynNT9f" "game1" "${main_ip}"
#16GXRfd9xj3XYMDti4y4ht7uzwoh55gZEc
chain33_ImportPrivkey "0x213286d352b01fd740b6eaeb78a4fd316d743dd51d2f12c6789977430a41e0c7" "16GXRfd9xj3XYMDti4y4ht7uzwoh55gZEc" "game2" "$main_ip"
local ACCOUNT_A="16Z3haNPQd9wrnFDw19rtpbgnN2xynNT9f"
local ACCOUNT_B="16GXRfd9xj3XYMDti4y4ht7uzwoh55gZEc"
if [ "$ispara" == false ]; then
chain33_applyCoins "$ACCOUNT_A" 12000000000 "${main_ip}"
chain33_QueryBalance "${ACCOUNT_A}" "$main_ip"
chain33_applyCoins "$ACCOUNT_B" 12000000000 "${main_ip}"
chain33_QueryBalance "${ACCOUNT_B}" "$main_ip"
else
# tx fee
chain33_applyCoins "$ACCOUNT_A" 1000000000 "${main_ip}"
chain33_QueryBalance "${ACCOUNT_A}" "$main_ip"
chain33_applyCoins "$ACCOUNT_B" 1000000000 "${main_ip}"
chain33_QueryBalance "${ACCOUNT_B}" "$main_ip"
local para_ip="${MAIN_HTTP}"
#para chain import pri key
chain33_ImportPrivkey "0xfa21dc33a6144c546537580d28d894355d1e9af7292be175808b0f5737c30849" "16Z3haNPQd9wrnFDw19rtpbgnN2xynNT9f" "game1" "$para_ip"
chain33_ImportPrivkey "0x213286d352b01fd740b6eaeb78a4fd316d743dd51d2f12c6789977430a41e0c7" "16GXRfd9xj3XYMDti4y4ht7uzwoh55gZEc" "game2" "$para_ip"
chain33_applyCoins "$ACCOUNT_A" 12000000000 "${para_ip}"
chain33_QueryBalance "${ACCOUNT_A}" "$para_ip"
chain33_applyCoins "$ACCOUNT_B" 12000000000 "${para_ip}"
chain33_QueryBalance "${ACCOUNT_B}" "$para_ip"
fi
chain33_SendToAddress "${ACCOUNT_B}" "$game_addr" 5000000000 "${MAIN_HTTP}"
chain33_QueryExecBalance "${ACCOUNT_B}" "game" "$MAIN_HTTP"
chain33_SendToAddress "${ACCOUNT_A}" "$game_addr" 5000000000 "${MAIN_HTTP}"
chain33_QueryExecBalance "${ACCOUNT_A}" "game" "$MAIN_HTTP"
chain33_BlockWait 1 "$MAIN_HTTP"
}
......@@ -197,4 +229,4 @@ function main() {
fi
}
main "$1"
chain33_debug_function main "$1"
......@@ -11,8 +11,8 @@ source ../dapp-test-common.sh
MAIN_HTTP=""
CASE_ERR=""
guess_admin_addr=12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
guess_user1_addr=1PUiGcbsccfxW3zuvHXZBJfznziph5miAo
guess_user2_addr=1EDnnePAZN48aC2hiTDzhkczfF39g1pZZX
guess_user1_addr=1NrfEBfdFJUUqgbw5ZbHXhdew6NNQumYhM
guess_user2_addr=17tRkBrccmFiVcLPXgEceRxDzJ2WaDZumN
guess_addr=""
guess_exec=""
......@@ -134,14 +134,46 @@ init() {
guess_addr=$(curl -ksd '{"method":"Chain33.ConvertExectoAddr","params":[{"execname":"guess"}]}' ${MAIN_HTTP} | jq -r ".result")
guess_exec="guess"
fi
echo "guess_addr=$guess_addr"
local from="1PUiGcbsccfxW3zuvHXZBJfznziph5miAo"
chain33_SendToAddress "$from" "$guess_addr" 10000000000 ${MAIN_HTTP}
local main_ip=${MAIN_HTTP//8901/8801}
#main chain import pri key
#1NrfEBfdFJUUqgbw5ZbHXhdew6NNQumYhM
chain33_ImportPrivkey "0xc889d2958843fc96d4bd3f578173137d37230e580d65e9074545c61e7e9c1932" "1NrfEBfdFJUUqgbw5ZbHXhdew6NNQumYhM" "guess1" "${main_ip}"
#17tRkBrccmFiVcLPXgEceRxDzJ2WaDZumN
chain33_ImportPrivkey "0xf10c79470dc74c229c4ee73b05d14c58322b771a6c749d27824f6a59bb6c2d73" "17tRkBrccmFiVcLPXgEceRxDzJ2WaDZumN" "guess2" "$main_ip"
local guess1="1NrfEBfdFJUUqgbw5ZbHXhdew6NNQumYhM"
local guess2="17tRkBrccmFiVcLPXgEceRxDzJ2WaDZumN"
if [ "$ispara" == false ]; then
chain33_applyCoins "$guess1" 12000000000 "${main_ip}"
chain33_QueryBalance "${guess1}" "$main_ip"
chain33_applyCoins "$guess2" 12000000000 "${main_ip}"
chain33_QueryBalance "${guess2}" "$main_ip"
else
# tx fee
chain33_applyCoins "$guess1" 1000000000 "${main_ip}"
chain33_QueryBalance "${guess1}" "$main_ip"
chain33_applyCoins "$guess2" 1000000000 "${main_ip}"
chain33_QueryBalance "${guess2}" "$main_ip"
local para_ip="${MAIN_HTTP}"
#para chain import pri key
chain33_ImportPrivkey "0xc889d2958843fc96d4bd3f578173137d37230e580d65e9074545c61e7e9c1932" "1NrfEBfdFJUUqgbw5ZbHXhdew6NNQumYhM" "guess1" "$para_ip"
chain33_ImportPrivkey "0xf10c79470dc74c229c4ee73b05d14c58322b771a6c749d27824f6a59bb6c2d73" "17tRkBrccmFiVcLPXgEceRxDzJ2WaDZumN" "guess2" "$para_ip"
chain33_applyCoins "$guess1" 12000000000 "${para_ip}"
chain33_QueryBalance "${guess1}" "$para_ip"
chain33_applyCoins "$guess2" 12000000000 "${para_ip}"
chain33_QueryBalance "${guess2}" "$para_ip"
fi
from="1EDnnePAZN48aC2hiTDzhkczfF39g1pZZX"
chain33_SendToAddress "$from" "$guess_addr" 10000000000 ${MAIN_HTTP}
chain33_SendToAddress "$guess1" "$guess_addr" 10000000000 ${MAIN_HTTP}
chain33_QueryExecBalance "${guess1}" "guess" "$MAIN_HTTP"
chain33_SendToAddress "$guess2" "$guess_addr" 10000000000 ${MAIN_HTTP}
chain33_QueryExecBalance "${guess2}" "guess" "$MAIN_HTTP"
chain33_BlockWait 1 "${MAIN_HTTP}"
}
......@@ -149,8 +181,8 @@ init() {
function run_test() {
#导入地址私钥
chain33_ImportPrivkey "56942AD84CCF4788ED6DACBC005A1D0C4F91B63BCF0C99A02BE03C8DEAE71138" "1PUiGcbsccfxW3zuvHXZBJfznziph5miAo" "user1" "$MAIN_HTTP"
chain33_ImportPrivkey "2116459C0EC8ED01AA0EEAE35CAC5C96F94473F7816F114873291217303F6989" "1EDnnePAZN48aC2hiTDzhkczfF39g1pZZX" "user2" "$MAIN_HTTP"
chain33_ImportPrivkey "0xc889d2958843fc96d4bd3f578173137d37230e580d65e9074545c61e7e9c1932" "1NrfEBfdFJUUqgbw5ZbHXhdew6NNQumYhM" "user1" "$MAIN_HTTP"
chain33_ImportPrivkey "0xf10c79470dc74c229c4ee73b05d14c58322b771a6c749d27824f6a59bb6c2d73" "17tRkBrccmFiVcLPXgEceRxDzJ2WaDZumN" "user2" "$MAIN_HTTP"
chain33_ImportPrivkey "4257D8692EF7FE13C68B65D6A52F03933DB2FA5CE8FAF210B5B8B80C721CED01" "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv" "admin" "$MAIN_HTTP"
chain33_QueryBalance "${guess_admin_addr}" "$MAIN_HTTP"
......@@ -167,13 +199,13 @@ function run_test() {
guess_QueryGameByID "$eventId" 11
#用户1下注
guess_game_bet "56942AD84CCF4788ED6DACBC005A1D0C4F91B63BCF0C99A02BE03C8DEAE71138" "A"
guess_game_bet "0xc889d2958843fc96d4bd3f578173137d37230e580d65e9074545c61e7e9c1932" "A"
#查询游戏状态
guess_QueryGameByID "$eventId" 12
#用户2下注
guess_game_bet "2116459C0EC8ED01AA0EEAE35CAC5C96F94473F7816F114873291217303F6989" "B"
guess_game_bet "0xf10c79470dc74c229c4ee73b05d14c58322b771a6c749d27824f6a59bb6c2d73" "B"
#查询游戏状态
guess_QueryGameByID "$eventId" 12
......@@ -233,13 +265,13 @@ function run_test() {
guess_QueryGameByID "$eventId" 11
#用户1下注
guess_game_bet "56942AD84CCF4788ED6DACBC005A1D0C4F91B63BCF0C99A02BE03C8DEAE71138" "A"
guess_game_bet "0xc889d2958843fc96d4bd3f578173137d37230e580d65e9074545c61e7e9c1932" "A"
#查询游戏状态
guess_QueryGameByID "$eventId" 12
#用户2下注
guess_game_bet "2116459C0EC8ED01AA0EEAE35CAC5C96F94473F7816F114873291217303F6989" "B"
guess_game_bet "0xf10c79470dc74c229c4ee73b05d14c58322b771a6c749d27824f6a59bb6c2d73" "B"
#查询游戏状态
guess_QueryGameByID "$eventId" 12
......@@ -258,13 +290,13 @@ function run_test() {
guess_QueryGameByID "$eventId" 11
#用户1下注
guess_game_bet "56942AD84CCF4788ED6DACBC005A1D0C4F91B63BCF0C99A02BE03C8DEAE71138" "A"
guess_game_bet "0xc889d2958843fc96d4bd3f578173137d37230e580d65e9074545c61e7e9c1932" "A"
#查询游戏状态
guess_QueryGameByID "$eventId" 12
#用户2下注
guess_game_bet "2116459C0EC8ED01AA0EEAE35CAC5C96F94473F7816F114873291217303F6989" "B"
guess_game_bet "0xf10c79470dc74c229c4ee73b05d14c58322b771a6c749d27824f6a59bb6c2d73" "B"
#查询游戏状态
guess_QueryGameByID "$eventId" 12
......@@ -304,4 +336,4 @@ function main() {
echo "=========== # guess rpc test end============="
}
main "$1"
chain33_debug_function main "$1"
......@@ -5,8 +5,8 @@ set -o pipefail
MAIN_HTTP=""
addr_A=1PUiGcbsccfxW3zuvHXZBJfznziph5miAo
addr_B=1EDnnePAZN48aC2hiTDzhkczfF39g1pZZX
addr_A=19vpbRuz2XtKopQS2ruiVuVZeRdLd5n4t3
addr_B=1FcofeCgU1KYbB8dSa7cV2wjAF2RpMuUQD
# shellcheck source=/dev/null
source ../dapp-test-common.sh
......@@ -24,7 +24,7 @@ hashlock_lock() {
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
chain33_SignRawTx "$tx" "56942AD84CCF4788ED6DACBC005A1D0C4F91B63BCF0C99A02BE03C8DEAE71138" ${MAIN_HTTP}
chain33_SignRawTx "$tx" "0x1089b7f980fc467f029b7ae301249b36e3b582c911b1af1a24616c83b3563dcb" ${MAIN_HTTP}
#echo "txHash ${txhash}"
echo "========== # hashlock lock tx end =========="
......@@ -44,7 +44,7 @@ hashlock_send() {
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
chain33_SignRawTx "$tx" "2116459C0EC8ED01AA0EEAE35CAC5C96F94473F7816F114873291217303F6989" ${MAIN_HTTP}
chain33_SignRawTx "$tx" "0xb76a398c3901dfe5c7335525da88fda4df24c11ad11af4332f00c0953cc2910f" ${MAIN_HTTP}
#echo "txHash ${txhash}"
echo "========== # hashlock send tx end =========="
......@@ -63,7 +63,7 @@ hashlock_unlock() {
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
chain33_SignRawTx "$tx" "56942AD84CCF4788ED6DACBC005A1D0C4F91B63BCF0C99A02BE03C8DEAE71138" ${MAIN_HTTP}
chain33_SignRawTx "$tx" "0x1089b7f980fc467f029b7ae301249b36e3b582c911b1af1a24616c83b3563dcb" ${MAIN_HTTP}
#echo "txHash ${txhash}"
echo "========== # hashlock unlock tx end =========="
......@@ -79,11 +79,45 @@ init() {
hashlock_addr=$(curl -ksd '{"method":"Chain33.ConvertExectoAddr","params":[{"execname":"hashlock"}]}' ${MAIN_HTTP} | jq -r ".result")
fi
local from="1PUiGcbsccfxW3zuvHXZBJfznziph5miAo"
chain33_SendToAddress "$from" "$hashlock_addr" 10000000000 ${MAIN_HTTP}
local main_ip=${MAIN_HTTP//8901/8801}
#main chain import pri key
#19vpbRuz2XtKopQS2ruiVuVZeRdLd5n4t3
chain33_ImportPrivkey "0x1089b7f980fc467f029b7ae301249b36e3b582c911b1af1a24616c83b3563dcb" "19vpbRuz2XtKopQS2ruiVuVZeRdLd5n4t3" "hashlock1" "${main_ip}"
#1FcofeCgU1KYbB8dSa7cV2wjAF2RpMuUQD
chain33_ImportPrivkey "0xb76a398c3901dfe5c7335525da88fda4df24c11ad11af4332f00c0953cc2910f" "1FcofeCgU1KYbB8dSa7cV2wjAF2RpMuUQD" "hashlock2" "$main_ip"
local hashlock1="19vpbRuz2XtKopQS2ruiVuVZeRdLd5n4t3"
local hashlock2="1FcofeCgU1KYbB8dSa7cV2wjAF2RpMuUQD"
if [ "$ispara" == false ]; then
chain33_applyCoins "$hashlock1" 12000000000 "${main_ip}"
chain33_QueryBalance "${hashlock1}" "$main_ip"
chain33_applyCoins "$hashlock2" 12000000000 "${main_ip}"
chain33_QueryBalance "${hashlock2}" "$main_ip"
else
# tx fee
chain33_applyCoins "$hashlock1" 1000000000 "${main_ip}"
chain33_QueryBalance "${hashlock1}" "$main_ip"
chain33_applyCoins "$hashlock2" 1000000000 "${main_ip}"
chain33_QueryBalance "${hashlock2}" "$main_ip"
local para_ip="${MAIN_HTTP}"
#para chain import pri key
chain33_ImportPrivkey "0x1089b7f980fc467f029b7ae301249b36e3b582c911b1af1a24616c83b3563dcb" "19vpbRuz2XtKopQS2ruiVuVZeRdLd5n4t3" "hashlock1" "$para_ip"
chain33_ImportPrivkey "0xb76a398c3901dfe5c7335525da88fda4df24c11ad11af4332f00c0953cc2910f" "1FcofeCgU1KYbB8dSa7cV2wjAF2RpMuUQD" "hashlock2" "$para_ip"
chain33_applyCoins "$hashlock1" 12000000000 "${para_ip}"
chain33_QueryBalance "${hashlock1}" "$para_ip"
chain33_applyCoins "$hashlock2" 12000000000 "${para_ip}"
chain33_QueryBalance "${hashlock2}" "$para_ip"
fi
chain33_SendToAddress "$hashlock1" "$hashlock_addr" 10000000000 ${MAIN_HTTP}
chain33_QueryExecBalance "${hashlock1}" "hashlock" "$MAIN_HTTP"
chain33_SendToAddress "$hashlock2" "$hashlock_addr" 10000000000 ${MAIN_HTTP}
chain33_QueryExecBalance "${hashlock2}" "hashlock" "$MAIN_HTTP"
from="1EDnnePAZN48aC2hiTDzhkczfF39g1pZZX"
chain33_SendToAddress "$from" "$hashlock_addr" 10000000000 ${MAIN_HTTP}
chain33_BlockWait 1 "${MAIN_HTTP}"
}
......@@ -99,7 +133,7 @@ function run_test() {
hashlock_lock "aef"
chain33_QueryBalance "$addr_A" "${MAIN_HTTP}"
sleep 75
sleep 5
hashlock_unlock "aef"
chain33_BlockWait 1 ${MAIN_HTTP}
chain33_QueryBalance "$addr_A" "${MAIN_HTTP}"
......@@ -121,4 +155,4 @@ function main() {
fi
}
main "$1"
chain33_debug_function main "$1"
This diff is collapsed.
......@@ -19,7 +19,7 @@ pokerbull_PlayRawTx() {
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
chain33_SignRawTx "$tx" "56942AD84CCF4788ED6DACBC005A1D0C4F91B63BCF0C99A02BE03C8DEAE71138" ${MAIN_HTTP}
chain33_SignRawTx "$tx" "0x0316d5e33e7bce2455413156cb95209f8c641af352ee5d648c647f24383e4d94" ${MAIN_HTTP}
echo "========== # pokerbull play tx end =========="
chain33_BlockWait 1 ${MAIN_HTTP}
......@@ -35,7 +35,7 @@ pokerbull_QuitRawTx() {
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
chain33_SignRawTx "$tx" "56942AD84CCF4788ED6DACBC005A1D0C4F91B63BCF0C99A02BE03C8DEAE71138" ${MAIN_HTTP}
chain33_SignRawTx "$tx" "0x0316d5e33e7bce2455413156cb95209f8c641af352ee5d648c647f24383e4d94" ${MAIN_HTTP}
echo "========== # pokerbull quit tx end =========="
chain33_BlockWait 1 "${MAIN_HTTP}"
......@@ -51,7 +51,7 @@ pokerbull_ContinueRawTx() {
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
chain33_SignRawTx "$tx" "2116459C0EC8ED01AA0EEAE35CAC5C96F94473F7816F114873291217303F6989" ${MAIN_HTTP}
chain33_SignRawTx "$tx" "0xa26038cbdd9e6fbfb85f2c3d032254755e75252b9edccbecc16d9ba117d96705" ${MAIN_HTTP}
echo "========== # pokerbull continue tx end =========="
chain33_BlockWait 1 "${MAIN_HTTP}"
......@@ -67,7 +67,7 @@ pokerbull_StartRawTx() {
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
chain33_SignRawTx "$tx" "56942AD84CCF4788ED6DACBC005A1D0C4F91B63BCF0C99A02BE03C8DEAE71138" ${MAIN_HTTP}
chain33_SignRawTx "$tx" "0x0316d5e33e7bce2455413156cb95209f8c641af352ee5d648c647f24383e4d94" ${MAIN_HTTP}
GAME_ID=$RAW_TX_HASH
echo "========== # pokerbull start tx end =========="
......@@ -84,7 +84,7 @@ pokerbull_QueryResult() {
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
data=$(curl -ksd '{"method":"Chain33.Query","params":[{"execer":"pokerbull","funcName":"QueryGameByAddr","payload":{"addr":"1PUiGcbsccfxW3zuvHXZBJfznziph5miAo"}}]}' ${MAIN_HTTP} | jq -r ".result")
data=$(curl -ksd '{"method":"Chain33.Query","params":[{"execer":"pokerbull","funcName":"QueryGameByAddr","payload":{"addr":"14VkqML8YTRK4o15Cf97CQhpbnRUa6sJY4"}}]}' ${MAIN_HTTP} | jq -r ".result")
[ "$data" != null ]
echo_rst "$FUNCNAME" "$?"
......@@ -103,11 +103,45 @@ init() {
pokerbull_addr=$(curl -ksd '{"method":"Chain33.ConvertExectoAddr","params":[{"execname":"pokerbull"}]}' ${MAIN_HTTP} | jq -r ".result")
fi
local from="1PUiGcbsccfxW3zuvHXZBJfznziph5miAo"
chain33_SendToAddress "$from" "$pokerbull_addr" 10000000000 ${MAIN_HTTP}
local main_ip=${MAIN_HTTP//8901/8801}
#main chain import pri key
#14VkqML8YTRK4o15Cf97CQhpbnRUa6sJY4
chain33_ImportPrivkey "0x0316d5e33e7bce2455413156cb95209f8c641af352ee5d648c647f24383e4d94" "14VkqML8YTRK4o15Cf97CQhpbnRUa6sJY4" "pokerbull1" "${main_ip}"
#1MuVM87DLigWhJxLJKvghTa1po4ZdWtDv1
chain33_ImportPrivkey "0xa26038cbdd9e6fbfb85f2c3d032254755e75252b9edccbecc16d9ba117d96705" "1MuVM87DLigWhJxLJKvghTa1po4ZdWtDv1" "pokerbull2" "$main_ip"
local pokerbull1="14VkqML8YTRK4o15Cf97CQhpbnRUa6sJY4"
local pokerbull2="1MuVM87DLigWhJxLJKvghTa1po4ZdWtDv1"
if [ "$ispara" == false ]; then
chain33_applyCoins "$pokerbull1" 12000000000 "${main_ip}"
chain33_QueryBalance "${pokerbull1}" "$main_ip"
chain33_applyCoins "$pokerbull2" 12000000000 "${main_ip}"
chain33_QueryBalance "${pokerbull2}" "$main_ip"
else
# tx fee
chain33_applyCoins "$pokerbull1" 1000000000 "${main_ip}"
chain33_QueryBalance "${pokerbull1}" "$main_ip"
chain33_applyCoins "$pokerbull2" 1000000000 "${main_ip}"
chain33_QueryBalance "${pokerbull2}" "$main_ip"
local para_ip="${MAIN_HTTP}"
#para chain import pri key
chain33_ImportPrivkey "0x0316d5e33e7bce2455413156cb95209f8c641af352ee5d648c647f24383e4d94" "14VkqML8YTRK4o15Cf97CQhpbnRUa6sJY4" "pokerbull1" "$para_ip"
chain33_ImportPrivkey "0xa26038cbdd9e6fbfb85f2c3d032254755e75252b9edccbecc16d9ba117d96705" "1MuVM87DLigWhJxLJKvghTa1po4ZdWtDv1" "pokerbull2" "$para_ip"
chain33_applyCoins "$pokerbull1" 12000000000 "${para_ip}"
chain33_QueryBalance "${pokerbull1}" "$para_ip"
chain33_applyCoins "$pokerbull2" 12000000000 "${para_ip}"
chain33_QueryBalance "${pokerbull2}" "$para_ip"
fi
chain33_SendToAddress "$pokerbull1" "$pokerbull_addr" 10000000000 ${MAIN_HTTP}
chain33_QueryExecBalance "${pokerbull1}" "pokerbull" "$MAIN_HTTP"
chain33_SendToAddress "$pokerbull2" "$pokerbull_addr" 10000000000 ${MAIN_HTTP}
chain33_QueryExecBalance "${pokerbull2}" "pokerbull" "$MAIN_HTTP"
from="1EDnnePAZN48aC2hiTDzhkczfF39g1pZZX"
chain33_SendToAddress "$from" "$pokerbull_addr" 10000000000 ${MAIN_HTTP}
chain33_BlockWait 1 "${MAIN_HTTP}"
}
......@@ -140,4 +174,4 @@ function main() {
fi
}
main "$1"
chain33_debug_function main "$1"
......@@ -260,4 +260,4 @@ function main() {
}
set -x
main "$1"
chain33_debug_function main "$1"
......@@ -17,7 +17,6 @@ ticket_CreateBindMiner() {
returnAddr=$2
returnPriv=$3
amount=$4
set -x
resp=$(curl -ksd '{"method":"ticket.CreateBindMiner","params":[{"bindAddr":"'"$minerAddr"'", "originAddr":"'"$returnAddr"'", "amount":'"$amount"', "checkBalance":true}]}' -H 'content-type:text/plain;' ${MAIN_HTTP})
ok=$(echo "${resp}" | jq -r ".error")
[[ $ok == null ]]
......@@ -26,25 +25,20 @@ ticket_CreateBindMiner() {
#发送交易
rawTx=$(echo "${resp}" | jq -r ".result.txHex")
chain33_SignRawTx "${rawTx}" "${returnPriv}" ${MAIN_HTTP}
set +x
}
ticket_SetAutoMining() {
flag=$1
set -x
resp=$(curl -ksd '{"method":"ticket.SetAutoMining","params":[{"flag":'"$flag"'}]}' -H 'content-type:text/plain;' ${MAIN_HTTP})
ok=$(jq '(.error|not) and (.result.isOK == true)' <<<"$resp")
set +x
[[ $ok == true ]]
rst=$?
echo_rst "$FUNCNAME" "$rst"
}
ticket_GetTicketCount() {
set -x
resp=$(curl -ksd '{"method":"ticket.GetTicketCount","params":[{}]}' -H 'content-type:text/plain;' ${MAIN_HTTP})
ok=$(jq '(.error|not) and (.result > 0)' <<<"$resp")
set +x
[[ $ok == true ]]
rst=$?
echo_rst "$FUNCNAME" "$rst"
......@@ -52,10 +46,8 @@ ticket_GetTicketCount() {
ticket_CloseTickets() {
addr=$1
set -x
resp=$(curl -ksd '{"method":"ticket.CloseTickets","params":[{"minerAddress":"'"$addr"'"}]}' -H 'content-type:text/plain;' ${MAIN_HTTP})
ok=$(jq '(.error|not) and (.result.hashes | length > 0)' <<<"$resp")
set +x
ok=$(jq '(.error|not)' <<<"$resp")
[[ $ok == true ]]
rst=$?
echo_rst "$FUNCNAME" "$rst"
......@@ -65,13 +57,10 @@ ticket_TicketInfos() {
tid=$1
minerAddr=$2
returnAddr=$3
status=$4
execer="ticket"
funcName="TicketInfos"
set -x
resp=$(curl -ksd '{"method":"Chain33.Query","params":[{"execer":"'"$execer"'","funcName":"'"$funcName"'","payload":{"ticketIds":["'"$tid"'"]}}]}' -H 'content-type:text/plain;' ${MAIN_HTTP})
ok=$(jq '(.error|not) and (.result.tickets | length > 0) and (.result.tickets[0].minerAddress == "'"$minerAddr"'") and (.result.tickets[0].returnAddress == "'"$returnAddr"'") and (.result.tickets[0].status == '"$status"')' <<<"$resp")
set +x
ok=$(jq '(.error|not) and (.result.tickets | length > 0) and (.result.tickets[0].minerAddress == "'"$minerAddr"'") and (.result.tickets[0].returnAddress == "'"$returnAddr"'")' <<<"$resp")
[[ $ok == true ]]
rst=$?
echo_rst "$FUNCNAME" "$rst"
......@@ -84,19 +73,15 @@ ticket_TicketList() {
execer="ticket"
funcName="TicketList"
resp=$(curl -ksd '{"method":"Chain33.Query","params":[{"execer":"'"$execer"'","funcName":"'"$funcName"'","payload":{"addr":"'"$minerAddr"'", "status":'"$status"'}}]}' -H 'content-type:text/plain;' ${MAIN_HTTP})
set -x
ok=$(jq '(.error|not) and (.result.tickets | length > 0) and (.result.tickets[0].minerAddress == "'"$minerAddr"'") and (.result.tickets[0].returnAddress == "'"$returnAddr"'") and (.result.tickets[0].status == '"$status"')' <<<"$resp")
set +x
ticket0=$(echo "${resp}" | jq -r ".result.tickets[0]")
echo -e "######\\n ticket[0] is $ticket0) \\n######"
[[ $ok == true ]]
rst=$?
echo_rst "$FUNCNAME" "$rst"
if [[ $status == 1 ]]; then
ticket0=$(echo "${resp}" | jq -r ".result.tickets[0]")
echo -e "######\\n ticket[0] is $ticket0) \\n######"
ticketId=$(echo "${resp}" | jq -r ".result.tickets[0].ticketId")
echo -e "######\\n ticketId is $ticketId \\n######"
fi
}
ticket_MinerAddress() {
......@@ -104,10 +89,8 @@ ticket_MinerAddress() {
minerAddr=$2
execer="ticket"
funcName="MinerAddress"
set -x
resp=$(curl -ksd '{"method":"Chain33.Query","params":[{"execer":"'"$execer"'","funcName":"'"$funcName"'","payload":{"data":"'"$returnAddr"'"}}]}' -H 'content-type:text/plain;' ${MAIN_HTTP})
ok=$(jq '(.error|not) and (.result.data == "'"$minerAddr"'")' <<<"$resp")
set +x
[[ $ok == true ]]
rst=$?
echo_rst "$FUNCNAME" "$rst"
......@@ -118,10 +101,8 @@ ticket_MinerSourceList() {
returnAddr=$2
execer="ticket"
funcName="MinerSourceList"
set -x
resp=$(curl -ksd '{"method":"Chain33.Query","params":[{"execer":"'"$execer"'","funcName":"'"$funcName"'","payload":{"data":"'"$minerAddr"'"}}]}' -H 'content-type:text/plain;' ${MAIN_HTTP})
ok=$(jq '(.error|not) and (.result.datas | length > 0) and (.result.datas[0] == "'"$returnAddr"'")' <<<"$resp")
set +x
[[ $ok == true ]]
rst=$?
echo_rst "$FUNCNAME" "$rst"
......@@ -132,10 +113,8 @@ ticket_RandNumHash() {
blockNum=$2
execer="ticket"
funcName="RandNumHash"
set -x
resp=$(curl -ksd '{"method":"Chain33.Query","params":[{"execer":"'"$execer"'","funcName":"'"$funcName"'","payload":{"hash":"'"$hash"'", "blockNum":'"$blockNum"'}}]}' -H 'content-type:text/plain;' ${MAIN_HTTP})
ok=$(jq '(.error|not) and (.result.hash != "")' <<<"$resp")
set +x
[[ $ok == true ]]
rst=$?
echo_rst "$FUNCNAME" "$rst"
......@@ -151,21 +130,19 @@ function run_testcases() {
returnAddr2="1NNaYHkscJaLJ2wUrFNeh6cQXBS4TrFYeB"
returnPriv2="0x794443611e7369a57b078881445b93b754cbc9b9b8f526535ab9c6d21d29203d"
set -x
chain33_SendToAddress "${minerAddr1}" "${minerAddr2}" 100000000 "${MAIN_HTTP}"
chain33_SendToAddress "${minerAddr1}" "${returnAddr2}" $((price + 5 * 100000000)) "${MAIN_HTTP}"
set +x
ticket_SetAutoMining 0
ticket_GetTicketCount
ticket_TicketList "${minerAddr1}" "${returnAddr1}" 1
ticket_TicketInfos "${ticketId}" "${minerAddr1}" "${returnAddr1}" 1
ticket_TicketInfos "${ticketId}" "${minerAddr1}" "${returnAddr1}"
#购票
ticket_CreateBindMiner "${minerAddr2}" "${returnAddr2}" "${returnPriv2}" ${price}
ticket_MinerAddress "${returnAddr2}" "${minerAddr2}"
ticket_MinerSourceList "${minerAddr2}" "${returnAddr2}"
#关闭
ticket_CloseTickets "${minerAddr2}"
ticket_CloseTickets "${minerAddr1}"
chain33_LastBlockhash "${MAIN_HTTP}"
ticket_RandNumHash "${LAST_BLOCK_HASH}" 5
......@@ -193,4 +170,4 @@ function main() {
echo "=========== # ticket rpc test end============="
}
main "$1"
chain33_debug_function main "$1"
#!/usr/bin/env bash
# shellcheck disable=SC2128
# shellcheck source=/dev/null
source ../dapp-test-common.sh
MAIN_HTTP=""
CASE_ERR=""
tokenAddr="1Q8hGLfoGe63efeWa8fJ4Pnukhkngt6poK"
recvAddr="14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
recvAddr="1CLrYLNhHfCfMUV7mtdqhbMSF6vGmtTvzq"
superManager="0xc34b5d9d44ac7b754806f761d3d4d2c4fe5214f6b074c19f069c4f5c2a29c8cc"
tokenSymbol="ABCDE"
token_addr=""
execName="token"
txHash=""
#color
RED='\033[1;31m'
......@@ -25,77 +29,6 @@ function echo_rst() {
fi
}
function chain33_ImportPrivkey() {
local pri=$2
local acc=$3
local req='"method":"Chain33.ImportPrivkey", "params":[{"privkey":"'"$pri"'", "label":"tokenAddr"}]'
echo "#request: $req"
resp=$(curl -ksd "{$req}" "$1")
echo "#response: $resp"
ok=$(jq '(.error|not) and (.result.label=="tokenAddr") and (.result.acc.addr == "'"$acc"'")' <<<"$resp")
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
}
function Chain33_SendToAddress() {
local from="$1"
local to="$2"
local amount=$3
local req='"method":"Chain33.SendToAddress", "params":[{"from":"'"$from"'","to":"'"$to"'", "amount":'"$amount"', "note":"test\n"}]'
# echo "#request: $req"
resp=$(curl -ksd "{$req}" "${MAIN_HTTP}")
# echo "#response: $resp"
ok=$(jq '(.error|not) and (.result.hash|length==66)' <<<"$resp")
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
hash=$(jq '(.result.hash)' <<<"$resp")
echo "hash=$hash"
# query_tx "$hash"
}
function chain33_unlock() {
ok=$(curl -k -s --data-binary '{"jsonrpc":"2.0","id":2,"method":"Chain33.UnLock","params":[{"passwd":"1314fuzamei","timeout":0}]}' -H 'content-type:text/plain;' ${MAIN_HTTP} | jq -r ".result.isOK")
[ "$ok" == true ]
rst=$?
echo_rst "$FUNCNAME" "$rst"
}
function block_wait() {
local req='"method":"Chain33.GetLastHeader","params":[]'
cur_height=$(curl -ksd "{$req}" ${MAIN_HTTP} | jq ".result.height")
expect=$((cur_height + ${1}))
local count=0
while true; do
new_height=$(curl -ksd "{$req}" ${MAIN_HTTP} | jq ".result.height")
if [ "${new_height}" -ge "${expect}" ]; then
break
fi
count=$((count + 1))
sleep 1
done
echo "wait new block $count s, cur height=$expect,old=$cur_height"
}
function signRawTx() {
unsignedTx=$1
addr=$2
signedTx=$(curl -s --data-binary '{"jsonrpc":"2.0","id":2,"method":"Chain33.SignRawTx","params":[{"addr":"'"${addr}"'","txHex":"'"${unsignedTx}"'","expire":"120s"}]}' -H 'content-type:text/plain;' ${MAIN_HTTP} | jq -r ".result")
if [ "$signedTx" == "null" ]; then
return 1
else
return 0
fi
}
function sendSignedTx() {
txHash=$(curl -s --data-binary '{"jsonrpc":"2.0","id":2,"method":"Chain33.SendTransaction","params":[{"token":"","data":"'"${signedTx}"'"}]}' -H 'content-type:text/plain;' ${MAIN_HTTP} | jq -r ".result")
if [ "$txHash" == "null" ]; then
return 1
else
return 0
fi
}
# 查询交易的执行结果
# 根据传入的规则,校验查询的结果 (参数1: 校验规则 参数2: 预期匹配结果)
function queryTransaction() {
......@@ -113,22 +46,45 @@ function queryTransaction() {
function init() {
ispara=$(echo '"'"${MAIN_HTTP}"'"' | jq '.|contains("8901")')
echo "ipara=$ispara"
chain33_ImportPrivkey "${MAIN_HTTP}" "${superManager}" "${tokenAddr}"
chain33_ImportPrivkey "${superManager}" "${tokenAddr}" "tokenAddr" "${MAIN_HTTP}"
local main_ip=${MAIN_HTTP//8901/8801}
#main chain import pri key
#1CLrYLNhHfCfMUV7mtdqhbMSF6vGmtTvzq
chain33_ImportPrivkey "0x882c963ce2afbedc2353cb417492aa9e889becd878a10f2529fc9e6c3b756128" "1CLrYLNhHfCfMUV7mtdqhbMSF6vGmtTvzq" "token1" "${main_ip}"
local ACCOUNT_A="1CLrYLNhHfCfMUV7mtdqhbMSF6vGmtTvzq"
if [ "$ispara" == false ]; then
chain33_applyCoins "$ACCOUNT_A" 12000000000 "${main_ip}"
chain33_QueryBalance "${ACCOUNT_A}" "$main_ip"
else
# tx fee
chain33_applyCoins "$ACCOUNT_A" 1000000000 "${main_ip}"
chain33_QueryBalance "${ACCOUNT_A}" "$main_ip"
local para_ip="${MAIN_HTTP}"
#para chain import pri key
chain33_ImportPrivkey "0x882c963ce2afbedc2353cb417492aa9e889becd878a10f2529fc9e6c3b756128" "1CLrYLNhHfCfMUV7mtdqhbMSF6vGmtTvzq" "token1" "$para_ip"
chain33_applyCoins "$ACCOUNT_A" 12000000000 "${para_ip}"
chain33_QueryBalance "${ACCOUNT_A}" "$para_ip"
fi
if [ "$ispara" == true ]; then
execName="user.p.para.token"
token_addr=$(curl -ksd '{"method":"Chain33.ConvertExectoAddr","params":[{"execname":"user.p.para.token"}]}' ${MAIN_HTTP} | jq -r ".result")
Chain33_SendToAddress "$recvAddr" "$tokenAddr" 100000000000
block_wait 2
Chain33_SendToAddress "$tokenAddr" "$token_addr" 1000000000
block_wait 2
chain33_SendToAddress "$recvAddr" "$tokenAddr" 10000000000 "${MAIN_HTTP}"
chain33_BlockWait 2 "${MAIN_HTTP}"
chain33_SendToAddress "$tokenAddr" "$token_addr" 1000000000 "${MAIN_HTTP}"
chain33_BlockWait 2 "${MAIN_HTTP}"
else
token_addr=$(curl -ksd '{"method":"Chain33.ConvertExectoAddr","params":[{"execname":"token"}]}' ${MAIN_HTTP} | jq -r ".result")
from="12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
Chain33_SendToAddress "$from" "$tokenAddr" 10000000000
block_wait 2
Chain33_SendToAddress "$tokenAddr" "$token_addr" 1000000000
block_wait 2
chain33_SendToAddress "$from" "$tokenAddr" 10000000000 "${MAIN_HTTP}"
chain33_BlockWait 2 "${MAIN_HTTP}"
chain33_SendToAddress "$tokenAddr" "$token_addr" 1000000000 "${MAIN_HTTP}"
chain33_BlockWait 2 "${MAIN_HTTP}"
fi
echo "token=$token_addr"
updateConfig
......@@ -141,13 +97,8 @@ function updateConfig() {
return
fi
signRawTx "${unsignedTx}" "${tokenAddr}"
echo_rst "update config signRawTx" "$?"
sendSignedTx
echo_rst "update config sendSignedTx" "$?"
block_wait 2
chain33_SignRawTx "${unsignedTx}" "${superManager}" "${MAIN_HTTP}"
txHash=$RAW_TX_HASH
queryTransaction ".error | not" "true"
echo_rst "update config queryExecRes" "$?"
......@@ -159,13 +110,8 @@ function token_preCreate() {
return
fi
signRawTx "${unsignedTx}" "${tokenAddr}"
echo_rst "token preCreate signRawTx" "$?"
sendSignedTx
echo_rst "token preCreate sendSignedTx" "$?"
block_wait 2
chain33_SignRawTx "${unsignedTx}" "${superManager}" "${MAIN_HTTP}"
txHash=$RAW_TX_HASH
queryTransaction ".error | not" "true"
echo_rst "token preCreate queryExecRes" "$?"
......@@ -186,13 +132,8 @@ function token_finish() {
return
fi
signRawTx "${unsignedTx}" "${tokenAddr}"
echo_rst "token finish signRawTx" "$?"
sendSignedTx
echo_rst "token finish sendSignedTx" "$?"
block_wait 2
chain33_SignRawTx "${unsignedTx}" "${superManager}" "${MAIN_HTTP}"
txHash=$RAW_TX_HASH
queryTransaction ".error | not" "true"
echo_rst "token finish queryExecRes" "$?"
......@@ -252,13 +193,8 @@ function token_burn() {
return
fi
signRawTx "${unsignedTx}" "${tokenAddr}"
echo_rst "token burn signRawTx" "$?"
sendSignedTx
echo_rst "token burn sendSignedTx" "$?"
block_wait 2
chain33_SignRawTx "${unsignedTx}" "${superManager}" "${MAIN_HTTP}"
txHash=$RAW_TX_HASH
queryTransaction ".error | not" "true"
echo_rst "token burn queryExecRes" "$?"
......@@ -271,13 +207,8 @@ function token_mint() {
return
fi
signRawTx "${unsignedTx}" "${tokenAddr}"
echo_rst "token mint signRawTx" "$?"
sendSignedTx
echo_rst "token mint sendSignedTx" "$?"
block_wait 2
chain33_SignRawTx "${unsignedTx}" "${superManager}" "${MAIN_HTTP}"
txHash=$RAW_TX_HASH
queryTransaction ".error | not" "true"
echo_rst "token mint queryExecRes" "$?"
......@@ -289,13 +220,8 @@ function token_transfer() {
return
fi
signRawTx "${unsignedTx}" "${tokenAddr}"
echo_rst "token transfer signRawTx" "$?"
sendSignedTx
echo_rst "token transfer sendSignedTx" "$?"
block_wait 2
chain33_SignRawTx "${unsignedTx}" "${superManager}" "${MAIN_HTTP}"
txHash=$RAW_TX_HASH
queryTransaction ".error | not" "true"
echo_rst "token transfer queryExecRes" "$?"
......@@ -308,13 +234,8 @@ function token_sendExec() {
return
fi
signRawTx "${unsignedTx}" "${tokenAddr}"
echo_rst "token sendExec signRawTx" "$?"
sendSignedTx
echo_rst "token sendExec sendSignedTx" "$?"
block_wait 2
chain33_SignRawTx "${unsignedTx}" "${superManager}" "${MAIN_HTTP}"
txHash=$RAW_TX_HASH
queryTransaction ".error | not" "true"
echo_rst "token sendExec queryExecRes" "$?"
......@@ -327,13 +248,8 @@ function token_withdraw() {
return
fi
signRawTx "${unsignedTx}" "${tokenAddr}"
echo_rst "token withdraw signRawTx" "$?"
sendSignedTx
echo_rst "token withdraw sendSignedTx" "$?"
block_wait 2
chain33_SignRawTx "${unsignedTx}" "${superManager}" "${MAIN_HTTP}"
txHash=$RAW_TX_HASH
queryTransaction ".error | not" "true"
echo_rst "token withdraw queryExecRes" "$?"
......@@ -375,4 +291,4 @@ function main() {
fi
}
main "$1"
chain33_debug_function main "$1"
......@@ -8,7 +8,7 @@ MAIN_HTTP=""
CASE_ERR=""
trade_addr=""
tradeAddr="12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
tradeBuyerAddr="14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
tradeBuyerAddr="1CvLe1qNaC7tCf5xmfAqJ9UJkMhtmhUKNg"
tokenSymbol="TOKEN"
#color
......@@ -132,7 +132,7 @@ function trade_createBuyTx() {
return
fi
chain33_SignRawTx "${unsignedTx}" "0xCC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944" "${MAIN_HTTP}"
chain33_SignRawTx "${unsignedTx}" "0xaeef1ad76d43a2056d0dcb57d5bf1ba96471550614ab9e7f611ef9c5ca403f42" "${MAIN_HTTP}"
queryTransaction ".error | not" "true"
echo_rst "trade createBuyTx queryExecRes" "$?"
......@@ -200,7 +200,7 @@ function trade_buyLimit() {
return
fi
chain33_SignRawTx "${unsignedTx}" "CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944" "${MAIN_HTTP}"
chain33_SignRawTx "${unsignedTx}" "0xaeef1ad76d43a2056d0dcb57d5bf1ba96471550614ab9e7f611ef9c5ca403f42" "${MAIN_HTTP}"
queryTransaction ".error | not" "true"
echo_rst "trade buyLimit queryExecRes" "$?"
......@@ -278,7 +278,29 @@ function init() {
token_addr=$(curl -ksd '{"method":"Chain33.ConvertExectoAddr","params":[{"execname":"'"${tokenExecName}"'"}]}' ${MAIN_HTTP} | jq -r ".result")
fi
chain33_SendToAddress "$tradeAddr" "$tradeBuyerAddr" 10000000000 "${MAIN_HTTP}"
local main_ip=${MAIN_HTTP//8901/8801}
#main chain import pri key
#1CvLe1qNaC7tCf5xmfAqJ9UJkMhtmhUKNg
chain33_ImportPrivkey "0xaeef1ad76d43a2056d0dcb57d5bf1ba96471550614ab9e7f611ef9c5ca403f42" "1CvLe1qNaC7tCf5xmfAqJ9UJkMhtmhUKNg" "trade1" "${main_ip}"
local ACCOUNT_A="1CvLe1qNaC7tCf5xmfAqJ9UJkMhtmhUKNg"
if [ "$ispara" == false ]; then
chain33_applyCoins "$ACCOUNT_A" 12000000000 "${main_ip}"
chain33_QueryBalance "${ACCOUNT_A}" "$main_ip"
else
# tx fee
chain33_applyCoins "$ACCOUNT_A" 1000000000 "${main_ip}"
chain33_QueryBalance "${ACCOUNT_A}" "$main_ip"
local para_ip="${MAIN_HTTP}"
#para chain import pri key
chain33_ImportPrivkey "0xaeef1ad76d43a2056d0dcb57d5bf1ba96471550614ab9e7f611ef9c5ca403f42" "1CvLe1qNaC7tCf5xmfAqJ9UJkMhtmhUKNg" "trade1" "$para_ip"
chain33_applyCoins "$ACCOUNT_A" 12000000000 "${para_ip}"
chain33_QueryBalance "${ACCOUNT_A}" "$para_ip"
fi
chain33_SendToAddress "$tradeAddr" "$trade_addr" 10000000000 "${MAIN_HTTP}"
chain33_SendToAddress "$tradeAddr" "$token_addr" 10000000000 "${MAIN_HTTP}"
chain33_BlockWait 2 "${MAIN_HTTP}"
......@@ -293,7 +315,7 @@ function init() {
token_balance
token_transfer "${tradeBuyerAddr}"
token_sendExec "0x4257d8692ef7fe13c68b65d6a52f03933db2fa5ce8faf210b5b8b80c721ced01"
token_sendExec "CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944 "
token_sendExec "0xaeef1ad76d43a2056d0dcb57d5bf1ba96471550614ab9e7f611ef9c5ca403f42 "
}
function run_test() {
......@@ -332,4 +354,4 @@ function main() {
fi
}
main "$1"
chain33_debug_function main "$1"
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