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
808a5d90
Commit
808a5d90
authored
Jun 18, 2019
by
caopingcp
Committed by
vipwzw
Jun 19, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix CreateBindMiner bug
parent
af8546e2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
16 deletions
+18
-16
dapp-test-common.sh
build/dapp-test-common.sh
+8
-0
test-rpc.sh
plugin/dapp/ticket/cmd/build/test-rpc.sh
+3
-13
rpc.go
plugin/dapp/ticket/rpc/rpc.go
+7
-3
No files found.
build/dapp-test-common.sh
View file @
808a5d90
#!/usr/bin/env bash
RAW_TX_HASH
=
""
LAST_BLOCK_HASH
=
""
CASE_ERR
=
""
#color
...
...
@@ -156,3 +157,10 @@ chain33_GetAccounts() {
resp
=
$(
curl
-ksd
'{"jsonrpc":"2.0","id":2,"method":"Chain33.GetAccounts","params":[{}]}'
-H
'content-type:text/plain;'
"
${
MAIN_HTTP
}
"
)
echo
"
$resp
"
}
chain33_LastBlockhash
()
{
local
MAIN_HTTP
=
$1
result
=
$(
curl
-ksd
'{"method":"Chain33.GetLastHeader","params":[{}]}'
-H
'content-type:text/plain;'
${
MAIN_HTTP
}
| jq
-r
".result.hash"
)
LAST_BLOCK_HASH
=
$result
echo
-e
"######
\\
n last blockhash is
$LAST_BLOCK_HASH
\\
n######"
}
plugin/dapp/ticket/cmd/build/test-rpc.sh
View file @
808a5d90
...
...
@@ -9,18 +9,8 @@ MAIN_HTTP=""
source
../dapp-test-common.sh
ticketId
=
""
blockhash
=
""
price
=
$((
10000
*
100000000
))
last_blockhash
()
{
result
=
$(
curl
-ksd
'{"method":"Chain33.GetLastHeader","params":[{}]}'
-H
'content-type:text/plain;'
${
MAIN_HTTP
}
| jq
-r
".result.hash"
)
[[
$result
!=
""
]]
rst
=
$?
echo_rst
"
$FUNCNAME
"
"
$rst
"
blockhash
=
$result
echo
-e
"######
\\
n last blockhash is
$blockhash
\\
n######"
}
ticket_CreateBindMiner
()
{
#创建交易
minerAddr
=
$1
...
...
@@ -28,7 +18,7 @@ ticket_CreateBindMiner() {
returnPriv
=
$3
amount
=
$4
set
-x
resp
=
$(
curl
-ksd
'{"method":"ticket.CreateBindMiner","params":[{"bindAddr":"'
"
$minerAddr
"
'", "originAddr":"'
"
$returnAddr
"
'", "amount":'
"
$amount
"
', "checkBalance":
fals
e}]}'
-H
'content-type:text/plain;'
${
MAIN_HTTP
})
resp
=
$(
curl
-ksd
'{"method":"ticket.CreateBindMiner","params":[{"bindAddr":"'
"
$minerAddr
"
'", "originAddr":"'
"
$returnAddr
"
'", "amount":'
"
$amount
"
', "checkBalance":
tru
e}]}'
-H
'content-type:text/plain;'
${
MAIN_HTTP
})
ok
=
$(
echo
"
${
resp
}
"
| jq
-r
".error"
)
[[
$ok
==
null
]]
rst
=
$?
...
...
@@ -177,8 +167,8 @@ function run_testcases() {
#关闭
ticket_CloseTickets
"
${
minerAddr2
}
"
last_blockhash
ticket_RandNumHash
"
${
blockhash
}
"
5
chain33_LastBlockhash
"
${
MAIN_HTTP
}
"
ticket_RandNumHash
"
${
LAST_BLOCK_HASH
}
"
5
}
function
main
()
{
...
...
plugin/dapp/ticket/rpc/rpc.go
View file @
808a5d90
...
...
@@ -28,10 +28,14 @@ func bindMiner(param *ty.ReqBindMiner) (*ty.ReplyBindMiner, error) {
// CreateBindMiner 创建绑定挖矿
func
(
g
*
channelClient
)
CreateBindMiner
(
ctx
context
.
Context
,
in
*
ty
.
ReqBindMiner
)
(
*
ty
.
ReplyBindMiner
,
error
)
{
if
in
.
Amount
%
(
10000
*
types
.
Coin
)
!=
0
||
in
.
Amount
<
0
{
header
,
err
:=
g
.
GetLastHeader
()
if
err
!=
nil
{
return
nil
,
err
}
if
in
.
Amount
%
types
.
GetP
(
header
.
Height
)
.
TicketPrice
!=
0
||
in
.
Amount
<
0
{
return
nil
,
types
.
ErrAmount
}
err
:
=
address
.
CheckAddress
(
in
.
BindAddr
)
err
=
address
.
CheckAddress
(
in
.
BindAddr
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -41,7 +45,7 @@ func (g *channelClient) CreateBindMiner(ctx context.Context, in *ty.ReqBindMiner
}
if
in
.
CheckBalance
{
getBalance
:=
&
types
.
ReqBalance
{
Addresses
:
[]
string
{
in
.
OriginAddr
},
Execer
:
"coins"
}
getBalance
:=
&
types
.
ReqBalance
{
Addresses
:
[]
string
{
in
.
OriginAddr
},
Execer
:
"coins"
,
AssetSymbol
:
"bty"
,
AssetExec
:
"coins"
}
balances
,
err
:=
g
.
GetCoinsAccountDB
()
.
GetBalance
(
g
,
getBalance
)
if
err
!=
nil
{
return
nil
,
err
...
...
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