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
6c751a8e
Commit
6c751a8e
authored
Oct 10, 2019
by
张振华
Committed by
vipwzw
Oct 16, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update ut cases
parent
4ce091c8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
52 additions
and
9 deletions
+52
-9
state_machine.go
plugin/consensus/dpos/state_machine.go
+3
-2
priv_validator_test.go
plugin/consensus/dpos/types/priv_validator_test.go
+47
-0
dposvotedb.go
plugin/dapp/dposvote/executor/dposvotedb.go
+1
-1
guessdb.go
plugin/dapp/guess/executor/guessdb.go
+1
-1
guess_test.go
plugin/dapp/guess/rpc/guess_test.go
+0
-0
const.go
plugin/dapp/guess/types/const.go
+0
-5
No files found.
plugin/consensus/dpos/state_machine.go
View file @
6c751a8e
...
...
@@ -142,7 +142,6 @@ func generateVote(cs *ConsensusState) *dpostype.Vote {
PeriodStop
:
task
.
PeriodStop
,
Height
:
height
+
1
,
}
cs
.
validatorMgr
.
FillVoteItem
(
voteItem
)
encode
,
err
:=
json
.
Marshal
(
voteItem
)
if
err
!=
nil
{
...
...
@@ -151,6 +150,8 @@ func generateVote(cs *ConsensusState) *dpostype.Vote {
voteItem
.
VoteID
=
crypto
.
Ripemd160
(
encode
)
cs
.
validatorMgr
.
FillVoteItem
(
voteItem
)
index
:=
cs
.
validatorMgr
.
GetIndexByPubKey
(
cs
.
privValidator
.
GetPubKey
()
.
Bytes
())
if
index
==
-
1
{
...
...
@@ -245,7 +246,7 @@ func checkTopNRegist(cs *ConsensusState) {
topN
:=
cs
.
GetTopNCandidatorsByVersion
(
info
.
Version
)
if
topN
==
nil
||
!
cs
.
IsTopNRegisted
(
topN
)
{
cands
,
err
:=
cs
.
client
.
QueryCandidators
()
if
err
!=
nil
||
cands
==
nil
{
if
err
!=
nil
||
cands
==
nil
||
len
(
cands
)
!=
int
(
dposDelegateNum
)
{
dposlog
.
Error
(
"QueryCandidators failed"
,
"now"
,
now
,
"height"
,
height
,
"HeightRegLimit"
,
info
.
HeightRegLimit
,
"pubkey"
,
strings
.
ToUpper
(
hex
.
EncodeToString
(
cs
.
privValidator
.
GetPubKey
()
.
Bytes
())))
LastCheckRegTopNTime
=
now
return
...
...
plugin/consensus/dpos/types/priv_validator_test.go
View file @
6c751a8e
...
...
@@ -5,6 +5,7 @@ import (
"encoding/hex"
"encoding/json"
"fmt"
"github.com/33cn/chain33/common/address"
"io"
"os"
"sort"
...
...
@@ -302,3 +303,48 @@ func TestSignTx(t *testing.T) {
remove
(
filename
)
}
func
TestPubkeyAndAddress
(
t
*
testing
.
T
)
{
priv
:=
"880D055D311827AB427031959F43238500D08F3EDF443EB903EC6D1A16A5783A"
pub
:=
"026BD23C69F9A1D7A50F185514EDCA25AFD00DD2A92485CC1E8CDA3EDD284CA838"
addr
:=
"22F4EA6D79D5AD0621900AB25A2BF01D3E288A7B"
testOneKey
(
priv
,
pub
,
addr
,
t
)
priv
=
"2C1B7E0B53548209E6915D8C5EB3162E9AF43D051C1316784034C9D549DD5F61"
pub
=
"02DE57B5427CE38E7D9811AC7CAE51A6FCFD251BCAD88DBDCF636EC9F7441B6AB6"
addr
=
"F518C3964A84EF2E37FD3284B5C638D3C928C537"
testOneKey
(
priv
,
pub
,
addr
,
t
)
priv
=
"2EA198F3F063F69B2DB860F41F8FAACB2EDEBCA1A74A75A5254B84E6F7D154B4"
pub
=
"036A818C01FA49F455E3779D073BD5FBE551A3E60BD447D8CFEE87F95037C29E59"
addr
=
"3FBB75FDC792E2618DA5D39B6C64B718AC0AAA5E"
testOneKey
(
priv
,
pub
,
addr
,
t
)
priv
=
"EEDD4815535AD81B6191EF9883346702C5117C80F8D85EB36FBD77D6CC979C8F"
pub
=
"023D3E5DDAD1F20C28E333FF05C16539ECB95CFAA881B66ADFCB2A5198E5BC0EFE"
addr
=
"ACB850206A75F233DDBB56A4D7DA6A015C3FE2EB"
testOneKey
(
priv
,
pub
,
addr
,
t
)
priv
=
"4EBB8B86F95DD7AB25CC27928D9AE04692DA9D7CA822CDA3FDE1DE778F01AFA7"
pub
=
"03DC5D8106E9E19EDFF91687CE55C97F3F6FA7584678313CF14925F76D0DB09055"
addr
=
"5A60D96560192EEE8EC9091FCC1AFC5511CA0BF0"
testOneKey
(
priv
,
pub
,
addr
,
t
)
}
func
testOneKey
(
priv
,
pub
,
addr
string
,
t
*
testing
.
T
)
{
tmp
,
_
:=
hex
.
DecodeString
(
priv
)
bPriv
,
_
:=
ConsensusCrypto
.
PrivKeyFromBytes
(
tmp
)
fmt
.
Println
(
fmt
.
Sprintf
(
"%x"
,
bPriv
))
bPub
,
_
:=
PubKeyFromString
(
pub
)
assert
.
True
(
t
,
bytes
.
Equal
(
bPub
.
Bytes
(),
bPriv
.
PubKey
()
.
Bytes
()))
bAddr
:=
address
.
PubKeyToAddress
(
bPub
.
Bytes
())
.
Hash160
[
:
]
fmt
.
Println
(
"addr:"
,
addr
)
fmt
.
Println
(
fmt
.
Sprintf
(
"%x"
,
bAddr
))
assert
.
True
(
t
,
addr
==
fmt
.
Sprintf
(
"%X"
,
bAddr
))
}
\ No newline at end of file
plugin/dapp/dposvote/executor/dposvotedb.go
View file @
6c751a8e
...
...
@@ -640,7 +640,7 @@ func queryTopNByVersion(db dbm.KV, req *dty.TopNCandidatorsQuery) (types.Message
strVersion
:=
fmt
.
Sprintf
(
"%018d"
,
req
.
Version
)
data
,
err
:=
db
.
Get
(
TopNKey
(
strVersion
))
if
err
!=
nil
||
data
==
nil
{
logger
.
Error
(
"queryTopNByVersion have err
:
"
,
"err"
,
err
.
Error
())
logger
.
Error
(
"queryTopNByVersion have err"
,
"err"
,
err
.
Error
())
return
nil
,
err
}
var
cands
dty
.
TopNCandidators
...
...
plugin/dapp/guess/executor/guessdb.go
View file @
6c751a8e
...
...
@@ -257,7 +257,7 @@ func (action *Action) getReceiptLog(game *gty.GuessGame, statusChange bool, bet
func
(
action
*
Action
)
readGame
(
id
string
)
(
*
gty
.
GuessGame
,
error
)
{
data
,
err
:=
action
.
db
.
Get
(
Key
(
id
))
if
err
!=
nil
{
logger
.
Error
(
"readGame have err
:
"
,
err
.
Error
())
logger
.
Error
(
"readGame have err
"
,
"err
"
,
err
.
Error
())
return
nil
,
err
}
var
game
gty
.
GuessGame
...
...
plugin/dapp/guess/rpc/guess_test.go
0 → 100644
View file @
6c751a8e
This diff is collapsed.
Click to expand it.
plugin/dapp/guess/types/const.go
View file @
6c751a8e
...
...
@@ -6,11 +6,6 @@ package types
//game action ty
const
(
PBGameActionStart
=
iota
+
1
PBGameActionContinue
PBGameActionQuit
PBGameActionQuery
GuessGameActionStart
=
iota
+
1
GuessGameActionBet
GuessGameActionStopBet
...
...
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