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
22daf0c7
Commit
22daf0c7
authored
May 31, 2019
by
pengjun
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/jpeng-go/plugin
parents
85d2759f
e4d6c37b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
56 deletions
+40
-56
docker-compose.sh
build/docker-compose.sh
+4
-1
test-rpc.sh
plugin/dapp/blackwhite/cmd/build/test-rpc.sh
+1
-1
test-rpc.sh
plugin/dapp/lottery/cmd/build/test-rpc.sh
+35
-54
No files found.
build/docker-compose.sh
View file @
22daf0c7
...
@@ -99,6 +99,9 @@ function base_init() {
...
@@ -99,6 +99,9 @@ function base_init() {
sed
-i
$sedfix
's/^nodeGroupFrozenCoins=.*/nodeGroupFrozenCoins=20/g'
chain33.toml
sed
-i
$sedfix
's/^nodeGroupFrozenCoins=.*/nodeGroupFrozenCoins=20/g'
chain33.toml
# ticket
sed
-i
$sedfix
's/^ticketPrice =.*/ticketPrice = 10000/g'
chain33.toml
}
}
function
start
()
{
function
start
()
{
...
@@ -143,7 +146,7 @@ function start() {
...
@@ -143,7 +146,7 @@ function start() {
${
CLI
}
block
hash
-t
0
${
CLI
}
block
hash
-t
0
res
=
$(${
CLI
}
block
hash
-t
0 | jq
-r
".hash"
)
res
=
$(${
CLI
}
block
hash
-t
0 | jq
-r
".hash"
)
#in case changes result in genesis change
#in case changes result in genesis change
if
[
"
${
res
}
"
!=
"0x
a87972dfc3510cb934cb987bcb88036f7a1ffd7dc069cb9a5f0af179895fd2e8
"
]
;
then
if
[
"
${
res
}
"
!=
"0x
67c58d6ba9175313f0468ae4e0ddec946549af7748037c2fdd5d54298afd20b6
"
]
;
then
echo
"genesis hash error!"
echo
"genesis hash error!"
exit
1
exit
1
fi
fi
...
...
plugin/dapp/blackwhite/cmd/build/test-rpc.sh
View file @
22daf0c7
...
@@ -244,7 +244,7 @@ function run_testcases() {
...
@@ -244,7 +244,7 @@ function run_testcases() {
blackwhite_BlackwhiteTimeoutDoneTx
"
$gID
"
blackwhite_BlackwhiteTimeoutDoneTx
"
$gID
"
#查询部分
#查询部分
block_wait
1
block_wait
3
blackwhite_GetBlackwhiteRoundInfo
"
$gID
"
blackwhite_GetBlackwhiteRoundInfo
"
$gID
"
blackwhite_GetBlackwhiteByStatusAndAddr
"
$gID
"
"
${
gameAddr1
}
"
blackwhite_GetBlackwhiteByStatusAndAddr
"
$gID
"
"
${
gameAddr1
}
"
blackwhite_GetBlackwhiteloopResult
"
$gID
"
blackwhite_GetBlackwhiteloopResult
"
$gID
"
...
...
plugin/dapp/lottery/cmd/build/test-rpc.sh
View file @
22daf0c7
...
@@ -23,48 +23,34 @@ echo_rst() {
...
@@ -23,48 +23,34 @@ echo_rst() {
lottery_addCreator_unsignedTx
=
"0a066d616e616765123c0a3a0a0f6c6f74746572792d63726561746f721222313271796f6361794e46374c7636433971573461767873324537553431664b5366761a0361646420a08d0630c788b8f7ccbadbc0703a223151344e687572654a784b4e4266373164323642394a336642516f5163666d657a32"
lottery_addCreator_unsignedTx
=
"0a066d616e616765123c0a3a0a0f6c6f74746572792d63726561746f721222313271796f6361794e46374c7636433971573461767873324537553431664b5366761a0361646420a08d0630c788b8f7ccbadbc0703a223151344e687572654a784b4e4266373164323642394a336642516f5163666d657a32"
lottery_addCreator_unsignedTx_para
=
"0a12757365722e702e706172612e6d616e616765123c0a3a0a0f6c6f74746572792d63726561746f721222313271796f6361794e46374c7636433971573461767873324537553431664b5366761a0361646420a08d0630a8bba1b887e7dade2b3a22314469484633317577783977356a6a733571514269474a6b4e686e71656564763157"
lottery_addCreator_unsignedTx_para
=
"0a12757365722e702e706172612e6d616e616765123c0a3a0a0f6c6f74746572792d63726561746f721222313271796f6361794e46374c7636433971573461767873324537553431664b5366761a0361646420a08d0630a8bba1b887e7dade2b3a22314469484633317577783977356a6a733571514269474a6b4e686e71656564763157"
lottery_creator_addr
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
lottery_creator_addr
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
lottery_creator_priv
=
"0x4257d8692ef7fe13c68b65d6a52f03933db2fa5ce8faf210b5b8b80c721ced01"
gID
=
""
gID
=
""
gResp
=
""
gResp
=
""
glAddr
=
""
gameAddr1
=
""
gameAddr2
=
""
gameAddr3
=
""
lottExecAddr
=
""
lottExecAddr
=
""
luckyNumber
=
""
purNum
=
30
purNum
=
30
drawNum
=
40
drawNum
=
40
opRatio
=
5
opRatio
=
5
devRatio
=
5
devRatio
=
5
luckyNumber
=
""
init
()
{
init
()
{
ispara
=
$(
echo
'"'
"
${
MAIN_HTTP
}
"
'"'
| jq
'.|contains("8901")'
)
ispara
=
$(
echo
'"'
"
${
MAIN_HTTP
}
"
'"'
| jq
'.|contains("8901")'
)
echo
"ispara=
$ispara
"
echo
"ispara=
$ispara
"
if
[[
$ispara
==
true
]]
;
then
if
[[
$ispara
==
true
]]
;
then
lottExecAddr
=
$(
curl
-ksd
'{"method":"Chain33.ConvertExectoAddr","params":[{"execname":"user.p.para.lottery"}]}'
${
MAIN_HTTP
}
| jq
-r
".result"
)
lottExecAddr
=
$(
curl
-ksd
'{"method":"Chain33.ConvertExectoAddr","params":[{"execname":"user.p.para.lottery"}]}'
${
MAIN_HTTP
}
| jq
-r
".result"
)
chain33_SendTransaction
"
${
lottery_addCreator_unsignedTx_para
}
"
"
${
lottery_creator_
addr
}
"
chain33_SendTransaction
"
${
lottery_addCreator_unsignedTx_para
}
"
"
${
lottery_creator_
priv
}
"
else
else
lottExecAddr
=
$(
curl
-ksd
'{"method":"Chain33.ConvertExectoAddr","params":[{"execname":"lottery"}]}'
${
MAIN_HTTP
}
| jq
-r
".result"
)
lottExecAddr
=
$(
curl
-ksd
'{"method":"Chain33.ConvertExectoAddr","params":[{"execname":"lottery"}]}'
${
MAIN_HTTP
}
| jq
-r
".result"
)
chain33_SendTransaction
"
${
lottery_addCreator_unsignedTx
}
"
"
${
lottery_creator_
addr
}
"
chain33_SendTransaction
"
${
lottery_addCreator_unsignedTx
}
"
"
${
lottery_creator_
priv
}
"
fi
fi
echo
"lottExecAddr=
$lottExecAddr
"
echo
"lottExecAddr=
$lottExecAddr
"
}
}
chain33_NewAccount
()
{
label
=
$1
result
=
$(
curl
-ksd
'{"method":"Chain33.NewAccount","params":[{"label":"'
"
$label
"
'"}]}'
-H
'content-type:text/plain;'
${
MAIN_HTTP
}
| jq
-r
".result.acc.addr"
)
[[
$result
!=
""
]]
rst
=
$?
echo_rst
"
$FUNCNAME
"
"
$rst
"
glAddr
=
$result
echo
"
$glAddr
"
}
function
block_wait
()
{
function
block_wait
()
{
if
[[
$#
-lt
1
]]
;
then
if
[[
$#
-lt
1
]]
;
then
echo
"wrong block_wait params"
echo
"wrong block_wait params"
...
@@ -142,10 +128,12 @@ chain33_SendToAddress() {
...
@@ -142,10 +128,12 @@ chain33_SendToAddress() {
chain33_SendTransaction
()
{
chain33_SendTransaction
()
{
rawTx
=
$1
rawTx
=
$1
addr
=
$2
priv
=
$2
#签名交易
#签名交易
resp
=
$(
curl
-ksd
'{"method":"Chain33.SignRawTx","params":[{"addr":"'
"
$addr
"
'","txHex":"'
"
$rawTx
"
'","expire":"120s","fee":10000000,"index":0}]}'
-H
'content-type:text/plain;'
${
MAIN_HTTP
})
set
-x
resp
=
$(
curl
-ksd
'{"method":"Chain33.SignRawTx","params":[{"privkey":"'
"
$priv
"
'","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"
)
set
+x
[[
$ok
==
null
]]
[[
$ok
==
null
]]
rst
=
$?
rst
=
$?
echo_rst
"chain33_SignRawTx"
"
$rst
"
echo_rst
"chain33_SignRawTx"
"
$rst
"
...
@@ -166,7 +154,7 @@ chain33_SendTransaction() {
...
@@ -166,7 +154,7 @@ chain33_SendTransaction() {
lottery_LotteryCreate
()
{
lottery_LotteryCreate
()
{
#创建交易
#创建交易
addr
=
$1
priv
=
$1
set
-x
set
-x
resp
=
$(
curl
-ksd
'{"method":"Chain33.CreateTransaction","params":[{"execer":"lottery","actionName":"LotteryCreate",
resp
=
$(
curl
-ksd
'{"method":"Chain33.CreateTransaction","params":[{"execer":"lottery","actionName":"LotteryCreate",
"payload":{"purBlockNum":'
"
$purNum
"
',"drawBlockNum":'
"
$drawNum
"
', "opRewardRatio":'
"
$opRatio
"
',"devRewardRatio":'
"
$devRatio
"
',"fee":1000000}}]}'
-H
'content-type:text/plain;'
${
MAIN_HTTP
})
"payload":{"purBlockNum":'
"
$purNum
"
',"drawBlockNum":'
"
$drawNum
"
', "opRewardRatio":'
"
$opRatio
"
',"devRewardRatio":'
"
$devRatio
"
',"fee":1000000}}]}'
-H
'content-type:text/plain;'
${
MAIN_HTTP
})
...
@@ -177,14 +165,14 @@ lottery_LotteryCreate() {
...
@@ -177,14 +165,14 @@ lottery_LotteryCreate() {
echo_rst
"
$FUNCNAME
"
"
$rst
"
echo_rst
"
$FUNCNAME
"
"
$rst
"
#发送交易
#发送交易
rawTx
=
$(
echo
"
${
resp
}
"
| jq
-r
".result"
)
rawTx
=
$(
echo
"
${
resp
}
"
| jq
-r
".result"
)
chain33_SendTransaction
"
${
rawTx
}
"
"
${
addr
}
"
chain33_SendTransaction
"
${
rawTx
}
"
"
${
priv
}
"
gID
=
"
${
gResp
}
"
gID
=
"
${
gResp
}
"
echo
"gameID
$gID
"
echo
"gameID
$gID
"
}
}
lottery_LotteryBuy
()
{
lottery_LotteryBuy
()
{
#创建交易
#创建交易
addr
=
$1
priv
=
$1
amount
=
$2
amount
=
$2
number
=
$3
number
=
$3
way
=
$4
way
=
$4
...
@@ -198,12 +186,12 @@ lottery_LotteryBuy() {
...
@@ -198,12 +186,12 @@ lottery_LotteryBuy() {
echo_rst
"
$FUNCNAME
"
"
$rst
"
echo_rst
"
$FUNCNAME
"
"
$rst
"
#发送交易
#发送交易
rawTx
=
$(
echo
"
${
resp
}
"
| jq
-r
".result"
)
rawTx
=
$(
echo
"
${
resp
}
"
| jq
-r
".result"
)
chain33_SendTransaction
"
${
rawTx
}
"
"
${
addr
}
"
chain33_SendTransaction
"
${
rawTx
}
"
"
${
priv
}
"
}
}
lottery_LotteryDraw
()
{
lottery_LotteryDraw
()
{
#创建交易
#创建交易
addr
=
$1
priv
=
$1
set
-x
set
-x
resp
=
$(
curl
-ksd
'{"method":"Chain33.CreateTransaction","params":[{"execer":"lottery","actionName":"LotteryDraw",
resp
=
$(
curl
-ksd
'{"method":"Chain33.CreateTransaction","params":[{"execer":"lottery","actionName":"LotteryDraw",
"payload":{"lotteryId":"'
"
$gID
"
'","fee":1000000}}]}'
-H
'content-type:text/plain;'
${
MAIN_HTTP
})
"payload":{"lotteryId":"'
"
$gID
"
'","fee":1000000}}]}'
-H
'content-type:text/plain;'
${
MAIN_HTTP
})
...
@@ -214,12 +202,12 @@ lottery_LotteryDraw() {
...
@@ -214,12 +202,12 @@ lottery_LotteryDraw() {
echo_rst
"
$FUNCNAME
"
"
$rst
"
echo_rst
"
$FUNCNAME
"
"
$rst
"
#发送交易
#发送交易
rawTx
=
$(
echo
"
${
resp
}
"
| jq
-r
".result"
)
rawTx
=
$(
echo
"
${
resp
}
"
| jq
-r
".result"
)
chain33_SendTransaction
"
${
rawTx
}
"
"
${
addr
}
"
chain33_SendTransaction
"
${
rawTx
}
"
"
${
priv
}
"
}
}
lottery_LotteryClose
()
{
lottery_LotteryClose
()
{
#创建交易
#创建交易
addr
=
$1
priv
=
$1
set
-x
set
-x
resp
=
$(
curl
-ksd
'{"method":"Chain33.CreateTransaction","params":[{"execer":"lottery","actionName":"LotteryClose",
resp
=
$(
curl
-ksd
'{"method":"Chain33.CreateTransaction","params":[{"execer":"lottery","actionName":"LotteryClose",
"payload":{"lotteryId":"'
"
$gID
"
'","fee":1000000}}]}'
-H
'content-type:text/plain;'
${
MAIN_HTTP
})
"payload":{"lotteryId":"'
"
$gID
"
'","fee":1000000}}]}'
-H
'content-type:text/plain;'
${
MAIN_HTTP
})
...
@@ -230,7 +218,7 @@ lottery_LotteryClose() {
...
@@ -230,7 +218,7 @@ lottery_LotteryClose() {
echo_rst
"
$FUNCNAME
"
"
$rst
"
echo_rst
"
$FUNCNAME
"
"
$rst
"
#发送交易
#发送交易
rawTx
=
$(
echo
"
${
resp
}
"
| jq
-r
".result"
)
rawTx
=
$(
echo
"
${
resp
}
"
| jq
-r
".result"
)
chain33_SendTransaction
"
${
rawTx
}
"
"
${
addr
}
"
chain33_SendTransaction
"
${
rawTx
}
"
"
${
priv
}
"
}
}
lottery_GetLotteryNormalInfo
()
{
lottery_GetLotteryNormalInfo
()
{
...
@@ -377,27 +365,20 @@ lottery_GetLotteryRoundGainInfo() {
...
@@ -377,27 +365,20 @@ lottery_GetLotteryRoundGainInfo() {
}
}
function
run_testcases
()
{
function
run_testcases
()
{
#先创建账户地址
#账户地址
chain33_NewAccount
"lottery111"
gameAddr1
=
"1PUiGcbsccfxW3zuvHXZBJfznziph5miAo"
gameAddr1
=
"
${
glAddr
}
"
gamePriv1
=
"0x56942AD84CCF4788ED6DACBC005A1D0C4F91B63BCF0C99A02BE03C8DEAE71138"
chain33_NewAccount
"lottery222"
gameAddr2
=
"1EDnnePAZN48aC2hiTDzhkczfF39g1pZZX"
gameAddr2
=
"
${
glAddr
}
"
gamePriv2
=
"0x2116459C0EC8ED01AA0EEAE35CAC5C96F94473F7816F114873291217303F6989"
chain33_NewAccount
"lottery333"
#该账户需要转账
gameAddr3
=
"
${
glAddr
}
"
gameAddr3
=
"12HKLEn6g4FH39yUbHh4EVJWcFo5CXg22d"
gamePriv3
=
"0x9d4f8ab11361be596468b265cb66946c87873d4a119713fd0c3d8302eae0a8e4"
#给每个账户分别转帐
origAddr
=
"1PUiGcbsccfxW3zuvHXZBJfznziph5miAo"
#主链中相应账户需要转帐
#主链中相应账户需要转帐
M_HTTP
=
${
MAIN_HTTP
//8901/8801
}
M_HTTP
=
${
MAIN_HTTP
//8901/8801
}
chain33_SendToAddress
"
${
origAddr
}
"
"
${
gameAddr1
}
"
300000000
"
${
M_HTTP
}
"
chain33_SendToAddress
"
${
gameAddr1
}
"
"
${
gameAddr3
}
"
300000000
"
${
M_HTTP
}
"
chain33_SendToAddress
"
${
origAddr
}
"
"
${
gameAddr2
}
"
300000000
"
${
M_HTTP
}
"
chain33_SendToAddress
"
${
origAddr
}
"
"
${
gameAddr3
}
"
300000000
"
${
M_HTTP
}
"
#平行链相应账户需要转帐
#平行链相应账户需要转帐
chain33_SendToAddress
"
${
origAddr
}
"
"
${
gameAddr1
}
"
300000000
"
${
MAIN_HTTP
}
"
chain33_SendToAddress
"
${
gameAddr1
}
"
"
${
gameAddr3
}
"
300000000
"
${
MAIN_HTTP
}
"
chain33_SendToAddress
"
${
origAddr
}
"
"
${
gameAddr2
}
"
300000000
"
${
MAIN_HTTP
}
"
chain33_SendToAddress
"
${
origAddr
}
"
"
${
gameAddr3
}
"
300000000
"
${
MAIN_HTTP
}
"
#给游戏合约中转帐
#给游戏合约中转帐
chain33_SendToAddress
"
${
gameAddr1
}
"
"
${
lottExecAddr
}
"
200000000
"
${
MAIN_HTTP
}
"
chain33_SendToAddress
"
${
gameAddr1
}
"
"
${
lottExecAddr
}
"
200000000
"
${
MAIN_HTTP
}
"
...
@@ -405,14 +386,14 @@ function run_testcases() {
...
@@ -405,14 +386,14 @@ function run_testcases() {
chain33_SendToAddress
"
${
gameAddr3
}
"
"
${
lottExecAddr
}
"
200000000
"
${
MAIN_HTTP
}
"
chain33_SendToAddress
"
${
gameAddr3
}
"
"
${
lottExecAddr
}
"
200000000
"
${
MAIN_HTTP
}
"
#创建游戏
#创建游戏
lottery_LotteryCreate
"
${
lottery_creator_
addr
}
"
lottery_LotteryCreate
"
${
lottery_creator_
priv
}
"
lottery_GetLotteryNormalInfo
"
$gID
"
"
${
lottery_creator_addr
}
"
lottery_GetLotteryNormalInfo
"
$gID
"
"
${
lottery_creator_addr
}
"
lottery_GetLotteryCurrentInfo
"
$gID
"
1 0
lottery_GetLotteryCurrentInfo
"
$gID
"
1 0
#第一次投注
#第一次投注
lottery_LotteryBuy
"
${
game
Addr
1
}
"
1 12345 1
lottery_LotteryBuy
"
${
game
Priv
1
}
"
1 12345 1
lottery_LotteryBuy
"
${
game
Addr
2
}
"
1 66666 2
lottery_LotteryBuy
"
${
game
Priv
2
}
"
1 66666 2
lottery_LotteryBuy
"
${
game
Addr
3
}
"
1 56789 5
lottery_LotteryBuy
"
${
game
Priv
3
}
"
1 56789 5
#查询
#查询
lottery_GetLotteryCurrentInfo
"
$gID
"
2 3
lottery_GetLotteryCurrentInfo
"
$gID
"
2 3
lottery_GetLotteryPurchaseAddr
"
$gID
"
3
lottery_GetLotteryPurchaseAddr
"
$gID
"
3
...
@@ -420,8 +401,8 @@ function run_testcases() {
...
@@ -420,8 +401,8 @@ function run_testcases() {
lottery_GetLotteryBuyRoundInfo
"
$gID
"
"
${
gameAddr2
}
"
1 1
"66666"
lottery_GetLotteryBuyRoundInfo
"
$gID
"
"
${
gameAddr2
}
"
1 1
"66666"
#第二次投注
#第二次投注
lottery_LotteryBuy
"
${
game
Addr
1
}
"
1 12321 1
lottery_LotteryBuy
"
${
game
Priv
1
}
"
1 12321 1
lottery_LotteryBuy
"
${
game
Addr
3
}
"
1 78987 5
lottery_LotteryBuy
"
${
game
Priv
3
}
"
1 78987 5
#查询
#查询
lottery_GetLotteryCurrentInfo
"
$gID
"
2 5
lottery_GetLotteryCurrentInfo
"
$gID
"
2 5
lottery_GetLotteryPurchaseAddr
"
$gID
"
3
lottery_GetLotteryPurchaseAddr
"
$gID
"
3
...
@@ -430,7 +411,7 @@ function run_testcases() {
...
@@ -430,7 +411,7 @@ function run_testcases() {
#游戏开奖
#游戏开奖
block_wait
${
drawNum
}
"
${
M_HTTP
}
"
block_wait
${
drawNum
}
"
${
M_HTTP
}
"
lottery_LotteryDraw
"
${
lottery_creator_
addr
}
"
lottery_LotteryDraw
"
${
lottery_creator_
priv
}
"
lottery_GetLotteryCurrentInfo
"
$gID
"
3 0
lottery_GetLotteryCurrentInfo
"
$gID
"
3 0
#游戏查询
#游戏查询
...
@@ -442,7 +423,7 @@ function run_testcases() {
...
@@ -442,7 +423,7 @@ function run_testcases() {
lottery_GetLotteryRoundGainInfo
"
$gID
"
"
${
gameAddr3
}
"
1 2
lottery_GetLotteryRoundGainInfo
"
$gID
"
"
${
gameAddr3
}
"
1 2
#关闭游戏
#关闭游戏
lottery_LotteryClose
"
${
lottery_creator_
addr
}
"
lottery_LotteryClose
"
${
lottery_creator_
priv
}
"
lottery_GetLotteryCurrentInfo
"
$gID
"
4 0
lottery_GetLotteryCurrentInfo
"
$gID
"
4 0
}
}
...
...
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