# 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""$?"
# echo_rst "$FUNCNAME" "$?"
}
function CreateGameTx(){
local amount=$1
local hash_value=$2
local req='"method":"Chain33.CreateTransaction","params":[{"execer":"'"${EXECTOR}"'", "actionName":"createGame", "payload":{"amount": '"${amount}"',"hashType":"sha256","hashValue":"'"${hash_value}"'"}}]'
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
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":"matchGame", "payload":{"gameId": "'"${gameId}"'","guess":2}}]'
local req='{"method":"Chain33.CreateTransaction","params":[{"execer":"'"${EXECTOR}"'", "actionName":"matchGame", "payload":{"gameId": "'"${gameId}"'","guess":2}}]}'
echo"#request: $req"
resp=$(curl -ksd"{$req}""${MAIN_HTTP}")
echo"#response: $resp"
http_req "$req"${MAIN_HTTP}'(.error|not) and (.result != "")'"MatchGame createRawTx"
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"
resp=$(curl -ksd"{$req}""${MAIN_HTTP}")
echo"#response: $resp"
http_req "$req"${MAIN_HTTP}'(.error|not) and (.result != "")'"CloseGame createRawTx"
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"
resp=$(curl -ksd"{$req}""${MAIN_HTTP}")
echo"#response: $resp"
http_req "$req"${MAIN_HTTP}'(.error|not) and (.result != "")'"CancleGame createRawTx"
local req='"method":"Chain33.Query","params":[{"execer":"'"${EXECTOR}"'","funcName":"QueryGameListByStatusAndAddr","payload":{"status":'"${status}"',"address":""}}]'
echo"#request: $req"
resp=$(curl -ksd"{$req}""${MAIN_HTTP}")
echo"#response: $resp"
GAMES=$(echo"${resp}" | jq -r".result.games")
echo"${GAMES}"
echo_rst "$FUNCNAME""$?"
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"
# 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(){
local gameId=$1
local status=$2
local req='"method":"Chain33.Query","params":[{"execer":"'"${EXECTOR}"'","funcName":"QueryGameById","payload":{"gameId":"'"${gameId}"'"}}]'
ok=$(jq '(.error|not) and (.result| [has("key","value"),true])'<<<"$resp")
["$ok"==true]
local rst=$?
echo_rst "$FUNCNAME""$rst"
# 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"
ok=$(jq '(.error|not) and (.result| [has("status"),true])'<<<"$resp")
["$ok"==true]
local rst=$?
echo_rst "$FUNCNAME""$rst"
# 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"
ok=$(jq '(.error|not) and (.result| [has("status"),true])'<<<"$resp")
["$ok"==true]
local rst=$?
echo_rst "$FUNCNAME""$rst"
# 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"
ok=$(jq '(.error|not) and (.result| [has("status"),true])'<<<"$resp")
["$ok"==true]
local rst=$?
echo_rst "$FUNCNAME""$rst"
# 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"
ok=$(jq '(.error|not) and .result.showSuccessful and (.result.pubkeypair=="0a9d212b2505aefaa8da370319088bbccfac097b007f52ed71d8133456c8185823c8eac43c5e937953d7b6c8e68b0db1f4f03df4946a29f524875118960a35fb")'<<<"$resp")
resok='(.error|not) and .result.showSuccessful and (.result.pubkeypair=="0a9d212b2505aefaa8da370319088bbccfac097b007f52ed71d8133456c8185823c8eac43c5e937953d7b6c8e68b0db1f4f03df4946a29f524875118960a35fb")'
ok=$(jq '(.error|not) and .result.results[0].IsOK'<<<"$resp")
["$ok"==true]
echo_rst "$FUNCNAME""$?"
http_req '{"method":"privacy.EnablePrivacy", "params":[{"addrs":["12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"]}]}'${MAIN_HTTP}'(.error|not) and .result.results[0].IsOK'"$FUNCNAME"
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'","assetExec":"token", "assetSymbol":"'"$symbol"'"}}]}'