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
c8445cf0
Commit
c8445cf0
authored
May 16, 2019
by
mdj33
Committed by
vipwzw
May 17, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix rpc test
parent
8991b218
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
11 deletions
+9
-11
test-rpc.sh
plugin/dapp/blackwhite/cmd/build/test-rpc.sh
+9
-11
No files found.
plugin/dapp/blackwhite/cmd/build/test-rpc.sh
View file @
c8445cf0
...
@@ -4,9 +4,7 @@ set -e
...
@@ -4,9 +4,7 @@ set -e
set
-o
pipefail
set
-o
pipefail
MAIN_HTTP
=
""
MAIN_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
()
{
...
@@ -72,14 +70,14 @@ chain33_SendTransaction() {
...
@@ -72,14 +70,14 @@ chain33_SendTransaction() {
rawTx
=
$1
rawTx
=
$1
addr
=
$2
addr
=
$2
#签名交易
#签名交易
resp
=
$(
curl
-ksd
'{"jsonrpc":"2.0","id":2,"method":"Chain33.SignRawTx","params":[{"addr":"'
"
$addr
"
'","txHex":"'
"
$rawTx
"
'","expire":"120s","fee":10000000,"index":0}]}'
-H
'content-type:text/plain;'
${
UNIT
_HTTP
})
resp
=
$(
curl
-ksd
'{"jsonrpc":"2.0","id":2,"method":"Chain33.SignRawTx","params":[{"addr":"'
"
$addr
"
'","txHex":"'
"
$rawTx
"
'","expire":"120s","fee":10000000,"index":0}]}'
-H
'content-type:text/plain;'
${
MAIN
_HTTP
})
ok
=
$(
echo
"
${
resp
}
"
| jq
-r
".error"
)
ok
=
$(
echo
"
${
resp
}
"
| jq
-r
".error"
)
[
"
$ok
"
==
null
]
[
"
$ok
"
==
null
]
rst
=
$?
rst
=
$?
echo_rst
"
$FUNCNAME
"
"
$rst
"
echo_rst
"
$FUNCNAME
"
"
$rst
"
signTx
=
$(
echo
"
${
resp
}
"
| jq
-r
".result"
)
signTx
=
$(
echo
"
${
resp
}
"
| jq
-r
".result"
)
resp
=
$(
curl
-ksd
'{"jsonrpc":"2.0","id":2,"method":"Chain33.SendTransaction","params":[{"data":"'
"
$signTx
"
'"}]}'
-H
'content-type:text/plain;'
${
UNIT
_HTTP
})
resp
=
$(
curl
-ksd
'{"jsonrpc":"2.0","id":2,"method":"Chain33.SendTransaction","params":[{"data":"'
"
$signTx
"
'"}]}'
-H
'content-type:text/plain;'
${
MAIN
_HTTP
})
ok
=
$(
echo
"
${
resp
}
"
| jq
-r
".error"
)
ok
=
$(
echo
"
${
resp
}
"
| jq
-r
".error"
)
[
"
$ok
"
==
null
]
[
"
$ok
"
==
null
]
rst
=
$?
rst
=
$?
...
@@ -92,7 +90,7 @@ chain33_SendTransaction() {
...
@@ -92,7 +90,7 @@ chain33_SendTransaction() {
blackwhite_BlackwhiteCreateTx
()
{
blackwhite_BlackwhiteCreateTx
()
{
#创建交易
#创建交易
addr
=
$1
addr
=
$1
resp
=
$(
curl
-ksd
'{"jsonrpc":"2.0","id":2,"method":"blackwhite.BlackwhiteCreateTx","params":[{"PlayAmount":100000000,"PlayerCount":3,"GameName":"hello","Timeout":600,"Fee":1000000}]}'
-H
'content-type:text/plain;'
${
UNIT
_HTTP
})
resp
=
$(
curl
-ksd
'{"jsonrpc":"2.0","id":2,"method":"blackwhite.BlackwhiteCreateTx","params":[{"PlayAmount":100000000,"PlayerCount":3,"GameName":"hello","Timeout":600,"Fee":1000000}]}'
-H
'content-type:text/plain;'
${
MAIN
_HTTP
})
ok
=
$(
echo
"
${
resp
}
"
| jq
-r
".error"
)
ok
=
$(
echo
"
${
resp
}
"
| jq
-r
".error"
)
[
"
$ok
"
==
null
]
[
"
$ok
"
==
null
]
rst
=
$?
rst
=
$?
...
@@ -109,7 +107,7 @@ blackwhite_BlackwhitePlayTx() {
...
@@ -109,7 +107,7 @@ blackwhite_BlackwhitePlayTx() {
round1
=
$2
round1
=
$2
round2
=
$3
round2
=
$3
round3
=
$4
round3
=
$4
resp
=
$(
curl
-ksd
'{"jsonrpc":"2.0","id":2,"method":"blackwhite.BlackwhitePlayTx","params":[{"gameID":"'
"
$gID
"
'","amount":100000000,"Fee":1000000,"hashValues":["'
"
$round1
"
'","'
"
$round2
"
'","'
"
$round3
"
'"]}]}'
-H
'content-type:text/plain;'
${
UNIT
_HTTP
})
resp
=
$(
curl
-ksd
'{"jsonrpc":"2.0","id":2,"method":"blackwhite.BlackwhitePlayTx","params":[{"gameID":"'
"
$gID
"
'","amount":100000000,"Fee":1000000,"hashValues":["'
"
$round1
"
'","'
"
$round2
"
'","'
"
$round3
"
'"]}]}'
-H
'content-type:text/plain;'
${
MAIN
_HTTP
})
ok
=
$(
echo
"
${
resp
}
"
| jq
-r
".error"
)
ok
=
$(
echo
"
${
resp
}
"
| jq
-r
".error"
)
[
"
$ok
"
==
null
]
[
"
$ok
"
==
null
]
rst
=
$?
rst
=
$?
...
@@ -122,7 +120,7 @@ blackwhite_BlackwhitePlayTx() {
...
@@ -122,7 +120,7 @@ blackwhite_BlackwhitePlayTx() {
blackwhite_BlackwhiteShowTx
()
{
blackwhite_BlackwhiteShowTx
()
{
addr
=
$1
addr
=
$1
sec
=
$2
sec
=
$2
resp
=
$(
curl
-ksd
'{"jsonrpc":"2.0","id":2,"method":"blackwhite.BlackwhiteShowTx","params":[{"gameID":"'
"
$gID
"
'","secret":"'
"
$sec
"
'","Fee":1000000}]}'
-H
'content-type:text/plain;'
${
UNIT
_HTTP
})
resp
=
$(
curl
-ksd
'{"jsonrpc":"2.0","id":2,"method":"blackwhite.BlackwhiteShowTx","params":[{"gameID":"'
"
$gID
"
'","secret":"'
"
$sec
"
'","Fee":1000000}]}'
-H
'content-type:text/plain;'
${
MAIN
_HTTP
})
ok
=
$(
echo
"
${
resp
}
"
| jq
-r
".error"
)
ok
=
$(
echo
"
${
resp
}
"
| jq
-r
".error"
)
[
"
$ok
"
==
null
]
[
"
$ok
"
==
null
]
rst
=
$?
rst
=
$?
...
@@ -134,7 +132,7 @@ blackwhite_BlackwhiteShowTx() {
...
@@ -134,7 +132,7 @@ blackwhite_BlackwhiteShowTx() {
blackwhite_BlackwhiteTimeoutDoneTx
()
{
blackwhite_BlackwhiteTimeoutDoneTx
()
{
gameID
=
$1
gameID
=
$1
resp
=
$(
curl
-ksd
'{"jsonrpc":"2.0","id":2,"method":"blackwhite.BlackwhiteTimeoutDoneTx","params":[{"gameID":"'
"
$gameID
"
'","Fee":1000000}]}'
-H
'content-type:text/plain;'
${
UNIT
_HTTP
})
resp
=
$(
curl
-ksd
'{"jsonrpc":"2.0","id":2,"method":"blackwhite.BlackwhiteTimeoutDoneTx","params":[{"gameID":"'
"
$gameID
"
'","Fee":1000000}]}'
-H
'content-type:text/plain;'
${
MAIN
_HTTP
})
ok
=
$(
echo
"
${
resp
}
"
| jq
-r
".error"
)
ok
=
$(
echo
"
${
resp
}
"
| jq
-r
".error"
)
[
"
$ok
"
==
null
]
[
"
$ok
"
==
null
]
rst
=
$?
rst
=
$?
...
@@ -145,7 +143,7 @@ blackwhite_GetBlackwhiteRoundInfo() {
...
@@ -145,7 +143,7 @@ blackwhite_GetBlackwhiteRoundInfo() {
gameID
=
$1
gameID
=
$1
execer
=
"blackwhite"
execer
=
"blackwhite"
funcName
=
"GetBlackwhiteRoundInfo"
funcName
=
"GetBlackwhiteRoundInfo"
resp
=
$(
curl
-ksd
'{"jsonrpc":"2.0","id":2,"method":"Chain33.Query","params":[{"execer":"'
"
$execer
"
'","funcName":"'
"
$funcName
"
'","payload":{"gameID":"'
"
$gameID
"
'"}}]}'
-H
'content-type:text/plain;'
${
UNIT
_HTTP
})
resp
=
$(
curl
-ksd
'{"jsonrpc":"2.0","id":2,"method":"Chain33.Query","params":[{"execer":"'
"
$execer
"
'","funcName":"'
"
$funcName
"
'","payload":{"gameID":"'
"
$gameID
"
'"}}]}'
-H
'content-type:text/plain;'
${
MAIN
_HTTP
})
ok
=
$(
jq
'(.error|not) and (.result.round | [has("gameID", "status", "playAmount", "playerCount", "curPlayerCount", "loop", "curShowCount", "timeout"),true] | unique | length == 1)'
<<<
"
$resp
"
)
ok
=
$(
jq
'(.error|not) and (.result.round | [has("gameID", "status", "playAmount", "playerCount", "curPlayerCount", "loop", "curShowCount", "timeout"),true] | unique | length == 1)'
<<<
"
$resp
"
)
[
"
$ok
"
==
true
]
[
"
$ok
"
==
true
]
rst
=
$?
rst
=
$?
...
@@ -157,7 +155,7 @@ blackwhite_GetBlackwhiteByStatusAndAddr() {
...
@@ -157,7 +155,7 @@ blackwhite_GetBlackwhiteByStatusAndAddr() {
addr
=
$2
addr
=
$2
execer
=
"blackwhite"
execer
=
"blackwhite"
funcName
=
"GetBlackwhiteByStatusAndAddr"
funcName
=
"GetBlackwhiteByStatusAndAddr"
resp
=
$(
curl
-ksd
'{"jsonrpc":"2.0","id":2,"method":"Chain33.Query","params":[{"execer":"'
"
$execer
"
'","funcName":"'
"
$funcName
"
'","payload":{"status":5,"address":"'
"
$addr
"
'","count":1,"direction":0,"index":-1}}]}'
-H
'content-type:text/plain;'
${
UNIT
_HTTP
})
resp
=
$(
curl
-ksd
'{"jsonrpc":"2.0","id":2,"method":"Chain33.Query","params":[{"execer":"'
"
$execer
"
'","funcName":"'
"
$funcName
"
'","payload":{"status":5,"address":"'
"
$addr
"
'","count":1,"direction":0,"index":-1}}]}'
-H
'content-type:text/plain;'
${
MAIN
_HTTP
})
ok
=
$(
jq
'(.error|not) and (.result.round[0].createAddr == "'
"
$addr
"
'") and (.result.round[0].status == 5) and (.result.round[0] | [has("gameID", "status", "playAmount", "playerCount", "curPlayerCount", "loop", "curShowCount", "timeout", "winner"),true] | unique | length == 1)'
<<<
"
$resp
"
)
ok
=
$(
jq
'(.error|not) and (.result.round[0].createAddr == "'
"
$addr
"
'") and (.result.round[0].status == 5) and (.result.round[0] | [has("gameID", "status", "playAmount", "playerCount", "curPlayerCount", "loop", "curShowCount", "timeout", "winner"),true] | unique | length == 1)'
<<<
"
$resp
"
)
[
"
$ok
"
==
true
]
[
"
$ok
"
==
true
]
rst
=
$?
rst
=
$?
...
@@ -168,7 +166,7 @@ blackwhite_GetBlackwhiteloopResult() {
...
@@ -168,7 +166,7 @@ blackwhite_GetBlackwhiteloopResult() {
gameID
=
$1
gameID
=
$1
execer
=
"blackwhite"
execer
=
"blackwhite"
funcName
=
"GetBlackwhiteloopResult"
funcName
=
"GetBlackwhiteloopResult"
resp
=
$(
curl
-ksd
'{"jsonrpc":"2.0","id":2,"method":"Chain33.Query","params":[{"execer":"'
"
$execer
"
'","funcName":"'
"
$funcName
"
'","payload":{"gameID":"'
"
$gameID
"
'","loopSeq":0}}]}'
-H
'content-type:text/plain;'
${
UNIT
_HTTP
})
resp
=
$(
curl
-ksd
'{"jsonrpc":"2.0","id":2,"method":"Chain33.Query","params":[{"execer":"'
"
$execer
"
'","funcName":"'
"
$funcName
"
'","payload":{"gameID":"'
"
$gameID
"
'","loopSeq":0}}]}'
-H
'content-type:text/plain;'
${
MAIN
_HTTP
})
ok
=
$(
jq
'(.error|not) and (.result.gameID == "'
"
$gameID
"
'") and (.result.results|length >= 1)'
<<<
"
$resp
"
)
ok
=
$(
jq
'(.error|not) and (.result.gameID == "'
"
$gameID
"
'") and (.result.results|length >= 1)'
<<<
"
$resp
"
)
[
"
$ok
"
==
true
]
[
"
$ok
"
==
true
]
rst
=
$?
rst
=
$?
...
...
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