Commit 9534e195 authored by mdj33's avatar mdj33 Committed by vipwzw

cp system rpc from chain33

parent 2d22e8bc
...@@ -23,6 +23,7 @@ build/guodun ...@@ -23,6 +23,7 @@ build/guodun
build/main.sh build/main.sh
build/main* build/main*
build/para.sh build/para.sh
build/system-test-rpc.sh
build/ci build/ci
build/autotest/* build/autotest/*
!build/autotest/build.sh !build/autotest/build.sh
......
...@@ -25,12 +25,12 @@ default: build depends ...@@ -25,12 +25,12 @@ default: build depends
build: build:
@go build $(BUILD_FLAGS) -v -i -o $(APP) @go build $(BUILD_FLAGS) -v -i -o $(APP)
@go build -v -i -o $(CLI) $(SRC_CLI) @go build -v -i -o $(CLI) $(SRC_CLI)
@cp chain33.toml build/ @cp chain33.toml $(CHAIN33_PATH)/build/system-test-rpc.sh build/
build_ci: depends ## Build the binary file for CI build_ci: depends ## Build the binary file for CI
@go build -v -i -o $(CLI) $(SRC_CLI) @go build -v -i -o $(CLI) $(SRC_CLI)
@go build $(BUILD_FLAGS) -v -o $(APP) @go build $(BUILD_FLAGS) -v -o $(APP)
@cp chain33.toml build/ @cp chain33.toml $(CHAIN33_PATH)/build/system-test-rpc.sh build/
para: para:
@go build -v -o build/$(NAME) -ldflags "-X $(SRC_CLI)/buildflags.ParaName=user.p.$(NAME). -X $(SRC_CLI)/buildflags.RPCAddr=http://localhost:8901" $(SRC_CLI) @go build -v -o build/$(NAME) -ldflags "-X $(SRC_CLI)/buildflags.ParaName=user.p.$(NAME). -X $(SRC_CLI)/buildflags.RPCAddr=http://localhost:8901" $(SRC_CLI)
...@@ -142,6 +142,7 @@ clean: ## Remove previous build ...@@ -142,6 +142,7 @@ clean: ## Remove previous build
@rm -rf build/logs @rm -rf build/logs
@rm -rf build/autotest/autotest @rm -rf build/autotest/autotest
@rm -rf build/ci @rm -rf build/ci
@rm -rf build/system-rpc-test.sh
@rm -rf tool @rm -rf tool
@go clean @go clean
......
...@@ -333,15 +333,15 @@ function base_config() { ...@@ -333,15 +333,15 @@ function base_config() {
# transfer "${CLI4}" # transfer "${CLI4}"
} }
function base_test() { function rpc_test() {
if [ "$DAPP" == "" ]; then if [ "$DAPP" == "" ]; then
system_test_rpc "http://${1}:8801" system_test_rpc "http://${1}:8801"
dapp_test_rpc "http://${1}:8801" dapp_test_rpc "http://${1}:8801"
fi fi
if [ "$DAPP" == "paracross" ]; then # if [ "$DAPP" == "paracross" ]; then
system_test_rpc "http://${1}:8901" # system_test_rpc "http://${1}:8901"
dapp_test_rpc "http://${1}:8901" # dapp_test_rpc "http://${1}:8901"
fi # fi
} }
function dapp_run() { function dapp_run() {
...@@ -365,9 +365,11 @@ function main() { ...@@ -365,9 +365,11 @@ function main() {
### test cases ### ### test cases ###
ip=$(${CLI} net info | jq -r ".externalAddr[0:10]") ip=$(${CLI} net info | jq -r ".externalAddr[0:10]")
base_test "${ip}"
dapp_run test "${ip}" dapp_run test "${ip}"
### rpc test ###
rpc_test "${ip}"
### finish ### ### finish ###
check_docker_container check_docker_container
echo "===============================DAPP=$DAPP main end=========================================================" echo "===============================DAPP=$DAPP main end========================================================="
......
...@@ -2,16 +2,19 @@ ...@@ -2,16 +2,19 @@
# shellcheck disable=SC2128 # shellcheck disable=SC2128
MAIN_HTTP="" MAIN_HTTP=""
PARA_HTTP=""
CASE_ERR="" CASE_ERR=""
UNIT_HTTP=""
#color
RED='\033[1;31m'
GRE='\033[1;32m'
NOC='\033[0m'
# $2=0 means true, other false # $2=0 means true, other false
echo_rst() { 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
...@@ -65,11 +68,12 @@ Chain33_SendToAddress() { ...@@ -65,11 +68,12 @@ Chain33_SendToAddress() {
req='"method":"Chain33.SendToAddress", "params":[{"from":"'"$from"'","to":"'"$to"'", "amount":'"$amount"', "note":"test\n"}]' req='"method":"Chain33.SendToAddress", "params":[{"from":"'"$from"'","to":"'"$to"'", "amount":'"$amount"', "note":"test\n"}]'
# echo "#request: $req" # echo "#request: $req"
resp=$(curl -ksd "{$req}" "${MAIN_HTTP}") resp=$(curl -ksd "{$req}" "${MAIN_HTTP}")
echo "#response: $resp" # echo "#response: $resp"
ok=$(jq '(.error|not) and (.result.hash|length==66)' <<<"$resp") ok=$(jq '(.error|not) and (.result.hash|length==66)' <<<"$resp")
[ "$ok" == true ] [ "$ok" == true ]
echo_rst "$FUNCNAME" "$?" echo_rst "$FUNCNAME" "$?"
# hash=$(jq '(.result.hash)' <<<"$resp") hash=$(jq '(.result.hash)' <<<"$resp")
echo "hash=$hash"
# query_tx "$hash" # query_tx "$hash"
} }
...@@ -97,7 +101,7 @@ sendTx() { ...@@ -97,7 +101,7 @@ sendTx() {
err=$(jq '(.error)' <<<"$resp") err=$(jq '(.error)' <<<"$resp")
txhash=$(jq -r ".result" <<<"$resp") txhash=$(jq -r ".result" <<<"$resp")
if [ "$err" == null ]; then if [ "$err" == null ]; then
echo "tx hash: $txhash" # echo "tx hash: $txhash"
query_tx "$txhash" query_tx "$txhash"
else else
echo "send tx error:$err" echo "send tx error:$err"
......
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