Commit 6337ad8b authored by liuyuhang's avatar liuyuhang

for test bw rpc

parent 95f6063b
...@@ -7,12 +7,18 @@ set -x ...@@ -7,12 +7,18 @@ set -x
MAIN_HTTP="" MAIN_HTTP=""
CASE_ERR="" CASE_ERR=""
#color
RED='\033[1;31m'
GRE='\033[1;32m'
NOC='\033[0m'
# base functions
# $2=0 means true, other false # $2=0 means true, other false
echo_rst() { function echo_rst() {
if [ "$2" -eq 0 ]; then if [ "$2" -eq 0 ]; then
echo "$1 ok" echo -e "${GRE}$1 ok${NOC}"
else else
echo "$1 err" echo -e "${RED}$1 fail${NOC}"
CASE_ERR="err" CASE_ERR="err"
fi fi
...@@ -49,6 +55,19 @@ chain33_NewAccount() { ...@@ -49,6 +55,19 @@ chain33_NewAccount() {
echo "$glAddr" echo "$glAddr"
} }
chain33_GetAccounts() {
resp=$(curl -ksd '{"jsonrpc":"2.0","id":2,"method":"Chain33.GetAccounts","params":[{}]}' -H 'content-type:text/plain;' ${MAIN_HTTP})
echo "$resp"
}
chain33_QueryTransaction() {
#先获取一笔交易
reHash=$1
#查询交易
resp=$(curl -ksd '{"jsonrpc":"2.0","id":2,"method":"Chain33.QueryTransaction","params":[{"hash":"'"$reHash"'","upgrade":false}]}' -H 'content-type:text/plain;' ${MAIN_HTTP})
echo "$resp"
}
function block_wait() { function block_wait() {
if [ "$#" -lt 1 ]; then if [ "$#" -lt 1 ]; then
echo "wrong block_wait params" echo "wrong block_wait params"
...@@ -100,6 +119,8 @@ chain33_SendTransaction() { ...@@ -100,6 +119,8 @@ chain33_SendTransaction() {
#返回交易 #返回交易
gResp=$(echo "${resp}" | jq -r ".result") gResp=$(echo "${resp}" | jq -r ".result")
echo "tx hash is $gResp" echo "tx hash is $gResp"
block_wait 1
chain33_QueryTransaction $gResp
} }
blackwhite_BlackwhiteCreateTx() { blackwhite_BlackwhiteCreateTx() {
...@@ -208,9 +229,12 @@ function run_testcases() { ...@@ -208,9 +229,12 @@ function run_testcases() {
chain33_NewAccount "label388" chain33_NewAccount "label388"
gameAddr3="${glAddr}" gameAddr3="${glAddr}"
#给每个账户分别转帐 #给每个账户分别转帐
origAddr="12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv" origAddr="12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
chain33_GetAccounts
#主链中相应账户需要转帐 #主链中相应账户需要转帐
M_HTTP=${MAIN_HTTP//8901/8801} M_HTTP=${MAIN_HTTP//8901/8801}
chain33_SendToAddress "${origAddr}" "${gameAddr1}" 1000000000 "${M_HTTP}" chain33_SendToAddress "${origAddr}" "${gameAddr1}" 1000000000 "${M_HTTP}"
......
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