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
02d27762
Commit
02d27762
authored
May 09, 2019
by
liuyuhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add rpc test
parent
39743d91
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
109 additions
and
7 deletions
+109
-7
system-test-rpc.sh
build/system-test-rpc.sh
+81
-1
build.sh
plugin/dapp/paracross/cmd/build.sh
+4
-0
test-rpc.sh
plugin/dapp/paracross/cmd/build/test-rpc.sh
+24
-6
No files found.
build/system-test-rpc.sh
View file @
02d27762
...
...
@@ -29,6 +29,77 @@ chain33_unlock() {
echo_rst
"
$FUNCNAME
"
"
$rst
"
}
chain33_GetHexTxByHash
()
{
result
=
$(
curl
-s
--data-binary
'{"jsonrpc":"2.0","id":2,"method":"Chain33.GetHexTxByHash","params":[{"hash":"","upgrade":false}]}'
-H
'content-type:text/plain;'
${
MAIN_HTTP
}
| jq
-r
".result"
)
[
"
$result
"
==
null
]
rst
=
$?
echo_rst
"
$FUNCNAME
"
"
$rst
"
}
chain33_QueryTransaction
()
{
result
=
$(
curl
-s
--data-binary
'{"jsonrpc":"2.0","id":2,"method":"Chain33.QueryTransaction","params":[{"hash":"","upgrade":false}]}'
-H
'content-type:text/plain;'
${
MAIN_HTTP
}
| jq
-r
".result"
)
[
"
$result
"
==
null
]
rst
=
$?
echo_rst
"
$FUNCNAME
"
"
$rst
"
}
chain33_GetBlocks
()
{
result
=
$(
curl
-s
--data-binary
'{"jsonrpc":"2.0","id":2,"method":"Chain33.GetBlocks","params":[{"start":0,"end":1}]}'
-H
'content-type:text/plain;'
${
MAIN_HTTP
}
| jq
-r
".error"
)
[
"
$result
"
==
null
]
rst
=
$?
echo_rst
"
$FUNCNAME
"
"
$rst
"
}
chain33_GetLastHeader
()
{
result
=
$(
curl
-s
--data-binary
'{"jsonrpc":"2.0","id":2,"method":"Chain33.GetLastHeader","params":[{}]}'
-H
'content-type:text/plain;'
${
MAIN_HTTP
}
| jq
-r
".error"
)
[
"
$result
"
==
null
]
rst
=
$?
echo_rst
"
$FUNCNAME
"
"
$rst
"
}
chain33_GetTxByAddr
()
{
result
=
$(
curl
-s
--data-binary
'{"jsonrpc":"2.0","id":2,"method":"Chain33.GetTxByAddr","params":[{"addr":"14KEKbYtKKQm4wMthSK9J4La4nAiidGozt","flag":0,"count":1,"direction":0,"height":-1,"index":0}]}'
-H
'content-type:text/plain;'
${
MAIN_HTTP
}
| jq
-r
".error"
)
[
"
$result
"
==
null
]
rst
=
$?
echo_rst
"
$FUNCNAME
"
"
$rst
"
}
chain33_GetTxByHashes
()
{
result
=
$(
curl
-s
--data-binary
'{"jsonrpc":"2.0","id":2,"method":"Chain33.GetTxByHashes","params":[{"hashes":["0x8040109d3859827d0f0c80ce91cc4ec80c496c45250f5e5755064b6da60842ab","0x501b910fd85d13d1ab7d776bce41a462f27c4bfeceb561dc47f0a11b10f452e4"]}]}'
-H
'content-type:text/plain;'
${
MAIN_HTTP
}
| jq
-r
".error"
)
[
"
$result
"
==
null
]
rst
=
$?
echo_rst
"
$FUNCNAME
"
"
$rst
"
}
chain33_GetMempool
()
{
result
=
$(
curl
-s
--data-binary
'{"jsonrpc":"2.0","id":2,"method":"Chain33.GetMempool","params":[{}]}'
-H
'content-type:text/plain;'
${
MAIN_HTTP
}
| jq
-r
".error"
)
[
"
$result
"
==
null
]
rst
=
$?
echo_rst
"
$FUNCNAME
"
"
$rst
"
}
chain33_GetAccountsV2
()
{
result
=
$(
curl
-s
--data-binary
'{"jsonrpc":"2.0","id":2,"method":"Chain33.GetAccountsV2","params":[{}]}'
-H
'content-type:text/plain;'
${
MAIN_HTTP
}
| jq
-r
".error"
)
[
"
$result
"
==
null
]
rst
=
$?
echo_rst
"
$FUNCNAME
"
"
$rst
"
}
chain33_GetAccounts
()
{
result
=
$(
curl
-s
--data-binary
'{"jsonrpc":"2.0","id":2,"method":"Chain33.GetAccounts","params":[{}]}'
-H
'content-type:text/plain;'
${
MAIN_HTTP
}
| jq
-r
".error"
)
[
"
$result
"
==
null
]
rst
=
$?
echo_rst
"
$FUNCNAME
"
"
$rst
"
}
chain33_NewAccount
()
{
result
=
$(
curl
-s
--data-binary
'{"jsonrpc":"2.0","id":2,"method":"Chain33.NewAccount","params":[{"label":"test111"}]}'
-H
'content-type:text/plain;'
${
MAIN_HTTP
}
| jq
-r
".result.label"
)
[
"
$result
"
==
"test111"
]
rst
=
$?
echo_rst
"
$FUNCNAME
"
"
$rst
"
}
function
system_test_rpc
()
{
local
ip
=
$1
MAIN_HTTP
=
"http://
$ip
:8801"
...
...
@@ -37,11 +108,20 @@ function system_test_rpc() {
chain33_lock
chain33_unlock
chain33_GetHexTxByHash
chain33_QueryTransaction
chain33_GetBlocks
chain33_GetLastHeader
chain33_GetTxByAddr
chain33_GetTxByHashes
chain33_GetMempool
chain33_GetAccountsV2
chain33_GetAccounts
chain33_NewAccount
if
[
-n
"
$CASE_ERR
"
]
;
then
echo
"there some case error"
exit
1
fi
}
#system_rpc_test
plugin/dapp/paracross/cmd/build.sh
View file @
02d27762
...
...
@@ -5,6 +5,7 @@ strcmd=${strpwd##*dapp/}
strapp
=
${
strcmd
%/cmd*
}
OUT_DIR
=
"
${
1
}
/
$strapp
"
OUT_TESTDIR
=
"
${
1
}
/dapptest/
$strapp
"
PARACLI
=
"
${
OUT_DIR
}
/chain33-para-cli"
PARANAME
=
para
...
...
@@ -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
}
"
# shellcheck disable=SC2086
cp
./build/
*
"
${
OUT_DIR
}
"
mkdir
-p
"
${
OUT_TESTDIR
}
"
cp
./test/
*
"
${
OUT_TESTDIR
}
"
plugin/dapp/paracross/cmd/build/test-rpc.sh
View file @
02d27762
...
...
@@ -4,6 +4,7 @@
MAIN_HTTP
=
""
PARA_HTTP
=
""
CASE_ERR
=
""
UNIT_HTTP
=
""
# $2=0 means true, other false
echo_rst
()
{
...
...
@@ -17,26 +18,41 @@ echo_rst() {
}
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
]
rst
=
$?
echo_rst
"
$FUNCNAME
"
"
$rst
"
}
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
]
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;'
${
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
]
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
()
{
local
ip
=
$1
MAIN_HTTP
=
"http://
$ip
:8801"
...
...
@@ -44,9 +60,11 @@ function dapp_rpc_test() {
echo
"=========== # paracross rpc test ============="
echo
"main_ip=
$MAIN_HTTP
,para_ip=
$PARA_HTTP
"
chain33_lock
chain33_unlock
paracross_GetBlock2MainInfo
UNIT_HTTP
=
$MAIN_HTTP
run_main_testcases
UNIT_HTTP
=
$PARA_HTTP
run_para_testcases
if
[
-n
"
$CASE_ERR
"
]
;
then
echo
"paracross there some case error"
...
...
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