Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
plugin
Commits
27c5e6fd
Commit
27c5e6fd
authored
May 08, 2019
by
mdj33
Committed by
vipwzw
May 08, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add dapp rpc test
parent
39743d91
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
107 additions
and
6 deletions
+107
-6
dapp-test-rpc.sh
build/dapp-test-rpc.sh
+20
-0
docker-compose.sh
build/docker-compose.sh
+3
-0
build.sh
plugin/dapp/paracross/cmd/build.sh
+4
-0
test-rpc.sh
plugin/dapp/paracross/cmd/build/test-rpc.sh
+24
-6
test-rpc.sh
plugin/dapp/paracross/cmd/test/test-rpc.sh
+56
-0
No files found.
build/dapp-test-rpc.sh
0 → 100755
View file @
27c5e6fd
#!/usr/bin/env bash
# shellcheck disable=SC2128
RPC_TESTFILE
=
test-rpc.sh
function
dapp_test_rpc
()
{
local
ip
=
$1
echo
"=========== # dapp rpc test ============="
if
[
-d
dapptest
]
;
then
cd
dapptest
||
return
dir
=
$(
find
.
-maxdepth
1
-type
d
!
-name
dapptest
!
-name
.
|
sed
's/^\.\///'
)
for
app
in
$dir
;
do
echo
"=========== #
$app
rpc test ============="
./
"
$app
/
${
RPC_TESTFILE
}
"
"
$ip
"
done
fi
}
#dapp_test_rpc $1
build/docker-compose.sh
View file @
27c5e6fd
...
@@ -60,6 +60,8 @@ fi
...
@@ -60,6 +60,8 @@ fi
if
[
-z
"
$DAPP
"
]
;
then
if
[
-z
"
$DAPP
"
]
;
then
# shellcheck source=/dev/null
# shellcheck source=/dev/null
source
system-test-rpc.sh
source
system-test-rpc.sh
# shellcheck source=/dev/null
source
dapp-test-rpc.sh
fi
fi
echo
"=========== # env setting ============="
echo
"=========== # env setting ============="
...
@@ -331,6 +333,7 @@ function base_config() {
...
@@ -331,6 +333,7 @@ function base_config() {
function
base_test
()
{
function
base_test
()
{
if
[
"
$DAPP
"
==
""
]
;
then
if
[
"
$DAPP
"
==
""
]
;
then
system_test_rpc
"
${
1
}
"
system_test_rpc
"
${
1
}
"
dapp_test_rpc
"
${
1
}
"
fi
fi
}
}
...
...
plugin/dapp/paracross/cmd/build.sh
View file @
27c5e6fd
...
@@ -5,6 +5,7 @@ strcmd=${strpwd##*dapp/}
...
@@ -5,6 +5,7 @@ strcmd=${strpwd##*dapp/}
strapp
=
${
strcmd
%/cmd*
}
strapp
=
${
strcmd
%/cmd*
}
OUT_DIR
=
"
${
1
}
/
$strapp
"
OUT_DIR
=
"
${
1
}
/
$strapp
"
OUT_TESTDIR
=
"
${
1
}
/dapptest/
$strapp
"
PARACLI
=
"
${
OUT_DIR
}
/chain33-para-cli"
PARACLI
=
"
${
OUT_DIR
}
/chain33-para-cli"
PARANAME
=
para
PARANAME
=
para
...
@@ -13,3 +14,6 @@ SRC_CLI=github.com/33cn/plugin/cli
...
@@ -13,3 +14,6 @@ SRC_CLI=github.com/33cn/plugin/cli
go build
-v
-o
"
${
PARACLI
}
"
-ldflags
"-X
${
SRC_CLI
}
/buildflags.ParaName=user.p.
${
PARANAME
}
. -X
${
SRC_CLI
}
/buildflags.RPCAddr=http://localhost:8901"
"
${
SRC_CLI
}
"
go build
-v
-o
"
${
PARACLI
}
"
-ldflags
"-X
${
SRC_CLI
}
/buildflags.ParaName=user.p.
${
PARANAME
}
. -X
${
SRC_CLI
}
/buildflags.RPCAddr=http://localhost:8901"
"
${
SRC_CLI
}
"
# shellcheck disable=SC2086
# shellcheck disable=SC2086
cp
./build/
*
"
${
OUT_DIR
}
"
cp
./build/
*
"
${
OUT_DIR
}
"
mkdir
-p
"
${
OUT_TESTDIR
}
"
cp
./test/
*
"
${
OUT_TESTDIR
}
"
plugin/dapp/paracross/cmd/build/test-rpc.sh
View file @
27c5e6fd
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
MAIN_HTTP
=
""
MAIN_HTTP
=
""
PARA_HTTP
=
""
PARA_HTTP
=
""
CASE_ERR
=
""
CASE_ERR
=
""
UNIT_HTTP
=
""
# $2=0 means true, other false
# $2=0 means true, other false
echo_rst
()
{
echo_rst
()
{
...
@@ -17,26 +18,41 @@ echo_rst() {
...
@@ -17,26 +18,41 @@ echo_rst() {
}
}
paracross_GetBlock2MainInfo
()
{
paracross_GetBlock2MainInfo
()
{
height
=
$(
curl
-s
--data-binary
'{"jsonrpc":"2.0","id":2,"method":"paracross.GetBlock2MainInfo","params":[{"start":1,"end":3}]}'
-H
'content-type:text/plain;'
${
PARA
_HTTP
}
| jq
-r
".result.items[1].height"
)
height
=
$(
curl
-s
--data-binary
'{"jsonrpc":"2.0","id":2,"method":"paracross.GetBlock2MainInfo","params":[{"start":1,"end":3}]}'
-H
'content-type:text/plain;'
${
UNIT
_HTTP
}
| jq
-r
".result.items[1].height"
)
[
"
$height
"
-eq
2
]
[
"
$height
"
-eq
2
]
rst
=
$?
rst
=
$?
echo_rst
"
$FUNCNAME
"
"
$rst
"
echo_rst
"
$FUNCNAME
"
"
$rst
"
}
}
chain33_lock
()
{
chain33_lock
()
{
ok
=
$(
curl
-s
--data-binary
'{"jsonrpc":"2.0","id":2,"method":"Chain33.Lock","params":[]}'
-H
'content-type:text/plain;'
${
PARA
_HTTP
}
| jq
-r
".result.isOK"
)
ok
=
$(
curl
-s
--data-binary
'{"jsonrpc":"2.0","id":2,"method":"Chain33.Lock","params":[]}'
-H
'content-type:text/plain;'
${
UNIT
_HTTP
}
| jq
-r
".result.isOK"
)
[
"
$ok
"
==
true
]
[
"
$ok
"
==
true
]
rst
=
$?
rst
=
$?
echo_rst
"
$FUNCNAME
"
"
$rst
"
echo_rst
"
$FUNCNAME
"
"
$rst
"
}
}
chain33_unlock
()
{
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;'
${
PARA
_HTTP
}
| jq
-r
".result.isOK"
)
ok
=
$(
curl
-s
--data-binary
'{"jsonrpc":"2.0","id":2,"method":"Chain33.UnLock","params":[{"passwd":"1314fuzamei","timeout":0}]}'
-H
'content-type:text/plain;'
${
UNIT
_HTTP
}
| jq
-r
".result.isOK"
)
[
"
$ok
"
==
true
]
[
"
$ok
"
==
true
]
rst
=
$?
rst
=
$?
echo_rst
"
$FUNCNAME
"
"
$rst
"
echo_rst
"
$FUNCNAME
"
"
$rst
"
}
}
function
run_main_testcases
()
{
chain33_lock
chain33_unlock
paracross_GetBlock2MainInfo
}
function
run_para_testcases
()
{
chain33_lock
chain33_unlock
paracross_GetBlock2MainInfo
}
function
dapp_rpc_test
()
{
function
dapp_rpc_test
()
{
local
ip
=
$1
local
ip
=
$1
MAIN_HTTP
=
"http://
$ip
:8801"
MAIN_HTTP
=
"http://
$ip
:8801"
...
@@ -44,9 +60,11 @@ function dapp_rpc_test() {
...
@@ -44,9 +60,11 @@ function dapp_rpc_test() {
echo
"=========== # paracross rpc test ============="
echo
"=========== # paracross rpc test ============="
echo
"main_ip=
$MAIN_HTTP
,para_ip=
$PARA_HTTP
"
echo
"main_ip=
$MAIN_HTTP
,para_ip=
$PARA_HTTP
"
chain33_lock
UNIT_HTTP
=
$MAIN_HTTP
chain33_unlock
run_main_testcases
paracross_GetBlock2MainInfo
UNIT_HTTP
=
$PARA_HTTP
run_para_testcases
if
[
-n
"
$CASE_ERR
"
]
;
then
if
[
-n
"
$CASE_ERR
"
]
;
then
echo
"paracross there some case error"
echo
"paracross there some case error"
...
...
plugin/dapp/paracross/cmd/test/test-rpc.sh
0 → 100755
View file @
27c5e6fd
#!/usr/bin/env bash
# shellcheck disable=SC2128
MAIN_HTTP
=
""
PARA_HTTP
=
""
CASE_ERR
=
""
UNIT_HTTP
=
""
# $2=0 means true, other false
echo_rst
()
{
if
[
"
$2
"
-eq
0
]
;
then
echo
"
$1
ok"
else
echo
"
$1
err"
CASE_ERR
=
"err"
fi
}
chain33_lock
()
{
ok
=
$(
curl
-s
--data-binary
'{"jsonrpc":"2.0","id":2,"method":"Chain33.Lock","params":[]}'
-H
'content-type:text/plain;'
${
UNIT_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;'
${
UNIT_HTTP
}
| jq
-r
".result.isOK"
)
[
"
$ok
"
==
true
]
rst
=
$?
echo_rst
"
$FUNCNAME
"
"
$rst
"
}
function
run_testcases
()
{
chain33_lock
chain33_unlock
}
function
paracross_rpc_test
()
{
local
ip
=
$1
MAIN_HTTP
=
"http://
$ip
:8801"
PARA_HTTP
=
"http://
$ip
:8901"
echo
"=========== # paracross rpc test ============="
echo
"main_ip=
$MAIN_HTTP
,para_ip=
$PARA_HTTP
"
UNIT_HTTP
=
$MAIN_HTTP
run_testcases
if
[
-n
"
$CASE_ERR
"
]
;
then
echo
"paracross there some case error"
exit
1
fi
}
paracross_rpc_test
"
$1
"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment