Commit 344c2dee authored by yingqiumin@126.com's avatar yingqiumin@126.com

finish rpc test improve

parent e6331519
...@@ -25,16 +25,25 @@ echo_rst() { ...@@ -25,16 +25,25 @@ echo_rst() {
} }
http_req() { http_req() {
# echo "request="$1" MAIN_HTTP="$2" js="$3" FUNCNAME="$4" response="$5""
# echo "#$4 request: $1" # echo "#$4 request: $1"
HTTP_RESP=$(curl -ksd "$1" "$2") HTTP_RESP=$(curl -ksd "$1" "$2")
RAW_RESP=$(jq -r "$5" <<<"$HTTP_RESP") RAW_RESP=$(jq -r "$5" <<<"$HTTP_RESP")
# echo "#response: $HTTP_RESP" # echo "#response: $HTTP_RESP" "$RAW_RESP"
ok=$(echo "$HTTP_RESP" | jq -r "$3") ok=$(echo "$HTTP_RESP" | jq -r "$3")
[ "$ok" == true ] [ "$ok" == true ]
rst=$? rst=$?
echo_rst "$4" "$rst" "$HTTP_RESP" echo_rst "$4" "$rst" "$HTTP_RESP"
} }
chain33_DecodeRawTransactionTx() {
# txHex="$1" priKey="$2" MAIN_HTTP="$3" FUNCNAME="$4"
req='{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$1"'"}]}'
http_req "$req" $3 '(.result.txs[0].execer != "")' "$4"
chain33_SignRawTx "$1" "$2" $3
chain33_BlockWait 1 $3
}
chain33_BlockWait() { chain33_BlockWait() {
local MAIN_HTTP=$2 local MAIN_HTTP=$2
local req='"method":"Chain33.GetLastHeader","params":[]' local req='"method":"Chain33.GetLastHeader","params":[]'
......
...@@ -11,12 +11,6 @@ function run_testcases() { ...@@ -11,12 +11,6 @@ function run_testcases() {
echo "run_testcases" echo "run_testcases"
} }
function debug_function() {
set -x
eval "$@"
set +x
}
function rpc_test() { function rpc_test() {
chain33_RpcTestBegin autonomy chain33_RpcTestBegin autonomy
...@@ -30,4 +24,4 @@ function rpc_test() { ...@@ -30,4 +24,4 @@ function rpc_test() {
} }
debug_function rpc_test "$1" chain33_debug_function rpc_test "$1"
\ No newline at end of file
...@@ -31,64 +31,35 @@ init() { ...@@ -31,64 +31,35 @@ init() {
chain33_NewAccount() { chain33_NewAccount() {
label=$1 label=$1
# result=$(curl -ksd '{"jsonrpc":"2.0","id":2,"method":"Chain33.NewAccount","params":[{"label":"'"$label"'"}]}' -H 'content-type:text/plain;' ${MAIN_HTTP} | jq -r ".result.acc.addr")
# [ "$result" != "" ]
# rst=$?
# echo_rst "$FUNCNAME" "$rst"
# glAddr=$result
# echo "$glAddr"
req='{"method":"Chain33.NewAccount","params":[{"label":"'"$label"'"}]}' req='{"method":"Chain33.NewAccount","params":[{"label":"'"$label"'"}]}'
http_req "$req" ${MAIN_HTTP} '(.result.acc.addr != "")' "$FUNCNAME" http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result.acc.addr|length > 0)' "$FUNCNAME" ".result.acc.addr"
glAddr=$RAW_RESP
} }
chain33_SendTransaction() { chain33_SendTransaction() {
rawTx=$1 rawTx=$1
addr=$2 addr=$2
#签名交易 #签名交易
# resp=$(curl -ksd '{"jsonrpc":"2.0","id":2,"method":"Chain33.SignRawTx","params":[{"addr":"'"$addr"'","txHex":"'"$rawTx"'","expire":"120s","fee":10000000,"index":0}]}' -H 'content-type:text/plain;' ${MAIN_HTTP})
# ok=$(echo "${resp}" | jq -r ".error")
# [ "$ok" == null ]
# rst=$?
# echo_rst "$FUNCNAME" "$rst"
req='{"method":"Chain33.SignRawTx","params":[{"addr":"'"$addr"'","txHex":"'"$rawTx"'","expire":"120s","fee":10000000,"index":0}]}' req='{"method":"Chain33.SignRawTx","params":[{"addr":"'"$addr"'","txHex":"'"$rawTx"'","expire":"120s","fee":10000000,"index":0}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not)' "$FUNCNAME" http_req "$req" ${MAIN_HTTP} '(.error|not)' "Chain33.SignRawTx" ".result"
signTx=$RAW_RESP
# signTx=$(echo "${resp}" | jq -r ".result")
# resp=$(curl -ksd '{"jsonrpc":"2.0","id":2,"method":"Chain33.SendTransaction","params":[{"data":"'"$signTx"'"}]}' -H 'content-type:text/plain;' ${MAIN_HTTP})
# ok=$(echo "${resp}" | jq -r ".error")
# [ "$ok" == null ]
# rst=$?
# echo_rst "$FUNCNAME" "$rst"
req='{"method":"Chain33.SendTransaction","params":[{"data":"'"$signTx"'"}]}' req='{"method":"Chain33.SendTransaction","params":[{"data":"'"$signTx"'"}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not)' "$FUNCNAME" http_req "$req" ${MAIN_HTTP} '(.error|not)' "$FUNCNAME" ".result"
gResp=$RAW_RESP
#返回交易 #返回交易
gResp=$(jq -r ".result" <<<"$HTTP_RESP") chain33_QueryTx "$RAW_RESP" "${MAIN_HTTP}"
echo "tx hash is $gResp"
chain33_QueryTx "$gResp" "${MAIN_HTTP}"
} }
blackwhite_BlackwhiteCreateTx() { blackwhite_BlackwhiteCreateTx() {
#创建交易 #创建交易
addr=$1 addr=$1
# resp=$(curl -ksd '{"jsonrpc":"2.0","id":2,"method":"blackwhite.BlackwhiteCreateTx","params":[{"PlayAmount":100000000,"PlayerCount":3,"GameName":"hello","Timeout":600,"Fee":1000000}]}' -H 'content-type:text/plain;' ${MAIN_HTTP})
# ok=$(echo "${resp}" | jq -r ".error")
# [ "$ok" == null ]
# rst=$?
# echo_rst "$FUNCNAME" "$rst"
req='{"method":"blackwhite.BlackwhiteCreateTx","params":[{"PlayAmount":100000000,"PlayerCount":3,"GameName":"hello","Timeout":600,"Fee":1000000}]}' req='{"method":"blackwhite.BlackwhiteCreateTx","params":[{"PlayAmount":100000000,"PlayerCount":3,"GameName":"hello","Timeout":600,"Fee":1000000}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not)' "$FUNCNAME" http_req "$req" ${MAIN_HTTP} '(.error|not)' "$FUNCNAME" ".result"
#发送交易 #发送交易
rawTx=$(echo "${HTTP_RESP}" | jq -r ".result") chain33_SendTransaction "$RAW_RESP" "${addr}"
chain33_SendTransaction "${rawTx}" "${addr}"
gID="${gResp}" gID="${gResp}"
echo "gameID $gID"
} }
blackwhite_BlackwhitePlayTx() { blackwhite_BlackwhitePlayTx() {
...@@ -96,70 +67,45 @@ blackwhite_BlackwhitePlayTx() { ...@@ -96,70 +67,45 @@ blackwhite_BlackwhitePlayTx() {
round1=$2 round1=$2
round2=$3 round2=$3
round3=$4 round3=$4
resp=$(curl -ksd '{"jsonrpc":"2.0","id":2,"method":"blackwhite.BlackwhitePlayTx","params":[{"gameID":"'"$gID"'","amount":100000000,"Fee":1000000,"hashValues":["'"$round1"'","'"$round2"'","'"$round3"'"]}]}' -H 'content-type:text/plain;' ${MAIN_HTTP}) req='{"method":"blackwhite.BlackwhitePlayTx","params":[{"gameID":"'"$gID"'","amount":100000000,"Fee":1000000,"hashValues":["'"$round1"'","'"$round2"'","'"$round3"'"]}]}'
ok=$(echo "${resp}" | jq -r ".error") http_req "$req" ${MAIN_HTTP} '(.error|not)' "$FUNCNAME" ".result"
[ "$ok" == null ]
rst=$?
echo_rst "$FUNCNAME" "$rst"
#发送交易 #发送交易
rawTx=$(echo "${resp}" | jq -r ".result") chain33_SendTransaction "$RAW_RESP" "${addr}"
chain33_SendTransaction "${rawTx}" "${addr}"
} }
blackwhite_BlackwhiteShowTx() { blackwhite_BlackwhiteShowTx() {
addr=$1 addr=$1
sec=$2 sec=$2
resp=$(curl -ksd '{"jsonrpc":"2.0","id":2,"method":"blackwhite.BlackwhiteShowTx","params":[{"gameID":"'"$gID"'","secret":"'"$sec"'","Fee":1000000}]}' -H 'content-type:text/plain;' ${MAIN_HTTP}) req='{"method":"blackwhite.BlackwhiteShowTx","params":[{"gameID":"'"$gID"'","secret":"'"$sec"'","Fee":1000000}]}'
ok=$(echo "${resp}" | jq -r ".error") http_req "$req" ${MAIN_HTTP} '(.error|not)' "$FUNCNAME" ".result"
[ "$ok" == null ] chain33_SendTransaction "$RAW_RESP" "${addr}"
rst=$?
echo_rst "$FUNCNAME" "$rst"
#发送交易
rawTx=$(echo "${resp}" | jq -r ".result")
chain33_SendTransaction "${rawTx}" "${addr}"
} }
blackwhite_BlackwhiteTimeoutDoneTx() { blackwhite_BlackwhiteTimeoutDoneTx() {
gameID=$1 gameID=$1
resp=$(curl -ksd '{"jsonrpc":"2.0","id":2,"method":"blackwhite.BlackwhiteTimeoutDoneTx","params":[{"gameID":"'"$gameID"'","Fee":1000000}]}' -H 'content-type:text/plain;' ${MAIN_HTTP}) req='{"method":"blackwhite.BlackwhiteTimeoutDoneTx","params":[{"gameID":"'"$gameID"'","Fee":1000000}]}'
ok=$(echo "${resp}" | jq -r ".error") http_req "$req" ${MAIN_HTTP} '(.error|not)' "$FUNCNAME"
[ "$ok" == null ]
rst=$?
echo_rst "$FUNCNAME" "$rst"
} }
blackwhite_GetBlackwhiteRoundInfo() { blackwhite_GetBlackwhiteRoundInfo() {
gameID=$1 gameID=$1
execer="blackwhite" req='{"method":"Chain33.Query","params":[{"execer":"blackwhite","funcName":"GetBlackwhiteRoundInfo","payload":{"gameID":"'"$gameID"'"}}]}'
funcName="GetBlackwhiteRoundInfo" http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result.round | [has("gameID", "status", "playAmount", "playerCount", "curPlayerCount", "loop", "curShowCount", "timeout"),true] | unique | length == 1)' "$FUNCNAME"
resp=$(curl -ksd '{"jsonrpc":"2.0","id":2,"method":"Chain33.Query","params":[{"execer":"'"$execer"'","funcName":"'"$funcName"'","payload":{"gameID":"'"$gameID"'"}}]}' -H 'content-type:text/plain;' ${MAIN_HTTP})
ok=$(jq '(.error|not) and (.result.round | [has("gameID", "status", "playAmount", "playerCount", "curPlayerCount", "loop", "curShowCount", "timeout"),true] | unique | length == 1)' <<<"$resp")
[ "$ok" == true ]
rst=$?
echo_rst "$FUNCNAME" "$rst"
} }
blackwhite_GetBlackwhiteByStatusAndAddr() { blackwhite_GetBlackwhiteByStatusAndAddr() {
gameID=$1 addr=$1
addr=$2 req='{"method":"Chain33.Query","params":[{"execer":"blackwhite","funcName":"GetBlackwhiteByStatusAndAddr","payload":{"status":5,"address":"'"$addr"'","count":1,"direction":0,"index":-1}}]}'
execer="blackwhite" resok='(.error|not) and (.result.round[0].createAddr == "'"$addr"'") and (.result.round[0].status == 5) and (.result.round[0] | [has("gameID", "status", "playAmount", "playerCount", "curPlayerCount", "loop", "curShowCount", "timeout", "winner"),true] | unique | length == 1)'
funcName="GetBlackwhiteByStatusAndAddr" http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
resp=$(curl -ksd '{"jsonrpc":"2.0","id":2,"method":"Chain33.Query","params":[{"execer":"'"$execer"'","funcName":"'"$funcName"'","payload":{"status":5,"address":"'"$addr"'","count":1,"direction":0,"index":-1}}]}' -H 'content-type:text/plain;' ${MAIN_HTTP})
ok=$(jq '(.error|not) and (.result.round[0].createAddr == "'"$addr"'") and (.result.round[0].status == 5) and (.result.round[0] | [has("gameID", "status", "playAmount", "playerCount", "curPlayerCount", "loop", "curShowCount", "timeout", "winner"),true] | unique | length == 1)' <<<"$resp")
[ "$ok" == true ]
rst=$?
echo_rst "$FUNCNAME" "$rst"
} }
blackwhite_GetBlackwhiteloopResult() { blackwhite_GetBlackwhiteloopResult() {
gameID=$1 gameID=$1
execer="blackwhite" req='{"method":"Chain33.Query","params":[{"execer":"blackwhite","funcName":"GetBlackwhiteloopResult","payload":{"gameID":"'"$gameID"'","loopSeq":0}}]}'
funcName="GetBlackwhiteloopResult" resok='(.error|not) and (.result.gameID == "'"$gameID"'") and (.result.results|length >= 1)'
resp=$(curl -ksd '{"jsonrpc":"2.0","id":2,"method":"Chain33.Query","params":[{"execer":"'"$execer"'","funcName":"'"$funcName"'","payload":{"gameID":"'"$gameID"'","loopSeq":0}}]}' -H 'content-type:text/plain;' ${MAIN_HTTP}) http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
ok=$(jq '(.error|not) and (.result.gameID == "'"$gameID"'") and (.result.results|length >= 1)' <<<"$resp")
[ "$ok" == true ]
rst=$?
echo_rst "$FUNCNAME" "$rst"
} }
function run_testcases() { function run_testcases() {
...@@ -216,9 +162,8 @@ function run_testcases() { ...@@ -216,9 +162,8 @@ function run_testcases() {
blackwhite_BlackwhiteTimeoutDoneTx "$gID" blackwhite_BlackwhiteTimeoutDoneTx "$gID"
#查询部分 #查询部分
blackwhite_GetBlackwhiteRoundInfo "$gID" blackwhite_GetBlackwhiteRoundInfo "$gID"
blackwhite_GetBlackwhiteByStatusAndAddr "$gID" "${gameAddr1}" blackwhite_GetBlackwhiteByStatusAndAddr "${gameAddr1}"
blackwhite_GetBlackwhiteloopResult "$gID" blackwhite_GetBlackwhiteloopResult "$gID"
} }
function main() { function main() {
...@@ -227,17 +172,8 @@ function main() { ...@@ -227,17 +172,8 @@ function main() {
echo "main_ip=$MAIN_HTTP" echo "main_ip=$MAIN_HTTP"
init init
run_testcases run_testcases
chain33_RpcTestRst blackwhite "$CASE_ERR" chain33_RpcTestRst blackwhite "$CASE_ERR"
}
function debug_function() {
set -x
eval "$@"
set +x
} }
debug_function main "$1" chain33_debug_function main "$1"
\ No newline at end of file
...@@ -30,8 +30,7 @@ function main() { ...@@ -30,8 +30,7 @@ function main() {
init init
run_test run_test
chain33_RpcTestRst dposvote "$CASE_ERR" chain33_RpcTestRst dposvote "$CASE_ERR"
} }
main "$1" chain33_debug_function main "$1"
...@@ -47,16 +47,9 @@ function evm_createContract() { ...@@ -47,16 +47,9 @@ function evm_createContract() {
} }
function evm_addressCheck() { function evm_addressCheck() {
res=$(curl -s --data-binary '{"jsonrpc":"2.0","id":2,"method":"Chain33.Query","params":[{"execer":"evm","funcName":"CheckAddrExists","payload":{"addr":"'${evm_contractAddr}'"}}]}' -H 'content-type:text/plain;' ${MAIN_HTTP}) req='{"method":"Chain33.Query","params":[{"execer":"evm","funcName":"CheckAddrExists","payload":{"addr":"'${evm_contractAddr}'"}}]}'
bContract=$(echo "${res}" | jq -r ".result.contract") resok='(.result.contract == true ) and (.result.contractAddr == "'"${evm_contractAddr}"'")'
contractAddr=$(echo "${res}" | jq -r ".result.contractAddr") http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
if [ "${bContract}" == "true" ] && [ "${contractAddr}" == "${evm_contractAddr}" ]; then
echo_rst "evm address check" 0
else
echo_rst "evm address check" 1
fi
return
} }
function evm_callContract() { function evm_callContract() {
op=$1 op=$1
...@@ -81,14 +74,8 @@ function evm_callContract() { ...@@ -81,14 +74,8 @@ function evm_callContract() {
} }
function evm_abiGet() { function evm_abiGet() {
abiInfo=$(curl -s --data-binary '{"jsonrpc":"2.0","id":2,"method":"Chain33.Query","params":[{"execer":"evm","funcName":"QueryABI","payload":{"address":"'${evm_contractAddr}'"}}]}' -H 'content-type:text/plain;' ${MAIN_HTTP}) req='{"method":"Chain33.Query","params":[{"execer":"evm","funcName":"QueryABI","payload":{"address":"'${evm_contractAddr}'"}}]}'
res=$(echo "${abiInfo}" | jq -r ".result" | jq -r 'has("abi")') http_req "$req" ${MAIN_HTTP} "(.result.abi != null)" "$FUNCNAME"
if [ "${res}" == "true" ]; then
echo_rst "CallContract queryExecRes" 0
else
echo_rst "CallContract queryExecRes" 1
fi
return
} }
function evm_transfer() { function evm_transfer() {
...@@ -111,16 +98,9 @@ function evm_transfer() { ...@@ -111,16 +98,9 @@ function evm_transfer() {
function evm_getBalance() { function evm_getBalance() {
expectBalance=$1 expectBalance=$1
echo "This is evm get balance test." req='{"method":"Chain33.GetBalance","params":[{"addresses":["'${evm_creatorAddr}'"],"execer":"'${evm_addr}'", "paraName": "'${paraName}'"}]}'
res=$(curl -s --data-binary '{"jsonrpc":"2.0","id":2,"method":"Chain33.GetBalance","params":[{"addresses":["'${evm_creatorAddr}'"],"execer":"'${evm_addr}'", "paraName": "'${paraName}'"}]}' -H 'content-type:text/plain;' ${MAIN_HTTP}) resok='(.result[0].balance == '$expectBalance') and (.result[0].addr == "'"$evm_creatorAddr"'")'
balance=$(echo "${res}" | jq -r ".result[0].balance") http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
addr=$(echo "${res}" | jq -r ".result[0].addr")
if [ "${balance}" == "${expectBalance}" ] && [ "${addr}" == "${evm_creatorAddr}" ]; then
echo_rst "evm getBalance" 0
else
echo_rst "evm getBalance" 1
fi
} }
function evm_withDraw() { function evm_withDraw() {
...@@ -243,14 +223,12 @@ function run_test() { ...@@ -243,14 +223,12 @@ function run_test() {
function main() { function main() {
chain33_RpcTestBegin evm chain33_RpcTestBegin evm
local ip=$1 local ip=$1
MAIN_HTTP=$ip MAIN_HTTP=$ip
echo "main_ip=$MAIN_HTTP" echo "main_ip=$MAIN_HTTP"
init init
run_test "$MAIN_HTTP" run_test "$MAIN_HTTP"
chain33_RpcTestRst evm "$CASE_ERR" chain33_RpcTestRst evm "$CASE_ERR"
} }
......
...@@ -8,6 +8,9 @@ GAME_ID="" ...@@ -8,6 +8,9 @@ GAME_ID=""
PASSWD="ABCD" PASSWD="ABCD"
HASH_VALUE=$(echo -n "ABCD1" | sha256sum | awk '{print $1}') HASH_VALUE=$(echo -n "ABCD1" | sha256sum | awk '{print $1}')
PRIVA_A="0xfa21dc33a6144c546537580d28d894355d1e9af7292be175808b0f5737c30849"
PRIVA_B="0x213286d352b01fd740b6eaeb78a4fd316d743dd51d2f12c6789977430a41e0c7"
EXECTOR="" EXECTOR=""
# shellcheck source=/dev/null # shellcheck source=/dev/null
...@@ -16,34 +19,16 @@ source ../dapp-test-common.sh ...@@ -16,34 +19,16 @@ source ../dapp-test-common.sh
function chain33_GetExecAddr() { function chain33_GetExecAddr() {
#获取GAME合约地址 #获取GAME合约地址
req='{"method":"Chain33.ConvertExectoAddr","params":[{"execname":"'"$1"'"}]}' req='{"method":"Chain33.ConvertExectoAddr","params":[{"execname":"'"$1"'"}]}'
resok='(.error|not)' http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME" ".result"
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME" GAME_ADDR=$RAW_RESP
# local exector=$1
# local req='"method":"Chain33.ConvertExectoAddr","params":[{"execname":"'"${exector}"'"}]'
# echo "#request: $req"
# resp=$(curl -ksd "{$req}" "${MAIN_HTTP}")
# echo "#response: $resp"
# GAME_ADDR=$(echo "${res}" | jq -r ".result")
# echo_rst "$FUNCNAME" "$?"
} }
function CreateGameTx() { function CreateGameTx() {
local amount=$1 local amount=$1
local hash_value=$2 local hash_value=$2
local req='{"method":"Chain33.CreateTransaction","params":[{"execer":"'"${EXECTOR}"'", "actionName":"createGame", "payload":{"amount": '"${amount}"',"hashType":"sha256","hashValue":"'"${hash_value}"'"}}]}' local req='{"method":"Chain33.CreateTransaction","params":[{"execer":"'"${EXECTOR}"'", "actionName":"createGame", "payload":{"amount": '"${amount}"',"hashType":"sha256","hashValue":"'"${hash_value}"'"}}]}'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME" http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME" ".result"
chain33_SignRawTx "${RAW_RESP}" "${PRIVA_A}" "${MAIN_HTTP}"
# echo "#request: $req"
# resp=$(curl -ksd "{$req}" "${MAIN_HTTP}")
# echo "#response: $resp"
# rawTx=$(echo "${resp}" | jq -r ".result")
# if [ "$rawTx" == "null" ]; then
# echo_rst "CreateGame createRawTx" 1
# fi
chain33_SignRawTx "${rawTx}" "${PRIVA_A}" "${MAIN_HTTP}"
GAME_ID=$RAW_TX_HASH GAME_ID=$RAW_TX_HASH
echo_rst "CreateGame query_tx" "$?" echo_rst "CreateGame query_tx" "$?"
...@@ -52,19 +37,8 @@ function CreateGameTx() { ...@@ -52,19 +37,8 @@ function CreateGameTx() {
function MatchGameTx() { function MatchGameTx() {
local gameId=$1 local gameId=$1
local req='{"method":"Chain33.CreateTransaction","params":[{"execer":"'"${EXECTOR}"'", "actionName":"matchGame", "payload":{"gameId": "'"${gameId}"'","guess":2}}]}' local req='{"method":"Chain33.CreateTransaction","params":[{"execer":"'"${EXECTOR}"'", "actionName":"matchGame", "payload":{"gameId": "'"${gameId}"'","guess":2}}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "MatchGame createRawTx" ".result"
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != "")' "MatchGame createRawTx" chain33_SignRawTx "${RAW_RESP}" "${PRIVA_B}" "${MAIN_HTTP}"
# echo "#request: $req"
# resp=$(curl -ksd "{$req}" "${MAIN_HTTP}")
# echo "#response: $resp"
rawTx=$(echo "${HTTP_RESP}" | jq -r ".result")
# if [ "$rawTx" == "null" ]; then
# echo_rst "MatchGame createRawTx" 1
# fi
chain33_SignRawTx "${rawTx}" "${PRIVA_B}" "${MAIN_HTTP}"
echo_rst "MatchGame query_tx" "$?" echo_rst "MatchGame query_tx" "$?"
} }
...@@ -73,18 +47,8 @@ function CloseGameTx() { ...@@ -73,18 +47,8 @@ function CloseGameTx() {
local secret=$2 local secret=$2
local req='{"method":"Chain33.CreateTransaction","params":[{"execer":"'"${EXECTOR}"'", "actionName":"closeGame", "payload":{"gameId": "'"${gameId}"'","secret":"'"${secret}"'","result":1}}]}' local req='{"method":"Chain33.CreateTransaction","params":[{"execer":"'"${EXECTOR}"'", "actionName":"closeGame", "payload":{"gameId": "'"${gameId}"'","secret":"'"${secret}"'","result":1}}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != "")' "CloseGame createRawTx" http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "CloseGame createRawTx" ".result"
chain33_SignRawTx "${RAW_RESP}" "${PRIVA_A}" "${MAIN_HTTP}"
# echo "#request: $req"
# resp=$(curl -ksd "{$req}" "${MAIN_HTTP}")
# echo "#response: $resp"
rawTx=$(echo "${HTTP_RESP}" | jq -r ".result")
# if [ "$rawTx" == "null" ]; then
# echo_rst "CloseGame createRawTx" 1
# fi
chain33_SignRawTx "${rawTx}" "${PRIVA_A}" "${MAIN_HTTP}"
echo_rst "CloseGame query_tx" "$?" echo_rst "CloseGame query_tx" "$?"
} }
...@@ -92,30 +56,15 @@ function CancleGameTx() { ...@@ -92,30 +56,15 @@ function CancleGameTx() {
local gameId=$1 local gameId=$1
local req='{"method":"Chain33.CreateTransaction","params":[{"execer":"'"${EXECTOR}"'", "actionName":"cancelGame", "payload":{"gameId": "'"${gameId}"'"}}]}' local req='{"method":"Chain33.CreateTransaction","params":[{"execer":"'"${EXECTOR}"'", "actionName":"cancelGame", "payload":{"gameId": "'"${gameId}"'"}}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != "")' "CancleGame createRawTx" http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "CancleGame createRawTx" ".result"
# echo "#request: $req" chain33_SignRawTx "${RAW_RESP}" "${PRIVA_A}" "${MAIN_HTTP}"
# resp=$(curl -ksd "{$req}" "${MAIN_HTTP}")
# echo "#response: $resp"
rawTx=$(echo "${HTTP_RESP}" | jq -r ".result")
# if [ "$rawTx" == "null" ]; then
# echo_rst "CancleGame createRawTx" 1
# fi
chain33_SignRawTx "${rawTx}" "${PRIVA_A}" "${MAIN_HTTP}"
echo_rst "CancleGame query_tx" "$?" echo_rst "CancleGame query_tx" "$?"
} }
function QueryGameByStatus() { function QueryGameByStatus() {
local status=$1 local status=$1
local req='{"method":"Chain33.Query","params":[{"execer":"'"${EXECTOR}"'","funcName":"QueryGameListByStatusAndAddr","payload":{"status":'"${status}"',"address":""}}]}' local req='{"method":"Chain33.Query","params":[{"execer":"'"${EXECTOR}"'","funcName":"QueryGameListByStatusAndAddr","payload":{"status":'"${status}"',"address":""}}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result.games != "")' "$FUNCNAME" http_req "$req" ${MAIN_HTTP} '(.error|not)' "$FUNCNAME" ".result.games"
# echo "#request: $req"
# resp=$(curl -ksd "{$req}" "${MAIN_HTTP}")
# echo "#response: $resp"
# GAMES=$(echo "${resp}" | jq -r ".result.games")
# echo "${GAMES}"
# echo_rst "$FUNCNAME" "$?"
} }
function QueryGameByGameId() { function QueryGameByGameId() {
...@@ -124,17 +73,6 @@ function QueryGameByGameId() { ...@@ -124,17 +73,6 @@ function QueryGameByGameId() {
local req='{"method":"Chain33.Query","params":[{"execer":"'"${EXECTOR}"'","funcName":"QueryGameById","payload":{"gameId":"'"${gameId}"'"}}]}' local req='{"method":"Chain33.Query","params":[{"execer":"'"${EXECTOR}"'","funcName":"QueryGameById","payload":{"gameId":"'"${gameId}"'"}}]}'
resok='(.error|not) and (.result.game.status = "'"${status}"'")' resok='(.error|not) and (.result.game.status = "'"${status}"'")'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME" http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
# echo "#request: $req"
# resp=$(curl -ksd "{$req}" "${MAIN_HTTP}")
# echo "#response: $resp"
# STATUS=$(echo "${resp}" | jq -r ".result.game.status")
# if [ "${STATUS}" -ne "${status}" ]; then
# echo "status is not equal"
# echo_rst "QueryGameByGameId" 1
# return 0
# fi
# echo_rst "QueryGameByGameId" 0
} }
function init() { function init() {
...@@ -153,10 +91,8 @@ function init() { ...@@ -153,10 +91,8 @@ function init() {
local main_ip=${MAIN_HTTP//8901/8801} local main_ip=${MAIN_HTTP//8901/8801}
#main chain import pri key #main chain import pri key
#16Z3haNPQd9wrnFDw19rtpbgnN2xynNT9f chain33_ImportPrivkey "$PRIVA_A" "16Z3haNPQd9wrnFDw19rtpbgnN2xynNT9f" "game1" "${main_ip}"
chain33_ImportPrivkey "0xfa21dc33a6144c546537580d28d894355d1e9af7292be175808b0f5737c30849" "16Z3haNPQd9wrnFDw19rtpbgnN2xynNT9f" "game1" "${main_ip}" chain33_ImportPrivkey "$PRIVA_B" "16GXRfd9xj3XYMDti4y4ht7uzwoh55gZEc" "game2" "$main_ip"
#16GXRfd9xj3XYMDti4y4ht7uzwoh55gZEc
chain33_ImportPrivkey "0x213286d352b01fd740b6eaeb78a4fd316d743dd51d2f12c6789977430a41e0c7" "16GXRfd9xj3XYMDti4y4ht7uzwoh55gZEc" "game2" "$main_ip"
local ACCOUNT_A="16Z3haNPQd9wrnFDw19rtpbgnN2xynNT9f" local ACCOUNT_A="16Z3haNPQd9wrnFDw19rtpbgnN2xynNT9f"
local ACCOUNT_B="16GXRfd9xj3XYMDti4y4ht7uzwoh55gZEc" local ACCOUNT_B="16GXRfd9xj3XYMDti4y4ht7uzwoh55gZEc"
...@@ -176,8 +112,8 @@ function init() { ...@@ -176,8 +112,8 @@ function init() {
chain33_QueryBalance "${ACCOUNT_B}" "$main_ip" chain33_QueryBalance "${ACCOUNT_B}" "$main_ip"
local para_ip="${MAIN_HTTP}" local para_ip="${MAIN_HTTP}"
#para chain import pri key #para chain import pri key
chain33_ImportPrivkey "0xfa21dc33a6144c546537580d28d894355d1e9af7292be175808b0f5737c30849" "16Z3haNPQd9wrnFDw19rtpbgnN2xynNT9f" "game1" "$para_ip" chain33_ImportPrivkey "$PRIVA_A" "16Z3haNPQd9wrnFDw19rtpbgnN2xynNT9f" "game1" "$para_ip"
chain33_ImportPrivkey "0x213286d352b01fd740b6eaeb78a4fd316d743dd51d2f12c6789977430a41e0c7" "16GXRfd9xj3XYMDti4y4ht7uzwoh55gZEc" "game2" "$para_ip" chain33_ImportPrivkey "$PRIVA_B" "16GXRfd9xj3XYMDti4y4ht7uzwoh55gZEc" "game2" "$para_ip"
chain33_applyCoins "$ACCOUNT_A" 12000000000 "${para_ip}" chain33_applyCoins "$ACCOUNT_A" 12000000000 "${para_ip}"
chain33_QueryBalance "${ACCOUNT_A}" "$para_ip" chain33_QueryBalance "${ACCOUNT_A}" "$para_ip"
...@@ -196,46 +132,29 @@ function init() { ...@@ -196,46 +132,29 @@ function init() {
function run_test() { function run_test() {
local ip=$1 local ip=$1
CreateGameTx 1000000000 "${HASH_VALUE}" CreateGameTx 1000000000 "${HASH_VALUE}"
QueryGameByGameId "${GAME_ID}" 1 QueryGameByGameId "${GAME_ID}" 1
QueryGameByStatus 1 QueryGameByStatus 1
MatchGameTx "${GAME_ID}" MatchGameTx "${GAME_ID}"
QueryGameByGameId "${GAME_ID}" 2 QueryGameByGameId "${GAME_ID}" 2
QueryGameByStatus 2 QueryGameByStatus 2
CloseGameTx "${GAME_ID}" "${PASSWD}" CloseGameTx "${GAME_ID}" "${PASSWD}"
QueryGameByGameId "${GAME_ID}" 4 QueryGameByGameId "${GAME_ID}" 4
QueryGameByStatus 4 QueryGameByStatus 4
CreateGameTx 500000000 "${HASH_VALUE}" CreateGameTx 500000000 "${HASH_VALUE}"
QueryGameByGameId "${GAME_ID}" 1 QueryGameByGameId "${GAME_ID}" 1
CancleGameTx "${GAME_ID}" CancleGameTx "${GAME_ID}"
QueryGameByGameId "${GAME_ID}" 3 QueryGameByGameId "${GAME_ID}" 3
QueryGameByStatus 3 QueryGameByStatus 3
} }
function main() { function main() {
chain33_RpcTestBegin game
local ip=$1 local ip=$1
MAIN_HTTP=$ip MAIN_HTTP=$ip
chain33_RpcTestBegin game
echo "main_ip=$MAIN_HTTP"
init init
run_test "$MAIN_HTTP" run_test "$MAIN_HTTP"
chain33_RpcTestRst game "$CASE_ERR" chain33_RpcTestRst game "$CASE_ERR"
} }
chain33_debug_function main "$1" chain33_debug_function main "$1"
#main "$1"
...@@ -20,103 +20,38 @@ eventId="" ...@@ -20,103 +20,38 @@ eventId=""
txhash="" txhash=""
guess_game_start() { guess_game_start() {
echo "========== # guess start tx begin =========="
tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"guess","actionName":"Start", "payload":{"topic":"WorldCup Final","options":"A:France;B:Claodia","category":"football","maxBetsOneTime":10000000000,"maxBetsNumber":100000000000,"devFeeFactor":5,"devFeeAddr":"1D6RFZNp2rh6QdbcZ1d7RWuBUz61We6SD7","platFeeFactor":5,"platFeeAddr":"1PHtChNt3UcfssR7v7trKSk3WJtAWjKjjX"}}]}' ${MAIN_HTTP} | jq -r ".result") tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"guess","actionName":"Start", "payload":{"topic":"WorldCup Final","options":"A:France;B:Claodia","category":"football","maxBetsOneTime":10000000000,"maxBetsNumber":100000000000,"devFeeFactor":5,"devFeeAddr":"1D6RFZNp2rh6QdbcZ1d7RWuBUz61We6SD7","platFeeFactor":5,"platFeeAddr":"1PHtChNt3UcfssR7v7trKSk3WJtAWjKjjX"}}]}' ${MAIN_HTTP} | jq -r ".result")
chain33_DecodeRawTransactionTx "$tx" "4257D8692EF7FE13C68B65D6A52F03933DB2FA5CE8FAF210B5B8B80C721CED01" ${MAIN_HTTP} "$FUNCNAME"
data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]")
ok=$(jq '(.execer != "")' <<<"$data")
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
chain33_SignRawTx "$tx" "4257D8692EF7FE13C68B65D6A52F03933DB2FA5CE8FAF210B5B8B80C721CED01" ${MAIN_HTTP}
eventId="${txhash}" eventId="${txhash}"
echo "eventId $eventId"
echo "========== # guess start tx end =========="
chain33_BlockWait 1 ${MAIN_HTTP}
} }
guess_game_bet() { guess_game_bet() {
local priv=$1 local priv=$1
local opt=$2 local opt=$2
echo "========== # guess bet tx begin =========="
tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"guess","actionName":"Bet", "payload":{"gameID":"'"${eventId}"'","option":"'"${opt}"'", "betsNum":500000000}}]}' ${MAIN_HTTP} | jq -r ".result") tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"guess","actionName":"Bet", "payload":{"gameID":"'"${eventId}"'","option":"'"${opt}"'", "betsNum":500000000}}]}' ${MAIN_HTTP} | jq -r ".result")
chain33_DecodeRawTransactionTx "$tx" "${priv}" ${MAIN_HTTP} "$FUNCNAME"
data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]")
ok=$(jq '(.execer != "")' <<<"$data")
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
chain33_SignRawTx "$tx" "${priv}" ${MAIN_HTTP}
echo "========== # guess bet tx end =========="
chain33_BlockWait 1 ${MAIN_HTTP}
} }
guess_game_stop() { guess_game_stop() {
echo "========== # guess stop tx begin =========="
tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"guess","actionName":"StopBet", "payload":{"gameID":"'"${eventId}"'"}}]}' ${MAIN_HTTP} | jq -r ".result") tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"guess","actionName":"StopBet", "payload":{"gameID":"'"${eventId}"'"}}]}' ${MAIN_HTTP} | jq -r ".result")
chain33_DecodeRawTransactionTx "$tx" "4257D8692EF7FE13C68B65D6A52F03933DB2FA5CE8FAF210B5B8B80C721CED01" ${MAIN_HTTP} "$FUNCNAME"
data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]")
ok=$(jq '(.execer != "")' <<<"$data")
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
chain33_SignRawTx "$tx" "4257D8692EF7FE13C68B65D6A52F03933DB2FA5CE8FAF210B5B8B80C721CED01" ${MAIN_HTTP}
echo "========== # guess stop tx end =========="
chain33_BlockWait 1 ${MAIN_HTTP}
} }
guess_game_publish() { guess_game_publish() {
echo "========== # guess publish tx begin =========="
tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"guess","actionName":"Publish", "payload":{"gameID":"'"${eventId}"'","result":"A"}}]}' ${MAIN_HTTP} | jq -r ".result") tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"guess","actionName":"Publish", "payload":{"gameID":"'"${eventId}"'","result":"A"}}]}' ${MAIN_HTTP} | jq -r ".result")
chain33_DecodeRawTransactionTx "$tx" "4257D8692EF7FE13C68B65D6A52F03933DB2FA5CE8FAF210B5B8B80C721CED01" ${MAIN_HTTP} "$FUNCNAME"
data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]")
ok=$(jq '(.execer != "")' <<<"$data")
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
chain33_SignRawTx "$tx" "4257D8692EF7FE13C68B65D6A52F03933DB2FA5CE8FAF210B5B8B80C721CED01" ${MAIN_HTTP}
echo "========== # guess publish tx end =========="
chain33_BlockWait 1 ${MAIN_HTTP}
} }
guess_game_abort() { guess_game_abort() {
echo "========== # guess abort tx begin =========="
tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"guess","actionName":"Abort", "payload":{"gameID":"'"${eventId}"'"}}]}' ${MAIN_HTTP} | jq -r ".result") tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"guess","actionName":"Abort", "payload":{"gameID":"'"${eventId}"'"}}]}' ${MAIN_HTTP} | jq -r ".result")
chain33_DecodeRawTransactionTx "$tx" "4257D8692EF7FE13C68B65D6A52F03933DB2FA5CE8FAF210B5B8B80C721CED01" ${MAIN_HTTP} "$FUNCNAME"
data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]")
ok=$(jq '(.execer != "")' <<<"$data")
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
chain33_SignRawTx "$tx" "4257D8692EF7FE13C68B65D6A52F03933DB2FA5CE8FAF210B5B8B80C721CED01" ${MAIN_HTTP}
echo "========== # guess abort tx end =========="
chain33_BlockWait 1 ${MAIN_HTTP}
} }
guess_QueryGameByID() { guess_QueryGameByID() {
local event_id=$1 local event_id=$1
local status=$2 local status=$2
echo "========== # guess QueryGameByID begin ==========" local req='{"method":"Chain33.Query", "params":[{"execer":"guess","funcName":"QueryGameByID","payload":{"gameID":"'"$event_id"'"}}]}'
local req='"method":"Chain33.Query", "params":[{"execer":"guess","funcName":"QueryGameByID","payload":{"gameID":"'"$event_id"'"}}]' http_req "$req" ${MAIN_HTTP} '(.result|has("game")) and (.result.game.status == '"$status"')' "$FUNCNAME"
#echo "#request: $req"
resp=$(curl -ksd "{$req}" ${MAIN_HTTP})
echo "#response: $resp"
ok=$(jq '(.result|has("game")) and (.result.game.status == '"$status"')' <<<"$resp")
[ "$ok" == true ]
rst=$?
echo_rst "$FUNCNAME" "$rst"
echo "========== # guess QueryGameByID end =========="
} }
init() { init() {
...@@ -174,7 +109,6 @@ init() { ...@@ -174,7 +109,6 @@ init() {
} }
function run_test() { function run_test() {
#导入地址私钥 #导入地址私钥
chain33_ImportPrivkey "0xc889d2958843fc96d4bd3f578173137d37230e580d65e9074545c61e7e9c1932" "1NrfEBfdFJUUqgbw5ZbHXhdew6NNQumYhM" "user1" "$MAIN_HTTP" chain33_ImportPrivkey "0xc889d2958843fc96d4bd3f578173137d37230e580d65e9074545c61e7e9c1932" "1NrfEBfdFJUUqgbw5ZbHXhdew6NNQumYhM" "user1" "$MAIN_HTTP"
chain33_ImportPrivkey "0xf10c79470dc74c229c4ee73b05d14c58322b771a6c749d27824f6a59bb6c2d73" "17tRkBrccmFiVcLPXgEceRxDzJ2WaDZumN" "user2" "$MAIN_HTTP" chain33_ImportPrivkey "0xf10c79470dc74c229c4ee73b05d14c58322b771a6c749d27824f6a59bb6c2d73" "17tRkBrccmFiVcLPXgEceRxDzJ2WaDZumN" "user2" "$MAIN_HTTP"
...@@ -320,7 +254,6 @@ function main() { ...@@ -320,7 +254,6 @@ function main() {
init init
run_test run_test
chain33_RpcTestRst guess "$CASE_ERR" chain33_RpcTestRst guess "$CASE_ERR"
} }
......
...@@ -12,74 +12,21 @@ addr_B=1FcofeCgU1KYbB8dSa7cV2wjAF2RpMuUQD ...@@ -12,74 +12,21 @@ addr_B=1FcofeCgU1KYbB8dSa7cV2wjAF2RpMuUQD
source ../dapp-test-common.sh source ../dapp-test-common.sh
hashlock_lock() { hashlock_lock() {
local secret=$1 local secret=$1
# echo "========== # hashlock lock tx begin =========="
tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"hashlock","actionName":"HashlockLock", "payload":{"secret":"'"${secret}"'","amount":1000000000, "time":75,"toAddr":"'"${addr_B}"'", "returnAddr":"'"${addr_A}"'","fee":100000000}}]}' ${MAIN_HTTP} | jq -r ".result") tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"hashlock","actionName":"HashlockLock", "payload":{"secret":"'"${secret}"'","amount":1000000000, "time":75,"toAddr":"'"${addr_B}"'", "returnAddr":"'"${addr_A}"'","fee":100000000}}]}' ${MAIN_HTTP} | jq -r ".result")
chain33_DecodeRawTransactionTx "$tx" "0x1089b7f980fc467f029b7ae301249b36e3b582c911b1af1a24616c83b3563dcb" ${MAIN_HTTP} "$FUNCNAME"
# data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]")
# ok=$(jq '(.execer != "")' <<<"$data")
# [ "$ok" == true ]
# echo_rst "$FUNCNAME" "$?"
req='{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}'
resok='(.result.txs[0].execer != "")'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
chain33_SignRawTx "$tx" "0x1089b7f980fc467f029b7ae301249b36e3b582c911b1af1a24616c83b3563dcb" ${MAIN_HTTP}
#echo "txHash ${txhash}"
echo "========== # hashlock lock tx end =========="
chain33_BlockWait 1 ${MAIN_HTTP}
} }
hashlock_send() { hashlock_send() {
local secret=$1 local secret=$1
echo "========== # hashlock send tx begin =========="
tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"hashlock","actionName":"HashlockSend", "payload":{"secret":"'"${secret}"'","fee":100000000}}]}' ${MAIN_HTTP} | jq -r ".result") tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"hashlock","actionName":"HashlockSend", "payload":{"secret":"'"${secret}"'","fee":100000000}}]}' ${MAIN_HTTP} | jq -r ".result")
chain33_DecodeRawTransactionTx "$tx" "0xb76a398c3901dfe5c7335525da88fda4df24c11ad11af4332f00c0953cc2910f" ${MAIN_HTTP} "$FUNCNAME"
# data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]")
# ok=$(jq '(.execer != "")' <<<"$data")
# [ "$ok" == true ]
# echo_rst "$FUNCNAME" "$?"
req='{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}'
resok='(.result.txs[0].execer != "")'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
chain33_SignRawTx "$tx" "0xb76a398c3901dfe5c7335525da88fda4df24c11ad11af4332f00c0953cc2910f" ${MAIN_HTTP}
#echo "txHash ${txhash}"
echo "========== # hashlock send tx end =========="
chain33_BlockWait 1 ${MAIN_HTTP}
} }
hashlock_unlock() { hashlock_unlock() {
local secret=$1 local secret=$1
echo "========== # hashlock unlock tx begin =========="
tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"hashlock","actionName":"HashlockUnlock", "payload":{"secret":"'"${secret}"'","fee":100000000}}]}' ${MAIN_HTTP} | jq -r ".result") tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"hashlock","actionName":"HashlockUnlock", "payload":{"secret":"'"${secret}"'","fee":100000000}}]}' ${MAIN_HTTP} | jq -r ".result")
chain33_DecodeRawTransactionTx "$tx" "0x1089b7f980fc467f029b7ae301249b36e3b582c911b1af1a24616c83b3563dcb" ${MAIN_HTTP} "$FUNCNAME"
# data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]")
# ok=$(jq '(.execer != "")' <<<"$data")
# [ "$ok" == true ]
# echo_rst "$FUNCNAME" "$?"
req='{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}'
resok='(.result.txs[0].execer != "")'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
chain33_SignRawTx "$tx" "0x1089b7f980fc467f029b7ae301249b36e3b582c911b1af1a24616c83b3563dcb" ${MAIN_HTTP}
#echo "txHash ${txhash}"
echo "========== # hashlock unlock tx end =========="
chain33_BlockWait 1 ${MAIN_HTTP}
} }
init() { init() {
...@@ -150,14 +97,13 @@ function run_test() { ...@@ -150,14 +97,13 @@ function run_test() {
} }
function main() { function main() {
MAIN_HTTP="$1"
chain33_RpcTestBegin hashlock chain33_RpcTestBegin hashlock
MAIN_HTTP="$1"
echo "ip=$MAIN_HTTP" echo "ip=$MAIN_HTTP"
init init
run_test run_test
chain33_RpcTestRst hashlock "$CASE_ERR" chain33_RpcTestRst hashlock "$CASE_ERR"
} }
chain33_debug_function main "$1" chain33_debug_function main "$1"
\ No newline at end of file
...@@ -40,74 +40,34 @@ function init() { ...@@ -40,74 +40,34 @@ function init() {
} }
function configJSCreator() { function configJSCreator() {
# req='{"jsonrpc": "2.0", "method" : "Chain33.CreateTransaction" , "params":[{"execer":"'${manager_name}'","actionName":"Modify","payload":{"key":"js-creator","op":"add", "value" : "'${beneficiary}'"}}]}' req='{"method":"Chain33.CreateTransaction","params":[{"execer":"'${manager_name}'","actionName":"Modify","payload":{"key":"js-creator","op":"add","value":"'${beneficiary}'"}}]}'
# echo "#request: $req" resok='(.error|not) and (.result != null)'
# resp=$(curl -ksd "$req" "${MAIN_HTTP}") http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME" ".result"
# echo "#resp: $resp" chain33_SignRawTx "$RAW_RESP" "${super_manager}" "${MAIN_HTTP}"
# ok=$(jq '(.error|not) and (.result != "")' <<<"$resp")
# [ "$ok" == true ]
# echo_rst "$FUNCNAME" "$?"
req='{"method":"Chain33.CreateTransaction","params":[{"execer":"'${manager_name}'","actionName":"Modify","payload":{"key":"js-creator","op":"add", "value" : "'${beneficiary}'"}}]}'
resok='(.error|not) and (.result != "")'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
rawtx=$(jq -r ".result" <<<"$HTTP_RESP")
chain33_SignRawTx "$rawtx" "${super_manager}" "${MAIN_HTTP}"
} }
function createJSContract() { function createJSContract() {
# req='{"jsonrpc": "2.0", "method" : "Chain33.CreateTransaction" , "params":[{"execer":"'${exec_name}'","actionName":"Create","payload":{"name":"'${game}'","code":"'${jsCode}'"}}]}'
# echo "#request: $req"
# resp=$(curl -ksd "$req" "${MAIN_HTTP}")
# echo "#resp: $resp"
# ok=$(jq '(.error|not) and (.result != "")' <<<"$resp")
# [ "$ok" == true ]
# echo_rst "$FUNCNAME" "$?"
req='{"method":"Chain33.CreateTransaction","params":[{"execer":"'${exec_name}'","actionName":"Create","payload":{"name":"'${game}'","code":"'${jsCode}'"}}]}' req='{"method":"Chain33.CreateTransaction","params":[{"execer":"'${exec_name}'","actionName":"Create","payload":{"name":"'${game}'","code":"'${jsCode}'"}}]}'
resok='(.error|not) and (.result != "")' resok='(.error|not) and (.result != null)'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME" http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME" ".result"
chain33_SignRawTx "$RAW_RESP" "${beneficiary_key}" "${MAIN_HTTP}"
rawtx=$(jq -r ".result" <<<"$HTTP_RESP")
chain33_SignRawTx "$rawtx" "${beneficiary_key}" "${MAIN_HTTP}"
} }
function callJS() { function callJS() {
#the_exec=
# req='{"jsonrpc": "2.0", "method" : "Chain33.CreateTransaction" , "params":[{"execer":"'${user_game}'","actionName":"Call","payload":{"name":"'${game}'","funcname":"hello", "args" : "{}"}}]}'
# echo "#request: $req"
# resp=$(curl -ksd "$req" "${MAIN_HTTP}")
# echo "#resp: $resp"
# ok=$(jq '(.error|not) and (.result != "")' <<<"$resp")
# [ "$ok" == true ]
# echo_rst "$FUNCNAME" "$?"
req='{"method":"Chain33.CreateTransaction","params":[{"execer":"'${user_game}'","actionName":"Call","payload":{"name":"'${game}'","funcname":"hello","args":"{}"}}]}' req='{"method":"Chain33.CreateTransaction","params":[{"execer":"'${user_game}'","actionName":"Call","payload":{"name":"'${game}'","funcname":"hello","args":"{}"}}]}'
resok='(.error|not) and (.result != "")' resok='(.error|not) and (.result != null)'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME" http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME" ".result"
chain33_SignRawTx "$RAW_RESP" "${beneficiary_key}" "${MAIN_HTTP}"
rawtx=$(jq -r ".result" <<<"$HTTP_RESP")
chain33_SignRawTx "$rawtx" "${beneficiary_key}" "${MAIN_HTTP}"
} }
function queryJS() { function queryJS() {
# req='{"jsonrpc": "2.0", "method" : "Chain33.Query" , "params":[{"execer":"'${user_game}'","funcName":"Query","payload":{"name":"'${game}'","funcname":"hello", "args" : "{}"}}]}'
# echo "#request: $req"
# resp=$(curl -ksd "$req" "${MAIN_HTTP}")
# echo "#resp: $resp"
# ok=$(jq '(.error|not) and (.result != "")' <<<"$resp")
# [ "$ok" == true ]
# echo_rst "$FUNCNAME" "$?"
req='{"method":"Chain33.Query","params":[{"execer":"'${user_game}'","funcName":"Query","payload":{"name":"'${game}'","funcname":"hello","args":"{}"}}]}' req='{"method":"Chain33.Query","params":[{"execer":"'${user_game}'","funcName":"Query","payload":{"name":"'${game}'","funcname":"hello","args":"{}"}}]}'
resok='(.error|not) and (.result != "")' resok='(.error|not) and (.result != null)'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME" http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
} }
function run_testcases() { function run_testcases() {
configJSCreator configJSCreator
createJSContract createJSContract
callJS callJS
queryJS queryJS
...@@ -115,13 +75,11 @@ function run_testcases() { ...@@ -115,13 +75,11 @@ function run_testcases() {
function rpc_test() { function rpc_test() {
chain33_RpcTestBegin js chain33_RpcTestBegin js
MAIN_HTTP="$1" MAIN_HTTP="$1"
echo "main_ip=$MAIN_HTTP" echo "main_ip=$MAIN_HTTP"
init init
run_testcases run_testcases
chain33_RpcTestRst js "$CASE_ERR" chain33_RpcTestRst js "$CASE_ERR"
} }
......
This diff is collapsed.
...@@ -77,28 +77,22 @@ function multisig_AccCreateTx() { ...@@ -77,28 +77,22 @@ function multisig_AccCreateTx() {
#获取创建的多重签名地址 #获取创建的多重签名地址
multisigAccAddr=$(curl -ksd '{"method":"Chain33.Query","params":[{"execer":"multisig","funcName":"MultiSigAccounts","payload":{"start":"0","end":"0"}}]}' ${MAIN_HTTP} | jq -r ".result.address[0]") multisigAccAddr=$(curl -ksd '{"method":"Chain33.Query","params":[{"execer":"multisig","funcName":"MultiSigAccounts","payload":{"start":"0","end":"0"}}]}' ${MAIN_HTTP} | jq -r ".result.address[0]")
echo "multisigAccAddr=$multisigAccAddr" # echo "multisigAccAddr=$multisigAccAddr"
#多重签名地址查询具体信息
result1=$(curl -ksd '{"method":"Chain33.Query","params":[{"execer":"multisig","funcName":"MultiSigAccountInfo","payload":{"multiSigAccAddr":"'"$multisigAccAddr"'"}}]}' ${MAIN_HTTP})
ok1=$(jq '(.result.createAddr == "'$GenAddr'")' <<<"$result1")
[ "$ok1" == true ]
rst=$?
echo_rst "$FUNCNAME" "$rst"
result=$(curl -ksd '{"method":"Chain33.Query","params":[{"execer":"multisig","funcName":"MultiSigAccAllAddress","payload":{"multiSigAccAddr":"'$GenAddr'"}}]}' ${MAIN_HTTP}) #多重签名地址查询具体信息
ok=$(jq '(.result.address[0] == "'"$multisigAccAddr"'")' <<<"$result") req='{"method":"Chain33.Query","params":[{"execer":"multisig","funcName":"MultiSigAccountInfo","payload":{"multiSigAccAddr":"'"$multisigAccAddr"'"}}]}'
[ "$ok" == true ] resok='(.result.createAddr == "'$GenAddr'")'
rst=$? http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
echo_rst "$FUNCNAME" "$rst"
req='{"method":"Chain33.Query","params":[{"execer":"multisig","funcName":"MultiSigAccAllAddress","payload":{"multiSigAccAddr":"'$GenAddr'"}}]}'
resok='(.result.address[0] == "'"$multisigAccAddr"'")'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
echo "========== # multisig_AccCreateTx ok ==========" echo "========== # multisig_AccCreateTx ok =========="
} }
#多重签名地址转入操作 #多重签名地址转入操作
function multisig_TransferInTx() { function multisig_TransferInTx() {
echo "========== # multisig_TransferInTx begin ==========" echo "========== # multisig_TransferInTx begin =========="
#首先转账到multisig合约中 #首先转账到multisig合约中
txHex=$(curl -ksd '{"method":"Chain33.CreateRawTransaction","params":[{"to":"'"$multisigExecAddr"'","amount":5000000000,"fee":1,"note":"12312","execName":"'"$execName"'"}]}' ${MAIN_HTTP} | jq -r ".result") txHex=$(curl -ksd '{"method":"Chain33.CreateRawTransaction","params":[{"to":"'"$multisigExecAddr"'","amount":5000000000,"fee":1,"note":"12312","execName":"'"$execName"'"}]}' ${MAIN_HTTP} | jq -r ".result")
chain33_SignRawTx "$txHex" "$PrivKeyGen" ${MAIN_HTTP} chain33_SignRawTx "$txHex" "$PrivKeyGen" ${MAIN_HTTP}
...@@ -111,12 +105,9 @@ function multisig_TransferInTx() { ...@@ -111,12 +105,9 @@ function multisig_TransferInTx() {
#chain33_BlockWait 1 ${MAIN_HTTP} #chain33_BlockWait 1 ${MAIN_HTTP}
#查询multisigAccAddr地址资产信息 #查询multisigAccAddr地址资产信息
accountasset=$(curl -ksd '{"method":"Chain33.Query","params":[{"execer":"multisig","funcName":"MultiSigAccAssets","payload":{"multiSigAddr":"'"$multisigAccAddr"'","assets":{"execer":"'$Asset'","symbol":"'$Symbol'"},"isAll":false}}]}' ${MAIN_HTTP} | jq -r ".result.accAssets[0]") req='{"method":"Chain33.Query","params":[{"execer":"multisig","funcName":"MultiSigAccAssets","payload":{"multiSigAddr":"'"$multisigAccAddr"'","assets":{"execer":"'$Asset'","symbol":"'$Symbol'"},"isAll":false}}]}'
echo "multisig_TransferInTx:=${accountasset}" resok='(.result.accAssets[0].assets.execer == "'$Asset'") and (.result.accAssets[0].assets.symbol == "'$Symbol'") and (.result.accAssets[0].account.frozen == "4000000000")'
ok=$(jq '(.assets.execer == "'$Asset'") and (.assets.symbol == "'$Symbol'") and (.account.frozen == "4000000000")' <<<"$accountasset") http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
[ "$ok" == true ]
rst=$?
echo_rst "$FUNCNAME" "$rst"
echo "========== # multisig_TransferInTx end ==========" echo "========== # multisig_TransferInTx end =========="
} }
...@@ -130,21 +121,14 @@ function multisig_TransferOutTx() { ...@@ -130,21 +121,14 @@ function multisig_TransferOutTx() {
#chain33_BlockWait 1 ${MAIN_HTTP} #chain33_BlockWait 1 ${MAIN_HTTP}
#查询AddrB账户在multisig合约下有2000000000 #查询AddrB账户在multisig合约下有2000000000
accountasset=$(curl -ksd '{"method":"Chain33.Query","params":[{"execer":"multisig","funcName":"MultiSigAccAssets","payload":{"multiSigAddr":"1LDGrokrZjo1HtSmSnw8ef3oy5Vm1nctbj","assets":{"execer":"coins","symbol":"'$Symbol'"},"isAll":false}}]}' ${MAIN_HTTP} | jq -r ".result.accAssets[0]") req='{"method":"Chain33.Query","params":[{"execer":"multisig","funcName":"MultiSigAccAssets","payload":{"multiSigAddr":"1LDGrokrZjo1HtSmSnw8ef3oy5Vm1nctbj","assets":{"execer":"coins","symbol":"'$Symbol'"},"isAll":false}}]}'
echo "multisig_TransferOutTx:=${accountasset}" resok='(.result.accAssets[0].assets.execer == "'$Asset'") and (.result.accAssets[0].assets.symbol == "'$Symbol'") and (.result.accAssets[0].account.balance == "2000000000")'
ok=$(jq '(.assets.execer == "'$Asset'") and (.assets.symbol == "'$Symbol'") and (.account.balance == "2000000000")' <<<"$accountasset") http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
[ "$ok" == true ]
rst=$?
echo_rst "$FUNCNAME" "$rst"
#查询multisigAccAddr地址资产信息,减少了2000000000 #查询multisigAccAddr地址资产信息,减少了2000000000
req='{"method":"Chain33.Query","params":[{"execer":"multisig","funcName":"MultiSigAccAssets","payload":{"multiSigAddr":"'"$multisigAccAddr"'","assets":{"execer":"'$Asset'","symbol":"'$Symbol'"},"isAll":false}}]}'
accountasset=$(curl -ksd '{"method":"Chain33.Query","params":[{"execer":"multisig","funcName":"MultiSigAccAssets","payload":{"multiSigAddr":"'"$multisigAccAddr"'","assets":{"execer":"'$Asset'","symbol":"'$Symbol'"},"isAll":false}}]}' ${MAIN_HTTP} | jq -r ".result.accAssets[0]") resok='(.result.accAssets[0].assets.execer == "'$Asset'") and (.result.accAssets[0].assets.symbol == "'$Symbol'") and (.result.accAssets[0].account.frozen == "2000000000")'
ok=$(jq '(.assets.execer == "'$Asset'") and (.assets.symbol == "'$Symbol'") and (.account.frozen == "2000000000")' <<<"$accountasset") http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
[ "$ok" == true ]
rst=$?
echo_rst "$FUNCNAME" "$rst"
echo "========== # multisig_TransferOutTx end ==========" echo "========== # multisig_TransferOutTx end =========="
} }
...@@ -157,12 +141,10 @@ function multisig_OwnerOperateTx() { ...@@ -157,12 +141,10 @@ function multisig_OwnerOperateTx() {
chain33_SignRawTx "$txHex" "$PrivKeyGen" ${MAIN_HTTP} chain33_SignRawTx "$txHex" "$PrivKeyGen" ${MAIN_HTTP}
#chain33_BlockWait 1 ${MAIN_HTTP} #chain33_BlockWait 1 ${MAIN_HTTP}
#查询多重签名账户的信息中有AddrE #查询多重签名账户的信息中有AddrEmultisig_TransferInTx
owner=$(curl -ksd '{"method":"Chain33.Query","params":[{"execer":"multisig","funcName":"MultiSigAccountInfo","payload":{"multiSigAccAddr":"'"$multisigAccAddr"'"}}]}' ${MAIN_HTTP} | jq -r ".result.owners[3]") req='{"method":"Chain33.Query","params":[{"execer":"multisig","funcName":"MultiSigAccountInfo","payload":{"multiSigAccAddr":"'"$multisigAccAddr"'"}}]}'
ok=$(jq '(.ownerAddr == "'$AddrE'")' <<<"$owner") resok='(.result.owners[3].ownerAddr == "'$AddrE'")'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
#删除多重签名账户的信息中owner AddrE #删除多重签名账户的信息中owner AddrE
...@@ -184,12 +166,9 @@ function multisig_OwnerOperateTx() { ...@@ -184,12 +166,9 @@ function multisig_OwnerOperateTx() {
#chain33_BlockWait 1 ${MAIN_HTTP} #chain33_BlockWait 1 ${MAIN_HTTP}
#查询多重签名账户的信息中有AddrE并且weight为30 #查询多重签名账户的信息中有AddrE并且weight为30
req='{"method":"Chain33.Query","params":[{"execer":"multisig","funcName":"MultiSigAccountInfo","payload":{"multiSigAccAddr":"'"$multisigAccAddr"'"}}]}'
owner=$(curl -ksd '{"method":"Chain33.Query","params":[{"execer":"multisig","funcName":"MultiSigAccountInfo","payload":{"multiSigAccAddr":"'"$multisigAccAddr"'"}}]}' ${MAIN_HTTP} | jq -r ".result.owners[0]") resok='(.result.owners[0].ownerAddr == "'$AddrE'") and (.result.owners[0].weight == "30")'
ok=$(jq '(.ownerAddr == "'$AddrE'") and (.weight == "30")' <<<"$owner") http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
} }
function multisig_AccOperateTx() { function multisig_AccOperateTx() {
...@@ -212,27 +191,17 @@ function multisig_AccOperateTx() { ...@@ -212,27 +191,17 @@ function multisig_AccOperateTx() {
#chain33_BlockWait 1 ${MAIN_HTTP} #chain33_BlockWait 1 ${MAIN_HTTP}
#获取本多重签名账户上的交易数,已经对应的交易信息 #获取本多重签名账户上的交易数,已经对应的交易信息
data=$(curl -ksd '{"method":"Chain33.Query","params":[{"execer":"multisig","funcName":"MultiSigAccTxCount","payload":{"multiSigAccAddr":"'"$multisigAccAddr"'"}}]}' ${MAIN_HTTP} | jq -r ".result") req='{"method":"Chain33.Query","params":[{"execer":"multisig","funcName":"MultiSigAccTxCount","payload":{"multiSigAccAddr":"'"$multisigAccAddr"'"}}]}'
ok=$(jq '(.data != "")' <<<"$data") http_req "$req" ${MAIN_HTTP} '(.result.data != null)' "$FUNCNAME"
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
#获取本多重签名账户上的交易数,通过交易交易id获取交易信息
data=$(curl -ksd '{"method":"Chain33.Query","params":[{"execer":"multisig","funcName":"MultiSigAccTxCount","payload":{"multiSigAccAddr":"'"$multisigAccAddr"'"}}]}' ${MAIN_HTTP} | jq -r ".result")
ok=$(jq '(.data != "")' <<<"$data")
[ "$ok" == true ] #获取本多重签名账户上的交易数,通过交易交易id获取交易信息 ????
echo_rst "$FUNCNAME" "$?" req='{"method":"Chain33.Query","params":[{"execer":"multisig","funcName":"MultiSigAccTxCount","payload":{"multiSigAccAddr":"'"$multisigAccAddr"'"}}]}'
http_req "$req" ${MAIN_HTTP} '(.result.data != null)' "$FUNCNAME"
#查询多重签名账户信息中 #查询多重签名账户信息中
req='{"method":"Chain33.Query","params":[{"execer":"multisig","funcName":"MultiSigTxInfo","payload":{"multiSigAddr":"'"$multisigAccAddr"'","txId":"7"}}]}'
data=$(curl -ksd '{"method":"Chain33.Query","params":[{"execer":"multisig","funcName":"MultiSigTxInfo","payload":{"multiSigAddr":"'"$multisigAccAddr"'","txId":"7"}}]}' ${MAIN_HTTP} | jq -r ".result") resok='(.result.txid == "7") and (.result.executed == true) and (.result.multiSigAddr == "'"$multisigAccAddr"'")'
ok=$(jq '(.txid == "7") and (.executed == true) and (.multiSigAddr == "'"$multisigAccAddr"'") ' <<<"$data") http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
} }
function run_test() { function run_test() {
...@@ -241,7 +210,6 @@ function run_test() { ...@@ -241,7 +210,6 @@ function run_test() {
multisig_TransferOutTx multisig_TransferOutTx
multisig_OwnerOperateTx multisig_OwnerOperateTx
multisig_AccOperateTx multisig_AccOperateTx
} }
function main() { function main() {
...@@ -251,8 +219,7 @@ function main() { ...@@ -251,8 +219,7 @@ function main() {
init init
run_test run_test
chain33_RpcTestRst multisi "$CASE_ERR" chain33_RpcTestRst multisi "$CASE_ERR"
} }
main "$1" chain33_debug_function main "$1"
...@@ -23,19 +23,9 @@ oracle_AddPublisher() { ...@@ -23,19 +23,9 @@ oracle_AddPublisher() {
} }
oracle_publish_transaction() { oracle_publish_transaction() {
# req='"method":"Chain33.CreateTransaction","params":[{"execer":"oracle","actionName":"EventPublish","payload":{"type":"football", "subType":"Premier League","time":1747814996,"content":"test","introduction":"test"}}]'
#echo "#request: $req"
# resp=$(curl -ksd "{$req}" ${MAIN_HTTP})
# echo "#response: $resp"
# ok=$(jq '(.error|not) and (.result != "")' <<<"$resp")
# [ "$ok" == true ]
# echo_rst "$FUNCNAME" "$?"
req='{"method":"Chain33.CreateTransaction","params":[{"execer":"oracle","actionName":"EventPublish","payload":{"type":"football", "subType":"Premier League","time":1747814996,"content":"test","introduction":"test"}}]}' req='{"method":"Chain33.CreateTransaction","params":[{"execer":"oracle","actionName":"EventPublish","payload":{"type":"football", "subType":"Premier League","time":1747814996,"content":"test","introduction":"test"}}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != "")' "$FUNCNAME" http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME" ".result"
chain33_SignRawTx "$RAW_RESP" "${oracle_publisher_key}" "${MAIN_HTTP}"
rawtx=$(jq -r ".result" <<<"$HTTP_RESP")
chain33_SignRawTx "$rawtx" "${oracle_publisher_key}" "${MAIN_HTTP}"
eventId="${txhash}" eventId="${txhash}"
echo "eventId $eventId" echo "eventId $eventId"
} }
...@@ -43,74 +33,33 @@ oracle_publish_transaction() { ...@@ -43,74 +33,33 @@ oracle_publish_transaction() {
oracle_prePublishResult_transaction() { oracle_prePublishResult_transaction() {
event_id=$1 event_id=$1
req='{"method":"Chain33.CreateTransaction","params":[{"execer":"oracle","actionName":"ResultPrePublish","payload":{"eventID":"'"$event_id"'", "source":"sina sport","result":"0:1"}}]}' req='{"method":"Chain33.CreateTransaction","params":[{"execer":"oracle","actionName":"ResultPrePublish","payload":{"eventID":"'"$event_id"'", "source":"sina sport","result":"0:1"}}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != "")' "$FUNCNAME" http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME" ".result"
chain33_SignRawTx "$RAW_RESP" "${oracle_publisher_key}" "${MAIN_HTTP}"
#echo "#request: $req"
# resp=$(curl -ksd "{$req}" ${MAIN_HTTP})
# echo "#response: $resp"
# ok=$(jq '(.error|not) and (.result != "")' <<<"$resp")
# [ "$ok" == true ]
# echo_rst "$FUNCNAME" "$?"
rawtx=$(jq -r ".result" <<<"$HTTP_RESP")
chain33_SignRawTx "$rawtx" "${oracle_publisher_key}" "${MAIN_HTTP}"
} }
oracle_eventAbort_transaction() { oracle_eventAbort_transaction() {
event_id=$1 event_id=$1
req='{"method":"Chain33.CreateTransaction","params":[{"execer":"oracle","actionName":"EventAbort","payload":{"eventID":"'"$event_id"'"}}]}' req='{"method":"Chain33.CreateTransaction","params":[{"execer":"oracle","actionName":"EventAbort","payload":{"eventID":"'"$event_id"'"}}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != "")' "$FUNCNAME" http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME" ".result"
chain33_SignRawTx "$RAW_RESP" "${oracle_publisher_key}" "${MAIN_HTTP}"
#echo "#request: $req"
# resp=$(curl -ksd "{$req}" ${MAIN_HTTP})
# echo "#response: $resp"
# ok=$(jq '(.error|not) and (.result != "")' <<<"$resp")
# [ "$ok" == true ]
# echo_rst "$FUNCNAME" "$?"
rawtx=$(jq -r ".result" <<<"$HTTP_RESP")
chain33_SignRawTx "$rawtx" "${oracle_publisher_key}" "${MAIN_HTTP}"
} }
oracle_resultAbort_transaction() { oracle_resultAbort_transaction() {
event_id=$1 event_id=$1
req='{"method":"Chain33.CreateTransaction","params":[{"execer":"oracle","actionName":"ResultAbort","payload":{"eventID":"'"$event_id"'"}}]}' req='{"method":"Chain33.CreateTransaction","params":[{"execer":"oracle","actionName":"ResultAbort","payload":{"eventID":"'"$event_id"'"}}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != "")' "$FUNCNAME" http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME" ".result"
chain33_SignRawTx "$RAW_RESP" "${oracle_publisher_key}" "${MAIN_HTTP}"
#echo "#request: $req"
# resp=$(curl -ksd "{$req}" ${MAIN_HTTP})
# echo "#response: $resp"
# ok=$(jq '(.error|not) and (.result != "")' <<<"$resp")
# [ "$ok" == true ]
# echo_rst "$FUNCNAME" "$?"
rawtx=$(jq -r ".result" <<<"$HTTP_RESP")
chain33_SignRawTx "$rawtx" "${oracle_publisher_key}" "${MAIN_HTTP}"
} }
oracle_publishResult_transaction() { oracle_publishResult_transaction() {
event_id=$1 event_id=$1
req='{"method":"Chain33.CreateTransaction","params":[{"execer":"oracle","actionName":"ResultPublish","payload":{"eventID":"'"$event_id"'", "source":"sina sport","result":"1:1"}}]}' req='{"method":"Chain33.CreateTransaction","params":[{"execer":"oracle","actionName":"ResultPublish","payload":{"eventID":"'"$event_id"'", "source":"sina sport","result":"1:1"}}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != "")' "$FUNCNAME" http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME" ".result"
chain33_SignRawTx "$RAW_RESP" "${oracle_publisher_key}" "${MAIN_HTTP}"
#echo "#request: $req"
# resp=$(curl -ksd "{$req}" ${MAIN_HTTP})
# echo "#response: $resp"
# ok=$(jq '(.error|not) and (.result != "")' <<<"$resp")
# [ "$ok" == true ]
# echo_rst "$FUNCNAME" "$?"
rawtx=$(jq -r ".result" <<<"$HTTP_RESP")
chain33_SignRawTx "$rawtx" "${oracle_publisher_key}" "${MAIN_HTTP}"
} }
oracle_QueryOraclesByID() { oracle_QueryOraclesByID() {
event_id=$1 event_id=$1
# local req='"method":"Chain33.Query", "params":[{"execer":"oracle","funcName":"QueryOraclesByIDs","payload":{"eventID":["'"$event_id"'"]}}]'
#echo "#request: $req"
# resp=$(curl -ksd "{$req}" ${MAIN_HTTP})
# echo "#response: $resp"
# ok=$(jq '(.error|not) and (.result.status[0] | [has("eventID", "status", "type", "subType", "source"),true] | unique | length == 1)' <<<"$resp")
# [ "$ok" == true ]
# rst=$?
# echo_rst "$FUNCNAME" "$rst"
req='{"method":"Chain33.Query", "params":[{"execer":"oracle","funcName":"QueryOraclesByIDs","payload":{"eventID":["'"$event_id"'"]}}]}' req='{"method":"Chain33.Query", "params":[{"execer":"oracle","funcName":"QueryOraclesByIDs","payload":{"eventID":["'"$event_id"'"]}}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result.status[0] | [has("eventID", "status", "type", "subType", "source"),true] | unique | length == 1)' "$FUNCNAME" http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result.status[0] | [has("eventID", "status", "type", "subType", "source"),true] | unique | length == 1)' "$FUNCNAME"
} }
...@@ -149,14 +98,12 @@ function run_test() { ...@@ -149,14 +98,12 @@ function run_test() {
} }
function main() { function main() {
chain33_RpcTestBegin oracle
MAIN_HTTP="$1" MAIN_HTTP="$1"
echo "main_ip=$MAIN_HTTP" echo "main_ip=$MAIN_HTTP"
chain33_RpcTestBegin oracle
run_test run_test
chain33_RpcTestRst oracle "$CASE_ERR" chain33_RpcTestRst oracle "$CASE_ERR"
} }
main "$1" chain33_debug_function main "$1"
...@@ -9,12 +9,7 @@ IS_PARA=false ...@@ -9,12 +9,7 @@ IS_PARA=false
source ../dapp-test-common.sh source ../dapp-test-common.sh
paracross_GetBlock2MainInfo() { paracross_GetBlock2MainInfo() {
local height http_req '{"method":"paracross.GetBlock2MainInfo","params":[{"start":1,"end":3}]}' ${UNIT_HTTP} "(.result.items[1].height == 2)" "$FUNCNAME"
height=$(curl -ksd '{"method":"paracross.GetBlock2MainInfo","params":[{"start":1,"end":3}]}' ${UNIT_HTTP} | jq -r ".result.items[1].height")
[ "$height" -eq 2 ]
local rst=$?
echo_rst "$FUNCNAME" "$rst"
} }
function paracross_SignAndSend() { function paracross_SignAndSend() {
...@@ -22,7 +17,6 @@ function paracross_SignAndSend() { ...@@ -22,7 +17,6 @@ function paracross_SignAndSend() {
local sendedTx local sendedTx
signedTx=$(curl -ksd '{"method":"Chain33.SignRawTx","params":[{"expire":"120s","fee":'"$1"',"privkey":"'"$2"'","txHex":"'"$3"'"}]}' ${UNIT_HTTP} | jq -r ".result") signedTx=$(curl -ksd '{"method":"Chain33.SignRawTx","params":[{"expire":"120s","fee":'"$1"',"privkey":"'"$2"'","txHex":"'"$3"'"}]}' ${UNIT_HTTP} | jq -r ".result")
#echo "signedTx:$signedTx"
sendedTx=$(curl -ksd '{"method":"Chain33.SendTransaction","params":[{"data":"'"$signedTx"'"}]}' ${UNIT_HTTP} | jq -r ".result") sendedTx=$(curl -ksd '{"method":"Chain33.SendTransaction","params":[{"data":"'"$signedTx"'"}]}' ${UNIT_HTTP} | jq -r ".result")
echo "sendedTx:$sendedTx" echo "sendedTx:$sendedTx"
} }
...@@ -63,7 +57,6 @@ function paracross_QueryMainBalance() { ...@@ -63,7 +57,6 @@ function paracross_QueryMainBalance() {
} }
function paracross_Transfer_Withdraw_Inner() { function paracross_Transfer_Withdraw_Inner() {
# 计数器,资产转移操作和取钱操作都成功才算成功,也就是 counter == 2 # 计数器,资产转移操作和取钱操作都成功才算成功,也就是 counter == 2
local count=0 local count=0
#fromAddr 跨链资产转移地址 #fromAddr 跨链资产转移地址
...@@ -201,33 +194,16 @@ function paracross_Transfer_Withdraw() { ...@@ -201,33 +194,16 @@ function paracross_Transfer_Withdraw() {
} }
function paracross_IsSync() { function paracross_IsSync() {
# local ok
if [ "$IS_PARA" == "true" ]; then if [ "$IS_PARA" == "true" ]; then
req='{"method":"paracross.IsSync","params":[]}' req='{"method":"paracross.IsSync","params":[]}'
# ok=$(curl -ksd '{"method":"paracross.IsSync","params":[]}' ${UNIT_HTTP} | jq -r ".result")
else else
# ok=$(curl -ksd '{"method":"Chain33.IsSync","params":[]}' ${UNIT_HTTP} | jq -r ".result")
req='{"method":"Chain33.IsSync","params":[]}' req='{"method":"Chain33.IsSync","params":[]}'
fi fi
http_req "$req" ${UNIT_HTTP} '.result' "$FUNCNAME" http_req "$req" ${UNIT_HTTP} '.result' "$FUNCNAME"
# [ "$ok" == true ]
# local rst=$?
# echo_rst "$FUNCNAME" "$rst"
} }
function paracross_ListTitles() { function paracross_ListTitles() {
# local resp
# local ok
local main_ip=${UNIT_HTTP//8901/8801} local main_ip=${UNIT_HTTP//8901/8801}
# resp=$(curl -ksd '{"method":"paracross.ListTitles","params":[]}' ${main_ip})
# echo "$resp"
# ok=$(jq '(.error|not) and (.result| [has("titles"),true])' <<<"$resp")
# [ "$ok" == true ]
# local rst=$?
# echo_rst "$FUNCNAME" "$rst"
http_req '{"method":"paracross.ListTitles","params":[]}' ${main_ip} '(.error|not) and (.result| [has("titles"),true])' "$FUNCNAME" http_req '{"method":"paracross.ListTitles","params":[]}' ${main_ip} '(.error|not) and (.result| [has("titles"),true])' "$FUNCNAME"
} }
...@@ -236,70 +212,23 @@ function paracross_GetHeight() { ...@@ -236,70 +212,23 @@ function paracross_GetHeight() {
local ok local ok
if [ "$IS_PARA" == "true" ]; then if [ "$IS_PARA" == "true" ]; then
# resp=$(curl -ksd '{"method":"paracross.GetHeight","params":[]}' ${UNIT_HTTP})
#echo $resp
# ok=$(jq '(.error|not) and (.result| [has("consensHeight"),true])' <<<"$resp")
# [ "$ok" == true ]
# local rst=$?
# echo_rst "$FUNCNAME" "$rst"
http_req '{"method":"paracross.GetHeight","params":[]}' ${UNIT_HTTP} '(.error|not) and (.result| [has("consensHeight"),true])' "$FUNCNAME" http_req '{"method":"paracross.GetHeight","params":[]}' ${UNIT_HTTP} '(.error|not) and (.result| [has("consensHeight"),true])' "$FUNCNAME"
fi fi
} }
function paracross_GetNodeGroupAddrs() { function paracross_GetNodeGroupAddrs() {
# local resp
# local ok
# resp=$(curl -ksd '{"method":"paracross.GetNodeGroupAddrs","params":[{"title":"user.p.para."}]}' ${UNIT_HTTP})
#echo $resp
# ok=$(jq '(.error|not) and (.result| [has("key","value"),true])' <<<"$resp")
# [ "$ok" == true ]
# local rst=$?
# echo_rst "$FUNCNAME" "$rst"
http_req '{"method":"paracross.GetNodeGroupAddrs","params":[{"title":"user.p.para."}]}' ${UNIT_HTTP} '(.error|not) and (.result| [has("key","value"),true])' "$FUNCNAME" http_req '{"method":"paracross.GetNodeGroupAddrs","params":[{"title":"user.p.para."}]}' ${UNIT_HTTP} '(.error|not) and (.result| [has("key","value"),true])' "$FUNCNAME"
} }
function paracross_GetNodeGroupStatus() { function paracross_GetNodeGroupStatus() {
# local resp
# local ok
# resp=$(curl -ksd '{"method":"paracross.GetNodeGroupStatus","params":[{"title":"user.p.para."}]}' ${UNIT_HTTP})
#echo $resp
# ok=$(jq '(.error|not) and (.result| [has("status"),true])' <<<"$resp")
# [ "$ok" == true ]
# local rst=$?
# echo_rst "$FUNCNAME" "$rst"
http_req '{"method":"paracross.GetNodeGroupStatus","params":[{"title":"user.p.para."}]}' ${UNIT_HTTP} '(.error|not) and (.result| [has("status"),true])' "$FUNCNAME" http_req '{"method":"paracross.GetNodeGroupStatus","params":[{"title":"user.p.para."}]}' ${UNIT_HTTP} '(.error|not) and (.result| [has("status"),true])' "$FUNCNAME"
} }
function paracross_ListNodeGroupStatus() { function paracross_ListNodeGroupStatus() {
# local resp
# local ok
# resp=$(curl -ksd '{"method":"paracross.ListNodeGroupStatus","params":[{"title":"user.p.para.","status":2}]}' ${UNIT_HTTP})
#echo $resp
# ok=$(jq '(.error|not) and (.result| [has("status"),true])' <<<"$resp")
# [ "$ok" == true ]
# local rst=$?
# echo_rst "$FUNCNAME" "$rst"
http_req '{"method":"paracross.ListNodeGroupStatus","params":[{"title":"user.p.para.","status":2}]}' ${UNIT_HTTP} '(.error|not) and (.result| [has("status"),true])' "$FUNCNAME" http_req '{"method":"paracross.ListNodeGroupStatus","params":[{"title":"user.p.para.","status":2}]}' ${UNIT_HTTP} '(.error|not) and (.result| [has("status"),true])' "$FUNCNAME"
} }
function paracross_ListNodeStatus() { function paracross_ListNodeStatus() {
# local resp
# local ok
# resp=$(curl -ksd '{"method":"paracross.ListNodeStatus","params":[{"title":"user.p.para.","status":4}]}' ${UNIT_HTTP})
#echo $resp
# ok=$(jq '(.error|not) and (.result| [has("status"),true])' <<<"$resp")
# [ "$ok" == true ]
# local rst=$?
# echo_rst "$FUNCNAME" "$rst"
http_req '{"method":"paracross.ListNodeStatus","params":[{"title":"user.p.para.","status":4}]}' ${UNIT_HTTP} '(.error|not) and (.result| [has("status"),true])' "$FUNCNAME" http_req '{"method":"paracross.ListNodeStatus","params":[{"title":"user.p.para.","status":4}]}' ${UNIT_HTTP} '(.error|not) and (.result| [has("status"),true])' "$FUNCNAME"
} }
...@@ -360,7 +289,7 @@ function paracross_txgroupex() { ...@@ -360,7 +289,7 @@ function paracross_txgroupex() {
} }
//测试平行链交易组跨链失败,主链自动恢复原值 #测试平行链交易组跨链失败,主链自动恢复原值
function paracross_testTxGroupFail() { function paracross_testTxGroupFail() {
local para_ip=$1 local para_ip=$1
...@@ -375,7 +304,7 @@ function paracross_testTxGroupFail() { ...@@ -375,7 +304,7 @@ function paracross_testTxGroupFail() {
#execer #execer
local trade_exec_addr="12bihjzbaYWjcpDiiy9SuAWeqNksQdiN13" local trade_exec_addr="12bihjzbaYWjcpDiiy9SuAWeqNksQdiN13"
//测试跨链过去1个,交易组转账8个失败的场景,主链应该还保持原来的 #测试跨链过去1个,交易组转账8个失败的场景,主链应该还保持原来的
local amount_trade=800000000 local amount_trade=800000000
local amount_transfer=100000000 local amount_transfer=100000000
local amount_left=500000000 local amount_left=500000000
......
...@@ -10,109 +10,39 @@ GAME_ID="" ...@@ -10,109 +10,39 @@ GAME_ID=""
source ../dapp-test-common.sh source ../dapp-test-common.sh
pokerbull_PlayRawTx() { pokerbull_PlayRawTx() {
echo "========== # pokerbull play tx begin =========="
tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"pokerbull","actionName":"Play","payload":{"gameId":"pokerbull-abc", "value":"1000000000", "round":1}}]}' ${MAIN_HTTP} | jq -r ".result") tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"pokerbull","actionName":"Play","payload":{"gameId":"pokerbull-abc", "value":"1000000000", "round":1}}]}' ${MAIN_HTTP} | jq -r ".result")
chain33_DecodeRawTransactionTx "$tx" "0x0316d5e33e7bce2455413156cb95209f8c641af352ee5d648c647f24383e4d94" ${MAIN_HTTP} "$FUNCNAME"
# data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]")
# ok=$(jq '(.execer != "")' <<<"$data")
# [ "$ok" == true ]
# echo_rst "$FUNCNAME" "$?"
req='{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}'
http_req "$req" ${MAIN_HTTP} '(.result.txs[0].execer != "")' "$FUNCNAME"
chain33_SignRawTx "$tx" "0x0316d5e33e7bce2455413156cb95209f8c641af352ee5d648c647f24383e4d94" ${MAIN_HTTP}
echo "========== # pokerbull play tx end =========="
chain33_BlockWait 1 ${MAIN_HTTP}
} }
pokerbull_QuitRawTx() { pokerbull_QuitRawTx() {
echo "========== # pokerbull quit tx begin =========="
tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"pokerbull","actionName":"Quit","payload":{"gameId":"'$GAME_ID'"}}]}' ${MAIN_HTTP} | jq -r ".result") tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"pokerbull","actionName":"Quit","payload":{"gameId":"'$GAME_ID'"}}]}' ${MAIN_HTTP} | jq -r ".result")
chain33_DecodeRawTransactionTx "$tx" "0x0316d5e33e7bce2455413156cb95209f8c641af352ee5d648c647f24383e4d94" ${MAIN_HTTP} "$FUNCNAME"
# data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]")
# ok=$(jq '(.execer != "")' <<<"$data")
# [ "$ok" == true ]
# echo_rst "$FUNCNAME" "$?"
req='{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}'
http_req "$req" ${MAIN_HTTP} '(.result.txs[0].execer != "")' "$FUNCNAME"
chain33_SignRawTx "$tx" "0x0316d5e33e7bce2455413156cb95209f8c641af352ee5d648c647f24383e4d94" ${MAIN_HTTP}
echo "========== # pokerbull quit tx end =========="
chain33_BlockWait 1 "${MAIN_HTTP}"
} }
pokerbull_ContinueRawTx() { pokerbull_ContinueRawTx() {
echo "========== # pokerbull continue tx begin =========="
tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"pokerbull","actionName":"Continue","payload":{"gameId":"'$GAME_ID'"}}]}' ${MAIN_HTTP} | jq -r ".result") tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"pokerbull","actionName":"Continue","payload":{"gameId":"'$GAME_ID'"}}]}' ${MAIN_HTTP} | jq -r ".result")
chain33_DecodeRawTransactionTx "$tx" "0xa26038cbdd9e6fbfb85f2c3d032254755e75252b9edccbecc16d9ba117d96705" ${MAIN_HTTP} "$FUNCNAME"
# data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]")
# ok=$(jq '(.execer != "")' <<<"$data")
# [ "$ok" == true ]
# echo_rst "$FUNCNAME" "$?"
req='{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}'
http_req "$req" ${MAIN_HTTP} '(.result.txs[0].execer != "")' "$FUNCNAME"
chain33_SignRawTx "$tx" "0xa26038cbdd9e6fbfb85f2c3d032254755e75252b9edccbecc16d9ba117d96705" ${MAIN_HTTP}
echo "========== # pokerbull continue tx end =========="
chain33_BlockWait 1 "${MAIN_HTTP}"
} }
pokerbull_StartRawTx() { pokerbull_StartRawTx() {
echo "========== # pokerbull start tx begin =========="
tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"pokerbull","actionName":"Start","payload":{"value":"1000000000", "playerNum":"2"}}]}' ${MAIN_HTTP} | jq -r ".result") tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"pokerbull","actionName":"Start","payload":{"value":"1000000000", "playerNum":"2"}}]}' ${MAIN_HTTP} | jq -r ".result")
# data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]")
# ok=$(jq '(.execer != "")' <<<"$data")
# [ "$ok" == true ]
# echo_rst "$FUNCNAME" "$?"
req='{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' req='{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}'
http_req "$req" ${MAIN_HTTP} '(.result.txs[0].execer != "")' "$FUNCNAME" http_req "$req" ${MAIN_HTTP} '(.result.txs[0].execer != null)' "$FUNCNAME"
chain33_SignRawTx "$tx" "0x0316d5e33e7bce2455413156cb95209f8c641af352ee5d648c647f24383e4d94" ${MAIN_HTTP} chain33_SignRawTx "$tx" "0x0316d5e33e7bce2455413156cb95209f8c641af352ee5d648c647f24383e4d94" ${MAIN_HTTP}
GAME_ID=$RAW_TX_HASH GAME_ID=$RAW_TX_HASH
echo "========== # pokerbull start tx end =========="
chain33_BlockWait 1 "${MAIN_HTTP}" chain33_BlockWait 1 "${MAIN_HTTP}"
} }
pokerbull_QueryResult() { pokerbull_QueryResult() {
echo "========== # pokerbull query result begin =========="
# local req='"method":"Chain33.Query","params":[{"execer":"pokerbull","funcName":"QueryGameByID","payload":{"gameId":"'$GAME_ID'"}}]'
# data=$(curl -ksd "{$req}" ${MAIN_HTTP} | jq -r ".result")
# ok=$(jq '(.game.gameId == "'"$GAME_ID"'")' <<<"$data")
# [ "$ok" == true ]
# echo_rst "$FUNCNAME" "$?"
req='{"method":"Chain33.Query","params":[{"execer":"pokerbull","funcName":"QueryGameByID","payload":{"gameId":"'$GAME_ID'"}}]}' req='{"method":"Chain33.Query","params":[{"execer":"pokerbull","funcName":"QueryGameByID","payload":{"gameId":"'$GAME_ID'"}}]}'
resok='(.result.game.gameId == "'"$GAME_ID"'")' resok='(.result.game.gameId == "'"$GAME_ID"'")'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME" http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
# data=$(curl -ksd '{"method":"Chain33.Query","params":[{"execer":"pokerbull","funcName":"QueryGameByAddr","payload":{"addr":"14VkqML8YTRK4o15Cf97CQhpbnRUa6sJY4"}}]}' ${MAIN_HTTP} | jq -r ".result")
# [ "$data" != null ]
# echo_rst "$FUNCNAME" "$?"
req='{"method":"Chain33.Query","params":[{"execer":"pokerbull","funcName":"QueryGameByAddr","payload":{"addr":"14VkqML8YTRK4o15Cf97CQhpbnRUa6sJY4"}}]}' req='{"method":"Chain33.Query","params":[{"execer":"pokerbull","funcName":"QueryGameByAddr","payload":{"addr":"14VkqML8YTRK4o15Cf97CQhpbnRUa6sJY4"}}]}'
http_req "$req" ${MAIN_HTTP} '(.result != null)' "$FUNCNAME" http_req "$req" ${MAIN_HTTP} '(.result != null)' "$FUNCNAME"
# data=$(curl -ksd '{"method":"Chain33.Query","params":[{"execer":"pokerbull","funcName":"QueryGameByStatus","payload":{"status":"3"}}]}' ${MAIN_HTTP} | jq -r ".result")
# [ "$data" != null ]
# echo_rst "$FUNCNAME" "$?"
req='{"method":"Chain33.Query","params":[{"execer":"pokerbull","funcName":"QueryGameByStatus","payload":{"status":"3"}}]}' req='{"method":"Chain33.Query","params":[{"execer":"pokerbull","funcName":"QueryGameByStatus","payload":{"status":"3"}}]}'
http_req "$req" ${MAIN_HTTP} '(.result != null)' "$FUNCNAME" http_req "$req" ${MAIN_HTTP} '(.result != null)' "$FUNCNAME"
echo "========== # pokerbull query result end =========="
} }
init() { init() {
...@@ -185,8 +115,7 @@ function main() { ...@@ -185,8 +115,7 @@ function main() {
init init
run_test run_test
chain33_RpcTestRst pokerbull "$CASE_ERR" chain33_RpcTestRst pokerbull "$CASE_ERR"
} }
chain33_debug_function main "$1" chain33_debug_function main "$1"
\ No newline at end of file
...@@ -51,11 +51,12 @@ function run_test() { ...@@ -51,11 +51,12 @@ function run_test() {
} }
function main() { function main() {
chain33_RpcTestBegin privacy
MAIN_HTTP="$1" MAIN_HTTP="$1"
echo "ip=$MAIN_HTTP" echo "ip=$MAIN_HTTP"
chain33_RpcTestBegin privacy
run_test run_test
chain33_RpcTestRst privacy "$CASE_ERR" chain33_RpcTestRst privacy "$CASE_ERR"
} }
main "$1" chain33_debug_function main "$1"
...@@ -8,19 +8,19 @@ MAIN_HTTP="" ...@@ -8,19 +8,19 @@ MAIN_HTTP=""
relay_CreateRawRelaySaveBTCHeadTx() { relay_CreateRawRelaySaveBTCHeadTx() {
local req='{"method":"relay.CreateRawRelaySaveBTCHeadTx","params":[{"hash":"5e7d9c599cd040ec2ba53f4dee28028710be8c135e779f65c56feadaae34c3f2","height":10,"version":536870912,"merkleRoot":"ab91cd4160e1379c337eee6b7a4bdbb7399d70268d86045aba150743c00c90b6","time":1530862108,"nonce":0,"bits":545259519,"previousHash":"604efe53975ab06cad8748fd703ad5bc960e8b752b2aae98f0f871a4a05abfc7","isReset":true}]}' local req='{"method":"relay.CreateRawRelaySaveBTCHeadTx","params":[{"hash":"5e7d9c599cd040ec2ba53f4dee28028710be8c135e779f65c56feadaae34c3f2","height":10,"version":536870912,"merkleRoot":"ab91cd4160e1379c337eee6b7a4bdbb7399d70268d86045aba150743c00c90b6","time":1530862108,"nonce":0,"bits":545259519,"previousHash":"604efe53975ab06cad8748fd703ad5bc960e8b752b2aae98f0f871a4a05abfc7","isReset":true}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != "")' "$FUNCNAME" ".result" http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME" ".result"
chain33_SignRawTx "$RAW_RESP" "0x22968d29c6de695381a8719ef7bf00e2edb6cce500bb59a4fc73c41887610962" "${MAIN_HTTP}" chain33_SignRawTx "$RAW_RESP" "0x22968d29c6de695381a8719ef7bf00e2edb6cce500bb59a4fc73c41887610962" "${MAIN_HTTP}"
} }
relay_CreateRawRelaySaveBTCHeadTx_11() { relay_CreateRawRelaySaveBTCHeadTx_11() {
local req='{"method":"relay.CreateRawRelaySaveBTCHeadTx","params":[{"hash":"7b7a4a9b49db5a1162be515d380cd186e98c2bf0bb90f1145485d7c43343fc7c","height":11,"version":536870912,"merkleRoot":"cfa9b66696aea63b7266ffaa1cb4b96c8dd6959eaabf2eb14173f4adaa551f6f","time":1530862108,"nonce":1,"bits":545259519,"previousHash":"5e7d9c599cd040ec2ba53f4dee28028710be8c135e779f65c56feadaae34c3f2","isReset":false}]}' local req='{"method":"relay.CreateRawRelaySaveBTCHeadTx","params":[{"hash":"7b7a4a9b49db5a1162be515d380cd186e98c2bf0bb90f1145485d7c43343fc7c","height":11,"version":536870912,"merkleRoot":"cfa9b66696aea63b7266ffaa1cb4b96c8dd6959eaabf2eb14173f4adaa551f6f","time":1530862108,"nonce":1,"bits":545259519,"previousHash":"5e7d9c599cd040ec2ba53f4dee28028710be8c135e779f65c56feadaae34c3f2","isReset":false}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != "")' "$FUNCNAME" ".result" http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME" ".result"
chain33_SignRawTx "$RAW_RESP" "0x22968d29c6de695381a8719ef7bf00e2edb6cce500bb59a4fc73c41887610962" "${MAIN_HTTP}" chain33_SignRawTx "$RAW_RESP" "0x22968d29c6de695381a8719ef7bf00e2edb6cce500bb59a4fc73c41887610962" "${MAIN_HTTP}"
} }
relay_CreateRawRelayOrderTx() { relay_CreateRawRelayOrderTx() {
local req='{"method":"relay.CreateRawRelayOrderTx","params":[{"operation":0,"coin":"BTC","amount":299000000,"addr":"1Am9UTGfdnxabvcywYG2hvzr6qK8T3oUZT","btyAmount":1000000000,"coinWaits":6}]}' local req='{"method":"relay.CreateRawRelayOrderTx","params":[{"operation":0,"coin":"BTC","amount":299000000,"addr":"1Am9UTGfdnxabvcywYG2hvzr6qK8T3oUZT","btyAmount":1000000000,"coinWaits":6}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != "")' "$FUNCNAME" ".result" http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME" ".result"
chain33_SignRawTx "$RAW_RESP" "0x22968d29c6de695381a8719ef7bf00e2edb6cce500bb59a4fc73c41887610962" "${MAIN_HTTP}" chain33_SignRawTx "$RAW_RESP" "0x22968d29c6de695381a8719ef7bf00e2edb6cce500bb59a4fc73c41887610962" "${MAIN_HTTP}"
} }
...@@ -35,7 +35,7 @@ relay_CreateRawRelayAcceptTx() { ...@@ -35,7 +35,7 @@ relay_CreateRawRelayAcceptTx() {
fi fi
local req='{"method":"relay.CreateRawRelayAcceptTx","params":[{"orderId":"'"$id"'","coinAddr":"1Am9UTGfdnxabvcywYG2hvzr6qK8T3oUZT"}]}' local req='{"method":"relay.CreateRawRelayAcceptTx","params":[{"orderId":"'"$id"'","coinAddr":"1Am9UTGfdnxabvcywYG2hvzr6qK8T3oUZT"}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != "")' "$FUNCNAME" ".result" http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME" ".result"
chain33_SignRawTx "$RAW_RESP" "0xec9162ea5fc2f473ab8240619a0a0f495ba9e9e5d4d9c434b8794a68280236c4" "${MAIN_HTTP}" chain33_SignRawTx "$RAW_RESP" "0xec9162ea5fc2f473ab8240619a0a0f495ba9e9e5d4d9c434b8794a68280236c4" "${MAIN_HTTP}"
} }
...@@ -50,7 +50,7 @@ relay_CreateRawRelayRevokeTx() { ...@@ -50,7 +50,7 @@ relay_CreateRawRelayRevokeTx() {
fi fi
local req='{"method":"relay.CreateRawRelayRevokeTx","params":[{"orderId":"'"$id"'","target":0,"action":1}]}' local req='{"method":"relay.CreateRawRelayRevokeTx","params":[{"orderId":"'"$id"'","target":0,"action":1}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != "")' "$FUNCNAME" ".result" http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME" ".result"
chain33_SignRawTx "$RAW_RESP" "0x22968d29c6de695381a8719ef7bf00e2edb6cce500bb59a4fc73c41887610962" "${MAIN_HTTP}" chain33_SignRawTx "$RAW_RESP" "0x22968d29c6de695381a8719ef7bf00e2edb6cce500bb59a4fc73c41887610962" "${MAIN_HTTP}"
} }
...@@ -65,19 +65,19 @@ relay_CreateRawRelayConfirmTx() { ...@@ -65,19 +65,19 @@ relay_CreateRawRelayConfirmTx() {
fi fi
local req='{"method":"relay.CreateRawRelayConfirmTx","params":[{"orderId":"'"$id"'","rawTx":"6359f0868171b1d194cbee1af2f16ea598ae8fad666d9b012c8ed2b79a236ec4"}]}' local req='{"method":"relay.CreateRawRelayConfirmTx","params":[{"orderId":"'"$id"'","rawTx":"6359f0868171b1d194cbee1af2f16ea598ae8fad666d9b012c8ed2b79a236ec4"}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != "")' "$FUNCNAME" ".result" http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME" ".result"
chain33_SignRawTx "$RAW_RESP" "0xec9162ea5fc2f473ab8240619a0a0f495ba9e9e5d4d9c434b8794a68280236c4" "${MAIN_HTTP}" chain33_SignRawTx "$RAW_RESP" "0xec9162ea5fc2f473ab8240619a0a0f495ba9e9e5d4d9c434b8794a68280236c4" "${MAIN_HTTP}"
} }
query_GetRelayOrderByStatus() { query_GetRelayOrderByStatus() {
status="$1" status="$1"
local req='{"method":"Chain33.Query", "params":[{"execer":"relay","funcName":"GetRelayOrderByStatus","payload":{"addr":"","status":"'"$status"'","coins":["BTC"],"pageNumber":0,"pageSize":0}}]}' local req='{"method":"Chain33.Query", "params":[{"execer":"relay","funcName":"GetRelayOrderByStatus","payload":{"addr":"","status":"'"$status"'","coins":["BTC"],"pageNumber":0,"pageSize":0}}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result.relayorders[0].id != "")' "$FUNCNAME" http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result.relayorders[0].id != null)' "$FUNCNAME"
} }
query_GetSellRelayOrder() { query_GetSellRelayOrder() {
local req='{"method":"Chain33.Query", "params":[{"execer":"relay","funcName":"GetSellRelayOrder","payload":{"addr":"1G5Cjy8LuQex2fuYv3gzb7B8MxAnxLEqt3","status":"pending","coins":["BTC"],"pageNumber":0,"pageSize":0}}]}' local req='{"method":"Chain33.Query", "params":[{"execer":"relay","funcName":"GetSellRelayOrder","payload":{"addr":"1G5Cjy8LuQex2fuYv3gzb7B8MxAnxLEqt3","status":"pending","coins":["BTC"],"pageNumber":0,"pageSize":0}}]}'
resok='(.error|not) and (.result.relayorders[0].status == "pending") and (.result.relayorders[0].coinOperation == 0) and (.result.relayorders[0].id != "")' resok='(.error|not) and (.result.relayorders[0].status == "pending") and (.result.relayorders[0].coinOperation == 0) and (.result.relayorders[0].id != null)'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME" http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
} }
...@@ -175,10 +175,10 @@ function rpc_test() { ...@@ -175,10 +175,10 @@ function rpc_test() {
chain33_RpcTestBegin Relay chain33_RpcTestBegin Relay
MAIN_HTTP="$1" MAIN_HTTP="$1"
echo "main_ip=$MAIN_HTTP" echo "main_ip=$MAIN_HTTP"
init init
run_testcases run_testcases
chain33_RpcTestRst Relay "$CASE_ERR" chain33_RpcTestRst Relay "$CASE_ERR"
} }
rpc_test "$1" chain33_debug_function rpc_test "$1"
#chain33_debug_function rpc_test "$1"
...@@ -61,140 +61,45 @@ function createToken() { ...@@ -61,140 +61,45 @@ function createToken() {
} }
retrieve_Backup() { retrieve_Backup() {
echo "========== # retrieve backup begin =========="
local req='{"method":"retrieve.CreateRawRetrieveBackupTx","params":[{"backupAddr":"'$retrieve1'","defaultAddr":"'$retrieve2'","delayPeriod": 61}]}' local req='{"method":"retrieve.CreateRawRetrieveBackupTx","params":[{"backupAddr":"'$retrieve1'","defaultAddr":"'$retrieve2'","delayPeriod": 61}]}'
tx=$(curl -ksd "$req" ${MAIN_HTTP} | jq -r ".result") tx=$(curl -ksd "$req" ${MAIN_HTTP} | jq -r ".result")
chain33_DecodeRawTransactionTx "$tx" "$retrieve2_key" ${MAIN_HTTP} "$FUNCNAME"
local reqDecode='{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}'
http_req "$reqDecode" ${MAIN_HTTP} '(.result.txs[0].execer != "")' "$FUNCNAME"
# data=$(curl -ksd "$reqDecode" ${MAIN_HTTP} | jq -r ".result.txs[0]")
# ok=$(jq '(.execer != "")' <<<"$data")
# [ "$ok" == true ]
# echo_rst "$FUNCNAME" "$?"
chain33_SignRawTx "$tx" "$retrieve2_key" ${MAIN_HTTP}
echo "========== # retrieve backup end =========="
chain33_BlockWait 1 "${MAIN_HTTP}"
} }
retrieve_Prepare() { retrieve_Prepare() {
echo "========== # retrieve prepare begin =========="
local req='{"method":"retrieve.CreateRawRetrievePrepareTx","params":[{"backupAddr":"'$retrieve1'","defaultAddr":"'$retrieve2'"}]}' local req='{"method":"retrieve.CreateRawRetrievePrepareTx","params":[{"backupAddr":"'$retrieve1'","defaultAddr":"'$retrieve2'"}]}'
tx=$(curl -ksd "$req" ${MAIN_HTTP} | jq -r ".result") tx=$(curl -ksd "$req" ${MAIN_HTTP} | jq -r ".result")
chain33_DecodeRawTransactionTx "$tx" "$retrieve1_key" ${MAIN_HTTP} "$FUNCNAME"
local reqDecode='{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}'
http_req "$reqDecode" ${MAIN_HTTP} '(.result.txs[0].execer != "")' "$FUNCNAME"
# data=$(curl -ksd "$reqDecode" ${MAIN_HTTP} | jq -r ".result.txs[0]")
# ok=$(jq '(.execer != "")' <<<"$data")
# [ "$ok" == true ]
# echo_rst "$FUNCNAME" "$?"
chain33_SignRawTx "$tx" "$retrieve1_key" ${MAIN_HTTP}
echo "========== # retrieve prepare end =========="
chain33_BlockWait 1 "${MAIN_HTTP}"
} }
retrieve_Perform() { retrieve_Perform() {
echo "========== # retrieve perform begin =========="
local req='{"method":"retrieve.CreateRawRetrievePerformTx","params":[{"backupAddr":"'$retrieve1'","defaultAddr":"'$retrieve2'"}]}' local req='{"method":"retrieve.CreateRawRetrievePerformTx","params":[{"backupAddr":"'$retrieve1'","defaultAddr":"'$retrieve2'"}]}'
tx=$(curl -ksd "$req" ${MAIN_HTTP} | jq -r ".result") tx=$(curl -ksd "$req" ${MAIN_HTTP} | jq -r ".result")
chain33_DecodeRawTransactionTx "$tx" "$retrieve1_key" ${MAIN_HTTP} "$FUNCNAME"
local reqDecode='{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}'
http_req "$reqDecode" ${MAIN_HTTP} '(.result.txs[0].execer != "")' "$FUNCNAME"
# data=$(curl -ksd "$reqDecode" ${MAIN_HTTP} | jq -r ".result.txs[0]")
# ok=$(jq '(.execer != "")' <<<"$data")
# [ "$ok" == true ]
# echo_rst "$FUNCNAME" "$?"
chain33_SignRawTx "$tx" "$retrieve1_key" ${MAIN_HTTP}
echo "========== # retrieve perform end =========="
chain33_BlockWait 1 "${MAIN_HTTP}"
} }
retrieve_Perform_Token() { retrieve_Perform_Token() {
echo "========== # retrieve perform begin =========="
local req='{"method":"retrieve.CreateRawRetrievePerformTx","params":[{"backupAddr":"'$retrieve1'","defaultAddr":"'$retrieve2'","assets": [{"exec":"token","symbol":"'"$symbol"'"}] }]}' local req='{"method":"retrieve.CreateRawRetrievePerformTx","params":[{"backupAddr":"'$retrieve1'","defaultAddr":"'$retrieve2'","assets": [{"exec":"token","symbol":"'"$symbol"'"}] }]}'
tx=$(curl -ksd "$req" ${MAIN_HTTP} | jq -r ".result") tx=$(curl -ksd "$req" ${MAIN_HTTP} | jq -r ".result")
chain33_DecodeRawTransactionTx "$tx" "$retrieve1_key" ${MAIN_HTTP} "$FUNCNAME"
local reqDecode='{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}'
http_req "$reqDecode" ${MAIN_HTTP} '(.result.txs[0].execer != "")' "$FUNCNAME"
# data=$(curl -ksd "$reqDecode" ${MAIN_HTTP} | jq -r ".result.txs[0]")
# ok=$(jq '(.execer != "")' <<<"$data")
# [ "$ok" == true ]
# echo_rst "$FUNCNAME" "$?"
chain33_SignRawTx "$tx" "$retrieve1_key" ${MAIN_HTTP}
echo "========== # retrieve perform end =========="
chain33_BlockWait 1 "${MAIN_HTTP}"
} }
retrieve_Cancel() { retrieve_Cancel() {
echo "========== # retrieve cancel begin =========="
local req='{"method":"retrieve.CreateRawRetrieveCancelTx","params":[{"backupAddr":"'$retrieve1'","defaultAddr":"'$retrieve2'"}]}' local req='{"method":"retrieve.CreateRawRetrieveCancelTx","params":[{"backupAddr":"'$retrieve1'","defaultAddr":"'$retrieve2'"}]}'
tx=$(curl -ksd "$req" ${MAIN_HTTP} | jq -r ".result") tx=$(curl -ksd "$req" ${MAIN_HTTP} | jq -r ".result")
chain33_DecodeRawTransactionTx "$tx" "$retrieve2_key" ${MAIN_HTTP} "$FUNCNAME"
local reqDecode='{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}'
http_req "$reqDecode" ${MAIN_HTTP} '(.result.txs[0].execer != "")' "$FUNCNAME"
# data=$(curl -ksd "$reqDecode" ${MAIN_HTTP} | jq -r ".result.txs[0]")
# ok=$(jq '(.execer != "")' <<<"$data")
# [ "$ok" == true ]
# echo_rst "$FUNCNAME" "$?"
chain33_SignRawTx "$tx" "$retrieve2_key" ${MAIN_HTTP}
echo "========== # retrieve cancel end =========="
chain33_BlockWait 1 "${MAIN_HTTP}"
} }
retrieve_QueryResult() { retrieve_QueryResult() {
echo "========== # retrieve query result begin =========="
local status=$1 local status=$1
local req='{"method":"Chain33.Query","params":[{"execer":"retrieve","funcName":"GetRetrieveInfo","payload":{"backupAddress":"'$retrieve1'", "defaultAddress":"'$retrieve2'"}}]}' local req='{"method":"Chain33.Query","params":[{"execer":"retrieve","funcName":"GetRetrieveInfo","payload":{"backupAddress":"'$retrieve1'", "defaultAddress":"'$retrieve2'"}}]}'
http_req "$req" ${MAIN_HTTP} '(.result.status == '"$status"')' "$FUNCNAME" http_req "$req" ${MAIN_HTTP} '(.result.status == '"$status"')' "$FUNCNAME"
# data=$(curl -ksd "$req" ${MAIN_HTTP} | jq -r ".result")
# ok=$(jq '(.status == '"$status"')' <<<"$data")
# [ "$ok" == true ]
# echo_rst "$FUNCNAME" "$?"
echo "========== # retrieve query result end =========="
} }
retrieve_QueryAssetResult() { retrieve_QueryAssetResult() {
echo "========== # retrieve query result begin =========="
local status=$1 local status=$1
local req='{"method":"Chain33.Query","params":[{"execer":"retrieve","funcName":"GetRetrieveInfo","payload":{"backupAddress":"'$retrieve1'", "defaultAddress":"'$retrieve2'","assetExec":"token", "assetSymbol":"'"$symbol"'"}}]}' local req='{"method":"Chain33.Query","params":[{"execer":"retrieve","funcName":"GetRetrieveInfo","payload":{"backupAddress":"'$retrieve1'", "defaultAddress":"'$retrieve2'","assetExec":"token", "assetSymbol":"'"$symbol"'"}}]}'
http_req "$req" ${MAIN_HTTP} '(.result.status == '"$status"')' "$FUNCNAME" http_req "$req" ${MAIN_HTTP} '(.result.status == '"$status"')' "$FUNCNAME"
# data=$(curl -ksd "$req" ${MAIN_HTTP} | jq -r ".result")
# ok=$(jq '(.status == '"$status"')' <<<"$data")
# [ "$ok" == true ]
# echo_rst "$FUNCNAME" "$?"
echo "========== # retrieve query result end =========="
} }
init() { init() {
...@@ -258,15 +163,13 @@ function run_test() { ...@@ -258,15 +163,13 @@ function run_test() {
} }
function main() { function main() {
MAIN_HTTP="$1"
chain33_RpcTestBegin retrieve chain33_RpcTestBegin retrieve
MAIN_HTTP="$1"
echo "ip=$MAIN_HTTP" echo "ip=$MAIN_HTTP"
init init
run_test run_test
chain33_RpcTestRst retrieve "$CASE_ERR" chain33_RpcTestRst retrieve "$CASE_ERR"
} }
set -x
chain33_debug_function main "$1" chain33_debug_function main "$1"
...@@ -17,49 +17,22 @@ ticket_CreateBindMiner() { ...@@ -17,49 +17,22 @@ ticket_CreateBindMiner() {
returnAddr=$2 returnAddr=$2
returnPriv=$3 returnPriv=$3
amount=$4 amount=$4
# 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 ]]
# rst=$?
# echo_rst "$FUNCNAME" "$rst"
req='{"method":"ticket.CreateBindMiner","params":[{"bindAddr":"'"$minerAddr"'", "originAddr":"'"$returnAddr"'", "amount":'"$amount"', "checkBalance":true}]}' req='{"method":"ticket.CreateBindMiner","params":[{"bindAddr":"'"$minerAddr"'", "originAddr":"'"$returnAddr"'", "amount":'"$amount"', "checkBalance":true}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not)' "$FUNCNAME" http_req "$req" ${MAIN_HTTP} '(.error|not)' "$FUNCNAME" ".result.txHex"
chain33_SignRawTx "$RAW_RESP" "${returnPriv}" ${MAIN_HTTP}
#发送交易
rawTx=$(echo "${HTTP_RESP}" | jq -r ".result.txHex")
chain33_SignRawTx "${rawTx}" "${returnPriv}" ${MAIN_HTTP}
} }
ticket_SetAutoMining() { ticket_SetAutoMining() {
flag=$1 flag=$1
# 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")
# [[ $ok == true ]]
# rst=$?
# echo_rst "$FUNCNAME" "$rst"
req='{"method":"ticket.SetAutoMining","params":[{"flag":'"$flag"'}]}' req='{"method":"ticket.SetAutoMining","params":[{"flag":'"$flag"'}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result.isOK == true)' "$FUNCNAME" http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result.isOK == true)' "$FUNCNAME"
} }
ticket_GetTicketCount() { ticket_GetTicketCount() {
# resp=$(curl -ksd '{"method":"ticket.GetTicketCount","params":[{}]}' -H 'content-type:text/plain;' ${MAIN_HTTP})
# ok=$(jq '(.error|not) and (.result > 0)' <<<"$resp")
# [[ $ok == true ]]
# rst=$?
# echo_rst "$FUNCNAME" "$rst"
http_req '{"method":"ticket.GetTicketCount","params":[{}]}' ${MAIN_HTTP} '(.error|not) and (.result > 0)' "$FUNCNAME" http_req '{"method":"ticket.GetTicketCount","params":[{}]}' ${MAIN_HTTP} '(.error|not) and (.result > 0)' "$FUNCNAME"
} }
ticket_CloseTickets() { ticket_CloseTickets() {
# addr=$1
# resp=$(curl -ksd '{"method":"ticket.CloseTickets","params":[{"minerAddress":"'"$addr"'"}]}' -H 'content-type:text/plain;' ${MAIN_HTTP})
# ok=$(jq '(.error|not)' <<<"$resp")
# [[ $ok == true ]]
# rst=$?
# echo_rst "$FUNCNAME" "$rst"
req='{"method":"ticket.CloseTickets","params":[{"minerAddress":"'"$addr"'"}]}' req='{"method":"ticket.CloseTickets","params":[{"minerAddress":"'"$addr"'"}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not)' "$FUNCNAME" http_req "$req" ${MAIN_HTTP} '(.error|not)' "$FUNCNAME"
} }
...@@ -68,14 +41,6 @@ ticket_TicketInfos() { ...@@ -68,14 +41,6 @@ ticket_TicketInfos() {
tid=$1 tid=$1
minerAddr=$2 minerAddr=$2
returnAddr=$3 returnAddr=$3
# execer="ticket"
# funcName="TicketInfos"
# 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"'")' <<<"$resp")
# [[ $ok == true ]]
# rst=$?
# echo_rst "$FUNCNAME" "$rst"
req='{"method":"Chain33.Query","params":[{"execer":"ticket","funcName":"TicketInfos","payload":{"ticketIds":["'"$tid"'"]}}]}' req='{"method":"Chain33.Query","params":[{"execer":"ticket","funcName":"TicketInfos","payload":{"ticketIds":["'"$tid"'"]}}]}'
resok='(.error|not) and (.result.tickets | length > 0) and (.result.tickets[0].minerAddress == "'"$minerAddr"'") and (.result.tickets[0].returnAddress == "'"$returnAddr"'")' resok='(.error|not) and (.result.tickets | length > 0) and (.result.tickets[0].minerAddress == "'"$minerAddr"'") and (.result.tickets[0].returnAddress == "'"$returnAddr"'")'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME" http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
...@@ -85,35 +50,19 @@ ticket_TicketList() { ...@@ -85,35 +50,19 @@ ticket_TicketList() {
minerAddr=$1 minerAddr=$1
returnAddr=$2 returnAddr=$2
status=$3 status=$3
# 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})
# 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")
# [[ $ok == true ]]
# rst=$?
# echo_rst "$FUNCNAME" "$rst"
req='{"method":"Chain33.Query","params":[{"execer":"ticket","funcName":"TicketList","payload":{"addr":"'"$minerAddr"'", "status":'"$status"'}}]}' req='{"method":"Chain33.Query","params":[{"execer":"ticket","funcName":"TicketList","payload":{"addr":"'"$minerAddr"'", "status":'"$status"'}}]}'
resok='(.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"')' resok='(.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"')'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME" http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
ticket0=$(echo "${HTTP_RESP}" | jq -r ".result.tickets[0]") ticket0=$(echo "${HTTP_RESP}" | jq -r ".result.tickets[0]")
echo -e "######\\n ticket[0] is $ticket0) \\n######" # echo -e "######\\n ticket[0] is $ticket0) \\n######"
ticketId=$(echo "${HTTP_RESP}" | jq -r ".result.tickets[0].ticketId") ticketId=$(echo "${HTTP_RESP}" | jq -r ".result.tickets[0].ticketId")
echo -e "######\\n ticketId is $ticketId \\n######" # echo -e "######\\n ticketId is $ticketId \\n######"
} }
ticket_MinerAddress() { ticket_MinerAddress() {
returnAddr=$1 returnAddr=$1
minerAddr=$2 minerAddr=$2
# execer="ticket"
# funcName="MinerAddress"
# 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")
# [[ $ok == true ]]
# rst=$?
# echo_rst "$FUNCNAME" "$rst"
req='{"method":"Chain33.Query","params":[{"execer":"ticket","funcName":"MinerAddress","payload":{"data":"'"$returnAddr"'"}}]}' req='{"method":"Chain33.Query","params":[{"execer":"ticket","funcName":"MinerAddress","payload":{"data":"'"$returnAddr"'"}}]}'
resok='(.error|not) and (.result.data == "'"$minerAddr"'")' resok='(.error|not) and (.result.data == "'"$minerAddr"'")'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME" http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
...@@ -122,14 +71,6 @@ ticket_MinerAddress() { ...@@ -122,14 +71,6 @@ ticket_MinerAddress() {
ticket_MinerSourceList() { ticket_MinerSourceList() {
minerAddr=$1 minerAddr=$1
returnAddr=$2 returnAddr=$2
# execer="ticket"
# funcName="MinerSourceList"
# 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")
# [[ $ok == true ]]
# rst=$?
# echo_rst "$FUNCNAME" "$rst"
req='{"method":"Chain33.Query","params":[{"execer":"ticket","funcName":"MinerSourceList","payload":{"data":"'"$minerAddr"'"}}]}' req='{"method":"Chain33.Query","params":[{"execer":"ticket","funcName":"MinerSourceList","payload":{"data":"'"$minerAddr"'"}}]}'
resok='(.error|not) and (.result.datas | length > 0) and (.result.datas[0] == "'"$returnAddr"'")' resok='(.error|not) and (.result.datas | length > 0) and (.result.datas[0] == "'"$returnAddr"'")'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME" http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
...@@ -138,16 +79,8 @@ ticket_MinerSourceList() { ...@@ -138,16 +79,8 @@ ticket_MinerSourceList() {
ticket_RandNumHash() { ticket_RandNumHash() {
hash=$1 hash=$1
blockNum=$2 blockNum=$2
# execer="ticket"
# funcName="RandNumHash"
# 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")
# [[ $ok == true ]]
# rst=$?
# echo_rst "$FUNCNAME" "$rst"
req='{"method":"Chain33.Query","params":[{"execer":"ticket","funcName":"RandNumHash","payload":{"hash":"'"$hash"'", "blockNum":'"$blockNum"'}}]}' req='{"method":"Chain33.Query","params":[{"execer":"ticket","funcName":"RandNumHash","payload":{"hash":"'"$hash"'", "blockNum":'"$blockNum"'}}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result.hash != "")' "$FUNCNAME" http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result.hash != null)' "$FUNCNAME"
} }
function run_testcases() { function run_testcases() {
......
...@@ -15,27 +15,27 @@ execName="token" ...@@ -15,27 +15,27 @@ execName="token"
txHash="" txHash=""
#color #color
RED='\033[1;31m' #RED='\033[1;31m'
GRE='\033[1;32m' #GRE='\033[1;32m'
NOC='\033[0m' #NOC='\033[0m'
# $2=0 means true, other false # $2=0 means true, other false
function echo_rst() { #function echo_rst() {
if [ "$2" -eq 0 ]; then # if [ "$2" -eq 0 ]; then
echo -e "${GRE}$1 ok${NOC}" # echo -e "${GRE}$1 ok${NOC}"
else # else
echo -e "${RED}$1 fail${NOC}" # echo -e "${RED}$1 fail${NOC}"
CASE_ERR="FAIL" # CASE_ERR="FAIL"
fi # fi
} #}
# 查询交易的执行结果 # 查询交易的执行结果
# 根据传入的规则,校验查询的结果 (参数1: 校验规则 参数2: 预期匹配结果) # 根据传入的规则,校验查询的结果 (参数1: 校验规则 参数2: 预期匹配结果)
function queryTransaction() { function queryTransaction() {
validator=$1 validator=$1
expectRes=$2 expectRes=$2
echo "txhash=${txHash}" # echo "txhash=${RAW_TX_HASH}"
res=$(curl -s --data-binary '{"jsonrpc":"2.0","id":2,"method":"Chain33.QueryTransaction","params":[{"hash":"'"${txHash}"'"}]}' -H 'content-type:text/plain;' ${MAIN_HTTP} | jq -r "${validator}") res=$(curl -s --data-binary '{"jsonrpc":"2.0","id":2,"method":"Chain33.QueryTransaction","params":[{"hash":"'"${RAW_TX_HASH}"'"}]}' -H 'content-type:text/plain;' ${MAIN_HTTP} | jq -r "${validator}")
if [ "${res}" != "${expectRes}" ]; then if [ "${res}" != "${expectRes}" ]; then
return 1 return 1
else else
...@@ -43,6 +43,13 @@ function queryTransaction() { ...@@ -43,6 +43,13 @@ function queryTransaction() {
fi fi
} }
function signRawTxAndQuery() {
chain33_SignRawTx "${unsignedTx}" "${superManager}" "${MAIN_HTTP}"
# txHash=$RAW_TX_HASH
queryTransaction ".error | not" "true"
echo_rst "$1 queryExecRes" "$?"
}
function init() { function init() {
ispara=$(echo '"'"${MAIN_HTTP}"'"' | jq '.|contains("8901")') ispara=$(echo '"'"${MAIN_HTTP}"'"' | jq '.|contains("8901")')
echo "ipara=$ispara" echo "ipara=$ispara"
...@@ -96,25 +103,16 @@ function updateConfig() { ...@@ -96,25 +103,16 @@ function updateConfig() {
echo_rst "update config create tx" 1 echo_rst "update config create tx" 1
return return
fi fi
signRawTxAndQuery "$FUNCNAME"
chain33_SignRawTx "${unsignedTx}" "${superManager}" "${MAIN_HTTP}"
txHash=$RAW_TX_HASH
queryTransaction ".error | not" "true"
echo_rst "update config queryExecRes" "$?"
} }
function token_preCreate() { function token_preCreate() {
unsignedTx=$(curl -s --data-binary '{"jsonrpc":"2.0","id":2,"method":"token.CreateRawTokenPreCreateTx","params":[{"name": "yinhebib", "symbol": "'"${tokenSymbol}"'", "total": 100000000000, "price": 100, "category": 1,"owner":"'${tokenAddr}'"}]}' -H 'content-type:text/plain;' ${MAIN_HTTP} | jq -r ".result") unsignedTx=$(curl -s --data-binary '{"jsonrpc":"2.0","id":2,"method":"token.CreateRawTokenPreCreateTx","params":[{"name": "yinhebib", "symbol": "'"${tokenSymbol}"'", "total": 100000000000, "price": 100, "category": 1,"owner":"'${tokenAddr}'"}]}' -H 'content-type:text/plain;' ${MAIN_HTTP} | jq -r ".result")
if [ "${unsignedTx}" == "" ]; then if [ "${unsignedTx}" == "" ]; then
echo_rst "token preCreate create tx" 1 echo_rst "token preCreate create tx" 1
return return
fi fi
signRawTxAndQuery "$FUNCNAME"
chain33_SignRawTx "${unsignedTx}" "${superManager}" "${MAIN_HTTP}"
txHash=$RAW_TX_HASH
queryTransaction ".error | not" "true"
echo_rst "token preCreate queryExecRes" "$?"
} }
function token_getPreCreated() { function token_getPreCreated() {
...@@ -132,21 +130,12 @@ function token_finish() { ...@@ -132,21 +130,12 @@ function token_finish() {
return return
fi fi
chain33_SignRawTx "${unsignedTx}" "${superManager}" "${MAIN_HTTP}" signRawTxAndQuery "$FUNCNAME"
txHash=$RAW_TX_HASH
queryTransaction ".error | not" "true"
echo_rst "token finish queryExecRes" "$?"
} }
function token_getFinishCreated() { function token_getFinishCreated() {
res=$(curl -s --data-binary '{"jsonrpc":"2.0","id":2,"method":"Chain33.Query","params":[{"execer":"'"${execName}"'","funcName":"GetTokens","payload":{"queryAll":true,"status":1,"tokens":[],"symbolOnly":false}}]}' -H 'content-type:text/plain;' ${MAIN_HTTP} | jq -r ".result.tokens" | grep "symbol") req='{"method":"Chain33.Query","params":[{"execer":"'"${execName}"'","funcName":"GetTokens","payload":{"queryAll":true,"status":1,"tokens":[],"symbolOnly":false}}]}'
http_req "$req" ${MAIN_HTTP} "(.result.tokens[0].symbol != null)" "$FUNCNAME"
if [ "${res}" != "" ]; then
echo_rst "token get finishCreated create tx" 0
else
echo_rst "token get finishCreated create tx" 1
fi
} }
function token_assets() { function token_assets() {
...@@ -166,8 +155,8 @@ function token_assets() { ...@@ -166,8 +155,8 @@ function token_assets() {
else else
echo_rst "token get assets tx" 1 echo_rst "token get assets tx" 1
fi fi
} }
function token_balance() { function token_balance() {
res=$(curl -s --data-binary '{"jsonrpc":"2.0","id":2,"method":"token.GetTokenBalance","params":[{"addresses": ["'${tokenAddr}'"],"tokenSymbol":"'"${tokenSymbol}"'","execer": "'"${execName}"'"}]}' -H 'content-type:text/plain;' ${MAIN_HTTP}) res=$(curl -s --data-binary '{"jsonrpc":"2.0","id":2,"method":"token.GetTokenBalance","params":[{"addresses": ["'${tokenAddr}'"],"tokenSymbol":"'"${tokenSymbol}"'","execer": "'"${execName}"'"}]}' -H 'content-type:text/plain;' ${MAIN_HTTP})
...@@ -193,11 +182,7 @@ function token_burn() { ...@@ -193,11 +182,7 @@ function token_burn() {
return return
fi fi
chain33_SignRawTx "${unsignedTx}" "${superManager}" "${MAIN_HTTP}" signRawTxAndQuery "$FUNCNAME"
txHash=$RAW_TX_HASH
queryTransaction ".error | not" "true"
echo_rst "token burn queryExecRes" "$?"
} }
function token_mint() { function token_mint() {
...@@ -207,11 +192,7 @@ function token_mint() { ...@@ -207,11 +192,7 @@ function token_mint() {
return return
fi fi
chain33_SignRawTx "${unsignedTx}" "${superManager}" "${MAIN_HTTP}" signRawTxAndQuery "$FUNCNAME"
txHash=$RAW_TX_HASH
queryTransaction ".error | not" "true"
echo_rst "token mint queryExecRes" "$?"
} }
function token_transfer() { function token_transfer() {
unsignedTx=$(curl -s --data-binary '{"jsonrpc":"2.0","id":2,"method":"Chain33.CreateTransaction","params":[{"execer": "'"${execName}"'","actionName":"Transfer","payload": {"cointoken":"'"${tokenSymbol}"'", "amount": "1000000000", "note": "", "to": "'"${recvAddr}"'"}}]}' -H 'content-type:text/plain;' ${MAIN_HTTP} | jq -r ".result") unsignedTx=$(curl -s --data-binary '{"jsonrpc":"2.0","id":2,"method":"Chain33.CreateTransaction","params":[{"execer": "'"${execName}"'","actionName":"Transfer","payload": {"cointoken":"'"${tokenSymbol}"'", "amount": "1000000000", "note": "", "to": "'"${recvAddr}"'"}}]}' -H 'content-type:text/plain;' ${MAIN_HTTP} | jq -r ".result")
...@@ -220,11 +201,7 @@ function token_transfer() { ...@@ -220,11 +201,7 @@ function token_transfer() {
return return
fi fi
chain33_SignRawTx "${unsignedTx}" "${superManager}" "${MAIN_HTTP}" signRawTxAndQuery "$FUNCNAME"
txHash=$RAW_TX_HASH
queryTransaction ".error | not" "true"
echo_rst "token transfer queryExecRes" "$?"
} }
function token_sendExec() { function token_sendExec() {
...@@ -234,11 +211,7 @@ function token_sendExec() { ...@@ -234,11 +211,7 @@ function token_sendExec() {
return return
fi fi
chain33_SignRawTx "${unsignedTx}" "${superManager}" "${MAIN_HTTP}" signRawTxAndQuery "$FUNCNAME"
txHash=$RAW_TX_HASH
queryTransaction ".error | not" "true"
echo_rst "token sendExec queryExecRes" "$?"
} }
function token_withdraw() { function token_withdraw() {
...@@ -248,16 +221,12 @@ function token_withdraw() { ...@@ -248,16 +221,12 @@ function token_withdraw() {
return return
fi fi
chain33_SignRawTx "${unsignedTx}" "${superManager}" "${MAIN_HTTP}" signRawTxAndQuery "$FUNCNAME"
txHash=$RAW_TX_HASH
queryTransaction ".error | not" "true"
echo_rst "token withdraw queryExecRes" "$?"
} }
function run_test() { function run_test() {
local ip=$1 local ip=$1
set -x # set -x
token_preCreate token_preCreate
token_getPreCreated token_getPreCreated
...@@ -271,19 +240,17 @@ function run_test() { ...@@ -271,19 +240,17 @@ function run_test() {
token_sendExec token_sendExec
token_assets token_assets
token_withdraw token_withdraw
set +x # set +x
} }
function main() { function main() {
local ip=$1
chain33_RpcTestBegin token chain33_RpcTestBegin token
local ip=$1
MAIN_HTTP=$ip MAIN_HTTP=$ip
echo "main_ip=$MAIN_HTTP" echo "main_ip=$MAIN_HTTP"
init init
run_test "$ip" run_test "$ip"
chain33_RpcTestRst token "$CASE_ERR" chain33_RpcTestRst token "$CASE_ERR"
} }
......
This diff is collapsed.
...@@ -10,18 +10,17 @@ txhash="" ...@@ -10,18 +10,17 @@ txhash=""
function query_unfreezeID() { function query_unfreezeID() {
chain33_BlockWait 1 "$MAIN_HTTP" chain33_BlockWait 1 "$MAIN_HTTP"
# echo "req=$req"
local times=10 local times=10
while true; do while true; do
req='{"method":"Chain33.QueryTransaction","params":[{"hash":"'"$txhash"'"}]}' req='{"method":"Chain33.QueryTransaction","params":[{"hash":"'"$txhash"'"}]}'
ret=$(curl -ksd "$req" ${MAIN_HTTP}) ret=$(curl -ksd "$req" ${MAIN_HTTP})
tx=$(jq -r ".result.tx.hash" <<<"$ret") tx=$(jq -r ".result.tx.hash" <<<"$ret")
echo "====query tx= ${txhash}, return=$ret " # echo "====query tx= ${txhash}, return=$ret "
if [ "${tx}" != "${txhash}" ]; then if [ "${tx}" != "${txhash}" ]; then
chain33_BlockWait 1 "${MAIN_HTTP}" chain33_BlockWait 1 "${MAIN_HTTP}"
times=$((times - 1)) times=$((times - 1))
if [ $times -le 0 ]; then if [ $times -le 0 ]; then
echo "====query tx=$txhash failed" echo -e "${RED}====query tx=$txhash failed${NOC}"
echo "req=$req" echo "req=$req"
curl -ksd "$req" ${MAIN_HTTP} curl -ksd "$req" ${MAIN_HTTP}
exit 1 exit 1
...@@ -31,7 +30,7 @@ function query_unfreezeID() { ...@@ -31,7 +30,7 @@ function query_unfreezeID() {
#echo "${unfreeze_id}" #echo "${unfreeze_id}"
unfreeze_id2=${unfreeze_id#\"mavl-unfreeze-} unfreeze_id2=${unfreeze_id#\"mavl-unfreeze-}
uid=${unfreeze_id2%\"} uid=${unfreeze_id2%\"}
echo "====query tx=$txhash success" echo -e "${GRE}====query tx=$txhash success${NOC}"
break break
fi fi
done done
...@@ -75,96 +74,51 @@ function init() { ...@@ -75,96 +74,51 @@ function init() {
function CreateRawUnfreezeCreate() { function CreateRawUnfreezeCreate() {
req='{"jsonrpc": "2.0", "method" : "unfreeze.CreateRawUnfreezeCreate" , "params":[{"startTime":10000,"assetExec":"coins","assetSymbol":"'$symbol'","totalCount":400000000,"beneficiary":"'$beneficiary'","means":"FixAmount","fixAmount": {"period":10,"amount":1000000}}]}' req='{"jsonrpc": "2.0", "method" : "unfreeze.CreateRawUnfreezeCreate" , "params":[{"startTime":10000,"assetExec":"coins","assetSymbol":"'$symbol'","totalCount":400000000,"beneficiary":"'$beneficiary'","means":"FixAmount","fixAmount": {"period":10,"amount":1000000}}]}'
# echo "#request: $req" http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME" ".result"
# resp=$(curl -ksd "$req" "${MAIN_HTTP}") chain33_SignRawTx "$RAW_RESP" "$owner_key" "${MAIN_HTTP}"
# echo "#resp: $resp"
# ok=$(jq '(.error|not) and (.result != "")' <<<"$resp")
# [ "$ok" == true ]
# echo_rst "$FUNCNAME" "$?"
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != "")' "$FUNCNAME"
rawtx=$(jq -r ".result" <<<"$HTTP_RESP")
chain33_SignRawTx "$rawtx" "$owner_key" "${MAIN_HTTP}"
query_unfreezeID query_unfreezeID
} }
function CreateRawUnfreezeWithdraw() { function CreateRawUnfreezeWithdraw() {
sleep 10 sleep 10
req='{"method":"unfreeze.CreateRawUnfreezeWithdraw","params":[{"unfreezeID":"'${uid}'"}]}' req='{"method":"unfreeze.CreateRawUnfreezeWithdraw","params":[{"unfreezeID":"'${uid}'"}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != "")' "$FUNCNAME" http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME" ".result"
# echo "#request: $req" chain33_SignRawTx "$RAW_RESP" "${beneficiary_key}" "${MAIN_HTTP}"
# resp=$(curl -ksd "$req" "${MAIN_HTTP}")
# echo "#resp: $resp"
# ok=$(jq '(.error|not) and (.result != "")' <<<"$resp")
# [ "$ok" == true ]
# echo_rst "$FUNCNAME" "$?"
rawtx=$(jq -r ".result" <<<"$HTTP_RESP")
chain33_SignRawTx "$rawtx" "${beneficiary_key}" "${MAIN_HTTP}"
} }
function CreateRawUnfreezeTerminate() { function CreateRawUnfreezeTerminate() {
req='{"method":"unfreeze.CreateRawUnfreezeTerminate","params":[{"unfreezeID":"'${uid}'"}]}' req='{"method":"unfreeze.CreateRawUnfreezeTerminate","params":[{"unfreezeID":"'${uid}'"}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != "")' "$FUNCNAME" http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME" ".result"
# echo "#request: $req" chain33_SignRawTx "$RAW_RESP" "$owner_key" "${MAIN_HTTP}"
# resp=$(curl -ksd "$req" "${MAIN_HTTP}")
# echo "#resp: $resp"
# ok=$(jq '(.error|not) and (.result != "")' <<<"$resp")
# [ "$ok" == true ]
# echo_rst "$FUNCNAME" "$?"
rawtx=$(jq -r ".result" <<<"$HTTP_RESP")
chain33_SignRawTx "$rawtx" "$owner_key" "${MAIN_HTTP}"
chain33_BlockWait 2 "${MAIN_HTTP}" chain33_BlockWait 2 "${MAIN_HTTP}"
} }
function GetUnfreeze() { function GetUnfreeze() {
req='{"method":"unfreeze.GetUnfreeze","params":[{"data":"'${uid}'"}]}' req='{"method":"unfreeze.GetUnfreeze","params":[{"data":"'${uid}'"}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != "")' "$FUNCNAME" http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME"
# echo "#request: $req"
# resp=$(curl -ksd "$req" "${MAIN_HTTP}")
# echo "#resp: $resp"
# ok=$(jq '(.error|not) and (.result != "")' <<<"$resp")
# [ "$ok" == true ]
# echo_rst "$FUNCNAME" "$?"
} }
function GetUnfreezeWithdraw() { function GetUnfreezeWithdraw() {
req='{"method":"unfreeze.GetUnfreezeWithdraw","params":[{"data":"'${uid}'"}]}' req='{"method":"unfreeze.GetUnfreezeWithdraw","params":[{"data":"'${uid}'"}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != "")' "$FUNCNAME" http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME"
# echo "#request: $req"
# resp=$(curl -ksd "$req" "${MAIN_HTTP}")
# echo "#resp: $resp"
# ok=$(jq '(.error|not) and (.result != "")' <<<"$resp")
# [ "$ok" == true ]
# echo_rst "$FUNCNAME" "$?"
} }
function run_testcases() { function run_testcases() {
CreateRawUnfreezeCreate CreateRawUnfreezeCreate
CreateRawUnfreezeWithdraw CreateRawUnfreezeWithdraw
GetUnfreeze GetUnfreeze
GetUnfreezeWithdraw GetUnfreezeWithdraw
CreateRawUnfreezeTerminate CreateRawUnfreezeTerminate
} }
function debug_function() {
set -x
eval "$@"
set +x
}
function rpc_test() { function rpc_test() {
chain33_RpcTestBegin unfreeze chain33_RpcTestBegin unfreeze
MAIN_HTTP="$1" MAIN_HTTP="$1"
echo "main_ip=$MAIN_HTTP" echo "main_ip=$MAIN_HTTP"
init init
run_testcases run_testcases
chain33_RpcTestRst unfreeze "$CASE_ERR" chain33_RpcTestRst unfreeze "$CASE_ERR"
} }
debug_function rpc_test "$1" chain33_debug_function rpc_test "$1"
\ No newline at end of file
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