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
bf75f36f
Commit
bf75f36f
authored
May 22, 2019
by
pengjun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add pokerbull rpc-test.sh
parent
3e747050
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
181 additions
and
3 deletions
+181
-3
Makefile
plugin/dapp/pokerbull/cmd/Makefile
+4
-0
build.sh
plugin/dapp/pokerbull/cmd/build.sh
+15
-0
test-rpc.sh
plugin/dapp/pokerbull/cmd/build/test-rpc.sh
+159
-0
game.go
plugin/dapp/pokerbull/cmd/game.go
+1
-1
plugin.go
plugin/dapp/pokerbull/plugin.go
+2
-2
No files found.
plugin/dapp/pokerbull/cmd/Makefile
0 → 100644
View file @
bf75f36f
all
:
chmod
+x ./build.sh
./build.sh
$(OUT)
$(FLAG)
\ No newline at end of file
plugin/dapp/pokerbull/cmd/build.sh
0 → 100644
View file @
bf75f36f
#!/bin/sh
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
}
"
cp
./build/test-rpc.sh
"
${
OUT_TESTDIR
}
"
plugin/dapp/pokerbull/cmd/build/test-rpc.sh
0 → 100644
View file @
bf75f36f
#!/usr/bin/env bash
# shellcheck disable=SC2128
set
-e
set
-o
pipefail
MAIN_HTTP
=
""
CASE_ERR
=
""
START_TX
=
""
CONTINUE_TX
=
""
QUIT_TX
=
""
PLAY_TX
=
""
#color
RED
=
'\033[1;31m'
GRE
=
'\033[1;32m'
NOC
=
'\033[0m'
echo_rst
()
{
if
[
"
$2
"
==
true
]
;
then
echo
-e
"
${
GRE
}
$1
ok
${
NOC
}
"
else
echo
-e
"
${
RED
}
$1
fail
${
NOC
}
"
CASE_ERR
=
"FAIL"
fi
}
pokerbull_PlayRawTx
()
{
tx
=
$(
curl
-ksd
'{"method":"Chain33.CreateTransaction","params":[{"execer":"pokerbull","actionName":"Play","payload":{"gameID":"'
$START_TX
'", "value":"1000000000", "round":1}}]}'
${
MAIN_HTTP
}
| jq
-r
".result"
)
PLAY_TX
=
$tx
data
=
$(
curl
-ksd
'{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'
"
$tx
"
'"}]}'
${
MAIN_HTTP
}
| jq
-r
".result.txs[0]"
)
ok
=
$(
jq
'(.execer == "Play")'
<<<
"
$data
"
)
[
"
$ok
"
==
true
]
rst
=
$?
echo_rst
"
$FUNCNAME
"
"
$rst
"
}
pokerbull_QuitRawTx
()
{
tx
=
$(
curl
-ksd
'{"method":"Chain33.CreateTransaction","params":[{"execer":"pokerbull","actionName":"Quit","payload":{"gameID":"'
$START_TX
'"}}]}'
${
MAIN_HTTP
}
| jq
-r
".result"
)
QUIT_TX
=
$tx
data
=
$(
curl
-ksd
'{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'
"
$tx
"
'"}]}'
${
MAIN_HTTP
}
| jq
-r
".result.txs[0]"
)
ok
=
$(
jq
'(.execer == "Quit")'
<<<
"
$data
"
)
[
"
$ok
"
==
true
]
rst
=
$?
echo_rst
"
$FUNCNAME
"
"
$rst
"
}
pokerbull_ContinueRawTx
()
{
tx
=
$(
curl
-ksd
'{"method":"Chain33.CreateTransaction","params":[{"execer":"pokerbull","actionName":"Continue","payload":{"gameID":"'
$START_TX
'"}}]}'
${
MAIN_HTTP
}
| jq
-r
".result"
)
CONTINUE_TX
=
$tx
data
=
$(
curl
-ksd
'{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'
"
$tx
"
'"}]}'
${
MAIN_HTTP
}
| jq
-r
".result.txs[0]"
)
ok
=
$(
jq
'(.execer == "Continue")'
<<<
"
$data
"
)
[
"
$ok
"
==
true
]
rst
=
$?
echo_rst
"
$FUNCNAME
"
"
$rst
"
}
pokerbull_StartRawTx
()
{
tx
=
$(
curl
-ksd
'{"method":"Chain33.CreateTransaction","params":[{"execer":"pokerbull","actionName":"Start","payload":{"value":"1000000000", "playerNum":"2"}}]}'
${
MAIN_HTTP
}
| jq
-r
".result"
)
START_TX
=
$tx
data
=
$(
curl
-ksd
'{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'
"
$tx
"
'"}]}'
${
MAIN_HTTP
}
| jq
-r
".result.txs[0]"
)
ok
=
$(
jq
'(.execer == "Start")'
<<<
"
$data
"
)
[
"
$ok
"
==
true
]
rst
=
$?
echo_rst
"
$FUNCNAME
"
"
$rst
"
}
Chain33_SendRawTx
()
{
local
req
=
'"method":"Chain33.SignRawTx", "params":[{"data":"'
"
$1
"
'", "addr":"'
"
$2
"
'", "expire":"3600"}]'
# echo "#request: $req"
resp
=
$(
curl
-ksd
"{
$req
}"
"
${
MAIN_HTTP
}
"
)
# echo "#response: $resp"
ok
=
$(
jq
'(.error|not)'
<<<
"
$resp
"
)
[
"
$ok
"
==
true
]
echo_rst
"
$FUNCNAME
"
"
$?
"
local
reqSend
=
'"method":"Chain33.SendTransaction", "params":[{"data":"'
"
$resp
"
'"}]'
# echo "#request: $req"
respSend
=
$(
curl
-ksd
"{
$req
}"
"
${
MAIN_HTTP
}
"
)
# echo "#response: $resp"
okSend
=
$(
jq
'(.error|not)'
<<<
"
$respSend
"
)
[
"
$okSend
"
==
true
]
echo_rst
"
$FUNCNAME
"
"
$?
"
}
Chain33_SendToAddress
()
{
local
from
=
"
$1
"
local
to
=
"
$2
"
local
amount
=
$3
local
req
=
'"method":"Chain33.SendToAddress", "params":[{"from":"'
"
$from
"
'","to":"'
"
$to
"
'", "amount":'
"
$amount
"
', "note":"test\n"}]'
# echo "#request: $req"
resp
=
$(
curl
-ksd
"{
$req
}"
"
${
MAIN_HTTP
}
"
)
# echo "#response: $resp"
ok
=
$(
jq
'(.error|not) and (.result.hash|length==66)'
<<<
"
$resp
"
)
[
"
$ok
"
==
true
]
echo_rst
"
$FUNCNAME
"
"
$?
"
hash
=
$(
jq
'(.result.hash)'
<<<
"
$resp
"
)
echo
"hash=
$hash
"
# query_tx "$hash"
}
init
()
{
ispara
=
$(
echo
'"'
"
${
MAIN_HTTP
}
"
'"'
| jq
'.|contains("8901")'
)
echo
"ipara=
$ispara
"
local
relay_addr
=
""
if
[
"
$ispara
"
==
true
]
;
then
pokerbull_addr
=
$(
curl
-ksd
'{"method":"Chain33.ConvertExectoAddr","params":[{"execname":"user.p.para.pokerbull"}]}'
${
MAIN_HTTP
}
| jq
-r
".result"
)
else
chain33_ImportPrivkey
"
${
MAIN_HTTP
}
"
"0x9c451df9e5cb05b88b28729aeaaeb3169a2414097401fcb4c79c1971df734588"
"1E5saiXVb9mW8wcWUUZjsHJPZs5GmdzuSY"
pokerbull_addr
=
$(
curl
-ksd
'{"method":"Chain33.ConvertExectoAddr","params":[{"execname":"pokerbull"}]}'
${
MAIN_HTTP
}
| jq
-r
".result"
)
fi
echo
"pokerbulladdr=
$pokerbull_addr
"
from
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
Chain33_SendToAddress
"
$from
"
"
$pokerbull_addr
"
10000000000
from
=
"1E5saiXVb9mW8wcWUUZjsHJPZs5GmdzuSY"
Chain33_SendToAddress
"
$from
"
"
$pokerbull_addr
"
10000000000
block_wait 1
}
function
run_test
()
{
pokerbull_StartRawTx
Chain33_SendRawTx
"
$START_TX
"
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
##pokerbull_ContinueRawTx
##pokerbull_QuitRawTx
##pokerbull_PlayRawTx
##pokerbull_QueryResult
}
function
main
()
{
MAIN_HTTP
=
"
$1
"
echo
"=========== # pokerbull rpc test ============="
echo
"ip=
$MAIN_HTTP
"
init
run_test
if
[
-n
"
$CASE_ERR
"
]
;
then
echo
-e
"
${
RED
}
=============Pokerbull Rpc Test Fail=============
${
NOC
}
"
exit
1
else
echo
-e
"
${
GRE
}
=============Pokerbull Rpc Test Pass==============
${
NOC
}
"
fi
}
main
"
$1
"
plugin/dapp/pokerbull/c
ommands
/game.go
→
plugin/dapp/pokerbull/c
md
/game.go
View file @
bf75f36f
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// license that can be found in the LICENSE file.
package
c
ommands
package
c
md
import
(
import
(
"fmt"
"fmt"
...
...
plugin/dapp/pokerbull/plugin.go
View file @
bf75f36f
...
@@ -6,7 +6,7 @@ package pokerbull
...
@@ -6,7 +6,7 @@ package pokerbull
import
(
import
(
"github.com/33cn/chain33/pluginmgr"
"github.com/33cn/chain33/pluginmgr"
"github.com/33cn/plugin/plugin/dapp/pokerbull/c
ommands
"
"github.com/33cn/plugin/plugin/dapp/pokerbull/c
md
"
"github.com/33cn/plugin/plugin/dapp/pokerbull/executor"
"github.com/33cn/plugin/plugin/dapp/pokerbull/executor"
"github.com/33cn/plugin/plugin/dapp/pokerbull/types"
"github.com/33cn/plugin/plugin/dapp/pokerbull/types"
)
)
...
@@ -16,6 +16,6 @@ func init() {
...
@@ -16,6 +16,6 @@ func init() {
Name
:
types
.
PokerBullX
,
Name
:
types
.
PokerBullX
,
ExecName
:
executor
.
GetName
(),
ExecName
:
executor
.
GetName
(),
Exec
:
executor
.
Init
,
Exec
:
executor
.
Init
,
Cmd
:
c
ommands
.
PokerBullCmd
,
Cmd
:
c
md
.
PokerBullCmd
,
})
})
}
}
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