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
05b8ae47
Commit
05b8ae47
authored
Aug 22, 2019
by
liuyuhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify test
parent
ae572080
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
147 additions
and
45 deletions
+147
-45
proposal_project.go
plugin/dapp/autonomy/commands/proposal_project.go
+1
-1
boardaction.go
plugin/dapp/autonomy/executor/boardaction.go
+15
-1
boardaction_test.go
plugin/dapp/autonomy/executor/boardaction_test.go
+84
-5
projectaction.go
plugin/dapp/autonomy/executor/projectaction.go
+7
-1
projectaction_test.go
plugin/dapp/autonomy/executor/projectaction_test.go
+24
-20
ruleaction.go
plugin/dapp/autonomy/executor/ruleaction.go
+8
-1
ruleaction_test.go
plugin/dapp/autonomy/executor/ruleaction_test.go
+6
-16
errors.go
plugin/dapp/autonomy/types/errors.go
+2
-0
No files found.
plugin/dapp/autonomy/commands/proposal_project.go
View file @
05b8ae47
...
...
@@ -201,7 +201,7 @@ func PubVoteProposalProjectCmd() *cobra.Command {
func
addPubVoteProposalProjectFlags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
StringP
(
"proposalID"
,
"p"
,
""
,
"proposal ID"
)
cmd
.
MarkFlagRequired
(
"proposalID"
)
cmd
.
Flags
()
.
Int32P
(
"oppose"
,
"
o
"
,
1
,
"is oppose, default true"
)
cmd
.
Flags
()
.
Int32P
(
"oppose"
,
"
s
"
,
1
,
"is oppose, default true"
)
cmd
.
Flags
()
.
StringP
(
"originAddr"
,
"o"
,
""
,
"origin address: addr1-addr2......addrN"
)
}
...
...
plugin/dapp/autonomy/executor/boardaction.go
View file @
05b8ae47
...
...
@@ -62,11 +62,19 @@ func (a *action) propBoard(prob *auty.ProposalBoard) (*types.Receipt, error) {
return
nil
,
types
.
ErrInvalidParam
}
mpBd
:=
make
(
map
[
string
]
struct
{})
for
_
,
board
:=
range
prob
.
Boards
{
if
err
:=
address
.
CheckAddress
(
board
);
err
!=
nil
{
alog
.
Error
(
"propBoard "
,
"addr"
,
board
,
"check toAddr error"
,
err
)
return
nil
,
types
.
ErrInvalidAddress
}
// 提案board重复地址去重复
if
_
,
ok
:=
mpBd
[
board
];
ok
{
err
:=
auty
.
ErrRepeatAddr
alog
.
Error
(
"propBoard "
,
"addr"
,
board
,
"propBoard have repeat addr "
,
err
)
return
nil
,
err
}
mpBd
[
board
]
=
struct
{}{}
}
// 获取当前生效提案规则
...
...
@@ -188,8 +196,14 @@ func (a *action) votePropBoard(voteProb *auty.VoteProposalBoard) (*types.Receipt
return
nil
,
err
}
// 挖矿地址验证
if
len
(
voteProb
.
OriginAddr
)
>
0
{
for
_
,
board
:=
range
voteProb
.
OriginAddr
{
if
err
:=
address
.
CheckAddress
(
board
);
err
!=
nil
{
alog
.
Error
(
"votePropBoard "
,
"addr"
,
board
,
"check toAddr error"
,
err
)
return
nil
,
types
.
ErrInvalidAddress
}
}
// 挖矿地址验证
addr
,
err
:=
a
.
verifyMinerAddr
(
voteProb
.
OriginAddr
,
a
.
fromaddr
)
if
err
!=
nil
{
alog
.
Error
(
"votePropBoard "
,
"from addr"
,
a
.
fromaddr
,
"error addr"
,
addr
,
"ProposalID"
,
...
...
plugin/dapp/autonomy/executor/boardaction_test.go
View file @
05b8ae47
...
...
@@ -22,6 +22,8 @@ import (
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
ticketTy
"github.com/33cn/plugin/plugin/dapp/ticket/types"
ticket
"github.com/33cn/plugin/plugin/dapp/ticket/executor"
)
// ExecEnv exec environment
...
...
@@ -45,7 +47,42 @@ var (
AddrC
=
"1NLHPEcbTWWxxU3dGUZBhayjrCHD3psX7k"
AddrD
=
"1MCftFynyvG2F4ED5mdHYgziDxx6vDrScs"
boards
=
[]
string
{
"1KSBd17H7ZK8iT37aJztFB22XGwsPTdwE4"
,
"1JRNjdEqp4LJ5fqycUBm9ayCKSeeskgMKR"
,
"1NLHPEcbTWWxxU3dGUZBhayjrCHD3psX7k"
}
PrivKey1
=
"0x9d4f8ab11361be596468b265cb66946c87873d4a119713fd0c3d8302eae0a8e4"
PrivKey2
=
"0xd165c84ed37c2a427fea487470ee671b7a0495d68d82607cafbc6348bf23bec5"
PrivKey3
=
"0xc21d38be90493512a5c2417d565269a8b23ce8152010e404ff4f75efead8183a"
PrivKey4
=
"0xfdf2bbff853ecff2e7b86b2a8b45726c6538ca7d1403dc94e50131ef379bdca0"
PrivKey5
=
"0x794443611e7369a57b078881445b93b754cbc9b9b8f526535ab9c6d21d29203d"
PrivKey6
=
"0xf2cc48d30560e4c92e84821df68cf1086de82ee6a5725fc2a590a58d6ffe4fc5"
PrivKey7
=
"0xeb4738a7c685a7ccf5471c3335a2d7ebe284b11d8a1717d814904b8d1ba936d9"
PrivKey8
=
"0x9d315182e56fde7fadb94408d360203894e5134216944e858f9b31f70e9ecf40"
PrivKey9
=
"0x128de4afa7c061c00d854a1bca51b58e80a2c292583739e5aebf4c0f778959e1"
PrivKey10
=
"0x1c3e6cac2f887e1ab9180e2d5772dc4ba01accb8d4df434faba097003eb35482"
boards
=
[]
string
{
AddrA
,
AddrB
,
AddrC
,
AddrD
,
"12HKLEn6g4FH39yUbHh4EVJWcFo5CXg22d"
,
"1Ka7EPFRqs3v9yreXG6qA4RQbNmbPJCZPj"
,
"12cjnN5D4DPdBQSwh6vjwJbtsW4EJALTMv"
,
"1Luh4AziYyaC5zP3hUXtXFZS873xAxm6rH"
,
"1NNaYHkscJaLJ2wUrFNeh6cQXBS4TrFYeB"
,
"1L1puAUjfmtDECKo2C1qLWsAMZtDGTBWf6"
,
"1LNf9AVXzUMQkQM5hgGLhkdrVtD8UMBSUm"
,
"1PcGKYYoLn1PLLJJodc1UpgWGeFAQasAkx"
,
"1BM2xhBk95qoae8zKNDWwAVGgBERhb7DQu"
,
"1Q9sQwothzM1gKSzkVZ8Dt1tqKX1uzSagx"
,
"15VUiygdxMSZ3rykwe742yomp2cPJ9Tfve"
,
"1DyR84CU5AHbGXLEnhHMwMvWNMeunLZsuJ"
,
"132pBvrgSYgHASxzoeL3bqnsqUpaBbUktm"
,
"1DEV4XwdBUWRkMuy4ARRiEAoxQ2LoDByNG"
,
"18Y87cw2hiYC71bvpD872oYMYXtw66Qp6o"
,
"1Fghq6cgdJEDr6gQBmvba3t6aXAkyZyjr2"
,
"142KsfJLvEA5FJxAgKm9ZDtFVjkRaPdu82"
,
}
total
=
types
.
Coin
*
30000
)
...
...
@@ -277,7 +314,7 @@ func voteProposalBoard(t *testing.T, env *ExecEnv, exec drivers.Driver, stateDB
{
PrivKeyA
,
false
},
{
PrivKeyB
,
true
},
{
PrivKeyC
,
true
},
//
{PrivKeyD, true},
{
PrivKeyD
,
true
},
}
for
_
,
record
:=
range
records
{
...
...
@@ -475,7 +512,7 @@ func TestCopyAutonomyProposalBoard(t *testing.T) {
require
.
Nil
(
t
,
copyAutonomyProposalBoard
(
nil
))
cur
:=
&
auty
.
AutonomyProposalBoard
{
PropBoard
:
&
auty
.
ProposalBoard
{
Year
:
1900
,
Month
:
1
},
CurRule
:
&
auty
.
RuleConfig
{
BoardA
ttend
Ratio
:
100
},
CurRule
:
&
auty
.
RuleConfig
{
BoardA
pprove
Ratio
:
100
},
VoteResult
:
&
auty
.
VoteResult
{
TotalVotes
:
100
},
Status
:
2
,
Address
:
"123"
,
...
...
@@ -483,19 +520,61 @@ func TestCopyAutonomyProposalBoard(t *testing.T) {
pre
:=
copyAutonomyProposalBoard
(
cur
)
cur
.
PropBoard
.
Year
=
1800
cur
.
PropBoard
.
Month
=
2
cur
.
CurRule
.
BoardA
ttend
Ratio
=
90
cur
.
CurRule
.
BoardA
pprove
Ratio
=
90
cur
.
VoteResult
.
TotalVotes
=
50
cur
.
Address
=
"234"
cur
.
Status
=
1
require
.
Equal
(
t
,
1900
,
int
(
pre
.
PropBoard
.
Year
))
require
.
Equal
(
t
,
1
,
int
(
pre
.
PropBoard
.
Month
))
require
.
Equal
(
t
,
100
,
int
(
pre
.
CurRule
.
BoardA
ttend
Ratio
))
require
.
Equal
(
t
,
100
,
int
(
pre
.
CurRule
.
BoardA
pprove
Ratio
))
require
.
Equal
(
t
,
100
,
int
(
pre
.
VoteResult
.
TotalVotes
))
require
.
Equal
(
t
,
"123"
,
pre
.
Address
)
require
.
Equal
(
t
,
2
,
int
(
pre
.
Status
))
}
func
TestVerifyMinerAddr
(
t
*
testing
.
T
)
{
at
:=
newAutonomy
()
.
(
*
Autonomy
)
stateDB
,
_
:=
dbm
.
NewGoMemDB
(
"state"
,
"state"
,
100
)
at
.
SetStateDB
(
stateDB
)
tx
:=
&
types
.
Transaction
{}
action
:=
newAction
(
at
,
tx
,
0
)
addrs
:=
[]
string
{
AddrA
,
AddrB
,
AddrC
,
}
// 授权地址AddrD
for
_
,
addr
:=
range
addrs
{
tkBind
:=
&
ticketTy
.
TicketBind
{
MinerAddress
:
AddrD
,
ReturnAddress
:
addr
,
}
stateDB
.
Set
(
ticket
.
BindKey
(
addr
),
types
.
Encode
(
tkBind
))
}
_
,
err
:=
action
.
verifyMinerAddr
(
addrs
,
AddrD
)
require
.
NoError
(
t
,
err
)
// ErrMinerAddr
testf
:=
"12HKLEn6g4FH39yUbHh4EVJWcFo5CXg22d"
addrs
=
[]
string
{
testf
}
addr
,
err
:=
action
.
verifyMinerAddr
(
addrs
,
AddrD
)
require
.
Equal
(
t
,
auty
.
ErrMinerAddr
,
err
)
require
.
Equal
(
t
,
testf
,
addr
)
// ErrBindAddr
testf
=
"1Ka7EPFRqs3v9yreXG6qA4RQbNmbPJCZPj"
tkBind
:=
&
ticketTy
.
TicketBind
{
MinerAddress
:
AddrA
,
ReturnAddress
:
testf
,
}
stateDB
.
Set
(
ticket
.
BindKey
(
testf
),
types
.
Encode
(
tkBind
))
addrs
=
[]
string
{
testf
}
addr
,
err
=
action
.
verifyMinerAddr
(
addrs
,
AddrD
)
require
.
Equal
(
t
,
auty
.
ErrBindAddr
,
err
)
require
.
Equal
(
t
,
testf
,
addr
)
}
func
signTx
(
tx
*
types
.
Transaction
,
hexPrivKey
string
)
(
*
types
.
Transaction
,
error
)
{
signType
:=
types
.
SECP256K1
c
,
err
:=
crypto
.
New
(
types
.
GetSignName
(
auty
.
AutonomyX
,
signType
))
...
...
plugin/dapp/autonomy/executor/projectaction.go
View file @
05b8ae47
...
...
@@ -317,8 +317,14 @@ func (a *action) pubVotePropProject(voteProb *auty.PubVoteProposalProject) (*typ
return
nil
,
err
}
// 挖矿地址验证
if
len
(
voteProb
.
OriginAddr
)
>
0
{
for
_
,
board
:=
range
voteProb
.
OriginAddr
{
if
err
:=
address
.
CheckAddress
(
board
);
err
!=
nil
{
alog
.
Error
(
"pubVotePropProject "
,
"addr"
,
board
,
"check toAddr error"
,
err
)
return
nil
,
types
.
ErrInvalidAddress
}
}
// 挖矿地址验证
addr
,
err
:=
a
.
verifyMinerAddr
(
voteProb
.
OriginAddr
,
a
.
fromaddr
)
if
err
!=
nil
{
alog
.
Error
(
"pubVotePropProject "
,
"from addr"
,
a
.
fromaddr
,
"error addr"
,
addr
,
"ProposalID"
,
...
...
plugin/dapp/autonomy/executor/projectaction_test.go
View file @
05b8ae47
...
...
@@ -36,22 +36,15 @@ const (
func
InitBoard
(
stateDB
dbm
.
KV
)
{
// add active board
board
:=
&
auty
.
ProposalBoard
{
Year
:
2019
,
Month
:
11
,
Day
:
1
,
Boards
:
[]
string
{
AddrA
,
AddrB
,
AddrC
,
AddrD
},
StartBlockHeight
:
1
,
EndBlockHeight
:
10
,
RealEndBlockHeight
:
5
,
}
stateDB
.
Set
(
activeBoardID
(),
types
.
Encode
(
board
))
act
:=
&
auty
.
ActiveBoard
{
Boards
:
boards
,
}
stateDB
.
Set
(
activeBoardID
(),
types
.
Encode
(
act
))
}
func
InitRule
(
stateDB
dbm
.
KV
)
{
// add active rule
rule
:=
&
auty
.
RuleConfig
{
BoardAttendRatio
:
boardAttendRatio
,
BoardApproveRatio
:
boardApproveRatio
,
PubOpposeRatio
:
pubOpposeRatio
,
ProposalAmount
:
proposalAmount
,
...
...
@@ -317,10 +310,21 @@ func voteProposalProject(t *testing.T, env *ExecEnv, exec drivers.Driver, stateD
appr
bool
}
records
:=
[]
record
{
{
PrivKeyA
,
fals
e
},
{
PrivKeyA
,
tru
e
},
{
PrivKeyB
,
true
},
{
PrivKeyC
,
true
},
//{PrivKeyD, true},
{
PrivKeyD
,
true
},
{
PrivKey1
,
true
},
{
PrivKey2
,
true
},
{
PrivKey3
,
true
},
{
PrivKey4
,
true
},
{
PrivKey5
,
true
},
{
PrivKey6
,
true
},
{
PrivKey7
,
true
},
{
PrivKey8
,
true
},
{
PrivKey9
,
true
},
{
PrivKey10
,
true
},
}
for
_
,
record
:=
range
records
{
...
...
@@ -590,7 +594,7 @@ func terminateProposalProjectTx(parm *auty.TerminateProposalProject) (*types.Tra
func
TestGetProjectReceiptLog
(
t
*
testing
.
T
)
{
pre
:=
&
auty
.
AutonomyProposalProject
{
PropProject
:
&
auty
.
ProposalProject
{
Year
:
1800
,
Month
:
1
},
CurRule
:
&
auty
.
RuleConfig
{
BoardA
ttend
Ratio
:
80
},
CurRule
:
&
auty
.
RuleConfig
{
BoardA
pprove
Ratio
:
80
},
Boards
:
[]
string
{
"111"
,
"222"
,
"333"
},
BoardVoteRes
:
&
auty
.
VoteResult
{
TotalVotes
:
100
},
Status
:
1
,
...
...
@@ -598,7 +602,7 @@ func TestGetProjectReceiptLog(t *testing.T) {
}
cur
:=
&
auty
.
AutonomyProposalProject
{
PropProject
:
&
auty
.
ProposalProject
{
Year
:
1900
,
Month
:
1
},
CurRule
:
&
auty
.
RuleConfig
{
BoardA
ttend
Ratio
:
90
},
CurRule
:
&
auty
.
RuleConfig
{
BoardA
pprove
Ratio
:
90
},
Boards
:
[]
string
{
"555"
,
"666"
,
"777"
},
BoardVoteRes
:
&
auty
.
VoteResult
{
TotalVotes
:
100
},
Status
:
2
,
...
...
@@ -611,8 +615,8 @@ func TestGetProjectReceiptLog(t *testing.T) {
require
.
NoError
(
t
,
err
)
require
.
Equal
(
t
,
int32
(
1800
),
recpt
.
Prev
.
PropProject
.
Year
)
require
.
Equal
(
t
,
int32
(
1900
),
recpt
.
Current
.
PropProject
.
Year
)
require
.
Equal
(
t
,
int32
(
80
),
recpt
.
Prev
.
CurRule
.
BoardA
ttend
Ratio
)
require
.
Equal
(
t
,
int32
(
90
),
recpt
.
Current
.
CurRule
.
BoardA
ttend
Ratio
)
require
.
Equal
(
t
,
int32
(
80
),
recpt
.
Prev
.
CurRule
.
BoardA
pprove
Ratio
)
require
.
Equal
(
t
,
int32
(
90
),
recpt
.
Current
.
CurRule
.
BoardA
pprove
Ratio
)
require
.
Equal
(
t
,
[]
string
{
"111"
,
"222"
,
"333"
},
recpt
.
Prev
.
Boards
)
require
.
Equal
(
t
,
[]
string
{
"555"
,
"666"
,
"777"
},
recpt
.
Current
.
Boards
)
}
...
...
@@ -621,7 +625,7 @@ func TestCopyAutonomyProposalProject(t *testing.T) {
require
.
Nil
(
t
,
copyAutonomyProposalProject
(
nil
))
cur
:=
&
auty
.
AutonomyProposalProject
{
PropProject
:
&
auty
.
ProposalProject
{
Year
:
1800
,
Month
:
1
},
CurRule
:
&
auty
.
RuleConfig
{
BoardA
ttend
Ratio
:
80
},
CurRule
:
&
auty
.
RuleConfig
{
BoardA
pprove
Ratio
:
80
},
Boards
:
[]
string
{
"111"
,
"222"
,
"333"
},
BoardVoteRes
:
&
auty
.
VoteResult
{
TotalVotes
:
100
},
PubVote
:
&
auty
.
PublicVote
{
Publicity
:
true
},
...
...
@@ -631,7 +635,7 @@ func TestCopyAutonomyProposalProject(t *testing.T) {
pre
:=
copyAutonomyProposalProject
(
cur
)
cur
.
PropProject
.
Year
=
1900
cur
.
PropProject
.
Month
=
2
cur
.
CurRule
.
BoardA
ttend
Ratio
=
90
cur
.
CurRule
.
BoardA
pprove
Ratio
=
90
cur
.
Boards
=
[]
string
{
"555"
,
"666"
,
"777"
}
cur
.
BoardVoteRes
.
TotalVotes
=
90
cur
.
PubVote
.
Publicity
=
false
...
...
@@ -641,7 +645,7 @@ func TestCopyAutonomyProposalProject(t *testing.T) {
require
.
Equal
(
t
,
1800
,
int
(
pre
.
PropProject
.
Year
))
require
.
Equal
(
t
,
1
,
int
(
pre
.
PropProject
.
Month
))
require
.
Equal
(
t
,
[]
string
{
"111"
,
"222"
,
"333"
},
pre
.
Boards
)
require
.
Equal
(
t
,
80
,
int
(
pre
.
CurRule
.
BoardA
ttend
Ratio
))
require
.
Equal
(
t
,
80
,
int
(
pre
.
CurRule
.
BoardA
pprove
Ratio
))
require
.
Equal
(
t
,
"123"
,
pre
.
Address
)
require
.
Equal
(
t
,
2
,
int
(
pre
.
Status
))
require
.
Equal
(
t
,
100
,
int
(
pre
.
BoardVoteRes
.
TotalVotes
))
...
...
plugin/dapp/autonomy/executor/ruleaction.go
View file @
05b8ae47
...
...
@@ -10,6 +10,7 @@ import (
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
"github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/common/address"
)
const
(
...
...
@@ -178,8 +179,14 @@ func (a *action) votePropRule(voteProb *auty.VoteProposalRule) (*types.Receipt,
return
nil
,
err
}
// 挖矿地址验证
if
len
(
voteProb
.
OriginAddr
)
>
0
{
for
_
,
board
:=
range
voteProb
.
OriginAddr
{
if
err
:=
address
.
CheckAddress
(
board
);
err
!=
nil
{
alog
.
Error
(
"votePropRule "
,
"addr"
,
board
,
"check toAddr error"
,
err
)
return
nil
,
types
.
ErrInvalidAddress
}
}
// 挖矿地址验证
addr
,
err
:=
a
.
verifyMinerAddr
(
voteProb
.
OriginAddr
,
a
.
fromaddr
)
if
err
!=
nil
{
alog
.
Error
(
"votePropRule "
,
"from addr"
,
a
.
fromaddr
,
"error addr"
,
addr
,
"ProposalID"
,
...
...
plugin/dapp/autonomy/executor/ruleaction_test.go
View file @
05b8ae47
...
...
@@ -21,12 +21,11 @@ import (
)
const
(
testBoardAttendRatio
int32
=
60
testBoardApproveRatio
int32
=
60
testPubOpposeRatio
int32
=
3
0
testProposalAmount
int64
=
0
testLargeProjectAmount
int64
=
1
testPublicPeriod
int32
=
100
testPubOpposeRatio
int32
=
3
5
testProposalAmount
=
minProposalAmount
*
2
testLargeProjectAmount
=
minLargeProjectAmount
*
2
testPublicPeriod
=
minPublicPeriod
)
func
TestRevokeProposalRule
(
t
*
testing
.
T
)
{
...
...
@@ -59,7 +58,6 @@ func testPropRule(t *testing.T, env *ExecEnv, exec drivers.Driver, stateDB dbm.K
Month
:
7
,
Day
:
10
,
RuleCfg
:
&
auty
.
RuleConfig
{
BoardAttendRatio
:
testBoardAttendRatio
,
BoardApproveRatio
:
testBoardApproveRatio
,
PubOpposeRatio
:
testPubOpposeRatio
,
ProposalAmount
:
testProposalAmount
,
...
...
@@ -164,7 +162,6 @@ func revokeProposalRule(t *testing.T, env *ExecEnv, exec drivers.Driver, stateDB
action
:=
newAction
(
au
,
&
types
.
Transaction
{},
0
)
rule
,
err
:=
action
.
getActiveRule
()
require
.
NoError
(
t
,
err
)
require
.
Equal
(
t
,
rule
.
BoardAttendRatio
,
boardAttendRatio
)
require
.
Equal
(
t
,
rule
.
BoardApproveRatio
,
boardApproveRatio
)
require
.
Equal
(
t
,
rule
.
PubOpposeRatio
,
pubOpposeRatio
)
require
.
Equal
(
t
,
rule
.
ProposalAmount
,
proposalAmount
)
...
...
@@ -218,7 +215,7 @@ func voteProposalRule(t *testing.T, env *ExecEnv, exec drivers.Driver, stateDB d
{
PrivKeyA
,
false
},
{
PrivKeyB
,
true
},
{
PrivKeyC
,
true
},
//
{PrivKeyD, true},
{
PrivKeyD
,
true
},
}
for
_
,
record
:=
range
records
{
...
...
@@ -291,10 +288,9 @@ func voteProposalRule(t *testing.T, env *ExecEnv, exec drivers.Driver, stateDB d
action
:=
newAction
(
au
,
&
types
.
Transaction
{},
0
)
rule
,
err
:=
action
.
getActiveRule
()
require
.
NoError
(
t
,
err
)
require
.
Equal
(
t
,
rule
.
BoardAttendRatio
,
testBoardAttendRatio
)
require
.
Equal
(
t
,
rule
.
BoardApproveRatio
,
testBoardApproveRatio
)
require
.
Equal
(
t
,
rule
.
PubOpposeRatio
,
testPubOpposeRatio
)
require
.
Equal
(
t
,
rule
.
ProposalAmount
,
p
roposalAmount
)
require
.
Equal
(
t
,
rule
.
ProposalAmount
,
testP
roposalAmount
)
require
.
Equal
(
t
,
rule
.
LargeProjectAmount
,
testLargeProjectAmount
)
require
.
Equal
(
t
,
rule
.
PublicPeriod
,
testPublicPeriod
)
}
...
...
@@ -373,7 +369,6 @@ func terminateProposalRule(t *testing.T, env *ExecEnv, exec drivers.Driver, stat
action
:=
newAction
(
au
,
&
types
.
Transaction
{},
0
)
rule
,
err
:=
action
.
getActiveRule
()
require
.
NoError
(
t
,
err
)
require
.
Equal
(
t
,
rule
.
BoardAttendRatio
,
boardAttendRatio
)
require
.
Equal
(
t
,
rule
.
BoardApproveRatio
,
boardApproveRatio
)
require
.
Equal
(
t
,
rule
.
PubOpposeRatio
,
pubOpposeRatio
)
require
.
Equal
(
t
,
rule
.
ProposalAmount
,
proposalAmount
)
...
...
@@ -445,7 +440,6 @@ func TestUpgradeRule(t *testing.T) {
new
:=
upgradeRule
(
nil
,
&
auty
.
RuleConfig
{})
require
.
Nil
(
t
,
new
)
cur
:=
&
auty
.
RuleConfig
{
BoardAttendRatio
:
1
,
BoardApproveRatio
:
2
,
PubOpposeRatio
:
3
,
ProposalAmount
:
4
,
...
...
@@ -453,7 +447,6 @@ func TestUpgradeRule(t *testing.T) {
PublicPeriod
:
6
,
}
modify
:=
&
auty
.
RuleConfig
{
BoardAttendRatio
:
0
,
BoardApproveRatio
:
-
1
,
PubOpposeRatio
:
0
,
ProposalAmount
:
-
1
,
...
...
@@ -462,7 +455,6 @@ func TestUpgradeRule(t *testing.T) {
}
new
=
upgradeRule
(
cur
,
modify
)
require
.
NotNil
(
t
,
new
)
require
.
Equal
(
t
,
new
.
BoardAttendRatio
,
cur
.
BoardAttendRatio
)
require
.
Equal
(
t
,
new
.
BoardApproveRatio
,
cur
.
BoardApproveRatio
)
require
.
Equal
(
t
,
new
.
PubOpposeRatio
,
cur
.
PubOpposeRatio
)
require
.
Equal
(
t
,
new
.
ProposalAmount
,
cur
.
ProposalAmount
)
...
...
@@ -470,7 +462,6 @@ func TestUpgradeRule(t *testing.T) {
require
.
Equal
(
t
,
new
.
PublicPeriod
,
cur
.
PublicPeriod
)
modify
=
&
auty
.
RuleConfig
{
BoardAttendRatio
:
10
,
BoardApproveRatio
:
20
,
PubOpposeRatio
:
30
,
ProposalAmount
:
40
,
...
...
@@ -479,7 +470,6 @@ func TestUpgradeRule(t *testing.T) {
}
new
=
upgradeRule
(
cur
,
modify
)
require
.
NotNil
(
t
,
new
)
require
.
Equal
(
t
,
new
.
BoardAttendRatio
,
modify
.
BoardAttendRatio
)
require
.
Equal
(
t
,
new
.
BoardApproveRatio
,
modify
.
BoardApproveRatio
)
require
.
Equal
(
t
,
new
.
PubOpposeRatio
,
modify
.
PubOpposeRatio
)
require
.
Equal
(
t
,
new
.
ProposalAmount
,
modify
.
ProposalAmount
)
...
...
plugin/dapp/autonomy/types/errors.go
View file @
05b8ae47
...
...
@@ -33,4 +33,6 @@ var (
ErrChangeBoardAddr
=
errors
.
New
(
"ErrChangeBoardAddr"
)
// ErrBoardNumber 董事会成员数错误
ErrBoardNumber
=
errors
.
New
(
"ErrBoardNumber"
)
// ErrRepeatAddr 重复地址
ErrRepeatAddr
=
errors
.
New
(
"ErrRepeatAddr"
)
)
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