Commit c8445cf0 authored by mdj33's avatar mdj33 Committed by vipwzw

fix rpc test

parent 8991b218
...@@ -4,9 +4,7 @@ set -e ...@@ -4,9 +4,7 @@ set -e
set -o pipefail set -o pipefail
MAIN_HTTP="" MAIN_HTTP=""
PARA_HTTP=""
CASE_ERR="" CASE_ERR=""
UNIT_HTTP=""
# $2=0 means true, other false # $2=0 means true, other false
echo_rst() { echo_rst() {
...@@ -72,14 +70,14 @@ chain33_SendTransaction() { ...@@ -72,14 +70,14 @@ 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;' ${UNIT_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"
signTx=$(echo "${resp}" | jq -r ".result") 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;' ${UNIT_HTTP}) 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=$(echo "${resp}" | jq -r ".error")
[ "$ok" == null ] [ "$ok" == null ]
rst=$? rst=$?
...@@ -92,7 +90,7 @@ chain33_SendTransaction() { ...@@ -92,7 +90,7 @@ 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;' ${UNIT_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=$?
...@@ -109,7 +107,7 @@ blackwhite_BlackwhitePlayTx() { ...@@ -109,7 +107,7 @@ 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;' ${UNIT_HTTP}) 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})
ok=$(echo "${resp}" | jq -r ".error") ok=$(echo "${resp}" | jq -r ".error")
[ "$ok" == null ] [ "$ok" == null ]
rst=$? rst=$?
...@@ -122,7 +120,7 @@ blackwhite_BlackwhitePlayTx() { ...@@ -122,7 +120,7 @@ blackwhite_BlackwhitePlayTx() {
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;' ${UNIT_HTTP}) 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})
ok=$(echo "${resp}" | jq -r ".error") ok=$(echo "${resp}" | jq -r ".error")
[ "$ok" == null ] [ "$ok" == null ]
rst=$? rst=$?
...@@ -134,7 +132,7 @@ blackwhite_BlackwhiteShowTx() { ...@@ -134,7 +132,7 @@ blackwhite_BlackwhiteShowTx() {
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;' ${UNIT_HTTP}) resp=$(curl -ksd '{"jsonrpc":"2.0","id":2,"method":"blackwhite.BlackwhiteTimeoutDoneTx","params":[{"gameID":"'"$gameID"'","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=$?
...@@ -145,7 +143,7 @@ blackwhite_GetBlackwhiteRoundInfo() { ...@@ -145,7 +143,7 @@ blackwhite_GetBlackwhiteRoundInfo() {
gameID=$1 gameID=$1
execer="blackwhite" execer="blackwhite"
funcName="GetBlackwhiteRoundInfo" funcName="GetBlackwhiteRoundInfo"
resp=$(curl -ksd '{"jsonrpc":"2.0","id":2,"method":"Chain33.Query","params":[{"execer":"'"$execer"'","funcName":"'"$funcName"'","payload":{"gameID":"'"$gameID"'"}}]}' -H 'content-type:text/plain;' ${UNIT_HTTP}) 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=$(jq '(.error|not) and (.result.round | [has("gameID", "status", "playAmount", "playerCount", "curPlayerCount", "loop", "curShowCount", "timeout"),true] | unique | length == 1)' <<<"$resp")
[ "$ok" == true ] [ "$ok" == true ]
rst=$? rst=$?
...@@ -157,7 +155,7 @@ blackwhite_GetBlackwhiteByStatusAndAddr() { ...@@ -157,7 +155,7 @@ blackwhite_GetBlackwhiteByStatusAndAddr() {
addr=$2 addr=$2
execer="blackwhite" execer="blackwhite"
funcName="GetBlackwhiteByStatusAndAddr" funcName="GetBlackwhiteByStatusAndAddr"
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;' ${UNIT_HTTP}) 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=$(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 ] [ "$ok" == true ]
rst=$? rst=$?
...@@ -168,7 +166,7 @@ blackwhite_GetBlackwhiteloopResult() { ...@@ -168,7 +166,7 @@ blackwhite_GetBlackwhiteloopResult() {
gameID=$1 gameID=$1
execer="blackwhite" execer="blackwhite"
funcName="GetBlackwhiteloopResult" funcName="GetBlackwhiteloopResult"
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;' ${UNIT_HTTP}) 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})
ok=$(jq '(.error|not) and (.result.gameID == "'"$gameID"'") and (.result.results|length >= 1)' <<<"$resp") ok=$(jq '(.error|not) and (.result.gameID == "'"$gameID"'") and (.result.results|length >= 1)' <<<"$resp")
[ "$ok" == true ] [ "$ok" == true ]
rst=$? rst=$?
......
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