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
d48fa9c1
Commit
d48fa9c1
authored
Oct 17, 2019
by
vipwzw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix rpc ticket test
parent
a2206aef
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
8 additions
and
106 deletions
+8
-106
go.mod
go.mod
+2
-0
go.sum
go.sum
+1
-0
jrpc_channel_test.go
plugin/dapp/ticket/rpc/jrpc_channel_test.go
+0
-73
rpc.go
plugin/dapp/ticket/rpc/rpc.go
+4
-0
rpc_real_test.go
plugin/dapp/ticket/rpc/rpc_real_test.go
+0
-18
rpc_test.go
plugin/dapp/ticket/rpc/rpc_test.go
+1
-15
No files found.
go.mod
View file @
d48fa9c1
...
...
@@ -20,6 +20,8 @@ require (
github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3
github.com/golang/protobuf v1.3.2
github.com/hashicorp/golang-lru v0.5.0
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/pkg/errors v0.8.0
github.com/prometheus/client_golang v1.1.0 // indirect
github.com/robertkrimen/otto v0.0.0-20180617131154-15f95af6e78d
...
...
go.sum
View file @
d48fa9c1
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/33cn/chain33 v0.0.0-20191017025459-6d5c61c7d134 h1:uglc+qoZXRLxsLn9TdwLV5YDzjnRbLV0QjaxqvVFh4M=
github.com/33cn/chain33 v0.0.0-20191017025459-6d5c61c7d134/go.mod h1:4I8n+Zyf3t0UKM5jjpqJY627Tub62oXkLsdzIv4r6rQ=
github.com/33cn/chain33 v0.0.0-20191017084333-edce70d31ccc h1:ZE5zFLMdGTiHF7fZcVk+uOT16Q5gwmT4p01MSz/9ZBQ=
github.com/AndreasBriese/bbloom v0.0.0-20180913140656-343706a395b7 h1:PqzgE6kAMi81xWQA2QIVxjWkFHptGgC547vchpUbtFo=
github.com/AndreasBriese/bbloom v0.0.0-20180913140656-343706a395b7/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8=
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
...
...
plugin/dapp/ticket/rpc/jrpc_channel_test.go
deleted
100644 → 0
View file @
a2206aef
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
rpc_test
import
(
"strings"
"testing"
"github.com/33cn/chain33/rpc/jsonclient"
rpctypes
"github.com/33cn/chain33/rpc/types"
_
"github.com/33cn/chain33/system"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/util/testnode"
_
"github.com/33cn/plugin/plugin"
"github.com/stretchr/testify/assert"
)
var
mocker
*
testnode
.
Chain33Mock
func
TestMain
(
m
*
testing
.
M
)
{
cfg
,
sub
:=
testnode
.
GetDefaultConfig
()
cfg
.
Consensus
.
Name
=
"ticket"
mocker
=
testnode
.
NewWithConfig
(
cfg
,
sub
,
nil
)
mocker
.
Listen
()
m
.
Run
()
mocker
.
Close
()
}
func
TestJRPCChannel
(
t
*
testing
.
T
)
{
jrpcClient
:=
mocker
.
GetJSONC
()
testCases
:=
[]
struct
{
fn
func
(
*
testing
.
T
,
*
jsonclient
.
JSONClient
)
error
}{
{
fn
:
testCountTicketCmd
},
{
fn
:
testCloseTicketCmd
},
{
fn
:
testGetColdAddrByMinerCmd
},
}
for
index
,
testCase
:=
range
testCases
{
err
:=
testCase
.
fn
(
t
,
jrpcClient
)
if
err
==
nil
{
continue
}
assert
.
NotEqualf
(
t
,
err
,
types
.
ErrActionNotSupport
,
"test index %d"
,
index
)
if
strings
.
Contains
(
err
.
Error
(),
"rpc: can't find"
)
{
assert
.
FailNowf
(
t
,
err
.
Error
(),
"test index %d"
,
index
)
}
t
.
Log
(
err
.
Error
())
}
}
func
testCountTicketCmd
(
t
*
testing
.
T
,
jrpc
*
jsonclient
.
JSONClient
)
error
{
var
res
int64
return
jrpc
.
Call
(
"ticket.GetTicketCount"
,
nil
,
&
res
)
}
func
testCloseTicketCmd
(
t
*
testing
.
T
,
jrpc
*
jsonclient
.
JSONClient
)
error
{
var
res
types
.
ReplyHashes
return
jrpc
.
Call
(
"ticket.CloseTickets"
,
nil
,
&
res
)
}
func
testGetColdAddrByMinerCmd
(
t
*
testing
.
T
,
jrpc
*
jsonclient
.
JSONClient
)
error
{
var
rep
interface
{}
var
params
rpctypes
.
Query4Jrpc
req
:=
&
types
.
ReqString
{}
params
.
Execer
=
"ticket"
params
.
FuncName
=
"MinerSourceList"
params
.
Payload
=
types
.
MustPBToJSON
(
req
)
rep
=
&
types
.
ReplyStrings
{}
return
jrpc
.
Call
(
"Chain33.Query"
,
params
,
rep
)
}
plugin/dapp/ticket/rpc/rpc.go
View file @
d48fa9c1
...
...
@@ -42,6 +42,10 @@ func (g *channelClient) CreateBindMiner(ctx context.Context, in *ty.ReqBindMiner
if
err
!=
nil
{
return
nil
,
err
}
price
:=
ty
.
GetTicketMinerParam
(
header
.
Height
)
.
TicketPrice
if
price
==
0
{
return
nil
,
types
.
ErrInvalidParam
}
if
in
.
Amount
%
ty
.
GetTicketMinerParam
(
header
.
Height
)
.
TicketPrice
!=
0
||
in
.
Amount
<
0
{
return
nil
,
types
.
ErrAmount
}
...
...
plugin/dapp/ticket/rpc/rpc_real_test.go
View file @
d48fa9c1
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
rpc_test
//only load all plugin and system
import
(
"testing"
rpctypes
"github.com/33cn/chain33/rpc/types"
_
"github.com/33cn/chain33/system"
_
"github.com/33cn/plugin/plugin"
ty
"github.com/33cn/plugin/plugin/dapp/ticket/types"
"github.com/stretchr/testify/assert"
)
func
TestNewTicket
(
t
*
testing
.
T
)
{
//选票(可以用hotwallet 关闭选票)
in
:=
&
ty
.
TicketClose
{
MinerAddress
:
mocker
.
GetHotAddress
()}
var
res
rpctypes
.
ReplyHashes
err
:=
mocker
.
GetJSONC
()
.
Call
(
"ticket.CloseTickets"
,
in
,
&
res
)
assert
.
Nil
(
t
,
err
)
}
plugin/dapp/ticket/rpc/rpc_test.go
View file @
d48fa9c1
...
...
@@ -128,30 +128,16 @@ func TestChannelClient_BindMiner(t *testing.T) {
storevalue
.
Values
=
append
(
storevalue
.
Values
,
accv
)
api
.
On
(
"StoreGet"
,
mock
.
Anything
)
.
Return
(
storevalue
,
nil
)
.
Twice
()
types
.
SetTitleOnlyForTest
(
"test"
)
cfg
,
_
:=
types
.
InitCfgString
(
cfgstring
)
types
.
Init
(
"test"
,
cfg
)
//var addrs = make([]string, 1)
//addrs = append(addrs, "1Jn2qu84Z1SUUosWjySggBS9pKWdAP3tZt")
var
in
=
&
ty
.
ReqBindMiner
{
BindAddr
:
"1Jn2qu84Z1SUUosWjySggBS9pKWdAP3tZt"
,
OriginAddr
:
"1Jn2qu84Z1SUUosWjySggBS9pKWdAP3tZt"
,
Amount
:
10000
*
types
.
Coin
,
CheckBalance
:
tru
e
,
CheckBalance
:
fals
e
,
}
_
,
err
:=
client
.
CreateBindMiner
(
context
.
Background
(),
in
)
assert
.
Nil
(
t
,
err
)
in
.
Amount
=
200000
*
types
.
Coin
_
,
err
=
client
.
CreateBindMiner
(
context
.
Background
(),
in
)
assert
.
Equal
(
t
,
types
.
ErrNoBalance
,
err
)
head
.
Height
=
20
//ForkChainParamV2
api
.
On
(
"GetLastHeader"
)
.
Return
(
head
,
nil
)
.
Times
(
2
)
_
,
err
=
client
.
CreateBindMiner
(
context
.
Background
(),
in
)
assert
.
Equal
(
t
,
types
.
ErrAmount
,
err
)
}
func
testGetTicketCountOK
(
t
*
testing
.
T
)
{
...
...
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