Commit f9df6fa2 authored by vipwzw's avatar vipwzw

auto ci

parent 344c2dee
......@@ -25,11 +25,11 @@ echo_rst() {
}
http_req() {
# echo "request="$1" MAIN_HTTP="$2" js="$3" FUNCNAME="$4" response="$5""
# echo "#$4 request: $1"
# echo "request="$1" MAIN_HTTP="$2" js="$3" FUNCNAME="$4" response="$5""
# echo "#$4 request: $1"
HTTP_RESP=$(curl -ksd "$1" "$2")
RAW_RESP=$(jq -r "$5" <<<"$HTTP_RESP")
# echo "#response: $HTTP_RESP" "$RAW_RESP"
# echo "#response: $HTTP_RESP" "$RAW_RESP"
ok=$(echo "$HTTP_RESP" | jq -r "$3")
[ "$ok" == true ]
rst=$?
......
......@@ -24,4 +24,4 @@ function rpc_test() {
}
chain33_debug_function rpc_test "$1"
\ No newline at end of file
chain33_debug_function rpc_test "$1"
......@@ -176,4 +176,4 @@ function main() {
chain33_RpcTestRst blackwhite "$CASE_ERR"
}
chain33_debug_function main "$1"
\ No newline at end of file
chain33_debug_function main "$1"
......@@ -19,8 +19,8 @@ source ../dapp-test-common.sh
function chain33_GetExecAddr() {
#获取GAME合约地址
req='{"method":"Chain33.ConvertExectoAddr","params":[{"execname":"'"$1"'"}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME" ".result"
GAME_ADDR=$RAW_RESP
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME" ".result"
GAME_ADDR=$RAW_RESP
}
function CreateGameTx() {
......
......@@ -106,4 +106,4 @@ function main() {
chain33_RpcTestRst hashlock "$CASE_ERR"
}
chain33_debug_function main "$1"
\ No newline at end of file
chain33_debug_function main "$1"
......@@ -41,29 +41,29 @@ function init() {
function configJSCreator() {
req='{"method":"Chain33.CreateTransaction","params":[{"execer":"'${manager_name}'","actionName":"Modify","payload":{"key":"js-creator","op":"add","value":"'${beneficiary}'"}}]}'
resok='(.error|not) and (.result != null)'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME" ".result"
resok='(.error|not) and (.result != null)'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME" ".result"
chain33_SignRawTx "$RAW_RESP" "${super_manager}" "${MAIN_HTTP}"
}
function createJSContract() {
req='{"method":"Chain33.CreateTransaction","params":[{"execer":"'${exec_name}'","actionName":"Create","payload":{"name":"'${game}'","code":"'${jsCode}'"}}]}'
resok='(.error|not) and (.result != null)'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME" ".result"
resok='(.error|not) and (.result != null)'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME" ".result"
chain33_SignRawTx "$RAW_RESP" "${beneficiary_key}" "${MAIN_HTTP}"
}
function callJS() {
req='{"method":"Chain33.CreateTransaction","params":[{"execer":"'${user_game}'","actionName":"Call","payload":{"name":"'${game}'","funcname":"hello","args":"{}"}}]}'
resok='(.error|not) and (.result != null)'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME" ".result"
resok='(.error|not) and (.result != null)'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME" ".result"
chain33_SignRawTx "$RAW_RESP" "${beneficiary_key}" "${MAIN_HTTP}"
}
function queryJS() {
req='{"method":"Chain33.Query","params":[{"execer":"'${user_game}'","funcName":"Query","payload":{"name":"'${game}'","funcname":"hello","args":"{}"}}]}'
resok='(.error|not) and (.result != null)'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
resok='(.error|not) and (.result != null)'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
}
function run_testcases() {
......
......@@ -75,7 +75,7 @@ lottery_LotteryCreate() {
#创建交易
priv=$1
req='{"method":"Chain33.CreateTransaction","params":[{"execer":"lottery","actionName":"LotteryCreate","payload":{"purBlockNum":'"$purNum"',"drawBlockNum":'"$drawNum"', "opRewardRatio":'"$opRatio"',"devRewardRatio":'"$devRatio"',"fee":1000000}}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not)' "$FUNCNAME" ".result"
http_req "$req" ${MAIN_HTTP} '(.error|not)' "$FUNCNAME" ".result"
#发送交易
chain33_SignRawTx "${RAW_RESP}" "${priv}" ${MAIN_HTTP}
......@@ -91,7 +91,7 @@ lottery_LotteryBuy() {
number=$3
way=$4
req='{"method":"Chain33.CreateTransaction","params":[{"execer":"lottery","actionName":"LotteryBuy","payload":{"lotteryId":"'"$gID"'","amount":'"$amount"',"number":'"$number"',"way":'"$way"',"fee":1000000}}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not)' "$FUNCNAME" ".result"
http_req "$req" ${MAIN_HTTP} '(.error|not)' "$FUNCNAME" ".result"
#发送交易
chain33_SignRawTx "${RAW_RESP}" "${priv}" ${MAIN_HTTP}
......@@ -101,7 +101,7 @@ lottery_LotteryDraw() {
#创建交易
priv=$1
req='{"method":"Chain33.CreateTransaction","params":[{"execer":"lottery","actionName":"LotteryDraw","payload":{"lotteryId":"'"$gID"'","fee":1000000}}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not)' "$FUNCNAME" ".result"
http_req "$req" ${MAIN_HTTP} '(.error|not)' "$FUNCNAME" ".result"
#发送交易
chain33_SignRawTx "${RAW_RESP}" "${priv}" ${MAIN_HTTP}
}
......@@ -110,7 +110,7 @@ lottery_LotteryClose() {
#创建交易
priv=$1
req='{"method":"Chain33.CreateTransaction","params":[{"execer":"lottery","actionName":"LotteryClose","payload":{"lotteryId":"'"$gID"'","fee":1000000}}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not)' "$FUNCNAME" ".result"
http_req "$req" ${MAIN_HTTP} '(.error|not)' "$FUNCNAME" ".result"
#发送交易
chain33_SignRawTx "${RAW_RESP}" "${priv}" ${MAIN_HTTP}
}
......@@ -119,7 +119,7 @@ lottery_GetLotteryNormalInfo() {
gameID=$1
addr=$2
req='{"method":"Chain33.Query","params":[{"execer":"lottery","funcName":"GetLotteryNormalInfo","payload":{"lotteryId":"'"$gameID"'"}}]}'
resok='(.error|not) and (.result.purBlockNum == "'"$purNum"'") and (.result.drawBlockNum == "'"$drawNum"'") and (.result.createAddr == "'"$addr"'") and (.result.opRewardRatio == "'"$opRatio"'") and (.result.devRewardRatio == "'"$devRatio"'") and (.result | [has("createHeight"), true] | unique | length == 1)'
resok='(.error|not) and (.result.purBlockNum == "'"$purNum"'") and (.result.drawBlockNum == "'"$drawNum"'") and (.result.createAddr == "'"$addr"'") and (.result.opRewardRatio == "'"$opRatio"'") and (.result.devRewardRatio == "'"$devRatio"'") and (.result | [has("createHeight"), true] | unique | length == 1)'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
}
......@@ -128,8 +128,8 @@ lottery_GetLotteryCurrentInfo() {
status=$2
amount=$3
req='{"method":"Chain33.Query","params":[{"execer":"lottery","funcName":"GetLotteryCurrentInfo","payload":{"lotteryId":"'"$gameID"'"}}]}'
resok='(.error|not) and (.result.status == '"$status"') and (.result.buyAmount == "'"$amount"'") and (.result | [has("lastTransToPurState", "lastTransToDrawState", "totalPurchasedTxNum", "round", "luckyNumber", "lastTransToPurStateOnMain", "lastTransToDrawStateOnMain", "purBlockNum", "drawBlockNum", "missingRecords", "totalAddrNum"), true] | unique | length == 1)'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME" ".result.luckyNumber"
resok='(.error|not) and (.result.status == '"$status"') and (.result.buyAmount == "'"$amount"'") and (.result | [has("lastTransToPurState", "lastTransToDrawState", "totalPurchasedTxNum", "round", "luckyNumber", "lastTransToPurStateOnMain", "lastTransToDrawStateOnMain", "purBlockNum", "drawBlockNum", "missingRecords", "totalAddrNum"), true] | unique | length == 1)'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME" ".result.luckyNumber"
if [[ $status == 3 ]]; then
luckyNumber=$RAW_RESP
......@@ -142,8 +142,8 @@ lottery_GetLotteryPurchaseAddr() {
gameID=$1
count=$2
req='{"method":"Chain33.Query","params":[{"execer":"lottery","funcName":"GetLotteryPurchaseAddr","payload":{"lotteryId":"'"$gameID"'"}}]}'
resok='(.error|not) and (.result.address | length == '"$count"')'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
resok='(.error|not) and (.result.address | length == '"$count"')'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
}
lottery_GetLotteryHistoryLuckyNumber() {
......@@ -151,8 +151,8 @@ lottery_GetLotteryHistoryLuckyNumber() {
count=$2
lucky=$3
req='{"method":"Chain33.Query","params":[{"execer":"lottery","funcName":"GetLotteryHistoryLuckyNumber","payload":{"lotteryId":"'"$gameID"'"}}]}'
resok='(.error|not) and (.result.records | length == '"$count"') and (.result.records[0].number == "'"$lucky"'")'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
resok='(.error|not) and (.result.records | length == '"$count"') and (.result.records[0].number == "'"$lucky"'")'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
}
lottery_GetLotteryRoundLuckyNumber() {
......@@ -160,8 +160,8 @@ lottery_GetLotteryRoundLuckyNumber() {
round=$2
lucky=$3
req='{"method":"Chain33.Query","params":[{"execer":"lottery","funcName":"GetLotteryRoundLuckyNumber","payload":{"lotteryId":"'"$gameID"'", "round":['"$round"']}}]}'
resok='(.error|not) and (.result.records | length == 1) and (.result.records[0].number == "'"$lucky"'")'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
resok='(.error|not) and (.result.records | length == 1) and (.result.records[0].number == "'"$lucky"'")'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
}
lottery_GetLotteryHistoryBuyInfo() {
......@@ -170,8 +170,8 @@ lottery_GetLotteryHistoryBuyInfo() {
count=$3
number=$4
req='{"method":"Chain33.Query","params":[{"execer":"lottery","funcName":"GetLotteryHistoryBuyInfo","payload":{"lotteryId":"'"$gameID"'", "addr":"'"$addr"'"}}]}'
resok='(.error|not) and (.result.records | length == '"$count"') and (.result.records[0].number == "'"$number"'")'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
resok='(.error|not) and (.result.records | length == '"$count"') and (.result.records[0].number == "'"$number"'")'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
}
lottery_GetLotteryBuyRoundInfo() {
......@@ -181,8 +181,8 @@ lottery_GetLotteryBuyRoundInfo() {
count=$4
number=$5
req='{"method":"Chain33.Query","params":[{"execer":"lottery","funcName":"GetLotteryBuyRoundInfo","payload":{"lotteryId":"'"$gameID"'", "addr":"'"$addr"'", "round":'"$round"'}}]}'
resok='(.error|not) and (.result.records | length == '"$count"') and (.result.records[0].number == "'"$number"'")'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
resok='(.error|not) and (.result.records | length == '"$count"') and (.result.records[0].number == "'"$number"'")'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
}
lottery_GetLotteryHistoryGainInfo() {
......@@ -191,8 +191,8 @@ lottery_GetLotteryHistoryGainInfo() {
count=$3
amount=$4
req='{"method":"Chain33.Query","params":[{"execer":"lottery","funcName":"GetLotteryHistoryGainInfo","payload":{"lotteryId":"'"$gameID"'", "addr":"'"$addr"'"}}]}'
resok='(.error|not) and (.result.records | length == '"$count"') and (.result.records[0].addr == "'"$addr"'") and (.result.records[0].buyAmount == "'"$amount"'")'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
resok='(.error|not) and (.result.records | length == '"$count"') and (.result.records[0].addr == "'"$addr"'") and (.result.records[0].buyAmount == "'"$amount"'")'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
}
lottery_GetLotteryRoundGainInfo() {
......@@ -201,8 +201,8 @@ lottery_GetLotteryRoundGainInfo() {
round=$3
amount=$4
req='{"method":"Chain33.Query","params":[{"execer":"lottery","funcName":"GetLotteryRoundGainInfo","payload":{"lotteryId":"'"$gameID"'", "addr":"'"$addr"'", "round":'"$round"'}}]}'
resok='(.error|not) and (.result.addr == "'"$addr"'") and (.result.round == "'"$round"'") and (.result.buyAmount == "'"$amount"'") and (.result | [has("fundAmount"), true] | unique | length == 1)'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
resok='(.error|not) and (.result.addr == "'"$addr"'") and (.result.round == "'"$round"'") and (.result.buyAmount == "'"$amount"'") and (.result | [has("fundAmount"), true] | unique | length == 1)'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
}
function run_testcases() {
......@@ -268,4 +268,4 @@ function main() {
chain33_RpcTestRst lottery "$CASE_ERR"
}
chain33_debug_function main "$1"
\ No newline at end of file
chain33_debug_function main "$1"
......@@ -77,7 +77,7 @@ 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]")
# echo "multisigAccAddr=$multisigAccAddr"
# echo "multisigAccAddr=$multisigAccAddr"
#多重签名地址查询具体信息
req='{"method":"Chain33.Query","params":[{"execer":"multisig","funcName":"MultiSigAccountInfo","payload":{"multiSigAccAddr":"'"$multisigAccAddr"'"}}]}'
......
......@@ -118,4 +118,4 @@ function main() {
chain33_RpcTestRst pokerbull "$CASE_ERR"
}
chain33_debug_function main "$1"
\ No newline at end of file
chain33_debug_function main "$1"
......@@ -55,9 +55,9 @@ ticket_TicketList() {
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
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")
# echo -e "######\\n ticketId is $ticketId \\n######"
# echo -e "######\\n ticketId is $ticketId \\n######"
}
ticket_MinerAddress() {
......
......@@ -34,7 +34,7 @@ txHash=""
function queryTransaction() {
validator=$1
expectRes=$2
# echo "txhash=${RAW_TX_HASH}"
# echo "txhash=${RAW_TX_HASH}"
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
return 1
......@@ -45,7 +45,7 @@ function queryTransaction() {
function signRawTxAndQuery() {
chain33_SignRawTx "${unsignedTx}" "${superManager}" "${MAIN_HTTP}"
# txHash=$RAW_TX_HASH
# txHash=$RAW_TX_HASH
queryTransaction ".error | not" "true"
echo_rst "$1 queryExecRes" "$?"
}
......@@ -226,7 +226,7 @@ function token_withdraw() {
function run_test() {
local ip=$1
# set -x
# set -x
token_preCreate
token_getPreCreated
......@@ -240,7 +240,7 @@ function run_test() {
token_sendExec
token_assets
token_withdraw
# set +x
# set +x
}
function main() {
......
......@@ -15,7 +15,7 @@ function query_unfreezeID() {
req='{"method":"Chain33.QueryTransaction","params":[{"hash":"'"$txhash"'"}]}'
ret=$(curl -ksd "$req" ${MAIN_HTTP})
tx=$(jq -r ".result.tx.hash" <<<"$ret")
# echo "====query tx= ${txhash}, return=$ret "
# echo "====query tx= ${txhash}, return=$ret "
if [ "${tx}" != "${txhash}" ]; then
chain33_BlockWait 1 "${MAIN_HTTP}"
times=$((times - 1))
......@@ -121,4 +121,4 @@ function rpc_test() {
chain33_RpcTestRst unfreeze "$CASE_ERR"
}
chain33_debug_function rpc_test "$1"
\ No newline at end of file
chain33_debug_function rpc_test "$1"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment