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
...
@@ -403,10 +403,18 @@ func copyAutonomyProposalBoard(cur *auty.AutonomyProposalBoard) *auty.AutonomyPr
return
nil
return
nil
}
}
newAut
:=
*
cur
newAut
:=
*
cur
newBoard
:=
*
cur
.
GetPropBoard
()
if
cur
.
PropBoard
!=
nil
{
newRes
:=
*
cur
.
GetVoteResult
()
newBoard
:=
*
cur
.
GetPropBoard
()
newAut
.
PropBoard
=
&
newBoard
newAut
.
PropBoard
=
&
newBoard
newAut
.
VoteResult
=
&
newRes
}
if
cur
.
CurRule
!=
nil
{
newRule
:=
*
cur
.
GetCurRule
()
newAut
.
CurRule
=
&
newRule
}
if
cur
.
VoteResult
!=
nil
{
newRes
:=
*
cur
.
GetVoteResult
()
newAut
.
VoteResult
=
&
newRes
}
return
&
newAut
return
&
newAut
}
}
plugin/dapp/autonomy/executor/boardaction_test.go
View file @
5b29261b
...
@@ -460,22 +460,25 @@ func TestCopyAutonomyProposalBoard(t *testing.T) {
...
@@ -460,22 +460,25 @@ func TestCopyAutonomyProposalBoard(t *testing.T) {
require
.
Nil
(
t
,
copyAutonomyProposalBoard
(
nil
))
require
.
Nil
(
t
,
copyAutonomyProposalBoard
(
nil
))
cur
:=
&
auty
.
AutonomyProposalBoard
{
cur
:=
&
auty
.
AutonomyProposalBoard
{
PropBoard
:
&
auty
.
ProposalBoard
{
Year
:
1900
,
Month
:
1
},
PropBoard
:
&
auty
.
ProposalBoard
{
Year
:
1900
,
Month
:
1
},
CurRule
:
&
auty
.
RuleConfig
{
BoardAttendRatio
:
100
},
VoteResult
:
&
auty
.
VoteResult
{
TotalVotes
:
100
},
VoteResult
:
&
auty
.
VoteResult
{
TotalVotes
:
100
},
Status
:
2
,
Status
:
2
,
Address
:
"123"
,
Address
:
"123"
,
}
}
new
:=
copyAutonomyProposalBoard
(
cur
)
pre
:=
copyAutonomyProposalBoard
(
cur
)
cur
.
PropBoard
.
Year
=
1800
cur
.
PropBoard
.
Year
=
1800
cur
.
PropBoard
.
Month
=
2
cur
.
PropBoard
.
Month
=
2
cur
.
CurRule
.
BoardAttendRatio
=
90
cur
.
VoteResult
.
TotalVotes
=
50
cur
.
VoteResult
.
TotalVotes
=
50
cur
.
Address
=
"234"
cur
.
Address
=
"234"
cur
.
Status
=
1
cur
.
Status
=
1
require
.
Equal
(
t
,
1900
,
int
(
new
.
PropBoard
.
Year
))
require
.
Equal
(
t
,
1900
,
int
(
pre
.
PropBoard
.
Year
))
require
.
Equal
(
t
,
1
,
int
(
new
.
PropBoard
.
Month
))
require
.
Equal
(
t
,
1
,
int
(
pre
.
PropBoard
.
Month
))
require
.
Equal
(
t
,
100
,
int
(
new
.
VoteResult
.
TotalVotes
))
require
.
Equal
(
t
,
100
,
int
(
pre
.
CurRule
.
BoardAttendRatio
))
require
.
Equal
(
t
,
"123"
,
new
.
Address
)
require
.
Equal
(
t
,
100
,
int
(
pre
.
VoteResult
.
TotalVotes
))
require
.
Equal
(
t
,
2
,
int
(
new
.
Status
))
require
.
Equal
(
t
,
"123"
,
pre
.
Address
)
require
.
Equal
(
t
,
2
,
int
(
pre
.
Status
))
}
}
func
signTx
(
tx
*
types
.
Transaction
,
hexPrivKey
string
)
(
*
types
.
Transaction
,
error
)
{
func
signTx
(
tx
*
types
.
Transaction
,
hexPrivKey
string
)
(
*
types
.
Transaction
,
error
)
{
...
...
plugin/dapp/autonomy/executor/projectaction.go
View file @
5b29261b
...
@@ -15,8 +15,8 @@ import (
...
@@ -15,8 +15,8 @@ import (
func
(
a
*
action
)
propProject
(
prob
*
auty
.
ProposalProject
)
(
*
types
.
Receipt
,
error
)
{
func
(
a
*
action
)
propProject
(
prob
*
auty
.
ProposalProject
)
(
*
types
.
Receipt
,
error
)
{
if
err
:=
address
.
CheckAddress
(
prob
.
ToAddr
);
err
!=
nil
{
if
err
:=
address
.
CheckAddress
(
prob
.
ToAddr
);
err
!=
nil
{
alog
.
Error
(
"propProject "
,
"check toAddr error"
,
err
)
alog
.
Error
(
"propProject "
,
"
addr"
,
prob
.
ToAddr
,
"
check toAddr error"
,
err
)
return
nil
,
types
.
ErrInvalid
Param
return
nil
,
types
.
ErrInvalid
Address
}
}
if
prob
.
StartBlockHeight
<
a
.
height
||
prob
.
EndBlockHeight
<
a
.
height
||
prob
.
Amount
<=
0
{
if
prob
.
StartBlockHeight
<
a
.
height
||
prob
.
EndBlockHeight
<
a
.
height
||
prob
.
Amount
<=
0
{
...
@@ -465,12 +465,22 @@ func copyAutonomyProposalProject(cur *auty.AutonomyProposalProject) *auty.Autono
...
@@ -465,12 +465,22 @@ func copyAutonomyProposalProject(cur *auty.AutonomyProposalProject) *auty.Autono
return
nil
return
nil
}
}
newAut
:=
*
cur
newAut
:=
*
cur
newProject
:=
*
cur
.
GetPropProject
()
if
cur
.
PropProject
!=
nil
{
newRes
:=
*
cur
.
GetBoardVoteRes
()
newProject
:=
*
cur
.
GetPropProject
()
newPub
:=
*
cur
.
GetPubVote
()
newAut
.
PropProject
=
&
newProject
newAut
.
PropProject
=
&
newProject
}
newAut
.
BoardVoteRes
=
&
newRes
if
cur
.
CurRule
!=
nil
{
newAut
.
PubVote
=
&
newPub
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
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
...
@@ -314,18 +314,22 @@ func copyAutonomyProposalRule(cur *auty.AutonomyProposalRule) *auty.AutonomyProp
return
nil
return
nil
}
}
newAut
:=
*
cur
newAut
:=
*
cur
newPropRule
:=
*
cur
.
GetPropRule
()
if
cur
.
PropRule
!=
nil
{
var
newCfg
*
auty
.
RuleConfig
newPropRule
:=
*
cur
.
GetPropRule
()
if
newPropRule
.
RuleCfg
!=
nil
{
newAut
.
PropRule
=
&
newPropRule
cfg
:=
*
cur
.
GetPropRule
()
.
GetRuleCfg
()
if
cur
.
PropRule
.
RuleCfg
!=
nil
{
newCfg
=
&
cfg
cfg
:=
*
cur
.
GetPropRule
()
.
GetRuleCfg
()
}
newAut
.
PropRule
.
RuleCfg
=
&
cfg
newRule
:=
*
cur
.
GetRule
()
}
newRes
:=
*
cur
.
GetVoteResult
()
}
newAut
.
PropRule
=
&
newPropRule
if
cur
.
Rule
!=
nil
{
newAut
.
PropRule
.
RuleCfg
=
newCfg
newRule
:=
*
cur
.
GetRule
()
newAut
.
Rule
=
&
newRule
newAut
.
Rule
=
&
newRule
newAut
.
VoteResult
=
&
newRes
}
if
cur
.
VoteResult
!=
nil
{
newRes
:=
*
cur
.
GetVoteResult
()
newAut
.
VoteResult
=
&
newRes
}
return
&
newAut
return
&
newAut
}
}
...
...
plugin/dapp/autonomy/executor/ruleaction_test.go
View file @
5b29261b
...
@@ -406,7 +406,7 @@ func TestCopyAutonomyProposalRule(t *testing.T) {
...
@@ -406,7 +406,7 @@ func TestCopyAutonomyProposalRule(t *testing.T) {
Status
:
2
,
Status
:
2
,
Address
:
"123"
,
Address
:
"123"
,
}
}
new
:=
copyAutonomyProposalRule
(
cur
)
pre
:=
copyAutonomyProposalRule
(
cur
)
cur
.
PropRule
.
Year
=
1800
cur
.
PropRule
.
Year
=
1800
cur
.
PropRule
.
Month
=
2
cur
.
PropRule
.
Month
=
2
cur
.
PropRule
.
RuleCfg
.
BoardApproveRatio
=
90
cur
.
PropRule
.
RuleCfg
.
BoardApproveRatio
=
90
...
@@ -415,13 +415,13 @@ func TestCopyAutonomyProposalRule(t *testing.T) {
...
@@ -415,13 +415,13 @@ func TestCopyAutonomyProposalRule(t *testing.T) {
cur
.
Address
=
"234"
cur
.
Address
=
"234"
cur
.
Status
=
1
cur
.
Status
=
1
require
.
Equal
(
t
,
1900
,
int
(
new
.
PropRule
.
Year
))
require
.
Equal
(
t
,
1900
,
int
(
pre
.
PropRule
.
Year
))
require
.
Equal
(
t
,
1
,
int
(
new
.
PropRule
.
Month
))
require
.
Equal
(
t
,
1
,
int
(
pre
.
PropRule
.
Month
))
require
.
Equal
(
t
,
100
,
int
(
new
.
VoteResult
.
TotalVotes
))
require
.
Equal
(
t
,
100
,
int
(
pre
.
VoteResult
.
TotalVotes
))
require
.
Equal
(
t
,
"123"
,
new
.
Address
)
require
.
Equal
(
t
,
"123"
,
pre
.
Address
)
require
.
Equal
(
t
,
2
,
int
(
new
.
Status
))
require
.
Equal
(
t
,
2
,
int
(
pre
.
Status
))
require
.
Equal
(
t
,
80
,
int
(
new
.
PropRule
.
RuleCfg
.
BoardApproveRatio
))
require
.
Equal
(
t
,
80
,
int
(
pre
.
PropRule
.
RuleCfg
.
BoardApproveRatio
))
require
.
Equal
(
t
,
100
,
int
(
new
.
Rule
.
BoardApproveRatio
))
require
.
Equal
(
t
,
100
,
int
(
pre
.
Rule
.
BoardApproveRatio
))
}
}
func
TestUpgradeRule
(
t
*
testing
.
T
)
{
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