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

add rpc test

parent 47e16411
......@@ -122,7 +122,7 @@ docker-compose: ## build docker-compose for chain33 run
@cd build && if ! [ -d ci ]; then \
make -C ../ ; \
fi; \
./docker-compose-pre.sh modify && cp chain33* Dockerfile docker-compose* ci/ && cd ci/ && ./docker-compose-pre.sh run $(proj) $(dapp) && cd ../..
./docker-compose-pre.sh modify && cp chain33* Dockerfile docker-compose.yml *.sh ci/ && cd ci/ && ./docker-compose-pre.sh run $(proj) $(dapp) && cd ../..
docker-compose-down: ## build docker-compose for chain33 run
@cd build && if [ -d ci ]; then \
......
......@@ -57,6 +57,10 @@ if [ -n "${DAPP}" ]; then
fi
if [ -z $DAPP ];then
source system-test-rpc.sh
fi
echo "=========== # env setting ============="
echo "DAPP=$DAPP"
echo "DAPP_TEST_FILE=$DAPP_TEST_FILE"
......@@ -323,9 +327,15 @@ function base_config() {
# transfer "${CLI4}"
}
function base_test(){
if [ "$DAPP" == "" ]; then
system_test_rpc "${1}"
fi
}
function dapp_run() {
if [ -e "$DAPP_TEST_FILE" ]; then
${DAPP} "${CLI}" "${1}"
${DAPP} "${CLI}" "${1}" "${2}"
fi
}
......@@ -343,7 +353,9 @@ function main() {
dapp_run config
### test cases ###
dapp_run test
ip=$(${CLI} net info|jq -r ".externalAddr[0:10]")
base_test "${ip}"
dapp_run test "${ip}"
### finish ###
check_docker_container
......
#!/usr/bin/env bash
MAIN_HTTP=""
# $2=0 means true, other false
echo_rst(){
if [ "$2" -eq 0 ];then
echo "$1 ok"
else
echo "$1 err"
fi
}
chain33_lock(){
ok=$(curl -s --data-binary '{"jsonrpc":"2.0","id":2,"method":"Chain33.Lock","params":[]}' -H 'content-type:text/plain;' ${MAIN_HTTP} |jq -r ".result.isOK")
[ "$ok" == true ]
rst=$?
echo_rst $FUNCNAME $rst
}
chain33_unlock(){
ok=$(curl -s --data-binary '{"jsonrpc":"2.0","id":2,"method":"Chain33.UnLock","params":[{"passwd":"1314fuzamei","timeout":0}]}' -H 'content-type:text/plain;' ${MAIN_HTTP} |jq -r ".result.isOK")
[ "$ok" == true ]
rst=$?
echo_rst $FUNCNAME $rst
}
function system_test_rpc(){
local ip=$1
MAIN_HTTP="http://$ip:8801"
echo "=========== # system rpc test ============="
echo "ip=$MAIN_HTTP"
chain33_lock
chain33_unlock
}
#system_rpc_test
#!/usr/bin/env bash
MAIN_HTTP=""
# $2=0 means true, other false
echo_rst(){
if [ "$2" -eq 0 ];then
echo "$1 ok"
else
echo "$1 err"
fi
}
chain33_lock(){
ok=$(curl -s --data-binary '{"jsonrpc":"2.0","id":2,"method":"Chain33.Lock","params":[]}' -H 'content-type:text/plain;' ${MAIN_HTTP} |jq -r ".result.isOK")
[ "$ok" == true ]
rst=$?
echo_rst $FUNCNAME $rst
}
chain33_unlock(){
ok=$(curl -s --data-binary '{"jsonrpc":"2.0","id":2,"method":"Chain33.UnLock","params":[{"passwd":"1314fuzamei","timeout":0}]}' -H 'content-type:text/plain;' ${MAIN_HTTP} |jq -r ".result.isOK")
[ "$ok" == true ]
rst=$?
echo_rst $FUNCNAME $rst
}
function dapp_rpc_test(){
local ip=$1
MAIN_HTTP="http://$ip:8901"
echo "=========== # paracross rpc test ============="
echo "ip=$MAIN_HTTP"
chain33_lock
chain33_unlock
}
#system_rpc_test
......@@ -14,6 +14,8 @@ if [ "$(uname)" == "Darwin" ]; then
xsedfix=".bak"
fi
source test-rpc.sh
function para_init() {
para_set_toml chain33.para33.toml
para_set_toml chain33.para32.toml
......@@ -584,6 +586,7 @@ function paracross() {
para_set_wallet
elif [ "${2}" == "test" ]; then
para_test "${1}"
dapp_rpc_test "${3}"
fi
if [ "${2}" == "forkInit" ]; then
......
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