Commit 019ae3da authored by yingqiumin@126.com's avatar yingqiumin@126.com

improve rpc test

parent e6e316b9
......@@ -23,7 +23,7 @@ echo_rst() {
fi
}
http_req() {
chain33_Http() {
local body=$(curl -ksd "$1" "$2")
RETURN_RESP=$(jq -r "$5" <<<"$body")
echo "#response: $body" "$RETURN_RESP"
......
......@@ -32,7 +32,7 @@ init() {
chain33_NewAccount() {
label=$1
req='{"method":"Chain33.NewAccount","params":[{"label":"'"$label"'"}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result.acc.addr|length > 0)' "$FUNCNAME" ".result.acc.addr"
chain33_Http "$req" ${MAIN_HTTP} '(.error|not) and (.result.acc.addr|length > 0)' "$FUNCNAME" ".result.acc.addr"
glAddr=$RETURN_RESP
}
......@@ -41,11 +41,11 @@ chain33_SendTransaction() {
addr=$2
#签名交易
req='{"method":"Chain33.SignRawTx","params":[{"addr":"'"$addr"'","txHex":"'"$rawTx"'","expire":"120s","fee":10000000,"index":0}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not)' "Chain33.SignRawTx" ".result"
chain33_Http "$req" ${MAIN_HTTP} '(.error|not)' "Chain33.SignRawTx" ".result"
signTx=$RETURN_RESP
req='{"method":"Chain33.SendTransaction","params":[{"data":"'"$signTx"'"}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not)' "$FUNCNAME" ".result"
chain33_Http "$req" ${MAIN_HTTP} '(.error|not)' "$FUNCNAME" ".result"
gResp=$RETURN_RESP
#返回交易
......@@ -56,7 +56,7 @@ blackwhite_BlackwhiteCreateTx() {
#创建交易
addr=$1
req='{"method":"blackwhite.BlackwhiteCreateTx","params":[{"PlayAmount":100000000,"PlayerCount":3,"GameName":"hello","Timeout":600,"Fee":1000000}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not)' "$FUNCNAME" ".result"
chain33_Http "$req" ${MAIN_HTTP} '(.error|not)' "$FUNCNAME" ".result"
#发送交易
chain33_SendTransaction "$RETURN_RESP" "${addr}"
gID="${gResp}"
......@@ -68,7 +68,7 @@ blackwhite_BlackwhitePlayTx() {
round2=$3
round3=$4
req='{"method":"blackwhite.BlackwhitePlayTx","params":[{"gameID":"'"$gID"'","amount":100000000,"Fee":1000000,"hashValues":["'"$round1"'","'"$round2"'","'"$round3"'"]}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not)' "$FUNCNAME" ".result"
chain33_Http "$req" ${MAIN_HTTP} '(.error|not)' "$FUNCNAME" ".result"
#发送交易
chain33_SendTransaction "$RETURN_RESP" "${addr}"
......@@ -78,34 +78,34 @@ blackwhite_BlackwhiteShowTx() {
addr=$1
sec=$2
req='{"method":"blackwhite.BlackwhiteShowTx","params":[{"gameID":"'"$gID"'","secret":"'"$sec"'","Fee":1000000}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not)' "$FUNCNAME" ".result"
chain33_Http "$req" ${MAIN_HTTP} '(.error|not)' "$FUNCNAME" ".result"
chain33_SendTransaction "$RETURN_RESP" "${addr}"
}
blackwhite_BlackwhiteTimeoutDoneTx() {
gameID=$1
req='{"method":"blackwhite.BlackwhiteTimeoutDoneTx","params":[{"gameID":"'"$gameID"'","Fee":1000000}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not)' "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} '(.error|not)' "$FUNCNAME"
}
blackwhite_GetBlackwhiteRoundInfo() {
gameID=$1
req='{"method":"Chain33.Query","params":[{"execer":"blackwhite","funcName":"GetBlackwhiteRoundInfo","payload":{"gameID":"'"$gameID"'"}}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result.round | [has("gameID", "status", "playAmount", "playerCount", "curPlayerCount", "loop", "curShowCount", "timeout"),true] | unique | length == 1)' "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} '(.error|not) and (.result.round | [has("gameID", "status", "playAmount", "playerCount", "curPlayerCount", "loop", "curShowCount", "timeout"),true] | unique | length == 1)' "$FUNCNAME"
}
blackwhite_GetBlackwhiteByStatusAndAddr() {
addr=$1
req='{"method":"Chain33.Query","params":[{"execer":"blackwhite","funcName":"GetBlackwhiteByStatusAndAddr","payload":{"status":5,"address":"'"$addr"'","count":1,"direction":0,"index":-1}}]}'
resok='(.error|not) and (.result.round[0].createAddr == "'"$addr"'") and (.result.round[0].status == 5) and (.result.round[0] | [has("gameID", "status", "playAmount", "playerCount", "curPlayerCount", "loop", "curShowCount", "timeout", "winner"),true] | unique | length == 1)'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
}
blackwhite_GetBlackwhiteloopResult() {
gameID=$1
req='{"method":"Chain33.Query","params":[{"execer":"blackwhite","funcName":"GetBlackwhiteloopResult","payload":{"gameID":"'"$gameID"'","loopSeq":0}}]}'
resok='(.error|not) and (.result.gameID == "'"$gameID"'") and (.result.results|length >= 1)'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
}
function run_testcases() {
......
......@@ -49,7 +49,7 @@ function evm_createContract() {
function evm_addressCheck() {
req='{"method":"Chain33.Query","params":[{"execer":"evm","funcName":"CheckAddrExists","payload":{"addr":"'${evm_contractAddr}'"}}]}'
resok='(.result.contract == true ) and (.result.contractAddr == "'"${evm_contractAddr}"'")'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
}
function evm_callContract() {
op=$1
......@@ -75,7 +75,7 @@ function evm_callContract() {
function evm_abiGet() {
req='{"method":"Chain33.Query","params":[{"execer":"evm","funcName":"QueryABI","payload":{"address":"'${evm_contractAddr}'"}}]}'
http_req "$req" ${MAIN_HTTP} "(.result.abi != null)" "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} "(.result.abi != null)" "$FUNCNAME"
}
function evm_transfer() {
......@@ -100,7 +100,7 @@ function evm_getBalance() {
expectBalance=$1
req='{"method":"Chain33.GetBalance","params":[{"addresses":["'${evm_creatorAddr}'"],"execer":"'${evm_addr}'", "paraName": "'${paraName}'"}]}'
resok='(.result[0].balance == '$expectBalance') and (.result[0].addr == "'"$evm_creatorAddr"'")'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
}
function evm_withDraw() {
......
......@@ -19,14 +19,14 @@ 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"
chain33_Http "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$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}"'"}}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME" ".result"
chain33_Http "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME" ".result"
chain33_SignRawTx "${RETURN_RESP}" "${PRIVA_A}" "${MAIN_HTTP}"
GAME_ID=$RAW_TX_HASH
......@@ -36,7 +36,7 @@ function CreateGameTx() {
function MatchGameTx() {
local gameId=$1
local req='{"method":"Chain33.CreateTransaction","params":[{"execer":"'"${EXECTOR}"'", "actionName":"matchGame", "payload":{"gameId": "'"${gameId}"'","guess":2}}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "MatchGame createRawTx" ".result"
chain33_Http "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "MatchGame createRawTx" ".result"
chain33_SignRawTx "${RETURN_RESP}" "${PRIVA_B}" "${MAIN_HTTP}"
echo_rst "MatchGame query_tx" "$?"
}
......@@ -46,7 +46,7 @@ function CloseGameTx() {
local secret=$2
local req='{"method":"Chain33.CreateTransaction","params":[{"execer":"'"${EXECTOR}"'", "actionName":"closeGame", "payload":{"gameId": "'"${gameId}"'","secret":"'"${secret}"'","result":1}}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "CloseGame createRawTx" ".result"
chain33_Http "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "CloseGame createRawTx" ".result"
chain33_SignRawTx "${RETURN_RESP}" "${PRIVA_A}" "${MAIN_HTTP}"
echo_rst "CloseGame query_tx" "$?"
}
......@@ -55,7 +55,7 @@ function CancleGameTx() {
local gameId=$1
local req='{"method":"Chain33.CreateTransaction","params":[{"execer":"'"${EXECTOR}"'", "actionName":"cancelGame", "payload":{"gameId": "'"${gameId}"'"}}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "CancleGame createRawTx" ".result"
chain33_Http "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "CancleGame createRawTx" ".result"
chain33_SignRawTx "${RETURN_RESP}" "${PRIVA_A}" "${MAIN_HTTP}"
echo_rst "CancleGame query_tx" "$?"
}
......@@ -63,7 +63,7 @@ function CancleGameTx() {
function QueryGameByStatus() {
local status=$1
local req='{"method":"Chain33.Query","params":[{"execer":"'"${EXECTOR}"'","funcName":"QueryGameListByStatusAndAddr","payload":{"status":'"${status}"',"address":""}}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not)' "$FUNCNAME" ".result.games"
chain33_Http "$req" ${MAIN_HTTP} '(.error|not)' "$FUNCNAME" ".result.games"
}
function QueryGameByGameId() {
......@@ -71,7 +71,7 @@ function QueryGameByGameId() {
local status=$2
local req='{"method":"Chain33.Query","params":[{"execer":"'"${EXECTOR}"'","funcName":"QueryGameById","payload":{"gameId":"'"${gameId}"'"}}]}'
resok='(.error|not) and (.result.game.status = "'"${status}"'")'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
}
function init() {
......
......@@ -51,7 +51,7 @@ guess_QueryGameByID() {
local event_id=$1
local status=$2
local req='{"method":"Chain33.Query", "params":[{"execer":"guess","funcName":"QueryGameByID","payload":{"gameID":"'"$event_id"'"}}]}'
http_req "$req" ${MAIN_HTTP} '(.result|has("game")) and (.result.game.status == '"$status"')' "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} '(.result|has("game")) and (.result.game.status == '"$status"')' "$FUNCNAME"
}
init() {
......
......@@ -42,28 +42,28 @@ 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"
chain33_Http "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME" ".result"
chain33_SignRawTx "$RETURN_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"
chain33_Http "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME" ".result"
chain33_SignRawTx "$RETURN_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"
chain33_Http "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME" ".result"
chain33_SignRawTx "$RETURN_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"
chain33_Http "$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"
chain33_Http "$req" ${MAIN_HTTP} '(.error|not)' "$FUNCNAME" ".result"
#发送交易
chain33_SignRawTx "${RETURN_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"
chain33_Http "$req" ${MAIN_HTTP} '(.error|not)' "$FUNCNAME" ".result"
#发送交易
chain33_SignRawTx "${RETURN_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"
chain33_Http "$req" ${MAIN_HTTP} '(.error|not)' "$FUNCNAME" ".result"
#发送交易
chain33_SignRawTx "${RETURN_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"
chain33_Http "$req" ${MAIN_HTTP} '(.error|not)' "$FUNCNAME" ".result"
#发送交易
chain33_SignRawTx "${RETURN_RESP}" "${priv}" ${MAIN_HTTP}
}
......@@ -120,7 +120,7 @@ lottery_GetLotteryNormalInfo() {
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)'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
}
lottery_GetLotteryCurrentInfo() {
......@@ -129,7 +129,7 @@ lottery_GetLotteryCurrentInfo() {
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"
chain33_Http "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME" ".result.luckyNumber"
if [[ $status == 3 ]]; then
luckyNumber=$RETURN_RESP
......@@ -143,7 +143,7 @@ lottery_GetLotteryPurchaseAddr() {
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"
chain33_Http "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
}
lottery_GetLotteryHistoryLuckyNumber() {
......@@ -152,7 +152,7 @@ lottery_GetLotteryHistoryLuckyNumber() {
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"
chain33_Http "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
}
lottery_GetLotteryRoundLuckyNumber() {
......@@ -161,7 +161,7 @@ lottery_GetLotteryRoundLuckyNumber() {
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"
chain33_Http "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
}
lottery_GetLotteryHistoryBuyInfo() {
......@@ -171,7 +171,7 @@ lottery_GetLotteryHistoryBuyInfo() {
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"
chain33_Http "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
}
lottery_GetLotteryBuyRoundInfo() {
......@@ -182,7 +182,7 @@ lottery_GetLotteryBuyRoundInfo() {
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"
chain33_Http "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
}
lottery_GetLotteryHistoryGainInfo() {
......@@ -192,7 +192,7 @@ lottery_GetLotteryHistoryGainInfo() {
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"
chain33_Http "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
}
lottery_GetLotteryRoundGainInfo() {
......@@ -202,7 +202,7 @@ lottery_GetLotteryRoundGainInfo() {
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"
chain33_Http "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
}
function run_testcases() {
......
......@@ -83,11 +83,11 @@ function multisig_AccCreateTx() {
#多重签名地址查询具体信息
req='{"method":"Chain33.Query","params":[{"execer":"multisig","funcName":"MultiSigAccountInfo","payload":{"multiSigAccAddr":"'"$multisigAccAddr"'"}}]}'
resok='(.result.createAddr == "'$GenAddr'")'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
req='{"method":"Chain33.Query","params":[{"execer":"multisig","funcName":"MultiSigAccAllAddress","payload":{"multiSigAccAddr":"'$GenAddr'"}}]}'
resok='(.result.address[0] == "'"$multisigAccAddr"'")'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
echo "========== # multisig_AccCreateTx ok =========="
}
......@@ -108,7 +108,7 @@ function multisig_TransferInTx() {
#查询multisigAccAddr地址资产信息
req='{"method":"Chain33.Query","params":[{"execer":"multisig","funcName":"MultiSigAccAssets","payload":{"multiSigAddr":"'"$multisigAccAddr"'","assets":{"execer":"'$Asset'","symbol":"'$Symbol'"},"isAll":false}}]}'
resok='(.result.accAssets[0].assets.execer == "'$Asset'") and (.result.accAssets[0].assets.symbol == "'$Symbol'") and (.result.accAssets[0].account.frozen == "4000000000")'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
echo "========== # multisig_TransferInTx end =========="
}
......@@ -124,12 +124,12 @@ function multisig_TransferOutTx() {
#查询AddrB账户在multisig合约下有2000000000
req='{"method":"Chain33.Query","params":[{"execer":"multisig","funcName":"MultiSigAccAssets","payload":{"multiSigAddr":"1LDGrokrZjo1HtSmSnw8ef3oy5Vm1nctbj","assets":{"execer":"coins","symbol":"'$Symbol'"},"isAll":false}}]}'
resok='(.result.accAssets[0].assets.execer == "'$Asset'") and (.result.accAssets[0].assets.symbol == "'$Symbol'") and (.result.accAssets[0].account.balance == "2000000000")'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
#查询multisigAccAddr地址资产信息,减少了2000000000
req='{"method":"Chain33.Query","params":[{"execer":"multisig","funcName":"MultiSigAccAssets","payload":{"multiSigAddr":"'"$multisigAccAddr"'","assets":{"execer":"'$Asset'","symbol":"'$Symbol'"},"isAll":false}}]}'
resok='(.result.accAssets[0].assets.execer == "'$Asset'") and (.result.accAssets[0].assets.symbol == "'$Symbol'") and (.result.accAssets[0].account.frozen == "2000000000")'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
echo "========== # multisig_TransferOutTx end =========="
}
......@@ -145,7 +145,7 @@ function multisig_OwnerOperateTx() {
#查询多重签名账户的信息中有AddrEmultisig_TransferInTx
req='{"method":"Chain33.Query","params":[{"execer":"multisig","funcName":"MultiSigAccountInfo","payload":{"multiSigAccAddr":"'"$multisigAccAddr"'"}}]}'
resok='(.result.owners[3].ownerAddr == "'$AddrE'")'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
#删除多重签名账户的信息中owner AddrE
......@@ -169,7 +169,7 @@ function multisig_OwnerOperateTx() {
#查询多重签名账户的信息中有AddrE并且weight为30
req='{"method":"Chain33.Query","params":[{"execer":"multisig","funcName":"MultiSigAccountInfo","payload":{"multiSigAccAddr":"'"$multisigAccAddr"'"}}]}'
resok='(.result.owners[0].ownerAddr == "'$AddrE'") and (.result.owners[0].weight == "30")'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
}
function multisig_AccOperateTx() {
......@@ -193,16 +193,16 @@ function multisig_AccOperateTx() {
#获取本多重签名账户上的交易数,已经对应的交易信息
req='{"method":"Chain33.Query","params":[{"execer":"multisig","funcName":"MultiSigAccTxCount","payload":{"multiSigAccAddr":"'"$multisigAccAddr"'"}}]}'
http_req "$req" ${MAIN_HTTP} '(.result.data != null)' "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} '(.result.data != null)' "$FUNCNAME"
#获取本多重签名账户上的交易数,通过交易交易id获取交易信息 ????
req='{"method":"Chain33.Query","params":[{"execer":"multisig","funcName":"MultiSigAccTxCount","payload":{"multiSigAccAddr":"'"$multisigAccAddr"'"}}]}'
http_req "$req" ${MAIN_HTTP} '(.result.data != null)' "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} '(.result.data != null)' "$FUNCNAME"
#查询多重签名账户信息中
req='{"method":"Chain33.Query","params":[{"execer":"multisig","funcName":"MultiSigTxInfo","payload":{"multiSigAddr":"'"$multisigAccAddr"'","txId":"7"}}]}'
resok='(.result.txid == "7") and (.result.executed == true) and (.result.multiSigAddr == "'"$multisigAccAddr"'")'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
}
function run_test() {
......
......@@ -24,7 +24,7 @@ oracle_AddPublisher() {
oracle_publish_transaction() {
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 != null)' "$FUNCNAME" ".result"
chain33_Http "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME" ".result"
chain33_SignRawTx "$RETURN_RESP" "${oracle_publisher_key}" "${MAIN_HTTP}"
eventId="${txhash}"
echo "eventId $eventId"
......@@ -33,35 +33,35 @@ oracle_publish_transaction() {
oracle_prePublishResult_transaction() {
event_id=$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 != null)' "$FUNCNAME" ".result"
chain33_Http "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME" ".result"
chain33_SignRawTx "$RETURN_RESP" "${oracle_publisher_key}" "${MAIN_HTTP}"
}
oracle_eventAbort_transaction() {
event_id=$1
req='{"method":"Chain33.CreateTransaction","params":[{"execer":"oracle","actionName":"EventAbort","payload":{"eventID":"'"$event_id"'"}}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME" ".result"
chain33_Http "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME" ".result"
chain33_SignRawTx "$RETURN_RESP" "${oracle_publisher_key}" "${MAIN_HTTP}"
}
oracle_resultAbort_transaction() {
event_id=$1
req='{"method":"Chain33.CreateTransaction","params":[{"execer":"oracle","actionName":"ResultAbort","payload":{"eventID":"'"$event_id"'"}}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME" ".result"
chain33_Http "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME" ".result"
chain33_SignRawTx "$RETURN_RESP" "${oracle_publisher_key}" "${MAIN_HTTP}"
}
oracle_publishResult_transaction() {
event_id=$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 != null)' "$FUNCNAME" ".result"
chain33_Http "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME" ".result"
chain33_SignRawTx "$RETURN_RESP" "${oracle_publisher_key}" "${MAIN_HTTP}"
}
oracle_QueryOraclesByID() {
event_id=$1
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"
chain33_Http "$req" ${MAIN_HTTP} '(.error|not) and (.result.status[0] | [has("eventID", "status", "type", "subType", "source"),true] | unique | length == 1)' "$FUNCNAME"
}
function run_test() {
......
......@@ -9,7 +9,7 @@ IS_PARA=false
source ../dapp-test-common.sh
paracross_GetBlock2MainInfo() {
http_req '{"method":"paracross.GetBlock2MainInfo","params":[{"start":1,"end":3}]}' ${UNIT_HTTP} "(.result.items[1].height == 2)" "$FUNCNAME"
chain33_Http '{"method":"paracross.GetBlock2MainInfo","params":[{"start":1,"end":3}]}' ${UNIT_HTTP} "(.result.items[1].height == 2)" "$FUNCNAME"
}
function paracross_QueryParaBalance() {
......@@ -190,34 +190,34 @@ function paracross_IsSync() {
else
req='{"method":"Chain33.IsSync","params":[]}'
fi
http_req "$req" ${UNIT_HTTP} '.result' "$FUNCNAME"
chain33_Http "$req" ${UNIT_HTTP} '.result' "$FUNCNAME"
}
function paracross_ListTitles() {
local main_ip=${UNIT_HTTP//8901/8801}
http_req '{"method":"paracross.ListTitles","params":[]}' ${main_ip} '(.error|not) and (.result| [has("titles"),true])' "$FUNCNAME"
chain33_Http '{"method":"paracross.ListTitles","params":[]}' ${main_ip} '(.error|not) and (.result| [has("titles"),true])' "$FUNCNAME"
}
function paracross_GetHeight() {
if [ "$IS_PARA" == "true" ]; then
http_req '{"method":"paracross.GetHeight","params":[]}' ${UNIT_HTTP} '(.error|not) and (.result| [has("consensHeight"),true])' "$FUNCNAME"
chain33_Http '{"method":"paracross.GetHeight","params":[]}' ${UNIT_HTTP} '(.error|not) and (.result| [has("consensHeight"),true])' "$FUNCNAME"
fi
}
function paracross_GetNodeGroupAddrs() {
http_req '{"method":"paracross.GetNodeGroupAddrs","params":[{"title":"user.p.para."}]}' ${UNIT_HTTP} '(.error|not) and (.result| [has("key","value"),true])' "$FUNCNAME"
chain33_Http '{"method":"paracross.GetNodeGroupAddrs","params":[{"title":"user.p.para."}]}' ${UNIT_HTTP} '(.error|not) and (.result| [has("key","value"),true])' "$FUNCNAME"
}
function paracross_GetNodeGroupStatus() {
http_req '{"method":"paracross.GetNodeGroupStatus","params":[{"title":"user.p.para."}]}' ${UNIT_HTTP} '(.error|not) and (.result| [has("status"),true])' "$FUNCNAME"
chain33_Http '{"method":"paracross.GetNodeGroupStatus","params":[{"title":"user.p.para."}]}' ${UNIT_HTTP} '(.error|not) and (.result| [has("status"),true])' "$FUNCNAME"
}
function paracross_ListNodeGroupStatus() {
http_req '{"method":"paracross.ListNodeGroupStatus","params":[{"title":"user.p.para.","status":2}]}' ${UNIT_HTTP} '(.error|not) and (.result| [has("status"),true])' "$FUNCNAME"
chain33_Http '{"method":"paracross.ListNodeGroupStatus","params":[{"title":"user.p.para.","status":2}]}' ${UNIT_HTTP} '(.error|not) and (.result| [has("status"),true])' "$FUNCNAME"
}
function paracross_ListNodeStatus() {
http_req '{"method":"paracross.ListNodeStatus","params":[{"title":"user.p.para.","status":4}]}' ${UNIT_HTTP} '(.error|not) and (.result| [has("status"),true])' "$FUNCNAME"
chain33_Http '{"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
......
......@@ -27,7 +27,7 @@ pokerbull_ContinueRawTx() {
pokerbull_StartRawTx() {
tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"pokerbull","actionName":"Start","payload":{"value":"1000000000", "playerNum":"2"}}]}' ${MAIN_HTTP} | jq -r ".result")
req='{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}'
http_req "$req" ${MAIN_HTTP} '(.result.txs[0].execer != null)' "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} '(.result.txs[0].execer != null)' "$FUNCNAME"
chain33_SignRawTx "$tx" "0x0316d5e33e7bce2455413156cb95209f8c641af352ee5d648c647f24383e4d94" ${MAIN_HTTP}
GAME_ID=$RAW_TX_HASH
chain33_BlockWait 1 "${MAIN_HTTP}"
......@@ -36,13 +36,13 @@ pokerbull_StartRawTx() {
pokerbull_QueryResult() {
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"
chain33_Http "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
req='{"method":"Chain33.Query","params":[{"execer":"pokerbull","funcName":"QueryGameByAddr","payload":{"addr":"14VkqML8YTRK4o15Cf97CQhpbnRUa6sJY4"}}]}'
http_req "$req" ${MAIN_HTTP} '(.result != null)' "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} '(.result != null)' "$FUNCNAME"
req='{"method":"Chain33.Query","params":[{"execer":"pokerbull","funcName":"QueryGameByStatus","payload":{"status":"3"}}]}'
http_req "$req" ${MAIN_HTTP} '(.result != null)' "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} '(.result != null)' "$FUNCNAME"
}
init() {
......
......@@ -10,34 +10,34 @@ MAIN_HTTP=""
privacy_CreateRawTransaction() {
req='{"method":"privacy.CreateRawTransaction","params":[{"pubkeypair":"0a9d212b2505aefaa8da370319088bbccfac097b007f52ed71d8133456c8185823c8eac43c5e937953d7b6c8e68b0db1f4f03df4946a29f524875118960a35fb", "assetExec":"coins", "tokenname":"BTY", "type":1, "amount":100000000}]}'
http_req "$req" ${MAIN_HTTP} '.error|not' "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} '.error|not' "$FUNCNAME"
}
privacy_GetPrivacyTxByAddr() {
http_req '{"method":"privacy.GetPrivacyTxByAddr","params":[{"tokenname":"BTY","sendRecvFlag":0,"from":"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv", "direction":1, "count":1}]}' ${MAIN_HTTP} '.error|not' "$FUNCNAME"
chain33_Http '{"method":"privacy.GetPrivacyTxByAddr","params":[{"tokenname":"BTY","sendRecvFlag":0,"from":"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv", "direction":1, "count":1}]}' ${MAIN_HTTP} '.error|not' "$FUNCNAME"
}
privacy_ShowPrivacyKey() {
req='{"method":"privacy.ShowPrivacyKey", "params":[{"data":"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"}]}'
resok='(.error|not) and .result.showSuccessful and (.result.pubkeypair=="0a9d212b2505aefaa8da370319088bbccfac097b007f52ed71d8133456c8185823c8eac43c5e937953d7b6c8e68b0db1f4f03df4946a29f524875118960a35fb")'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
}
privacy_ShowPrivacyAccountInfo() {
req='{"method":"privacy.ShowPrivacyAccountInfo", "params":[{"addr":"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv", "token":"BTY", "displaymode":1}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result|[has("utxos", "ftxos", "displaymode"), true] | unique | length == 1)' "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} '(.error|not) and (.result|[has("utxos", "ftxos", "displaymode"), true] | unique | length == 1)' "$FUNCNAME"
}
privacy_ShowPrivacyAccountSpend() {
http_req '{"method":"privacy.ShowPrivacyAccountSpend", "params":[{"addr":"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv", "token":"BTY"}]}' ${MAIN_HTTP} '(.error|not) and .result.utxoHaveTxHashs' "$FUNCNAME"
chain33_Http '{"method":"privacy.ShowPrivacyAccountSpend", "params":[{"addr":"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv", "token":"BTY"}]}' ${MAIN_HTTP} '(.error|not) and .result.utxoHaveTxHashs' "$FUNCNAME"
}
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"
chain33_Http '{"method":"privacy.RescanUtxos", "params":[{"addrs":["12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"], "flag":0}]}' ${MAIN_HTTP} '(.error|not) and (.result|[has("flag", "repRescanResults"), true] | unique | length == 1)' "$FUNCNAME"
}
privacy_EnablePrivacy() {
http_req '{"method":"privacy.EnablePrivacy", "params":[{"addrs":["12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"]}]}' ${MAIN_HTTP} '(.error|not) and .result.results[0].IsOK' "$FUNCNAME"
chain33_Http '{"method":"privacy.EnablePrivacy", "params":[{"addrs":["12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"]}]}' ${MAIN_HTTP} '(.error|not) and .result.results[0].IsOK' "$FUNCNAME"
}
function run_test() {
......
......@@ -8,19 +8,19 @@ MAIN_HTTP=""
relay_CreateRawRelaySaveBTCHeadTx() {
local req='{"method":"relay.CreateRawRelaySaveBTCHeadTx","params":[{"hash":"5e7d9c599cd040ec2ba53f4dee28028710be8c135e779f65c56feadaae34c3f2","height":10,"version":536870912,"merkleRoot":"ab91cd4160e1379c337eee6b7a4bdbb7399d70268d86045aba150743c00c90b6","time":1530862108,"nonce":0,"bits":545259519,"previousHash":"604efe53975ab06cad8748fd703ad5bc960e8b752b2aae98f0f871a4a05abfc7","isReset":true}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME" ".result"
chain33_Http "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME" ".result"
chain33_SignRawTx "$RETURN_RESP" "0x22968d29c6de695381a8719ef7bf00e2edb6cce500bb59a4fc73c41887610962" "${MAIN_HTTP}"
}
relay_CreateRawRelaySaveBTCHeadTx_11() {
local req='{"method":"relay.CreateRawRelaySaveBTCHeadTx","params":[{"hash":"7b7a4a9b49db5a1162be515d380cd186e98c2bf0bb90f1145485d7c43343fc7c","height":11,"version":536870912,"merkleRoot":"cfa9b66696aea63b7266ffaa1cb4b96c8dd6959eaabf2eb14173f4adaa551f6f","time":1530862108,"nonce":1,"bits":545259519,"previousHash":"5e7d9c599cd040ec2ba53f4dee28028710be8c135e779f65c56feadaae34c3f2","isReset":false}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME" ".result"
chain33_Http "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME" ".result"
chain33_SignRawTx "$RETURN_RESP" "0x22968d29c6de695381a8719ef7bf00e2edb6cce500bb59a4fc73c41887610962" "${MAIN_HTTP}"
}
relay_CreateRawRelayOrderTx() {
local req='{"method":"relay.CreateRawRelayOrderTx","params":[{"operation":0,"coin":"BTC","amount":299000000,"addr":"1Am9UTGfdnxabvcywYG2hvzr6qK8T3oUZT","btyAmount":1000000000,"coinWaits":6}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME" ".result"
chain33_Http "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME" ".result"
chain33_SignRawTx "$RETURN_RESP" "0x22968d29c6de695381a8719ef7bf00e2edb6cce500bb59a4fc73c41887610962" "${MAIN_HTTP}"
}
......@@ -35,7 +35,7 @@ relay_CreateRawRelayAcceptTx() {
fi
local req='{"method":"relay.CreateRawRelayAcceptTx","params":[{"orderId":"'"$id"'","coinAddr":"1Am9UTGfdnxabvcywYG2hvzr6qK8T3oUZT"}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME" ".result"
chain33_Http "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME" ".result"
chain33_SignRawTx "$RETURN_RESP" "0xec9162ea5fc2f473ab8240619a0a0f495ba9e9e5d4d9c434b8794a68280236c4" "${MAIN_HTTP}"
}
......@@ -50,7 +50,7 @@ relay_CreateRawRelayRevokeTx() {
fi
local req='{"method":"relay.CreateRawRelayRevokeTx","params":[{"orderId":"'"$id"'","target":0,"action":1}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME" ".result"
chain33_Http "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME" ".result"
chain33_SignRawTx "$RETURN_RESP" "0x22968d29c6de695381a8719ef7bf00e2edb6cce500bb59a4fc73c41887610962" "${MAIN_HTTP}"
}
......@@ -65,35 +65,35 @@ relay_CreateRawRelayConfirmTx() {
fi
local req='{"method":"relay.CreateRawRelayConfirmTx","params":[{"orderId":"'"$id"'","rawTx":"6359f0868171b1d194cbee1af2f16ea598ae8fad666d9b012c8ed2b79a236ec4"}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME" ".result"
chain33_Http "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME" ".result"
chain33_SignRawTx "$RETURN_RESP" "0xec9162ea5fc2f473ab8240619a0a0f495ba9e9e5d4d9c434b8794a68280236c4" "${MAIN_HTTP}"
}
query_GetRelayOrderByStatus() {
status="$1"
local req='{"method":"Chain33.Query", "params":[{"execer":"relay","funcName":"GetRelayOrderByStatus","payload":{"addr":"","status":"'"$status"'","coins":["BTC"],"pageNumber":0,"pageSize":0}}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result.relayorders[0].id != null)' "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} '(.error|not) and (.result.relayorders[0].id != null)' "$FUNCNAME"
}
query_GetSellRelayOrder() {
local req='{"method":"Chain33.Query", "params":[{"execer":"relay","funcName":"GetSellRelayOrder","payload":{"addr":"1G5Cjy8LuQex2fuYv3gzb7B8MxAnxLEqt3","status":"pending","coins":["BTC"],"pageNumber":0,"pageSize":0}}]}'
resok='(.error|not) and (.result.relayorders[0].status == "pending") and (.result.relayorders[0].coinOperation == 0) and (.result.relayorders[0].id != null)'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
}
query_GetBuyRelayOrder() {
local req='{"method":"Chain33.Query", "params":[{"execer":"relay","funcName":"GetBuyRelayOrder","payload":{"addr":"1EZKahMRfoMiKp1BewjWrQWoaJ9kmC4hum","status":"locking","coins":["BTC"],"pageNumber":0,"pageSize":0}}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result.relayorders[0].status == "locking")' "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} '(.error|not) and (.result.relayorders[0].status == "locking")' "$FUNCNAME"
}
query_GetBTCHeaderList() {
local req='{"method":"Chain33.Query", "params":[{"execer":"relay","funcName":"GetBTCHeaderList","payload":{"reqHeight":"10","counts":10,"direction":0}}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result.heights|length == 2)' "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} '(.error|not) and (.result.heights|length == 2)' "$FUNCNAME"
}
query_GetBTCHeaderCurHeight() {
local req='{"method":"Chain33.Query", "params":[{"execer":"relay","funcName":"GetBTCHeaderCurHeight","payload":{"baseHeight":"0"}}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result.baseHeight == "10") and (.result.curHeight == "10")' "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} '(.error|not) and (.result.baseHeight == "10") and (.result.curHeight == "10")' "$FUNCNAME"
}
init() {
......
......@@ -93,13 +93,13 @@ retrieve_Cancel() {
retrieve_QueryResult() {
local status=$1
local req='{"method":"Chain33.Query","params":[{"execer":"retrieve","funcName":"GetRetrieveInfo","payload":{"backupAddress":"'$retrieve1'", "defaultAddress":"'$retrieve2'"}}]}'
http_req "$req" ${MAIN_HTTP} '(.result.status == '"$status"')' "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} '(.result.status == '"$status"')' "$FUNCNAME"
}
retrieve_QueryAssetResult() {
local status=$1
local req='{"method":"Chain33.Query","params":[{"execer":"retrieve","funcName":"GetRetrieveInfo","payload":{"backupAddress":"'$retrieve1'", "defaultAddress":"'$retrieve2'","assetExec":"token", "assetSymbol":"'"$symbol"'"}}]}'
http_req "$req" ${MAIN_HTTP} '(.result.status == '"$status"')' "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} '(.result.status == '"$status"')' "$FUNCNAME"
}
init() {
......
......@@ -18,24 +18,24 @@ ticket_CreateBindMiner() {
returnPriv=$3
amount=$4
req='{"method":"ticket.CreateBindMiner","params":[{"bindAddr":"'"$minerAddr"'", "originAddr":"'"$returnAddr"'", "amount":'"$amount"', "checkBalance":true}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not)' "$FUNCNAME" ".result.txHex"
chain33_Http "$req" ${MAIN_HTTP} '(.error|not)' "$FUNCNAME" ".result.txHex"
chain33_SignRawTx "$RETURN_RESP" "${returnPriv}" ${MAIN_HTTP}
}
ticket_SetAutoMining() {
flag=$1
req='{"method":"ticket.SetAutoMining","params":[{"flag":'"$flag"'}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result.isOK == true)' "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} '(.error|not) and (.result.isOK == true)' "$FUNCNAME"
}
ticket_GetTicketCount() {
http_req '{"method":"ticket.GetTicketCount","params":[{}]}' ${MAIN_HTTP} '(.error|not) and (.result > 0)' "$FUNCNAME"
chain33_Http '{"method":"ticket.GetTicketCount","params":[{}]}' ${MAIN_HTTP} '(.error|not) and (.result > 0)' "$FUNCNAME"
}
ticket_CloseTickets() {
addr=$1
req='{"method":"ticket.CloseTickets","params":[{"minerAddress":"'"$addr"'"}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not)' "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} '(.error|not)' "$FUNCNAME"
}
ticket_TicketInfos() {
......@@ -44,7 +44,7 @@ ticket_TicketInfos() {
returnAddr=$3
req='{"method":"Chain33.Query","params":[{"execer":"ticket","funcName":"TicketInfos","payload":{"ticketIds":["'"$tid"'"]}}]}'
resok='(.error|not) and (.result.tickets | length > 0) and (.result.tickets[0].minerAddress == "'"$minerAddr"'") and (.result.tickets[0].returnAddress == "'"$returnAddr"'")'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
}
ticket_TicketList() {
......@@ -53,7 +53,7 @@ ticket_TicketList() {
status=$3
req='{"method":"Chain33.Query","params":[{"execer":"ticket","funcName":"TicketList","payload":{"addr":"'"$minerAddr"'", "status":'"$status"'}}]}'
resok='(.error|not) and (.result.tickets | length > 0) and (.result.tickets[0].minerAddress == "'"$minerAddr"'") and (.result.tickets[0].returnAddress == "'"$returnAddr"'") and (.result.tickets[0].status == '"$status"')'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
ticket0=$(echo "${RETURN_RESP}" | jq -r ".result.tickets[0]")
echo -e "######\\n ticket[0] is $ticket0) \\n######"
......@@ -66,7 +66,7 @@ ticket_MinerAddress() {
minerAddr=$2
req='{"method":"Chain33.Query","params":[{"execer":"ticket","funcName":"MinerAddress","payload":{"data":"'"$returnAddr"'"}}]}'
resok='(.error|not) and (.result.data == "'"$minerAddr"'")'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
}
ticket_MinerSourceList() {
......@@ -74,14 +74,14 @@ ticket_MinerSourceList() {
returnAddr=$2
req='{"method":"Chain33.Query","params":[{"execer":"ticket","funcName":"MinerSourceList","payload":{"data":"'"$minerAddr"'"}}]}'
resok='(.error|not) and (.result.datas | length > 0) and (.result.datas[0] == "'"$returnAddr"'")'
http_req "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} "$resok" "$FUNCNAME"
}
ticket_RandNumHash() {
hash=$1
blockNum=$2
req='{"method":"Chain33.Query","params":[{"execer":"ticket","funcName":"RandNumHash","payload":{"hash":"'"$hash"'", "blockNum":'"$blockNum"'}}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result.hash != null)' "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} '(.error|not) and (.result.hash != null)' "$FUNCNAME"
}
function run_testcases() {
......
......@@ -135,7 +135,7 @@ function token_finish() {
function token_getFinishCreated() {
req='{"method":"Chain33.Query","params":[{"execer":"'"${execName}"'","funcName":"GetTokens","payload":{"queryAll":true,"status":1,"tokens":[],"symbolOnly":false}}]}'
http_req "$req" ${MAIN_HTTP} "(.result.tokens[0].symbol != null)" "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} "(.result.tokens[0].symbol != null)" "$FUNCNAME"
}
function token_assets() {
......
......@@ -40,7 +40,7 @@ function token_finish() {
function token_balance() {
req='{"method":"token.GetTokenBalance","params":[{"addresses": ["'"${tradeAddr}"'"],"tokenSymbol":"'"${tokenSymbol}"'","execer": "'"${tokenExecName}"'"}]}'
http_req "$req" ${MAIN_HTTP} '(.error | not) and (.result[0].addr == "'"${tradeAddr}"'") and (.result[0].balance == 1000000000000)' "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} '(.error | not) and (.result[0].addr == "'"${tradeAddr}"'") and (.result[0].balance == 1000000000000)' "$FUNCNAME"
}
function token_transfer() {
......@@ -74,7 +74,7 @@ function trade_createSellTx() {
function trade_getSellOrder() {
req='{"method":"Chain33.Query","params":[{"execer":"'"${tradeExecName}"'","funcName":"GetOnesSellOrder","payload":{"addr": "'"${tradeAddr}"'","token":["'"${tokenSymbol}"'"]}}]}'
http_req "$req" ${MAIN_HTTP} '(.error | not)' "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} '(.error | not)' "$FUNCNAME"
sellID=$(echo "${RETURN_RESP}" | jq -r ".result.orders[0].sellID" | awk -F '-' '{print $4}')
}
......@@ -89,32 +89,32 @@ function trade_createBuyTx() {
function trade_getBuyOrder() {
req='{"method":"Chain33.Query","params":[{"execer":"'"${tradeExecName}"'","funcName":"GetOnesBuyOrder","payload":{"addr": "'"${tradeBuyerAddr}"'","token":["'"${tokenSymbol}"'"]}}]}'
http_req "$req" ${MAIN_HTTP} '(.error | not)' "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} '(.error | not)' "$FUNCNAME"
}
function trade_statusBuyOrder() {
req='{"method":"Chain33.Query","params":[{"execer":"'"${tradeExecName}"'","funcName":"GetOnesBuyOrderWithStatus","payload":{"addr": "'"${tradeBuyerAddr}"'","status":6}}]}'
http_req "$req" ${MAIN_HTTP} '(.error | not)' "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} '(.error | not)' "$FUNCNAME"
}
function trade_statusOrder() {
req='{"method":"Chain33.Query","params":[{"execer":"'"${tradeExecName}"'","funcName":"GetOnesOrderWithStatus","payload":{"addr": "'"${tradeAddr}"'","status":1}}]}'
http_req "$req" ${MAIN_HTTP} '(.error | not)' "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} '(.error | not)' "$FUNCNAME"
}
function trade_statusSellOrder() {
req='{"method":"Chain33.Query","params":[{"execer":"'"${tradeExecName}"'","funcName":"GetOnesSellOrderWithStatus","payload":{"addr": "'"${tradeAddr}"'", "status":1}}]}'
http_req "$req" ${MAIN_HTTP} '(.error | not)' "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} '(.error | not)' "$FUNCNAME"
}
function trade_statusTokenBuyOrder() {
req='{"method":"Chain33.Query","params":[{"execer":"'"${tradeExecName}"'","funcName":"GetTokenBuyOrderByStatus","payload":{"tokenSymbol": "'"${tokenSymbol}"'", "count" :1 , "direction": 1,"status":6}}]}'
http_req "$req" ${MAIN_HTTP} '(.error | not)' "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} '(.error | not)' "$FUNCNAME"
}
function trade_statusTokenSellOrder() {
req='{"method":"Chain33.Query","params":[{"execer":"'"${tradeExecName}"'","funcName":"GetTokenSellOrderByStatus","payload":{"tokenSymbol": "'"${tokenSymbol}"'", "count" :1 , "direction": 1,"status":1}}]}'
http_req "$req" ${MAIN_HTTP} '(.error | not)' "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} '(.error | not)' "$FUNCNAME"
}
function trade_buyLimit() {
......
......@@ -74,7 +74,7 @@ function init() {
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}}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME" ".result"
chain33_Http "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME" ".result"
chain33_SignRawTx "$RETURN_RESP" "$owner_key" "${MAIN_HTTP}"
query_unfreezeID
}
......@@ -82,25 +82,25 @@ function CreateRawUnfreezeCreate() {
function CreateRawUnfreezeWithdraw() {
sleep 10
req='{"method":"unfreeze.CreateRawUnfreezeWithdraw","params":[{"unfreezeID":"'${uid}'"}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME" ".result"
chain33_Http "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME" ".result"
chain33_SignRawTx "$RETURN_RESP" "${beneficiary_key}" "${MAIN_HTTP}"
}
function CreateRawUnfreezeTerminate() {
req='{"method":"unfreeze.CreateRawUnfreezeTerminate","params":[{"unfreezeID":"'${uid}'"}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME" ".result"
chain33_Http "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME" ".result"
chain33_SignRawTx "$RETURN_RESP" "$owner_key" "${MAIN_HTTP}"
chain33_BlockWait 2 "${MAIN_HTTP}"
}
function GetUnfreeze() {
req='{"method":"unfreeze.GetUnfreeze","params":[{"data":"'${uid}'"}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME"
}
function GetUnfreezeWithdraw() {
req='{"method":"unfreeze.GetUnfreezeWithdraw","params":[{"data":"'${uid}'"}]}'
http_req "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME"
chain33_Http "$req" ${MAIN_HTTP} '(.error|not) and (.result != null)' "$FUNCNAME"
}
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