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
ab25c4be
Unverified
Commit
ab25c4be
authored
Jun 05, 2019
by
vipwzw
Committed by
GitHub
Jun 05, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #488 from zzh33cn/hashlock-rpc-test
add hashlock rpc test cases
parents
586d3ebf
cd40b19c
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
147 additions
and
2 deletions
+147
-2
docker-compose.sh
build/docker-compose.sh
+2
-1
Makefile
plugin/dapp/hashlock/cmd/Makefile
+4
-0
build.sh
plugin/dapp/hashlock/cmd/build.sh
+15
-0
test-rpc.sh
plugin/dapp/hashlock/cmd/build/test-rpc.sh
+124
-0
test-rpc.sh
plugin/dapp/pokerbull/cmd/build/test-rpc.sh
+1
-0
test-rpc.sh
plugin/dapp/token/cmd/build/test-rpc.sh
+1
-1
No files found.
build/docker-compose.sh
View file @
ab25c4be
...
...
@@ -374,6 +374,7 @@ function rpc_test() {
if
[
"
$DAPP
"
==
"paracross"
]
;
then
system_test_rpc
"http://
${
1
}
:8901"
dapp_test_address
"
${
CLI
}
"
dapp_test_rpc
"http://
${
1
}
:8901"
fi
...
...
@@ -403,7 +404,7 @@ function main() {
dapp_run
test
"
${
ip
}
"
### rpc test ###
#
rpc_test "${ip}"
#rpc_test "${ip}"
### finish ###
check_docker_container
...
...
plugin/dapp/hashlock/cmd/Makefile
0 → 100644
View file @
ab25c4be
all
:
chmod
+x ./build.sh
./build.sh
$(OUT)
$(FLAG)
\ No newline at end of file
plugin/dapp/hashlock/cmd/build.sh
0 → 100755
View file @
ab25c4be
#!/usr/bin/env bash
strpwd
=
$(
pwd
)
strcmd
=
${
strpwd
##*dapp/
}
strapp
=
${
strcmd
%/cmd*
}
OUT_DIR
=
"
${
1
}
/
$strapp
"
#FLAG=$2
mkdir
-p
"
${
OUT_DIR
}
"
cp
./build/
*
"
${
OUT_DIR
}
"
OUT_TESTDIR
=
"
${
1
}
/dapptest/
$strapp
"
mkdir
-p
"
${
OUT_TESTDIR
}
"
chmod
+x ./build/test-rpc.sh
cp
./build/test-rpc.sh
"
${
OUT_TESTDIR
}
"
plugin/dapp/hashlock/cmd/build/test-rpc.sh
0 → 100755
View file @
ab25c4be
#!/usr/bin/env bash
# shellcheck disable=SC2128
set
-e
set
-o
pipefail
MAIN_HTTP
=
""
addr_A
=
1PUiGcbsccfxW3zuvHXZBJfznziph5miAo
addr_B
=
1EDnnePAZN48aC2hiTDzhkczfF39g1pZZX
# shellcheck source=/dev/null
source
../dapp-test-common.sh
hashlock_lock
()
{
local
secret
=
$1
echo
"========== # hashlock lock tx begin =========="
tx
=
$(
curl
-ksd
'{"method":"Chain33.CreateTransaction","params":[{"execer":"hashlock","actionName":"HashlockLock", "payload":{"secret":"'
"
${
secret
}
"
'","amount":1000000000, "time":75,"toAddr":"'
"
${
addr_B
}
"
'", "returnAddr":"'
"
${
addr_A
}
"
'","fee":100000000}}]}'
${
MAIN_HTTP
}
| jq
-r
".result"
)
data
=
$(
curl
-ksd
'{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'
"
$tx
"
'"}]}'
${
MAIN_HTTP
}
| jq
-r
".result.txs[0]"
)
ok
=
$(
jq
'(.execer != "")'
<<<
"
$data
"
)
[
"
$ok
"
==
true
]
echo_rst
"
$FUNCNAME
"
"
$?
"
chain33_SignRawTx
"
$tx
"
"56942AD84CCF4788ED6DACBC005A1D0C4F91B63BCF0C99A02BE03C8DEAE71138"
${
MAIN_HTTP
}
#echo "txHash ${txhash}"
echo
"========== # hashlock lock tx end =========="
chain33_BlockWait 1
${
MAIN_HTTP
}
}
hashlock_send
()
{
local
secret
=
$1
echo
"========== # hashlock send tx begin =========="
tx
=
$(
curl
-ksd
'{"method":"Chain33.CreateTransaction","params":[{"execer":"hashlock","actionName":"HashlockSend", "payload":{"secret":"'
"
${
secret
}
"
'","fee":100000000}}]}'
${
MAIN_HTTP
}
| jq
-r
".result"
)
data
=
$(
curl
-ksd
'{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'
"
$tx
"
'"}]}'
${
MAIN_HTTP
}
| jq
-r
".result.txs[0]"
)
ok
=
$(
jq
'(.execer != "")'
<<<
"
$data
"
)
[
"
$ok
"
==
true
]
echo_rst
"
$FUNCNAME
"
"
$?
"
chain33_SignRawTx
"
$tx
"
"2116459C0EC8ED01AA0EEAE35CAC5C96F94473F7816F114873291217303F6989"
${
MAIN_HTTP
}
#echo "txHash ${txhash}"
echo
"========== # hashlock send tx end =========="
chain33_BlockWait 1
${
MAIN_HTTP
}
}
hashlock_unlock
()
{
local
secret
=
$1
echo
"========== # hashlock unlock tx begin =========="
tx
=
$(
curl
-ksd
'{"method":"Chain33.CreateTransaction","params":[{"execer":"hashlock","actionName":"HashlockUnlock", "payload":{"secret":"'
"
${
secret
}
"
'","fee":100000000}}]}'
${
MAIN_HTTP
}
| jq
-r
".result"
)
data
=
$(
curl
-ksd
'{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'
"
$tx
"
'"}]}'
${
MAIN_HTTP
}
| jq
-r
".result.txs[0]"
)
ok
=
$(
jq
'(.execer != "")'
<<<
"
$data
"
)
[
"
$ok
"
==
true
]
echo_rst
"
$FUNCNAME
"
"
$?
"
chain33_SignRawTx
"
$tx
"
"56942AD84CCF4788ED6DACBC005A1D0C4F91B63BCF0C99A02BE03C8DEAE71138"
${
MAIN_HTTP
}
#echo "txHash ${txhash}"
echo
"========== # hashlock unlock tx end =========="
chain33_BlockWait 1
${
MAIN_HTTP
}
}
init
()
{
ispara
=
$(
echo
'"'
"
${
MAIN_HTTP
}
"
'"'
| jq
'.|contains("8901")'
)
echo
"ipara=
$ispara
"
if
[
"
$ispara
"
==
true
]
;
then
hashlock_addr
=
$(
curl
-ksd
'{"method":"Chain33.ConvertExectoAddr","params":[{"execname":"user.p.para.hashlock"}]}'
${
MAIN_HTTP
}
| jq
-r
".result"
)
else
hashlock_addr
=
$(
curl
-ksd
'{"method":"Chain33.ConvertExectoAddr","params":[{"execname":"hashlock"}]}'
${
MAIN_HTTP
}
| jq
-r
".result"
)
fi
local
from
=
"1PUiGcbsccfxW3zuvHXZBJfznziph5miAo"
chain33_SendToAddress
"
$from
"
"
$hashlock_addr
"
10000000000
${
MAIN_HTTP
}
from
=
"1EDnnePAZN48aC2hiTDzhkczfF39g1pZZX"
chain33_SendToAddress
"
$from
"
"
$hashlock_addr
"
10000000000
${
MAIN_HTTP
}
chain33_BlockWait 1
"
${
MAIN_HTTP
}
"
}
function
run_test
()
{
chain33_QueryBalance
"
$addr_A
"
"
${
MAIN_HTTP
}
"
chain33_QueryBalance
"
$addr_B
"
"
${
MAIN_HTTP
}
"
hashlock_lock
"abc"
chain33_QueryBalance
"
$addr_A
"
"
${
MAIN_HTTP
}
"
hashlock_send
"abc"
chain33_QueryBalance
"
$addr_B
"
"
${
MAIN_HTTP
}
"
hashlock_unlock
"abc"
hashlock_lock
"aef"
chain33_QueryBalance
"
$addr_A
"
"
${
MAIN_HTTP
}
"
sleep
75
hashlock_unlock
"aef"
chain33_BlockWait 1
${
MAIN_HTTP
}
chain33_QueryBalance
"
$addr_A
"
"
${
MAIN_HTTP
}
"
}
function
main
()
{
MAIN_HTTP
=
"
$1
"
echo
"=========== # Hashlock rpc test ============="
echo
"ip=
$MAIN_HTTP
"
init
run_test
if
[
-n
"
$CASE_ERR
"
]
;
then
echo
-e
"
${
RED
}
=============Hashlock Rpc Test Fail=============
${
NOC
}
"
exit
1
else
echo
-e
"
${
GRE
}
=============Hashlock Rpc Test Pass==============
${
NOC
}
"
fi
}
main
"
$1
"
plugin/dapp/pokerbull/cmd/build/test-rpc.sh
View file @
ab25c4be
...
...
@@ -78,6 +78,7 @@ pokerbull_QueryResult() {
echo
"========== # pokerbull query result begin =========="
local
req
=
'"method":"Chain33.Query","params":[{"execer":"pokerbull","funcName":"QueryGameByID","payload":{"gameId":"'
$GAME_ID
'"}}]'
data
=
$(
curl
-ksd
"{
$req
}"
${
MAIN_HTTP
}
| jq
-r
".result"
)
ok
=
$(
jq
'(.game.gameId == '
"
$GAME_ID
"
')'
<<<
"
$data
"
)
[
"
$ok
"
==
true
]
...
...
plugin/dapp/token/cmd/build/test-rpc.sh
View file @
ab25c4be
...
...
@@ -314,7 +314,7 @@ function token_sendExec() {
sendSignedTx
echo_rst
"token sendExec sendSignedTx"
"
$?
"
block_wait
1
block_wait
2
queryTransaction
".error | not"
"true"
echo_rst
"token sendExec queryExecRes"
"
$?
"
...
...
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