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
5b29261b
Commit
5b29261b
authored
Jul 19, 2019
by
liuyuhang
Committed by
33cn
Aug 14, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add test
parent
e720e6de
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
63 additions
and
38 deletions
+63
-38
boardaction.go
plugin/dapp/autonomy/executor/boardaction.go
+12
-4
boardaction_test.go
plugin/dapp/autonomy/executor/boardaction_test.go
+9
-6
projectaction.go
plugin/dapp/autonomy/executor/projectaction.go
+18
-8
projectaction_test.go
plugin/dapp/autonomy/executor/projectaction_test.go
+0
-0
ruleaction.go
plugin/dapp/autonomy/executor/ruleaction.go
+16
-12
ruleaction_test.go
plugin/dapp/autonomy/executor/ruleaction_test.go
+8
-8
No files found.
plugin/dapp/autonomy/executor/boardaction.go
View file @
5b29261b
...
...
@@ -403,10 +403,18 @@ func copyAutonomyProposalBoard(cur *auty.AutonomyProposalBoard) *auty.AutonomyPr
return
nil
}
newAut
:=
*
cur
newBoard
:=
*
cur
.
GetPropBoard
()
newRes
:=
*
cur
.
GetVoteResult
()
newAut
.
PropBoard
=
&
newBoard
newAut
.
VoteResult
=
&
newRes
if
cur
.
PropBoard
!=
nil
{
newBoard
:=
*
cur
.
GetPropBoard
()
newAut
.
PropBoard
=
&
newBoard
}
if
cur
.
CurRule
!=
nil
{
newRule
:=
*
cur
.
GetCurRule
()
newAut
.
CurRule
=
&
newRule
}
if
cur
.
VoteResult
!=
nil
{
newRes
:=
*
cur
.
GetVoteResult
()
newAut
.
VoteResult
=
&
newRes
}
return
&
newAut
}
plugin/dapp/autonomy/executor/boardaction_test.go
View file @
5b29261b
...
...
@@ -460,22 +460,25 @@ func TestCopyAutonomyProposalBoard(t *testing.T) {
require
.
Nil
(
t
,
copyAutonomyProposalBoard
(
nil
))
cur
:=
&
auty
.
AutonomyProposalBoard
{
PropBoard
:
&
auty
.
ProposalBoard
{
Year
:
1900
,
Month
:
1
},
CurRule
:
&
auty
.
RuleConfig
{
BoardAttendRatio
:
100
},
VoteResult
:
&
auty
.
VoteResult
{
TotalVotes
:
100
},
Status
:
2
,
Address
:
"123"
,
}
new
:=
copyAutonomyProposalBoard
(
cur
)
pre
:=
copyAutonomyProposalBoard
(
cur
)
cur
.
PropBoard
.
Year
=
1800
cur
.
PropBoard
.
Month
=
2
cur
.
CurRule
.
BoardAttendRatio
=
90
cur
.
VoteResult
.
TotalVotes
=
50
cur
.
Address
=
"234"
cur
.
Status
=
1
require
.
Equal
(
t
,
1900
,
int
(
new
.
PropBoard
.
Year
))
require
.
Equal
(
t
,
1
,
int
(
new
.
PropBoard
.
Month
))
require
.
Equal
(
t
,
100
,
int
(
new
.
VoteResult
.
TotalVotes
))
require
.
Equal
(
t
,
"123"
,
new
.
Address
)
require
.
Equal
(
t
,
2
,
int
(
new
.
Status
))
require
.
Equal
(
t
,
1900
,
int
(
pre
.
PropBoard
.
Year
))
require
.
Equal
(
t
,
1
,
int
(
pre
.
PropBoard
.
Month
))
require
.
Equal
(
t
,
100
,
int
(
pre
.
CurRule
.
BoardAttendRatio
))
require
.
Equal
(
t
,
100
,
int
(
pre
.
VoteResult
.
TotalVotes
))
require
.
Equal
(
t
,
"123"
,
pre
.
Address
)
require
.
Equal
(
t
,
2
,
int
(
pre
.
Status
))
}
func
signTx
(
tx
*
types
.
Transaction
,
hexPrivKey
string
)
(
*
types
.
Transaction
,
error
)
{
...
...
plugin/dapp/autonomy/executor/projectaction.go
View file @
5b29261b
...
...
@@ -15,8 +15,8 @@ import (
func
(
a
*
action
)
propProject
(
prob
*
auty
.
ProposalProject
)
(
*
types
.
Receipt
,
error
)
{
if
err
:=
address
.
CheckAddress
(
prob
.
ToAddr
);
err
!=
nil
{
alog
.
Error
(
"propProject "
,
"check toAddr error"
,
err
)
return
nil
,
types
.
ErrInvalid
Param
alog
.
Error
(
"propProject "
,
"
addr"
,
prob
.
ToAddr
,
"
check toAddr error"
,
err
)
return
nil
,
types
.
ErrInvalid
Address
}
if
prob
.
StartBlockHeight
<
a
.
height
||
prob
.
EndBlockHeight
<
a
.
height
||
prob
.
Amount
<=
0
{
...
...
@@ -465,12 +465,22 @@ func copyAutonomyProposalProject(cur *auty.AutonomyProposalProject) *auty.Autono
return
nil
}
newAut
:=
*
cur
newProject
:=
*
cur
.
GetPropProject
()
newRes
:=
*
cur
.
GetBoardVoteRes
()
newPub
:=
*
cur
.
GetPubVote
()
newAut
.
PropProject
=
&
newProject
newAut
.
BoardVoteRes
=
&
newRes
newAut
.
PubVote
=
&
newPub
if
cur
.
PropProject
!=
nil
{
newProject
:=
*
cur
.
GetPropProject
()
newAut
.
PropProject
=
&
newProject
}
if
cur
.
CurRule
!=
nil
{
newRule
:=
*
cur
.
GetCurRule
()
newAut
.
CurRule
=
&
newRule
}
if
cur
.
BoardVoteRes
!=
nil
{
newRes
:=
*
cur
.
GetBoardVoteRes
()
newAut
.
BoardVoteRes
=
&
newRes
}
if
cur
.
PubVote
!=
nil
{
newPub
:=
*
cur
.
GetPubVote
()
newAut
.
PubVote
=
&
newPub
}
return
&
newAut
}
plugin/dapp/autonomy/executor/projectaction_test.go
0 → 100644
View file @
5b29261b
This diff is collapsed.
Click to expand it.
plugin/dapp/autonomy/executor/ruleaction.go
View file @
5b29261b
...
...
@@ -314,18 +314,22 @@ func copyAutonomyProposalRule(cur *auty.AutonomyProposalRule) *auty.AutonomyProp
return
nil
}
newAut
:=
*
cur
newPropRule
:=
*
cur
.
GetPropRule
()
var
newCfg
*
auty
.
RuleConfig
if
newPropRule
.
RuleCfg
!=
nil
{
cfg
:=
*
cur
.
GetPropRule
()
.
GetRuleCfg
()
newCfg
=
&
cfg
}
newRule
:=
*
cur
.
GetRule
()
newRes
:=
*
cur
.
GetVoteResult
()
newAut
.
PropRule
=
&
newPropRule
newAut
.
PropRule
.
RuleCfg
=
newCfg
newAut
.
Rule
=
&
newRule
newAut
.
VoteResult
=
&
newRes
if
cur
.
PropRule
!=
nil
{
newPropRule
:=
*
cur
.
GetPropRule
()
newAut
.
PropRule
=
&
newPropRule
if
cur
.
PropRule
.
RuleCfg
!=
nil
{
cfg
:=
*
cur
.
GetPropRule
()
.
GetRuleCfg
()
newAut
.
PropRule
.
RuleCfg
=
&
cfg
}
}
if
cur
.
Rule
!=
nil
{
newRule
:=
*
cur
.
GetRule
()
newAut
.
Rule
=
&
newRule
}
if
cur
.
VoteResult
!=
nil
{
newRes
:=
*
cur
.
GetVoteResult
()
newAut
.
VoteResult
=
&
newRes
}
return
&
newAut
}
...
...
plugin/dapp/autonomy/executor/ruleaction_test.go
View file @
5b29261b
...
...
@@ -406,7 +406,7 @@ func TestCopyAutonomyProposalRule(t *testing.T) {
Status
:
2
,
Address
:
"123"
,
}
new
:=
copyAutonomyProposalRule
(
cur
)
pre
:=
copyAutonomyProposalRule
(
cur
)
cur
.
PropRule
.
Year
=
1800
cur
.
PropRule
.
Month
=
2
cur
.
PropRule
.
RuleCfg
.
BoardApproveRatio
=
90
...
...
@@ -415,13 +415,13 @@ func TestCopyAutonomyProposalRule(t *testing.T) {
cur
.
Address
=
"234"
cur
.
Status
=
1
require
.
Equal
(
t
,
1900
,
int
(
new
.
PropRule
.
Year
))
require
.
Equal
(
t
,
1
,
int
(
new
.
PropRule
.
Month
))
require
.
Equal
(
t
,
100
,
int
(
new
.
VoteResult
.
TotalVotes
))
require
.
Equal
(
t
,
"123"
,
new
.
Address
)
require
.
Equal
(
t
,
2
,
int
(
new
.
Status
))
require
.
Equal
(
t
,
80
,
int
(
new
.
PropRule
.
RuleCfg
.
BoardApproveRatio
))
require
.
Equal
(
t
,
100
,
int
(
new
.
Rule
.
BoardApproveRatio
))
require
.
Equal
(
t
,
1900
,
int
(
pre
.
PropRule
.
Year
))
require
.
Equal
(
t
,
1
,
int
(
pre
.
PropRule
.
Month
))
require
.
Equal
(
t
,
100
,
int
(
pre
.
VoteResult
.
TotalVotes
))
require
.
Equal
(
t
,
"123"
,
pre
.
Address
)
require
.
Equal
(
t
,
2
,
int
(
pre
.
Status
))
require
.
Equal
(
t
,
80
,
int
(
pre
.
PropRule
.
RuleCfg
.
BoardApproveRatio
))
require
.
Equal
(
t
,
100
,
int
(
pre
.
Rule
.
BoardApproveRatio
))
}
func
TestUpgradeRule
(
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