Commit e6331519 authored by yingqiumin@126.com's avatar yingqiumin@126.com

优化rpc test,保存代码

parent f6de10f0
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
RAW_TX_HASH="" RAW_TX_HASH=""
LAST_BLOCK_HASH="" LAST_BLOCK_HASH=""
CASE_ERR="" CASE_ERR=""
HTTP_RESP=""
RAW_RESP=""
#color #color
RED='\033[1;31m' RED='\033[1;31m'
...@@ -16,11 +18,23 @@ echo_rst() { ...@@ -16,11 +18,23 @@ echo_rst() {
echo -e "${GRE}$1 not support${NOC}" echo -e "${GRE}$1 not support${NOC}"
else else
echo -e "${RED}$1 fail${NOC}" echo -e "${RED}$1 fail${NOC}"
echo -e "${RED}$3 ${NOC}"
CASE_ERR="err" CASE_ERR="err"
echo $CASE_ERR echo $CASE_ERR
fi fi
} }
http_req() {
# echo "#$4 request: $1"
HTTP_RESP=$(curl -ksd "$1" "$2")
RAW_RESP=$(jq -r "$5" <<<"$HTTP_RESP")
# echo "#response: $HTTP_RESP"
ok=$(echo "$HTTP_RESP" | jq -r "$3")
[ "$ok" == true ]
rst=$?
echo_rst "$4" "$rst" "$HTTP_RESP"
}
chain33_BlockWait() { chain33_BlockWait() {
local MAIN_HTTP=$2 local MAIN_HTTP=$2
local req='"method":"Chain33.GetLastHeader","params":[]' local req='"method":"Chain33.GetLastHeader","params":[]'
......
...@@ -31,32 +31,43 @@ init() { ...@@ -31,32 +31,43 @@ 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=$(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" != "" ] # [ "$result" != "" ]
rst=$? # rst=$?
echo_rst "$FUNCNAME" "$rst" # echo_rst "$FUNCNAME" "$rst"
glAddr=$result # glAddr=$result
echo "$glAddr" # echo "$glAddr"
req='{"method":"Chain33.NewAccount","params":[{"label":"'"$label"'"}]}'
http_req "$req" ${MAIN_HTTP} '(.result.acc.addr != "")' "$FUNCNAME"
} }
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}) # 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=$(echo "${resp}" | jq -r ".error")
[ "$ok" == null ] # [ "$ok" == null ]
rst=$? # rst=$?
echo_rst "$FUNCNAME" "$rst" # echo_rst "$FUNCNAME" "$rst"
req='{"method":"Chain33.SignRawTx","params":[{"addr":"'"$addr"'","txHex":"'"$rawTx"'","expire":"120s","fee":10000000,"index":0}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not)' "$FUNCNAME"
# 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"'"}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not)' "$FUNCNAME"
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"
#返回交易 #返回交易
gResp=$(jq -r ".result" <<<"$resp") gResp=$(jq -r ".result" <<<"$HTTP_RESP")
echo "tx hash is $gResp" echo "tx hash is $gResp"
chain33_QueryTx "$gResp" "${MAIN_HTTP}" chain33_QueryTx "$gResp" "${MAIN_HTTP}"
} }
...@@ -64,13 +75,17 @@ chain33_SendTransaction() { ...@@ -64,13 +75,17 @@ chain33_SendTransaction() {
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}) # 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=$(echo "${resp}" | jq -r ".error")
[ "$ok" == null ] # [ "$ok" == null ]
rst=$? # rst=$?
echo_rst "$FUNCNAME" "$rst" # echo_rst "$FUNCNAME" "$rst"
req='{"method":"blackwhite.BlackwhiteCreateTx","params":[{"PlayAmount":100000000,"PlayerCount":3,"GameName":"hello","Timeout":600,"Fee":1000000}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not)' "$FUNCNAME"
#发送交易 #发送交易
rawTx=$(echo "${resp}" | jq -r ".result") rawTx=$(echo "${HTTP_RESP}" | jq -r ".result")
chain33_SendTransaction "${rawTx}" "${addr}" chain33_SendTransaction "${rawTx}" "${addr}"
gID="${gResp}" gID="${gResp}"
echo "gameID $gID" echo "gameID $gID"
......
#!/usr/bin/env bash #!/usr/bin/env bash
# shellcheck disable=SC2128 # shellcheck disable=SC2128
set -e # set -e
set -o pipefail set -o pipefail
MAIN_HTTP="" MAIN_HTTP=""
...@@ -15,27 +15,33 @@ source ../dapp-test-common.sh ...@@ -15,27 +15,33 @@ source ../dapp-test-common.sh
function chain33_GetExecAddr() { function chain33_GetExecAddr() {
#获取GAME合约地址 #获取GAME合约地址
local exector=$1 req='{"method":"Chain33.ConvertExectoAddr","params":[{"execname":"'"$1"'"}]}'
local req='"method":"Chain33.ConvertExectoAddr","params":[{"execname":"'"${exector}"'"}]' resok='(.error|not)'
echo "#request: $req" http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
resp=$(curl -ksd "{$req}" "${MAIN_HTTP}")
echo "#response: $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") # GAME_ADDR=$(echo "${res}" | jq -r ".result")
echo_rst "$FUNCNAME" "$?" # 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}"'"}}]}'
echo "#request: $req" http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
resp=$(curl -ksd "{$req}" "${MAIN_HTTP}") # echo "#request: $req"
echo "#response: $resp"
rawTx=$(echo "${resp}" | jq -r ".result") # resp=$(curl -ksd "{$req}" "${MAIN_HTTP}")
if [ "$rawTx" == "null" ]; then # echo "#response: $resp"
echo_rst "CreateGame createRawTx" 1 # rawTx=$(echo "${resp}" | jq -r ".result")
fi # if [ "$rawTx" == "null" ]; then
# echo_rst "CreateGame createRawTx" 1
# fi
chain33_SignRawTx "${rawTx}" "${PRIVA_A}" "${MAIN_HTTP}" chain33_SignRawTx "${rawTx}" "${PRIVA_A}" "${MAIN_HTTP}"
GAME_ID=$RAW_TX_HASH GAME_ID=$RAW_TX_HASH
...@@ -45,16 +51,18 @@ function CreateGameTx() { ...@@ -45,16 +51,18 @@ 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}}]}'
echo "#request: $req" http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != "")' "MatchGame createRawTx"
resp=$(curl -ksd "{$req}" "${MAIN_HTTP}")
echo "#response: $resp"
rawTx=$(echo "${resp}" | jq -r ".result") # echo "#request: $req"
if [ "$rawTx" == "null" ]; then # resp=$(curl -ksd "{$req}" "${MAIN_HTTP}")
echo_rst "MatchGame createRawTx" 1 # echo "#response: $resp"
fi
rawTx=$(echo "${HTTP_RESP}" | jq -r ".result")
# if [ "$rawTx" == "null" ]; then
# echo_rst "MatchGame createRawTx" 1
# fi
chain33_SignRawTx "${rawTx}" "${PRIVA_B}" "${MAIN_HTTP}" chain33_SignRawTx "${rawTx}" "${PRIVA_B}" "${MAIN_HTTP}"
echo_rst "MatchGame query_tx" "$?" echo_rst "MatchGame query_tx" "$?"
...@@ -63,16 +71,18 @@ function MatchGameTx() { ...@@ -63,16 +71,18 @@ function MatchGameTx() {
function CloseGameTx() { function CloseGameTx() {
local gameId=$1 local gameId=$1
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}}]}'
echo "#request: $req" http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != "")' "CloseGame createRawTx"
resp=$(curl -ksd "{$req}" "${MAIN_HTTP}")
echo "#response: $resp"
rawTx=$(echo "${resp}" | jq -r ".result") # echo "#request: $req"
if [ "$rawTx" == "null" ]; then # resp=$(curl -ksd "{$req}" "${MAIN_HTTP}")
echo_rst "CloseGame createRawTx" 1 # echo "#response: $resp"
fi
rawTx=$(echo "${HTTP_RESP}" | jq -r ".result")
# if [ "$rawTx" == "null" ]; then
# echo_rst "CloseGame createRawTx" 1
# fi
chain33_SignRawTx "${rawTx}" "${PRIVA_A}" "${MAIN_HTTP}" chain33_SignRawTx "${rawTx}" "${PRIVA_A}" "${MAIN_HTTP}"
echo_rst "CloseGame query_tx" "$?" echo_rst "CloseGame query_tx" "$?"
...@@ -80,16 +90,17 @@ function CloseGameTx() { ...@@ -80,16 +90,17 @@ function CloseGameTx() {
function CancleGameTx() { 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}"'"}}]}'
echo "#request: $req" http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != "")' "CancleGame createRawTx"
resp=$(curl -ksd "{$req}" "${MAIN_HTTP}") # echo "#request: $req"
echo "#response: $resp" # resp=$(curl -ksd "{$req}" "${MAIN_HTTP}")
# echo "#response: $resp"
rawTx=$(echo "${resp}" | jq -r ".result") rawTx=$(echo "${HTTP_RESP}" | jq -r ".result")
if [ "$rawTx" == "null" ]; then # if [ "$rawTx" == "null" ]; then
echo_rst "CancleGame createRawTx" 1 # echo_rst "CancleGame createRawTx" 1
fi # fi
chain33_SignRawTx "${rawTx}" "${PRIVA_A}" "${MAIN_HTTP}" chain33_SignRawTx "${rawTx}" "${PRIVA_A}" "${MAIN_HTTP}"
echo_rst "CancleGame query_tx" "$?" echo_rst "CancleGame query_tx" "$?"
...@@ -97,29 +108,33 @@ function CancleGameTx() { ...@@ -97,29 +108,33 @@ function CancleGameTx() {
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":""}}]}'
echo "#request: $req" http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result.games != "")' "$FUNCNAME"
resp=$(curl -ksd "{$req}" "${MAIN_HTTP}") # echo "#request: $req"
echo "#response: $resp" # resp=$(curl -ksd "{$req}" "${MAIN_HTTP}")
GAMES=$(echo "${resp}" | jq -r ".result.games") # echo "#response: $resp"
echo "${GAMES}" # GAMES=$(echo "${resp}" | jq -r ".result.games")
echo_rst "$FUNCNAME" "$?" # echo "${GAMES}"
# echo_rst "$FUNCNAME" "$?"
} }
function QueryGameByGameId() { function QueryGameByGameId() {
local gameId=$1 local gameId=$1
local status=$2 local status=$2
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}"'"}}]}'
echo "#request: $req" resok='(.error|not) and (.result.game.status = "'"${status}"'")'
resp=$(curl -ksd "{$req}" "${MAIN_HTTP}") http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
echo "#response: $resp"
STATUS=$(echo "${resp}" | jq -r ".result.game.status") # echo "#request: $req"
if [ "${STATUS}" -ne "${status}" ]; then # resp=$(curl -ksd "{$req}" "${MAIN_HTTP}")
echo "status is not equal" # echo "#response: $resp"
echo_rst "QueryGameByGameId" 1 # STATUS=$(echo "${resp}" | jq -r ".result.game.status")
return 0 # if [ "${STATUS}" -ne "${status}" ]; then
fi # echo "status is not equal"
echo_rst "QueryGameByGameId" 0 # echo_rst "QueryGameByGameId" 1
# return 0
# fi
# echo_rst "QueryGameByGameId" 0
} }
function init() { function init() {
...@@ -212,9 +227,10 @@ function run_test() { ...@@ -212,9 +227,10 @@ function run_test() {
function main() { function main() {
local ip=$1 local ip=$1
MAIN_HTTP=$ip MAIN_HTTP=$ip
chain33_RpcTestBegin game chain33_RpcTestBegin game
echo "main_ip=$MAIN_HTTP"
echo "main_ip=$MAIN_HTTP"
init init
run_test "$MAIN_HTTP" run_test "$MAIN_HTTP"
...@@ -222,3 +238,4 @@ function main() { ...@@ -222,3 +238,4 @@ function main() {
} }
chain33_debug_function main "$1" chain33_debug_function main "$1"
#main "$1"
...@@ -14,15 +14,19 @@ source ../dapp-test-common.sh ...@@ -14,15 +14,19 @@ source ../dapp-test-common.sh
hashlock_lock() { hashlock_lock() {
local secret=$1 local secret=$1
echo "========== # hashlock lock tx begin ==========" # 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")
data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]") # data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]")
ok=$(jq '(.execer != "")' <<<"$data") # ok=$(jq '(.execer != "")' <<<"$data")
[ "$ok" == true ] # [ "$ok" == true ]
echo_rst "$FUNCNAME" "$?" # 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} chain33_SignRawTx "$tx" "0x1089b7f980fc467f029b7ae301249b36e3b582c911b1af1a24616c83b3563dcb" ${MAIN_HTTP}
#echo "txHash ${txhash}" #echo "txHash ${txhash}"
...@@ -38,11 +42,15 @@ hashlock_send() { ...@@ -38,11 +42,15 @@ hashlock_send() {
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")
data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]") # data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]")
ok=$(jq '(.execer != "")' <<<"$data") # ok=$(jq '(.execer != "")' <<<"$data")
# [ "$ok" == true ]
# echo_rst "$FUNCNAME" "$?"
[ "$ok" == true ] req='{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}'
echo_rst "$FUNCNAME" "$?" resok='(.result.txs[0].execer != "")'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
chain33_SignRawTx "$tx" "0xb76a398c3901dfe5c7335525da88fda4df24c11ad11af4332f00c0953cc2910f" ${MAIN_HTTP} chain33_SignRawTx "$tx" "0xb76a398c3901dfe5c7335525da88fda4df24c11ad11af4332f00c0953cc2910f" ${MAIN_HTTP}
#echo "txHash ${txhash}" #echo "txHash ${txhash}"
...@@ -57,11 +65,15 @@ hashlock_unlock() { ...@@ -57,11 +65,15 @@ hashlock_unlock() {
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")
data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]") # data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]")
ok=$(jq '(.execer != "")' <<<"$data") # ok=$(jq '(.execer != "")' <<<"$data")
[ "$ok" == true ] # [ "$ok" == true ]
echo_rst "$FUNCNAME" "$?" # 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} chain33_SignRawTx "$tx" "0x1089b7f980fc467f029b7ae301249b36e3b582c911b1af1a24616c83b3563dcb" ${MAIN_HTTP}
#echo "txHash ${txhash}" #echo "txHash ${txhash}"
...@@ -129,10 +141,8 @@ function run_test() { ...@@ -129,10 +141,8 @@ function run_test() {
hashlock_send "abc" hashlock_send "abc"
chain33_QueryBalance "$addr_B" "${MAIN_HTTP}" chain33_QueryBalance "$addr_B" "${MAIN_HTTP}"
hashlock_unlock "abc" hashlock_unlock "abc"
hashlock_lock "aef" hashlock_lock "aef"
chain33_QueryBalance "$addr_A" "${MAIN_HTTP}" chain33_QueryBalance "$addr_A" "${MAIN_HTTP}"
sleep 5 sleep 5
hashlock_unlock "aef" hashlock_unlock "aef"
chain33_BlockWait 1 ${MAIN_HTTP} chain33_BlockWait 1 ${MAIN_HTTP}
...@@ -142,8 +152,8 @@ function run_test() { ...@@ -142,8 +152,8 @@ function run_test() {
function main() { function main() {
MAIN_HTTP="$1" MAIN_HTTP="$1"
chain33_RpcTestBegin hashlock chain33_RpcTestBegin hashlock
echo "ip=$MAIN_HTTP"
echo "ip=$MAIN_HTTP"
init init
run_test run_test
......
...@@ -40,50 +40,69 @@ function init() { ...@@ -40,50 +40,69 @@ 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='{"jsonrpc": "2.0", "method" : "Chain33.CreateTransaction" , "params":[{"execer":"'${manager_name}'","actionName":"Modify","payload":{"key":"js-creator","op":"add", "value" : "'${beneficiary}'"}}]}'
echo "#request: $req" # echo "#request: $req"
resp=$(curl -ksd "$req" "${MAIN_HTTP}") # resp=$(curl -ksd "$req" "${MAIN_HTTP}")
# echo "#resp: $resp" # echo "#resp: $resp"
ok=$(jq '(.error|not) and (.result != "")' <<<"$resp") # ok=$(jq '(.error|not) and (.result != "")' <<<"$resp")
[ "$ok" == true ] # [ "$ok" == true ]
echo_rst "$FUNCNAME" "$?" # echo_rst "$FUNCNAME" "$?"
rawtx=$(jq -r ".result" <<<"$resp")
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}" 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}'"}}]}' # req='{"jsonrpc": "2.0", "method" : "Chain33.CreateTransaction" , "params":[{"execer":"'${exec_name}'","actionName":"Create","payload":{"name":"'${game}'","code":"'${jsCode}'"}}]}'
echo "#request: $req" # echo "#request: $req"
resp=$(curl -ksd "$req" "${MAIN_HTTP}") # resp=$(curl -ksd "$req" "${MAIN_HTTP}")
# echo "#resp: $resp" # echo "#resp: $resp"
ok=$(jq '(.error|not) and (.result != "")' <<<"$resp") # ok=$(jq '(.error|not) and (.result != "")' <<<"$resp")
[ "$ok" == true ] # [ "$ok" == true ]
echo_rst "$FUNCNAME" "$?" # echo_rst "$FUNCNAME" "$?"
rawtx=$(jq -r ".result" <<<"$resp")
req='{"method":"Chain33.CreateTransaction","params":[{"execer":"'${exec_name}'","actionName":"Create","payload":{"name":"'${game}'","code":"'${jsCode}'"}}]}'
resok='(.error|not) and (.result != "")'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
rawtx=$(jq -r ".result" <<<"$HTTP_RESP")
chain33_SignRawTx "$rawtx" "${beneficiary_key}" "${MAIN_HTTP}" chain33_SignRawTx "$rawtx" "${beneficiary_key}" "${MAIN_HTTP}"
} }
function callJS() { function callJS() {
#the_exec= #the_exec=
req='{"jsonrpc": "2.0", "method" : "Chain33.CreateTransaction" , "params":[{"execer":"'${user_game}'","actionName":"Call","payload":{"name":"'${game}'","funcname":"hello", "args" : "{}"}}]}' # req='{"jsonrpc": "2.0", "method" : "Chain33.CreateTransaction" , "params":[{"execer":"'${user_game}'","actionName":"Call","payload":{"name":"'${game}'","funcname":"hello", "args" : "{}"}}]}'
# echo "#request: $req" # echo "#request: $req"
resp=$(curl -ksd "$req" "${MAIN_HTTP}") # resp=$(curl -ksd "$req" "${MAIN_HTTP}")
# echo "#resp: $resp" # echo "#resp: $resp"
ok=$(jq '(.error|not) and (.result != "")' <<<"$resp") # ok=$(jq '(.error|not) and (.result != "")' <<<"$resp")
[ "$ok" == true ] # [ "$ok" == true ]
echo_rst "$FUNCNAME" "$?" # echo_rst "$FUNCNAME" "$?"
rawtx=$(jq -r ".result" <<<"$resp")
req='{"method":"Chain33.CreateTransaction","params":[{"execer":"'${user_game}'","actionName":"Call","payload":{"name":"'${game}'","funcname":"hello","args":"{}"}}]}'
resok='(.error|not) and (.result != "")'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
rawtx=$(jq -r ".result" <<<"$HTTP_RESP")
chain33_SignRawTx "$rawtx" "${beneficiary_key}" "${MAIN_HTTP}" 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" : "{}"}}]}' # req='{"jsonrpc": "2.0", "method" : "Chain33.Query" , "params":[{"execer":"'${user_game}'","funcName":"Query","payload":{"name":"'${game}'","funcname":"hello", "args" : "{}"}}]}'
# echo "#request: $req" # echo "#request: $req"
resp=$(curl -ksd "$req" "${MAIN_HTTP}") # resp=$(curl -ksd "$req" "${MAIN_HTTP}")
# echo "#resp: $resp" # echo "#resp: $resp"
ok=$(jq '(.error|not) and (.result != "")' <<<"$resp") # ok=$(jq '(.error|not) and (.result != "")' <<<"$resp")
[ "$ok" == true ] # [ "$ok" == true ]
echo_rst "$FUNCNAME" "$?" # echo_rst "$FUNCNAME" "$?"
req='{"method":"Chain33.Query","params":[{"execer":"'${user_game}'","funcName":"Query","payload":{"name":"'${game}'","funcname":"hello","args":"{}"}}]}'
resok='(.error|not) and (.result != "")'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
} }
function run_testcases() { function run_testcases() {
......
This diff is collapsed.
...@@ -23,14 +23,18 @@ oracle_AddPublisher() { ...@@ -23,14 +23,18 @@ 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"}}]' # req='"method":"Chain33.CreateTransaction","params":[{"execer":"oracle","actionName":"EventPublish","payload":{"type":"football", "subType":"Premier League","time":1747814996,"content":"test","introduction":"test"}}]'
#echo "#request: $req" #echo "#request: $req"
resp=$(curl -ksd "{$req}" ${MAIN_HTTP}) # resp=$(curl -ksd "{$req}" ${MAIN_HTTP})
echo "#response: $resp" # echo "#response: $resp"
ok=$(jq '(.error|not) and (.result != "")' <<<"$resp") # ok=$(jq '(.error|not) and (.result != "")' <<<"$resp")
[ "$ok" == true ] # [ "$ok" == true ]
echo_rst "$FUNCNAME" "$?" # echo_rst "$FUNCNAME" "$?"
rawtx=$(jq -r ".result" <<<"$resp")
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"
rawtx=$(jq -r ".result" <<<"$HTTP_RESP")
chain33_SignRawTx "$rawtx" "${oracle_publisher_key}" "${MAIN_HTTP}" chain33_SignRawTx "$rawtx" "${oracle_publisher_key}" "${MAIN_HTTP}"
eventId="${txhash}" eventId="${txhash}"
echo "eventId $eventId" echo "eventId $eventId"
...@@ -38,66 +42,77 @@ oracle_publish_transaction() { ...@@ -38,66 +42,77 @@ 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"
#echo "#request: $req" #echo "#request: $req"
resp=$(curl -ksd "{$req}" ${MAIN_HTTP}) # resp=$(curl -ksd "{$req}" ${MAIN_HTTP})
echo "#response: $resp" # echo "#response: $resp"
ok=$(jq '(.error|not) and (.result != "")' <<<"$resp") # ok=$(jq '(.error|not) and (.result != "")' <<<"$resp")
[ "$ok" == true ] # [ "$ok" == true ]
echo_rst "$FUNCNAME" "$?" # echo_rst "$FUNCNAME" "$?"
rawtx=$(jq -r ".result" <<<"$resp") rawtx=$(jq -r ".result" <<<"$HTTP_RESP")
chain33_SignRawTx "$rawtx" "${oracle_publisher_key}" "${MAIN_HTTP}" 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"
#echo "#request: $req" #echo "#request: $req"
resp=$(curl -ksd "{$req}" ${MAIN_HTTP}) # resp=$(curl -ksd "{$req}" ${MAIN_HTTP})
echo "#response: $resp" # echo "#response: $resp"
ok=$(jq '(.error|not) and (.result != "")' <<<"$resp") # ok=$(jq '(.error|not) and (.result != "")' <<<"$resp")
[ "$ok" == true ] # [ "$ok" == true ]
echo_rst "$FUNCNAME" "$?" # echo_rst "$FUNCNAME" "$?"
rawtx=$(jq -r ".result" <<<"$resp") rawtx=$(jq -r ".result" <<<"$HTTP_RESP")
chain33_SignRawTx "$rawtx" "${oracle_publisher_key}" "${MAIN_HTTP}" 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"
#echo "#request: $req" #echo "#request: $req"
resp=$(curl -ksd "{$req}" ${MAIN_HTTP}) # resp=$(curl -ksd "{$req}" ${MAIN_HTTP})
echo "#response: $resp" # echo "#response: $resp"
ok=$(jq '(.error|not) and (.result != "")' <<<"$resp") # ok=$(jq '(.error|not) and (.result != "")' <<<"$resp")
[ "$ok" == true ] # [ "$ok" == true ]
echo_rst "$FUNCNAME" "$?" # echo_rst "$FUNCNAME" "$?"
rawtx=$(jq -r ".result" <<<"$resp") rawtx=$(jq -r ".result" <<<"$HTTP_RESP")
chain33_SignRawTx "$rawtx" "${oracle_publisher_key}" "${MAIN_HTTP}" 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"
#echo "#request: $req" #echo "#request: $req"
resp=$(curl -ksd "{$req}" ${MAIN_HTTP}) # resp=$(curl -ksd "{$req}" ${MAIN_HTTP})
echo "#response: $resp" # echo "#response: $resp"
ok=$(jq '(.error|not) and (.result != "")' <<<"$resp") # ok=$(jq '(.error|not) and (.result != "")' <<<"$resp")
[ "$ok" == true ] # [ "$ok" == true ]
echo_rst "$FUNCNAME" "$?" # echo_rst "$FUNCNAME" "$?"
rawtx=$(jq -r ".result" <<<"$resp") rawtx=$(jq -r ".result" <<<"$HTTP_RESP")
chain33_SignRawTx "$rawtx" "${oracle_publisher_key}" "${MAIN_HTTP}" 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"'"]}}]' # local req='"method":"Chain33.Query", "params":[{"execer":"oracle","funcName":"QueryOraclesByIDs","payload":{"eventID":["'"$event_id"'"]}}]'
#echo "#request: $req" #echo "#request: $req"
resp=$(curl -ksd "{$req}" ${MAIN_HTTP}) # resp=$(curl -ksd "{$req}" ${MAIN_HTTP})
echo "#response: $resp" # echo "#response: $resp"
ok=$(jq '(.error|not) and (.result.status[0] | [has("eventID", "status", "type", "subType", "source"),true] | unique | length == 1)' <<<"$resp") # ok=$(jq '(.error|not) and (.result.status[0] | [has("eventID", "status", "type", "subType", "source"),true] | unique | length == 1)' <<<"$resp")
[ "$ok" == true ] # [ "$ok" == true ]
rst=$? # rst=$?
echo_rst "$FUNCNAME" "$rst" # echo_rst "$FUNCNAME" "$rst"
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"
} }
function run_test() { function run_test() {
......
...@@ -201,30 +201,34 @@ function paracross_Transfer_Withdraw() { ...@@ -201,30 +201,34 @@ function paracross_Transfer_Withdraw() {
} }
function paracross_IsSync() { function paracross_IsSync() {
local ok # local ok
if [ "$IS_PARA" == "true" ]; then if [ "$IS_PARA" == "true" ]; then
ok=$(curl -ksd '{"method":"paracross.IsSync","params":[]}' ${UNIT_HTTP} | jq -r ".result") 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") # ok=$(curl -ksd '{"method":"Chain33.IsSync","params":[]}' ${UNIT_HTTP} | jq -r ".result")
req='{"method":"Chain33.IsSync","params":[]}'
fi fi
http_req "$req" ${UNIT_HTTP} '.result' "$FUNCNAME"
[ "$ok" == true ] # [ "$ok" == true ]
local rst=$? # local rst=$?
echo_rst "$FUNCNAME" "$rst" # echo_rst "$FUNCNAME" "$rst"
} }
function paracross_ListTitles() { function paracross_ListTitles() {
# local resp
local resp # local ok
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}) # resp=$(curl -ksd '{"method":"paracross.ListTitles","params":[]}' ${main_ip})
echo "$resp" # echo "$resp"
ok=$(jq '(.error|not) and (.result| [has("titles"),true])' <<<"$resp") # ok=$(jq '(.error|not) and (.result| [has("titles"),true])' <<<"$resp")
[ "$ok" == true ] # [ "$ok" == true ]
local rst=$? # local rst=$?
echo_rst "$FUNCNAME" "$rst" # echo_rst "$FUNCNAME" "$rst"
http_req '{"method":"paracross.ListTitles","params":[]}' ${main_ip} '(.error|not) and (.result| [has("titles"),true])' "$FUNCNAME"
} }
function paracross_GetHeight() { function paracross_GetHeight() {
...@@ -232,61 +236,71 @@ function paracross_GetHeight() { ...@@ -232,61 +236,71 @@ 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}) # resp=$(curl -ksd '{"method":"paracross.GetHeight","params":[]}' ${UNIT_HTTP})
#echo $resp #echo $resp
ok=$(jq '(.error|not) and (.result| [has("consensHeight"),true])' <<<"$resp") # ok=$(jq '(.error|not) and (.result| [has("consensHeight"),true])' <<<"$resp")
[ "$ok" == true ] # [ "$ok" == true ]
local rst=$? # local rst=$?
echo_rst "$FUNCNAME" "$rst" # echo_rst "$FUNCNAME" "$rst"
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 resp
local ok # local ok
resp=$(curl -ksd '{"method":"paracross.GetNodeGroupAddrs","params":[{"title":"user.p.para."}]}' ${UNIT_HTTP}) # resp=$(curl -ksd '{"method":"paracross.GetNodeGroupAddrs","params":[{"title":"user.p.para."}]}' ${UNIT_HTTP})
#echo $resp #echo $resp
ok=$(jq '(.error|not) and (.result| [has("key","value"),true])' <<<"$resp") # ok=$(jq '(.error|not) and (.result| [has("key","value"),true])' <<<"$resp")
[ "$ok" == true ] # [ "$ok" == true ]
local rst=$? # local rst=$?
echo_rst "$FUNCNAME" "$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"
} }
function paracross_GetNodeGroupStatus() { function paracross_GetNodeGroupStatus() {
local resp # local resp
local ok # local ok
resp=$(curl -ksd '{"method":"paracross.GetNodeGroupStatus","params":[{"title":"user.p.para."}]}' ${UNIT_HTTP}) # resp=$(curl -ksd '{"method":"paracross.GetNodeGroupStatus","params":[{"title":"user.p.para."}]}' ${UNIT_HTTP})
#echo $resp #echo $resp
ok=$(jq '(.error|not) and (.result| [has("status"),true])' <<<"$resp") # ok=$(jq '(.error|not) and (.result| [has("status"),true])' <<<"$resp")
[ "$ok" == true ] # [ "$ok" == true ]
local rst=$? # local rst=$?
echo_rst "$FUNCNAME" "$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"
} }
function paracross_ListNodeGroupStatus() { function paracross_ListNodeGroupStatus() {
local resp # local resp
local ok # local ok
resp=$(curl -ksd '{"method":"paracross.ListNodeGroupStatus","params":[{"title":"user.p.para.","status":2}]}' ${UNIT_HTTP}) # resp=$(curl -ksd '{"method":"paracross.ListNodeGroupStatus","params":[{"title":"user.p.para.","status":2}]}' ${UNIT_HTTP})
#echo $resp #echo $resp
ok=$(jq '(.error|not) and (.result| [has("status"),true])' <<<"$resp") # ok=$(jq '(.error|not) and (.result| [has("status"),true])' <<<"$resp")
[ "$ok" == true ] # [ "$ok" == true ]
local rst=$? # local rst=$?
echo_rst "$FUNCNAME" "$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"
} }
function paracross_ListNodeStatus() { function paracross_ListNodeStatus() {
local resp # local resp
local ok # local ok
resp=$(curl -ksd '{"method":"paracross.ListNodeStatus","params":[{"title":"user.p.para.","status":4}]}' ${UNIT_HTTP}) # resp=$(curl -ksd '{"method":"paracross.ListNodeStatus","params":[{"title":"user.p.para.","status":4}]}' ${UNIT_HTTP})
#echo $resp #echo $resp
ok=$(jq '(.error|not) and (.result| [has("status"),true])' <<<"$resp") # ok=$(jq '(.error|not) and (.result| [has("status"),true])' <<<"$resp")
[ "$ok" == true ] # [ "$ok" == true ]
local rst=$? # local rst=$?
echo_rst "$FUNCNAME" "$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"
} }
#main chain import pri key #main chain import pri key
......
...@@ -13,11 +13,14 @@ pokerbull_PlayRawTx() { ...@@ -13,11 +13,14 @@ pokerbull_PlayRawTx() {
echo "========== # pokerbull play tx begin ==========" 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")
data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]") # data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]")
ok=$(jq '(.execer != "")' <<<"$data") # ok=$(jq '(.execer != "")' <<<"$data")
[ "$ok" == true ] # [ "$ok" == true ]
echo_rst "$FUNCNAME" "$?" # 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} chain33_SignRawTx "$tx" "0x0316d5e33e7bce2455413156cb95209f8c641af352ee5d648c647f24383e4d94" ${MAIN_HTTP}
echo "========== # pokerbull play tx end ==========" echo "========== # pokerbull play tx end =========="
...@@ -29,11 +32,13 @@ pokerbull_QuitRawTx() { ...@@ -29,11 +32,13 @@ pokerbull_QuitRawTx() {
echo "========== # pokerbull quit tx begin ==========" 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")
data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]") # data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]")
ok=$(jq '(.execer != "")' <<<"$data") # ok=$(jq '(.execer != "")' <<<"$data")
[ "$ok" == true ] # [ "$ok" == true ]
echo_rst "$FUNCNAME" "$?" # 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} chain33_SignRawTx "$tx" "0x0316d5e33e7bce2455413156cb95209f8c641af352ee5d648c647f24383e4d94" ${MAIN_HTTP}
echo "========== # pokerbull quit tx end ==========" echo "========== # pokerbull quit tx end =========="
...@@ -45,11 +50,13 @@ pokerbull_ContinueRawTx() { ...@@ -45,11 +50,13 @@ pokerbull_ContinueRawTx() {
echo "========== # pokerbull continue tx begin ==========" 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")
data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]") # data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]")
ok=$(jq '(.execer != "")' <<<"$data") # ok=$(jq '(.execer != "")' <<<"$data")
[ "$ok" == true ] # [ "$ok" == true ]
echo_rst "$FUNCNAME" "$?" # 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} chain33_SignRawTx "$tx" "0xa26038cbdd9e6fbfb85f2c3d032254755e75252b9edccbecc16d9ba117d96705" ${MAIN_HTTP}
echo "========== # pokerbull continue tx end ==========" echo "========== # pokerbull continue tx end =========="
...@@ -61,11 +68,14 @@ pokerbull_StartRawTx() { ...@@ -61,11 +68,14 @@ pokerbull_StartRawTx() {
echo "========== # pokerbull start tx begin ==========" 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]") # data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]")
ok=$(jq '(.execer != "")' <<<"$data") # ok=$(jq '(.execer != "")' <<<"$data")
# [ "$ok" == true ]
# echo_rst "$FUNCNAME" "$?"
[ "$ok" == true ] req='{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}'
echo_rst "$FUNCNAME" "$?" http_req "$req" ${MAIN_HTTP} '(.result.txs[0].execer != "")' "$FUNCNAME"
chain33_SignRawTx "$tx" "0x0316d5e33e7bce2455413156cb95209f8c641af352ee5d648c647f24383e4d94" ${MAIN_HTTP} chain33_SignRawTx "$tx" "0x0316d5e33e7bce2455413156cb95209f8c641af352ee5d648c647f24383e4d94" ${MAIN_HTTP}
GAME_ID=$RAW_TX_HASH GAME_ID=$RAW_TX_HASH
...@@ -76,21 +86,32 @@ pokerbull_StartRawTx() { ...@@ -76,21 +86,32 @@ pokerbull_StartRawTx() {
pokerbull_QueryResult() { pokerbull_QueryResult() {
echo "========== # pokerbull query result begin ==========" echo "========== # pokerbull query result begin =========="
local req='"method":"Chain33.Query","params":[{"execer":"pokerbull","funcName":"QueryGameByID","payload":{"gameId":"'$GAME_ID'"}}]' # local req='"method":"Chain33.Query","params":[{"execer":"pokerbull","funcName":"QueryGameByID","payload":{"gameId":"'$GAME_ID'"}}]'
data=$(curl -ksd "{$req}" ${MAIN_HTTP} | jq -r ".result") # data=$(curl -ksd "{$req}" ${MAIN_HTTP} | jq -r ".result")
# ok=$(jq '(.game.gameId == "'"$GAME_ID"'")' <<<"$data")
# [ "$ok" == true ]
# echo_rst "$FUNCNAME" "$?"
ok=$(jq '(.game.gameId == "'"$GAME_ID"'")' <<<"$data") req='{"method":"Chain33.Query","params":[{"execer":"pokerbull","funcName":"QueryGameByID","payload":{"gameId":"'$GAME_ID'"}}]}'
resok='(.result.game.gameId == "'"$GAME_ID"'")'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
[ "$ok" == true ] # data=$(curl -ksd '{"method":"Chain33.Query","params":[{"execer":"pokerbull","funcName":"QueryGameByAddr","payload":{"addr":"14VkqML8YTRK4o15Cf97CQhpbnRUa6sJY4"}}]}' ${MAIN_HTTP} | jq -r ".result")
echo_rst "$FUNCNAME" "$?" # [ "$data" != null ]
# echo_rst "$FUNCNAME" "$?"
data=$(curl -ksd '{"method":"Chain33.Query","params":[{"execer":"pokerbull","funcName":"QueryGameByAddr","payload":{"addr":"14VkqML8YTRK4o15Cf97CQhpbnRUa6sJY4"}}]}' ${MAIN_HTTP} | jq -r ".result") req='{"method":"Chain33.Query","params":[{"execer":"pokerbull","funcName":"QueryGameByAddr","payload":{"addr":"14VkqML8YTRK4o15Cf97CQhpbnRUa6sJY4"}}]}'
[ "$data" != null ] http_req "$req" ${MAIN_HTTP} '(.result != null)' "$FUNCNAME"
echo_rst "$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"}}]}'
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" "$?"
echo "========== # pokerbull query result end ==========" echo "========== # pokerbull query result end =========="
} }
...@@ -155,7 +176,6 @@ function run_test() { ...@@ -155,7 +176,6 @@ function run_test() {
pokerbull_PlayRawTx pokerbull_PlayRawTx
pokerbull_QueryResult pokerbull_QueryResult
} }
function main() { function main() {
......
...@@ -9,107 +9,52 @@ source ../dapp-test-common.sh ...@@ -9,107 +9,52 @@ source ../dapp-test-common.sh
MAIN_HTTP="" MAIN_HTTP=""
privacy_CreateRawTransaction() { privacy_CreateRawTransaction() {
req='{"method":"privacy.CreateRawTransaction","params":[{"pubkeypair":"0a9d212b2505aefaa8da370319088bbccfac097b007f52ed71d8133456c8185823c8eac43c5e937953d7b6c8e68b0db1f4f03df4946a29f524875118960a35fb", "assetExec":"coins", "tokenname":"BTY", "type":1, "amount":100000000}]}'
local ip=$1 http_req "$req" ${MAIN_HTTP} '.error|not' "$FUNCNAME"
req='"method":"privacy.CreateRawTransaction","params":[{"pubkeypair":"0a9d212b2505aefaa8da370319088bbccfac097b007f52ed71d8133456c8185823c8eac43c5e937953d7b6c8e68b0db1f4f03df4946a29f524875118960a35fb", "assetExec":"coins", "tokenname":"BTY", "type":1, "amount":100000000}]'
echo "#request: $req"
resp=$(curl -ksd "{$req}" "$ip")
echo "#response: $resp"
ok=$(jq '.error|not' <<<"$resp")
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
} }
privacy_GetPrivacyTxByAddr() { privacy_GetPrivacyTxByAddr() {
http_req '{"method":"privacy.GetPrivacyTxByAddr","params":[{"tokenname":"BTY","sendRecvFlag":0,"from":"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv", "direction":1, "count":1}]}' ${MAIN_HTTP} '.error|not' "$FUNCNAME"
local ip=$1
req='"method":"privacy.GetPrivacyTxByAddr","params":[{"tokenname":"BTY","sendRecvFlag":0,"from":"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv", "direction":1, "count":1}]'
echo "#request: $req"
resp=$(curl -ksd "{$req}" "$ip")
echo "#response: $resp"
ok=$(jq '.error|not' <<<"$resp")
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
} }
privacy_ShowPrivacyKey() { privacy_ShowPrivacyKey() {
req='{"method":"privacy.ShowPrivacyKey", "params":[{"data":"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"}]}'
local ip=$1 resok='(.error|not) and .result.showSuccessful and (.result.pubkeypair=="0a9d212b2505aefaa8da370319088bbccfac097b007f52ed71d8133456c8185823c8eac43c5e937953d7b6c8e68b0db1f4f03df4946a29f524875118960a35fb")'
req='"method":"privacy.ShowPrivacyKey", "params":[{"data":"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"}]' http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
echo "#request: $req"
resp=$(curl -ksd "{$req}" "$ip")
echo "#response: $resp"
ok=$(jq '(.error|not) and .result.showSuccessful and (.result.pubkeypair=="0a9d212b2505aefaa8da370319088bbccfac097b007f52ed71d8133456c8185823c8eac43c5e937953d7b6c8e68b0db1f4f03df4946a29f524875118960a35fb")' <<<"$resp")
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
} }
privacy_ShowPrivacyAccountInfo() { privacy_ShowPrivacyAccountInfo() {
req='{"method":"privacy.ShowPrivacyAccountInfo", "params":[{"addr":"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv", "token":"BTY", "displaymode":1}]}'
local ip=$1 http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result|[has("utxos", "ftxos", "displaymode"), true] | unique | length == 1)' "$FUNCNAME"
req='"method":"privacy.ShowPrivacyAccountInfo", "params":[{"addr":"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv", "token":"BTY", "displaymode":1}]'
echo "#request: $req"
resp=$(curl -ksd "{$req}" "$ip")
echo "#response: $resp"
ok=$(jq '(.error|not) and (.result|[has("utxos", "ftxos", "displaymode"), true] | unique | length == 1)' <<<"$resp")
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
} }
privacy_ShowPrivacyAccountSpend() { privacy_ShowPrivacyAccountSpend() {
http_req '{"method":"privacy.ShowPrivacyAccountSpend", "params":[{"addr":"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv", "token":"BTY"}]}' ${MAIN_HTTP} '(.error|not) and .result.utxoHaveTxHashs' "$FUNCNAME"
local ip=$1
req='"method":"privacy.ShowPrivacyAccountSpend", "params":[{"addr":"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv", "token":"BTY"}]'
echo "#request: $req"
resp=$(curl -ksd "{$req}" "$ip")
echo "#response: $resp"
ok=$(jq '(.error|not) and .result.utxoHaveTxHashs' <<<"$resp")
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
} }
privacy_RescanUtxos() { privacy_RescanUtxos() {
http_req '{"method":"privacy.RescanUtxos", "params":[{"addrs":["12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"], "flag":0}]}' ${MAIN_HTTP} '(.error|not) and (.result|[has("flag", "repRescanResults"), true] | unique | length == 1)' "$FUNCNAME"
local ip=$1
req='"method":"privacy.RescanUtxos", "params":[{"addrs":["12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"], "flag":0}]'
echo "#request: $req"
resp=$(curl -ksd "{$req}" "$ip")
echo "#response: $resp"
ok=$(jq '(.error|not) and (.result|[has("flag", "repRescanResults"), true] | unique | length == 1)' <<<"$resp")
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
} }
privacy_EnablePrivacy() { privacy_EnablePrivacy() {
http_req '{"method":"privacy.EnablePrivacy", "params":[{"addrs":["12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"]}]}' ${MAIN_HTTP} '(.error|not) and .result.results[0].IsOK' "$FUNCNAME"
local ip=$1
req='"method":"privacy.EnablePrivacy", "params":[{"addrs":["12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"]}]'
echo "#request: $req"
resp=$(curl -ksd "{$req}" "$ip")
echo "#response: $resp"
ok=$(jq '(.error|not) and .result.results[0].IsOK' <<<"$resp")
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
} }
function run_test() { function run_test() {
local ip=$1 privacy_EnablePrivacy
privacy_EnablePrivacy "$ip" privacy_ShowPrivacyKey
privacy_ShowPrivacyKey "$ip" privacy_CreateRawTransaction
privacy_CreateRawTransaction "$ip" privacy_ShowPrivacyAccountInfo
privacy_ShowPrivacyAccountInfo "$ip" privacy_ShowPrivacyAccountSpend
privacy_ShowPrivacyAccountSpend "$ip" privacy_RescanUtxos
privacy_RescanUtxos "$ip" privacy_GetPrivacyTxByAddr
privacy_GetPrivacyTxByAddr "$ip"
} }
function main() { function main() {
MAIN_HTTP="$1" MAIN_HTTP="$1"
chain33_RpcTestBegin privacy
echo "ip=$MAIN_HTTP" echo "ip=$MAIN_HTTP"
chain33_RpcTestBegin privacy
run_test "$MAIN_HTTP" run_test
chain33_RpcTestRst privacy "$CASE_ERR" chain33_RpcTestRst privacy "$CASE_ERR"
} }
......
This diff is collapsed.
...@@ -67,11 +67,13 @@ retrieve_Backup() { ...@@ -67,11 +67,13 @@ retrieve_Backup() {
tx=$(curl -ksd "$req" ${MAIN_HTTP} | jq -r ".result") tx=$(curl -ksd "$req" ${MAIN_HTTP} | jq -r ".result")
local reqDecode='{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' local reqDecode='{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}'
data=$(curl -ksd "$reqDecode" ${MAIN_HTTP} | jq -r ".result.txs[0]") http_req "$reqDecode" ${MAIN_HTTP} '(.result.txs[0].execer != "")' "$FUNCNAME"
ok=$(jq '(.execer != "")' <<<"$data")
[ "$ok" == true ] # data=$(curl -ksd "$reqDecode" ${MAIN_HTTP} | jq -r ".result.txs[0]")
echo_rst "$FUNCNAME" "$?" # ok=$(jq '(.execer != "")' <<<"$data")
# [ "$ok" == true ]
# echo_rst "$FUNCNAME" "$?"
chain33_SignRawTx "$tx" "$retrieve2_key" ${MAIN_HTTP} chain33_SignRawTx "$tx" "$retrieve2_key" ${MAIN_HTTP}
echo "========== # retrieve backup end ==========" echo "========== # retrieve backup end =========="
...@@ -86,11 +88,13 @@ retrieve_Prepare() { ...@@ -86,11 +88,13 @@ retrieve_Prepare() {
tx=$(curl -ksd "$req" ${MAIN_HTTP} | jq -r ".result") tx=$(curl -ksd "$req" ${MAIN_HTTP} | jq -r ".result")
local reqDecode='{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' local reqDecode='{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}'
data=$(curl -ksd "$reqDecode" ${MAIN_HTTP} | jq -r ".result.txs[0]") http_req "$reqDecode" ${MAIN_HTTP} '(.result.txs[0].execer != "")' "$FUNCNAME"
ok=$(jq '(.execer != "")' <<<"$data")
# data=$(curl -ksd "$reqDecode" ${MAIN_HTTP} | jq -r ".result.txs[0]")
# ok=$(jq '(.execer != "")' <<<"$data")
[ "$ok" == true ] # [ "$ok" == true ]
echo_rst "$FUNCNAME" "$?" # echo_rst "$FUNCNAME" "$?"
chain33_SignRawTx "$tx" "$retrieve1_key" ${MAIN_HTTP} chain33_SignRawTx "$tx" "$retrieve1_key" ${MAIN_HTTP}
echo "========== # retrieve prepare end ==========" echo "========== # retrieve prepare end =========="
...@@ -105,11 +109,13 @@ retrieve_Perform() { ...@@ -105,11 +109,13 @@ retrieve_Perform() {
tx=$(curl -ksd "$req" ${MAIN_HTTP} | jq -r ".result") tx=$(curl -ksd "$req" ${MAIN_HTTP} | jq -r ".result")
local reqDecode='{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' local reqDecode='{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}'
data=$(curl -ksd "$reqDecode" ${MAIN_HTTP} | jq -r ".result.txs[0]") http_req "$reqDecode" ${MAIN_HTTP} '(.result.txs[0].execer != "")' "$FUNCNAME"
ok=$(jq '(.execer != "")' <<<"$data")
[ "$ok" == true ] # data=$(curl -ksd "$reqDecode" ${MAIN_HTTP} | jq -r ".result.txs[0]")
echo_rst "$FUNCNAME" "$?" # ok=$(jq '(.execer != "")' <<<"$data")
# [ "$ok" == true ]
# echo_rst "$FUNCNAME" "$?"
chain33_SignRawTx "$tx" "$retrieve1_key" ${MAIN_HTTP} chain33_SignRawTx "$tx" "$retrieve1_key" ${MAIN_HTTP}
echo "========== # retrieve perform end ==========" echo "========== # retrieve perform end =========="
...@@ -124,11 +130,13 @@ retrieve_Perform_Token() { ...@@ -124,11 +130,13 @@ retrieve_Perform_Token() {
tx=$(curl -ksd "$req" ${MAIN_HTTP} | jq -r ".result") tx=$(curl -ksd "$req" ${MAIN_HTTP} | jq -r ".result")
local reqDecode='{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' local reqDecode='{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}'
data=$(curl -ksd "$reqDecode" ${MAIN_HTTP} | jq -r ".result.txs[0]") http_req "$reqDecode" ${MAIN_HTTP} '(.result.txs[0].execer != "")' "$FUNCNAME"
ok=$(jq '(.execer != "")' <<<"$data")
# data=$(curl -ksd "$reqDecode" ${MAIN_HTTP} | jq -r ".result.txs[0]")
# ok=$(jq '(.execer != "")' <<<"$data")
[ "$ok" == true ] # [ "$ok" == true ]
echo_rst "$FUNCNAME" "$?" # echo_rst "$FUNCNAME" "$?"
chain33_SignRawTx "$tx" "$retrieve1_key" ${MAIN_HTTP} chain33_SignRawTx "$tx" "$retrieve1_key" ${MAIN_HTTP}
echo "========== # retrieve perform end ==========" echo "========== # retrieve perform end =========="
...@@ -143,11 +151,13 @@ retrieve_Cancel() { ...@@ -143,11 +151,13 @@ retrieve_Cancel() {
tx=$(curl -ksd "$req" ${MAIN_HTTP} | jq -r ".result") tx=$(curl -ksd "$req" ${MAIN_HTTP} | jq -r ".result")
local reqDecode='{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' local reqDecode='{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}'
data=$(curl -ksd "$reqDecode" ${MAIN_HTTP} | jq -r ".result.txs[0]") http_req "$reqDecode" ${MAIN_HTTP} '(.result.txs[0].execer != "")' "$FUNCNAME"
ok=$(jq '(.execer != "")' <<<"$data")
[ "$ok" == true ] # data=$(curl -ksd "$reqDecode" ${MAIN_HTTP} | jq -r ".result.txs[0]")
echo_rst "$FUNCNAME" "$?" # ok=$(jq '(.execer != "")' <<<"$data")
# [ "$ok" == true ]
# echo_rst "$FUNCNAME" "$?"
chain33_SignRawTx "$tx" "$retrieve2_key" ${MAIN_HTTP} chain33_SignRawTx "$tx" "$retrieve2_key" ${MAIN_HTTP}
echo "========== # retrieve cancel end ==========" echo "========== # retrieve cancel end =========="
...@@ -161,11 +171,13 @@ retrieve_QueryResult() { ...@@ -161,11 +171,13 @@ retrieve_QueryResult() {
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'"}}]}'
data=$(curl -ksd "$req" ${MAIN_HTTP} | jq -r ".result") http_req "$req" ${MAIN_HTTP} '(.result.status == '"$status"')' "$FUNCNAME"
ok=$(jq '(.status == '"$status"')' <<<"$data")
# data=$(curl -ksd "$req" ${MAIN_HTTP} | jq -r ".result")
# ok=$(jq '(.status == '"$status"')' <<<"$data")
[ "$ok" == true ] # [ "$ok" == true ]
echo_rst "$FUNCNAME" "$?" # echo_rst "$FUNCNAME" "$?"
echo "========== # retrieve query result end ==========" echo "========== # retrieve query result end =========="
} }
...@@ -175,11 +187,13 @@ retrieve_QueryAssetResult() { ...@@ -175,11 +187,13 @@ retrieve_QueryAssetResult() {
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"'"}}]}'
data=$(curl -ksd "$req" ${MAIN_HTTP} | jq -r ".result") http_req "$req" ${MAIN_HTTP} '(.result.status == '"$status"')' "$FUNCNAME"
ok=$(jq '(.status == '"$status"')' <<<"$data")
# data=$(curl -ksd "$req" ${MAIN_HTTP} | jq -r ".result")
# ok=$(jq '(.status == '"$status"')' <<<"$data")
[ "$ok" == true ] # [ "$ok" == true ]
echo_rst "$FUNCNAME" "$?" # echo_rst "$FUNCNAME" "$?"
echo "========== # retrieve query result end ==========" echo "========== # retrieve query result end =========="
} }
......
This diff is collapsed.
...@@ -76,12 +76,15 @@ function init() { ...@@ -76,12 +76,15 @@ 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" # echo "#request: $req"
resp=$(curl -ksd "$req" "${MAIN_HTTP}") # resp=$(curl -ksd "$req" "${MAIN_HTTP}")
# echo "#resp: $resp" # echo "#resp: $resp"
ok=$(jq '(.error|not) and (.result != "")' <<<"$resp") # ok=$(jq '(.error|not) and (.result != "")' <<<"$resp")
[ "$ok" == true ] # [ "$ok" == true ]
echo_rst "$FUNCNAME" "$?" # echo_rst "$FUNCNAME" "$?"
rawtx=$(jq -r ".result" <<<"$resp")
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != "")' "$FUNCNAME"
rawtx=$(jq -r ".result" <<<"$HTTP_RESP")
chain33_SignRawTx "$rawtx" "$owner_key" "${MAIN_HTTP}" chain33_SignRawTx "$rawtx" "$owner_key" "${MAIN_HTTP}"
query_unfreezeID query_unfreezeID
} }
...@@ -89,47 +92,51 @@ function CreateRawUnfreezeCreate() { ...@@ -89,47 +92,51 @@ function CreateRawUnfreezeCreate() {
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"
# echo "#request: $req" # echo "#request: $req"
resp=$(curl -ksd "$req" "${MAIN_HTTP}") # resp=$(curl -ksd "$req" "${MAIN_HTTP}")
# echo "#resp: $resp" # echo "#resp: $resp"
ok=$(jq '(.error|not) and (.result != "")' <<<"$resp") # ok=$(jq '(.error|not) and (.result != "")' <<<"$resp")
[ "$ok" == true ] # [ "$ok" == true ]
echo_rst "$FUNCNAME" "$?" # echo_rst "$FUNCNAME" "$?"
rawtx=$(jq -r ".result" <<<"$resp") rawtx=$(jq -r ".result" <<<"$HTTP_RESP")
chain33_SignRawTx "$rawtx" "${beneficiary_key}" "${MAIN_HTTP}" 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"
# echo "#request: $req" # echo "#request: $req"
resp=$(curl -ksd "$req" "${MAIN_HTTP}") # resp=$(curl -ksd "$req" "${MAIN_HTTP}")
# echo "#resp: $resp" # echo "#resp: $resp"
ok=$(jq '(.error|not) and (.result != "")' <<<"$resp") # ok=$(jq '(.error|not) and (.result != "")' <<<"$resp")
[ "$ok" == true ] # [ "$ok" == true ]
echo_rst "$FUNCNAME" "$?" # echo_rst "$FUNCNAME" "$?"
rawtx=$(jq -r ".result" <<<"$resp") rawtx=$(jq -r ".result" <<<"$HTTP_RESP")
chain33_SignRawTx "$rawtx" "$owner_key" "${MAIN_HTTP}" 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"
# echo "#request: $req" # echo "#request: $req"
resp=$(curl -ksd "$req" "${MAIN_HTTP}") # resp=$(curl -ksd "$req" "${MAIN_HTTP}")
# echo "#resp: $resp" # echo "#resp: $resp"
ok=$(jq '(.error|not) and (.result != "")' <<<"$resp") # ok=$(jq '(.error|not) and (.result != "")' <<<"$resp")
[ "$ok" == true ] # [ "$ok" == true ]
echo_rst "$FUNCNAME" "$?" # 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"
# echo "#request: $req" # echo "#request: $req"
resp=$(curl -ksd "$req" "${MAIN_HTTP}") # resp=$(curl -ksd "$req" "${MAIN_HTTP}")
# echo "#resp: $resp" # echo "#resp: $resp"
ok=$(jq '(.error|not) and (.result != "")' <<<"$resp") # ok=$(jq '(.error|not) and (.result != "")' <<<"$resp")
[ "$ok" == true ] # [ "$ok" == true ]
echo_rst "$FUNCNAME" "$?" # echo_rst "$FUNCNAME" "$?"
} }
function run_testcases() { function run_testcases() {
......
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