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
cf9a539d
Commit
cf9a539d
authored
Jul 25, 2019
by
vipwzw
Committed by
33cn
Aug 14, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto ci
parent
8c44c577
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
33 changed files
with
394 additions
and
308 deletions
+394
-308
proposal_board.go
plugin/dapp/autonomy/commands/proposal_board.go
+2
-3
proposal_project.go
plugin/dapp/autonomy/commands/proposal_project.go
+5
-6
proposal_rule.go
plugin/dapp/autonomy/commands/proposal_rule.go
+11
-11
autonomy.go
plugin/dapp/autonomy/executor/autonomy.go
+1
-2
board.go
plugin/dapp/autonomy/executor/board.go
+3
-2
board_test.go
plugin/dapp/autonomy/executor/board_test.go
+21
-20
boardaction.go
plugin/dapp/autonomy/executor/boardaction.go
+17
-18
boardaction_test.go
plugin/dapp/autonomy/executor/boardaction_test.go
+26
-27
exec.go
plugin/dapp/autonomy/executor/exec.go
+0
-0
exec_del_local.go
plugin/dapp/autonomy/executor/exec_del_local.go
+3
-3
exec_local.go
plugin/dapp/autonomy/executor/exec_local.go
+3
-3
kv.go
plugin/dapp/autonomy/executor/kv.go
+4
-4
project.go
plugin/dapp/autonomy/executor/project.go
+0
-0
project_test.go
plugin/dapp/autonomy/executor/project_test.go
+21
-20
projectaction.go
plugin/dapp/autonomy/executor/projectaction.go
+16
-18
projectaction_test.go
plugin/dapp/autonomy/executor/projectaction_test.go
+42
-42
query.go
plugin/dapp/autonomy/executor/query.go
+0
-3
rule.go
plugin/dapp/autonomy/executor/rule.go
+0
-0
rule_test.go
plugin/dapp/autonomy/executor/rule_test.go
+43
-42
ruleaction.go
plugin/dapp/autonomy/executor/ruleaction.go
+13
-17
ruleaction_test.go
plugin/dapp/autonomy/executor/ruleaction_test.go
+31
-32
board_jrpc_channel_test.go
plugin/dapp/autonomy/rpc/board_jrpc_channel_test.go
+2
-3
jrpc.go
plugin/dapp/autonomy/rpc/jrpc.go
+0
-0
project_jrpc_channel_test.go
plugin/dapp/autonomy/rpc/project_jrpc_channel_test.go
+2
-4
rpc.go
plugin/dapp/autonomy/rpc/rpc.go
+0
-0
rule_jrpc_channel_test.go
plugin/dapp/autonomy/rpc/rule_jrpc_channel_test.go
+2
-2
autonomy.pb.go
plugin/dapp/autonomy/types/autonomy.pb.go
+0
-0
board.pb.go
plugin/dapp/autonomy/types/board.pb.go
+0
-0
const.go
plugin/dapp/autonomy/types/const.go
+0
-1
lcommon.pb.go
plugin/dapp/autonomy/types/lcommon.pb.go
+125
-24
project.pb.go
plugin/dapp/autonomy/types/project.pb.go
+0
-0
rule.pb.go
plugin/dapp/autonomy/types/rule.pb.go
+0
-0
types.go
plugin/dapp/autonomy/types/types.go
+1
-1
No files found.
plugin/dapp/autonomy/commands/proposal_board.go
View file @
cf9a539d
...
@@ -10,11 +10,10 @@ import (
...
@@ -10,11 +10,10 @@ import (
jsonrpc
"github.com/33cn/chain33/rpc/jsonclient"
jsonrpc
"github.com/33cn/chain33/rpc/jsonclient"
rpctypes
"github.com/33cn/chain33/rpc/types"
rpctypes
"github.com/33cn/chain33/rpc/types"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
"github.com/spf13/cobra"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
"github.com/spf13/cobra"
)
)
// AutonomyCmd 自治系统命令行
// AutonomyCmd 自治系统命令行
func
AutonomyCmd
()
*
cobra
.
Command
{
func
AutonomyCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
...
@@ -228,7 +227,7 @@ func addShowProposalBoardflags(cmd *cobra.Command) {
...
@@ -228,7 +227,7 @@ func addShowProposalBoardflags(cmd *cobra.Command) {
func
showProposalBoard
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
showProposalBoard
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
typ
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"type"
)
typ
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"type"
)
propID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
propID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
status
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"status"
)
status
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"status"
)
count
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"count"
)
count
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"count"
)
direction
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"direction"
)
direction
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"direction"
)
...
...
plugin/dapp/autonomy/commands/proposal_project.go
View file @
cf9a539d
...
@@ -5,11 +5,11 @@
...
@@ -5,11 +5,11 @@
package
commands
package
commands
import
(
import
(
"github.com/spf13/cobra"
"github.com/33cn/chain33/types"
jsonrpc
"github.com/33cn/chain33/rpc/jsonclient"
jsonrpc
"github.com/33cn/chain33/rpc/jsonclient"
rpctypes
"github.com/33cn/chain33/rpc/types"
rpctypes
"github.com/33cn/chain33/rpc/types"
"github.com/33cn/chain33/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
"github.com/spf13/cobra"
)
)
// ProposalProjectCmd 创建提案命令
// ProposalProjectCmd 创建提案命令
...
@@ -78,12 +78,12 @@ func proposalProject(cmd *cobra.Command, args []string) {
...
@@ -78,12 +78,12 @@ func proposalProject(cmd *cobra.Command, args []string) {
Production
:
production
,
Production
:
production
,
Description
:
description
,
Description
:
description
,
Contractor
:
contractor
,
Contractor
:
contractor
,
Amount
:
amount
*
types
.
Coin
,
Amount
:
amount
*
types
.
Coin
,
AmountDetail
:
amountDetail
,
AmountDetail
:
amountDetail
,
ToAddr
:
toAddr
,
ToAddr
:
toAddr
,
StartBlockHeight
:
startBlock
,
StartBlockHeight
:
startBlock
,
EndBlockHeight
:
endBlock
,
EndBlockHeight
:
endBlock
,
ProjectNeedBlockNum
:
projectNeedBlockNum
,
ProjectNeedBlockNum
:
projectNeedBlockNum
,
}
}
var
res
string
var
res
string
...
@@ -194,7 +194,6 @@ func pubVoteProposalProject(cmd *cobra.Command, args []string) {
...
@@ -194,7 +194,6 @@ func pubVoteProposalProject(cmd *cobra.Command, args []string) {
ctx
.
RunWithoutMarshal
()
ctx
.
RunWithoutMarshal
()
}
}
// TerminateProposalProject 终止提案
// TerminateProposalProject 终止提案
func
TerminateProposalProjectCmd
()
*
cobra
.
Command
{
func
TerminateProposalProjectCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
...
@@ -248,7 +247,7 @@ func addShowProposalProjectflags(cmd *cobra.Command) {
...
@@ -248,7 +247,7 @@ func addShowProposalProjectflags(cmd *cobra.Command) {
func
showProposalProject
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
showProposalProject
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
typ
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"type"
)
typ
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"type"
)
propID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
propID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
status
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"status"
)
status
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"status"
)
count
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"count"
)
count
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"count"
)
direction
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"direction"
)
direction
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"direction"
)
...
...
plugin/dapp/autonomy/commands/proposal_rule.go
View file @
cf9a539d
...
@@ -8,8 +8,8 @@ import (
...
@@ -8,8 +8,8 @@ import (
jsonrpc
"github.com/33cn/chain33/rpc/jsonclient"
jsonrpc
"github.com/33cn/chain33/rpc/jsonclient"
rpctypes
"github.com/33cn/chain33/rpc/types"
rpctypes
"github.com/33cn/chain33/rpc/types"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
"github.com/spf13/cobra"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
"github.com/spf13/cobra"
)
)
// ProposalRuleCmd 创建提案命令
// ProposalRuleCmd 创建提案命令
...
@@ -197,7 +197,7 @@ func addShowProposalRuleflags(cmd *cobra.Command) {
...
@@ -197,7 +197,7 @@ func addShowProposalRuleflags(cmd *cobra.Command) {
func
showProposalRule
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
showProposalRule
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
typ
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"type"
)
typ
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"type"
)
propID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
propID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
status
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"status"
)
status
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"status"
)
count
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"count"
)
count
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"count"
)
direction
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"direction"
)
direction
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"direction"
)
...
@@ -248,10 +248,10 @@ func addTransferFundflags(cmd *cobra.Command) {
...
@@ -248,10 +248,10 @@ func addTransferFundflags(cmd *cobra.Command) {
func
transferFund
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
transferFund
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
amount
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"amount"
)
amount
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"amount"
)
note
,
_
:=
cmd
.
Flags
()
.
GetString
(
"note"
)
note
,
_
:=
cmd
.
Flags
()
.
GetString
(
"note"
)
params
:=
&
auty
.
TransferFund
{
params
:=
&
auty
.
TransferFund
{
Amount
:
amount
*
types
.
Coin
,
Amount
:
amount
*
types
.
Coin
,
Note
:
note
,
Note
:
note
,
}
}
var
res
string
var
res
string
...
@@ -280,14 +280,14 @@ func addCommentProposalflags(cmd *cobra.Command) {
...
@@ -280,14 +280,14 @@ func addCommentProposalflags(cmd *cobra.Command) {
func
commentProposal
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
commentProposal
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
proposalID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
proposalID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
repCmtHash
,
_
:=
cmd
.
Flags
()
.
GetString
(
"repCmtHash"
)
repCmtHash
,
_
:=
cmd
.
Flags
()
.
GetString
(
"repCmtHash"
)
comment
,
_
:=
cmd
.
Flags
()
.
GetString
(
"comment"
)
comment
,
_
:=
cmd
.
Flags
()
.
GetString
(
"comment"
)
params
:=
&
auty
.
Comment
{
params
:=
&
auty
.
Comment
{
ProposalID
:
proposalID
,
ProposalID
:
proposalID
,
RepCmtHash
:
repCmtHash
,
RepCmtHash
:
repCmtHash
,
Comment
:
comment
,
Comment
:
comment
,
}
}
var
res
string
var
res
string
ctx
:=
jsonrpc
.
NewRPCCtx
(
rpcLaddr
,
"autonomy.CommentProposalTx"
,
params
,
&
res
)
ctx
:=
jsonrpc
.
NewRPCCtx
(
rpcLaddr
,
"autonomy.CommentProposalTx"
,
params
,
&
res
)
...
@@ -315,7 +315,7 @@ func addShowProposalCommentflags(cmd *cobra.Command) {
...
@@ -315,7 +315,7 @@ func addShowProposalCommentflags(cmd *cobra.Command) {
func
showProposalComment
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
showProposalComment
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
propID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
propID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
count
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"count"
)
count
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"count"
)
direction
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"direction"
)
direction
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"direction"
)
index
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"index"
)
index
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"index"
)
...
...
plugin/dapp/autonomy/executor/autonomy.go
View file @
cf9a539d
...
@@ -5,11 +5,11 @@
...
@@ -5,11 +5,11 @@
package
executor
package
executor
import
(
import
(
"github.com/33cn/chain33/common/address"
log
"github.com/33cn/chain33/common/log/log15"
log
"github.com/33cn/chain33/common/log/log15"
drivers
"github.com/33cn/chain33/system/dapp"
drivers
"github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
"github.com/33cn/chain33/common/address"
)
)
var
(
var
(
...
@@ -19,7 +19,6 @@ var (
...
@@ -19,7 +19,6 @@ var (
autonomyFundAddr
=
address
.
ExecAddress
(
"autonomyfund"
)
autonomyFundAddr
=
address
.
ExecAddress
(
"autonomyfund"
)
)
)
func
init
()
{
func
init
()
{
ety
:=
types
.
LoadExecutorType
(
driverName
)
ety
:=
types
.
LoadExecutorType
(
driverName
)
ety
.
InitFuncList
(
types
.
ListMethod
(
&
Autonomy
{}))
ety
.
InitFuncList
(
types
.
ListMethod
(
&
Autonomy
{}))
...
...
plugin/dapp/autonomy/executor/board.go
View file @
cf9a539d
...
@@ -5,10 +5,11 @@
...
@@ -5,10 +5,11 @@
package
executor
package
executor
import
(
import
(
"fmt"
"github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
"fmt"
)
)
func
(
a
*
Autonomy
)
execLocalBoard
(
receiptData
*
types
.
ReceiptData
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
a
*
Autonomy
)
execLocalBoard
(
receiptData
*
types
.
ReceiptData
)
(
*
types
.
LocalDBSet
,
error
)
{
...
@@ -112,7 +113,7 @@ func (a *Autonomy) getProposalBoard(req *types.ReqString) (types.Message, error)
...
@@ -112,7 +113,7 @@ func (a *Autonomy) getProposalBoard(req *types.ReqString) (types.Message, error)
return
rep
,
nil
return
rep
,
nil
}
}
func
(
a
*
Autonomy
)
listProposalBoard
(
req
*
auty
.
ReqQueryProposalBoard
)
(
types
.
Message
,
error
)
{
func
(
a
*
Autonomy
)
listProposalBoard
(
req
*
auty
.
ReqQueryProposalBoard
)
(
types
.
Message
,
error
)
{
if
req
==
nil
{
if
req
==
nil
{
return
nil
,
types
.
ErrInvalidParam
return
nil
,
types
.
ErrInvalidParam
}
}
...
...
plugin/dapp/autonomy/executor/board_test.go
View file @
cf9a539d
...
@@ -6,11 +6,12 @@ package executor
...
@@ -6,11 +6,12 @@ package executor
import
(
import
(
"testing"
"testing"
"github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/util"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/require"
"github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/util"
)
)
func
TestExecLocalBoard
(
t
*
testing
.
T
)
{
func
TestExecLocalBoard
(
t
*
testing
.
T
)
{
...
@@ -31,7 +32,7 @@ func TestExecLocalBoard(t *testing.T) {
...
@@ -31,7 +32,7 @@ func TestExecLocalBoard(t *testing.T) {
}
}
receipt
:=
&
types
.
ReceiptData
{
receipt
:=
&
types
.
ReceiptData
{
Logs
:
[]
*
types
.
ReceiptLog
{
Logs
:
[]
*
types
.
ReceiptLog
{
{
Ty
:
auty
.
TyLogPropBoard
,
Log
:
types
.
Encode
(
receiptBoard
)},
{
Ty
:
auty
.
TyLogPropBoard
,
Log
:
types
.
Encode
(
receiptBoard
)},
},
},
}
}
set
,
err
:=
au
.
execLocalBoard
(
receipt
)
set
,
err
:=
au
.
execLocalBoard
(
receipt
)
...
@@ -51,7 +52,7 @@ func TestExecLocalBoard(t *testing.T) {
...
@@ -51,7 +52,7 @@ func TestExecLocalBoard(t *testing.T) {
}
}
set
,
err
=
au
.
execLocalBoard
(
&
types
.
ReceiptData
{
set
,
err
=
au
.
execLocalBoard
(
&
types
.
ReceiptData
{
Logs
:
[]
*
types
.
ReceiptLog
{
Logs
:
[]
*
types
.
ReceiptLog
{
{
Ty
:
auty
.
TyLogRvkPropBoard
,
Log
:
types
.
Encode
(
receiptBoard1
)},
{
Ty
:
auty
.
TyLogRvkPropBoard
,
Log
:
types
.
Encode
(
receiptBoard1
)},
},
},
})
})
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
...
@@ -76,7 +77,7 @@ func TestExecLocalBoard(t *testing.T) {
...
@@ -76,7 +77,7 @@ func TestExecLocalBoard(t *testing.T) {
}
}
set
,
err
=
au
.
execLocalBoard
(
&
types
.
ReceiptData
{
set
,
err
=
au
.
execLocalBoard
(
&
types
.
ReceiptData
{
Logs
:
[]
*
types
.
ReceiptLog
{
Logs
:
[]
*
types
.
ReceiptLog
{
{
Ty
:
auty
.
TyLogVotePropBoard
,
Log
:
types
.
Encode
(
receiptBoard2
)},
{
Ty
:
auty
.
TyLogVotePropBoard
,
Log
:
types
.
Encode
(
receiptBoard2
)},
},
},
})
})
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
...
@@ -106,7 +107,7 @@ func TestExecDelLocalBoard(t *testing.T) {
...
@@ -106,7 +107,7 @@ func TestExecDelLocalBoard(t *testing.T) {
}
}
receipt
:=
&
types
.
ReceiptData
{
receipt
:=
&
types
.
ReceiptData
{
Logs
:
[]
*
types
.
ReceiptLog
{
Logs
:
[]
*
types
.
ReceiptLog
{
{
Ty
:
auty
.
TyLogPropBoard
,
Log
:
types
.
Encode
(
receiptBoard
)},
{
Ty
:
auty
.
TyLogPropBoard
,
Log
:
types
.
Encode
(
receiptBoard
)},
},
},
}
}
set
,
err
:=
au
.
execDelLocalBoard
(
receipt
)
set
,
err
:=
au
.
execDelLocalBoard
(
receipt
)
...
@@ -127,7 +128,7 @@ func TestExecDelLocalBoard(t *testing.T) {
...
@@ -127,7 +128,7 @@ func TestExecDelLocalBoard(t *testing.T) {
}
}
set
,
err
=
au
.
execDelLocalBoard
(
&
types
.
ReceiptData
{
set
,
err
=
au
.
execDelLocalBoard
(
&
types
.
ReceiptData
{
Logs
:
[]
*
types
.
ReceiptLog
{
Logs
:
[]
*
types
.
ReceiptLog
{
{
Ty
:
auty
.
TyLogVotePropBoard
,
Log
:
types
.
Encode
(
receiptBoard2
)},
{
Ty
:
auty
.
TyLogVotePropBoard
,
Log
:
types
.
Encode
(
receiptBoard2
)},
},
},
})
})
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
...
@@ -148,7 +149,7 @@ func TestGetProposalBoard(t *testing.T) {
...
@@ -148,7 +149,7 @@ func TestGetProposalBoard(t *testing.T) {
au
.
SetStateDB
(
storedb
)
au
.
SetStateDB
(
storedb
)
tx
:=
"1111111111111111111"
tx
:=
"1111111111111111111"
storedb
.
Set
(
propBoardID
(
tx
),
types
.
Encode
(
&
auty
.
AutonomyProposalBoard
{}))
storedb
.
Set
(
propBoardID
(
tx
),
types
.
Encode
(
&
auty
.
AutonomyProposalBoard
{}))
rsp
,
err
:=
au
.
getProposalBoard
(
&
types
.
ReqString
{
Data
:
tx
})
rsp
,
err
:=
au
.
getProposalBoard
(
&
types
.
ReqString
{
Data
:
tx
})
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
rsp
)
require
.
NotNil
(
t
,
rsp
)
require
.
Equal
(
t
,
len
(
rsp
.
(
*
auty
.
ReplyQueryProposalBoard
)
.
PropBoards
),
1
)
require
.
Equal
(
t
,
len
(
rsp
.
(
*
auty
.
ReplyQueryProposalBoard
)
.
PropBoards
),
1
)
...
@@ -201,9 +202,9 @@ func TestListProposalBoard(t *testing.T) {
...
@@ -201,9 +202,9 @@ func TestListProposalBoard(t *testing.T) {
// 反向查找
// 反向查找
req
:=
&
auty
.
ReqQueryProposalBoard
{
req
:=
&
auty
.
ReqQueryProposalBoard
{
Status
:
auty
.
AutonomyStatusProposalBoard
,
Status
:
auty
.
AutonomyStatusProposalBoard
,
Count
:
10
,
Count
:
10
,
Direction
:
0
,
Direction
:
0
,
Index
:
-
1
,
Index
:
-
1
,
}
}
rsp
,
err
:=
au
.
listProposalBoard
(
req
)
rsp
,
err
:=
au
.
listProposalBoard
(
req
)
...
@@ -218,9 +219,9 @@ func TestListProposalBoard(t *testing.T) {
...
@@ -218,9 +219,9 @@ func TestListProposalBoard(t *testing.T) {
// 正向查找
// 正向查找
req
=
&
auty
.
ReqQueryProposalBoard
{
req
=
&
auty
.
ReqQueryProposalBoard
{
Status
:
auty
.
AutonomyStatusProposalBoard
,
Status
:
auty
.
AutonomyStatusProposalBoard
,
Count
:
10
,
Count
:
10
,
Direction
:
1
,
Direction
:
1
,
Index
:
-
1
,
Index
:
-
1
,
}
}
rsp
,
err
=
au
.
listProposalBoard
(
req
)
rsp
,
err
=
au
.
listProposalBoard
(
req
)
...
@@ -233,9 +234,9 @@ func TestListProposalBoard(t *testing.T) {
...
@@ -233,9 +234,9 @@ func TestListProposalBoard(t *testing.T) {
// 翻页查找
// 翻页查找
req
=
&
auty
.
ReqQueryProposalBoard
{
req
=
&
auty
.
ReqQueryProposalBoard
{
Status
:
auty
.
AutonomyStatusProposalBoard
,
Status
:
auty
.
AutonomyStatusProposalBoard
,
Count
:
1
,
Count
:
1
,
Direction
:
0
,
Direction
:
0
,
Index
:
-
1
,
Index
:
-
1
,
}
}
rsp
,
err
=
au
.
listProposalBoard
(
req
)
rsp
,
err
=
au
.
listProposalBoard
(
req
)
...
@@ -248,9 +249,9 @@ func TestListProposalBoard(t *testing.T) {
...
@@ -248,9 +249,9 @@ func TestListProposalBoard(t *testing.T) {
//
//
Index
:=
height
*
types
.
MaxTxsPerBlock
+
int64
(
index
)
Index
:=
height
*
types
.
MaxTxsPerBlock
+
int64
(
index
)
req
=
&
auty
.
ReqQueryProposalBoard
{
req
=
&
auty
.
ReqQueryProposalBoard
{
Status
:
auty
.
AutonomyStatusProposalBoard
,
Status
:
auty
.
AutonomyStatusProposalBoard
,
Count
:
10
,
Count
:
10
,
Direction
:
0
,
Direction
:
0
,
Index
:
Index
,
Index
:
Index
,
}
}
rsp
,
err
=
au
.
listProposalBoard
(
req
)
rsp
,
err
=
au
.
listProposalBoard
(
req
)
...
...
plugin/dapp/autonomy/executor/boardaction.go
View file @
cf9a539d
...
@@ -6,11 +6,11 @@ package executor
...
@@ -6,11 +6,11 @@ package executor
import
(
import
(
"github.com/33cn/chain33/account"
"github.com/33cn/chain33/account"
"github.com/33cn/chain33/client"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common"
dbm
"github.com/33cn/chain33/common/db"
dbm
"github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/client"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
"github.com/33cn/chain33/common/address"
"github.com/33cn/chain33/common/address"
...
@@ -21,7 +21,7 @@ const (
...
@@ -21,7 +21,7 @@ const (
maxBoards
=
30
maxBoards
=
30
publicPeriod
int32
=
120960
// 公示一周时间,以区块高度计算
publicPeriod
int32
=
120960
// 公示一周时间,以区块高度计算
ticketPrice
=
types
.
Coin
*
3000
// 单张票价
ticketPrice
=
types
.
Coin
*
3000
// 单张票价
largeProjectAmount
=
types
.
Coin
*
100
*
10000
// 重大项目公示金额阈值
largeProjectAmount
=
types
.
Coin
*
100
*
10000
// 重大项目公示金额阈值
proposalAmount
=
types
.
Coin
*
1000
// 创建者消耗金额
proposalAmount
=
types
.
Coin
*
1000
// 创建者消耗金额
boardAttendRatio
int32
=
66
// 董事会成员参与率,以%计,可修改
boardAttendRatio
int32
=
66
// 董事会成员参与率,以%计,可修改
boardApproveRatio
int32
=
66
// 董事会成员赞成率,以%计,可修改
boardApproveRatio
int32
=
66
// 董事会成员赞成率,以%计,可修改
...
@@ -88,8 +88,8 @@ func (a *action) propBoard(prob *auty.ProposalBoard) (*types.Receipt, error) {
...
@@ -88,8 +88,8 @@ func (a *action) propBoard(prob *auty.ProposalBoard) (*types.Receipt, error) {
kv
=
append
(
kv
,
receipt
.
KV
...
)
kv
=
append
(
kv
,
receipt
.
KV
...
)
cur
:=
&
auty
.
AutonomyProposalBoard
{
cur
:=
&
auty
.
AutonomyProposalBoard
{
PropBoard
:
prob
,
PropBoard
:
prob
,
CurRule
:
rule
,
CurRule
:
rule
,
VoteResult
:
&
auty
.
VoteResult
{},
VoteResult
:
&
auty
.
VoteResult
{},
Status
:
auty
.
AutonomyStatusProposalBoard
,
Status
:
auty
.
AutonomyStatusProposalBoard
,
Address
:
a
.
fromaddr
,
Address
:
a
.
fromaddr
,
...
@@ -202,7 +202,7 @@ func (a *action) votePropBoard(voteProb *auty.VoteProposalBoard) (*types.Receipt
...
@@ -202,7 +202,7 @@ func (a *action) votePropBoard(voteProb *auty.VoteProposalBoard) (*types.Receipt
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
cur
.
VoteResult
.
TotalVotes
=
int32
(
account
.
Balance
/
ticketPrice
)
cur
.
VoteResult
.
TotalVotes
=
int32
(
account
.
Balance
/
ticketPrice
)
}
}
account
,
err
:=
a
.
getStartHeightVoteAccount
(
a
.
fromaddr
,
start
)
account
,
err
:=
a
.
getStartHeightVoteAccount
(
a
.
fromaddr
,
start
)
...
@@ -210,9 +210,9 @@ func (a *action) votePropBoard(voteProb *auty.VoteProposalBoard) (*types.Receipt
...
@@ -210,9 +210,9 @@ func (a *action) votePropBoard(voteProb *auty.VoteProposalBoard) (*types.Receipt
return
nil
,
err
return
nil
,
err
}
}
if
voteProb
.
Approve
{
if
voteProb
.
Approve
{
cur
.
VoteResult
.
ApproveVotes
+=
int32
(
account
.
Balance
/
ticketPrice
)
cur
.
VoteResult
.
ApproveVotes
+=
int32
(
account
.
Balance
/
ticketPrice
)
}
else
{
}
else
{
cur
.
VoteResult
.
OpposeVotes
+=
int32
(
account
.
Balance
/
ticketPrice
)
cur
.
VoteResult
.
OpposeVotes
+=
int32
(
account
.
Balance
/
ticketPrice
)
}
}
var
logs
[]
*
types
.
ReceiptLog
var
logs
[]
*
types
.
ReceiptLog
...
@@ -230,9 +230,9 @@ func (a *action) votePropBoard(voteProb *auty.VoteProposalBoard) (*types.Receipt
...
@@ -230,9 +230,9 @@ func (a *action) votePropBoard(voteProb *auty.VoteProposalBoard) (*types.Receipt
}
}
if
cur
.
VoteResult
.
TotalVotes
!=
0
&&
if
cur
.
VoteResult
.
TotalVotes
!=
0
&&
cur
.
VoteResult
.
ApproveVotes
+
cur
.
VoteResult
.
OpposeVotes
!=
0
&&
cur
.
VoteResult
.
ApproveVotes
+
cur
.
VoteResult
.
OpposeVotes
!=
0
&&
float32
(
cur
.
VoteResult
.
ApproveVotes
+
cur
.
VoteResult
.
OpposeVotes
)
/
float32
(
cur
.
VoteResult
.
TotalVotes
)
>=
float32
(
pubAttendRatio
)
/
100.0
&&
float32
(
cur
.
VoteResult
.
ApproveVotes
+
cur
.
VoteResult
.
OpposeVotes
)
/
float32
(
cur
.
VoteResult
.
TotalVotes
)
>=
float32
(
pubAttendRatio
)
/
100.0
&&
float32
(
cur
.
VoteResult
.
ApproveVotes
)
/
float32
(
cur
.
VoteResult
.
ApproveVotes
+
cur
.
VoteResult
.
OpposeVotes
)
>=
float32
(
pubApproveRatio
)
/
100.0
{
float32
(
cur
.
VoteResult
.
ApproveVotes
)
/
float32
(
cur
.
VoteResult
.
ApproveVotes
+
cur
.
VoteResult
.
OpposeVotes
)
>=
float32
(
pubApproveRatio
)
/
100.0
{
cur
.
VoteResult
.
Pass
=
true
cur
.
VoteResult
.
Pass
=
true
cur
.
PropBoard
.
RealEndBlockHeight
=
a
.
height
cur
.
PropBoard
.
RealEndBlockHeight
=
a
.
height
}
}
...
@@ -249,7 +249,7 @@ func (a *action) votePropBoard(voteProb *auty.VoteProposalBoard) (*types.Receipt
...
@@ -249,7 +249,7 @@ func (a *action) votePropBoard(voteProb *auty.VoteProposalBoard) (*types.Receipt
// 更新当前具有权利的董事会成员
// 更新当前具有权利的董事会成员
if
cur
.
VoteResult
.
Pass
{
if
cur
.
VoteResult
.
Pass
{
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
activeBoardID
(),
Value
:
types
.
Encode
(
cur
.
PropBoard
)})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
activeBoardID
(),
Value
:
types
.
Encode
(
cur
.
PropBoard
)})
}
}
ty
:=
auty
.
TyLogVotePropBoard
ty
:=
auty
.
TyLogVotePropBoard
...
@@ -295,11 +295,11 @@ func (a *action) tmintPropBoard(tmintProb *auty.TerminateProposalBoard) (*types.
...
@@ -295,11 +295,11 @@ func (a *action) tmintPropBoard(tmintProb *auty.TerminateProposalBoard) (*types.
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
cur
.
VoteResult
.
TotalVotes
=
int32
(
account
.
Balance
/
ticketPrice
)
cur
.
VoteResult
.
TotalVotes
=
int32
(
account
.
Balance
/
ticketPrice
)
}
}
if
float32
(
cur
.
VoteResult
.
ApproveVotes
+
cur
.
VoteResult
.
OpposeVotes
)
/
float32
(
cur
.
VoteResult
.
TotalVotes
)
>=
float32
(
pubAttendRatio
)
/
100.0
&&
if
float32
(
cur
.
VoteResult
.
ApproveVotes
+
cur
.
VoteResult
.
OpposeVotes
)
/
float32
(
cur
.
VoteResult
.
TotalVotes
)
>=
float32
(
pubAttendRatio
)
/
100.0
&&
float32
(
cur
.
VoteResult
.
ApproveVotes
)
/
float32
(
cur
.
VoteResult
.
ApproveVotes
+
cur
.
VoteResult
.
OpposeVotes
)
>=
float32
(
pubApproveRatio
)
/
100.0
{
float32
(
cur
.
VoteResult
.
ApproveVotes
)
/
float32
(
cur
.
VoteResult
.
ApproveVotes
+
cur
.
VoteResult
.
OpposeVotes
)
>=
float32
(
pubApproveRatio
)
/
100.0
{
cur
.
VoteResult
.
Pass
=
true
cur
.
VoteResult
.
Pass
=
true
}
else
{
}
else
{
cur
.
VoteResult
.
Pass
=
false
cur
.
VoteResult
.
Pass
=
false
...
@@ -326,7 +326,7 @@ func (a *action) tmintPropBoard(tmintProb *auty.TerminateProposalBoard) (*types.
...
@@ -326,7 +326,7 @@ func (a *action) tmintPropBoard(tmintProb *auty.TerminateProposalBoard) (*types.
// 更新当前具有权利的董事会成员
// 更新当前具有权利的董事会成员
if
cur
.
VoteResult
.
Pass
{
if
cur
.
VoteResult
.
Pass
{
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
activeBoardID
(),
Value
:
types
.
Encode
(
cur
.
PropBoard
)})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
activeBoardID
(),
Value
:
types
.
Encode
(
cur
.
PropBoard
)})
}
}
receiptLog
:=
getReceiptLog
(
pre
,
cur
,
auty
.
TyLogTmintPropBoard
)
receiptLog
:=
getReceiptLog
(
pre
,
cur
,
auty
.
TyLogTmintPropBoard
)
...
@@ -338,7 +338,7 @@ func (a *action) tmintPropBoard(tmintProb *auty.TerminateProposalBoard) (*types.
...
@@ -338,7 +338,7 @@ func (a *action) tmintPropBoard(tmintProb *auty.TerminateProposalBoard) (*types.
func
(
a
*
action
)
getStartHeightVoteAccount
(
addr
string
,
height
int64
)
(
*
types
.
Account
,
error
)
{
func
(
a
*
action
)
getStartHeightVoteAccount
(
addr
string
,
height
int64
)
(
*
types
.
Account
,
error
)
{
param
:=
&
types
.
ReqBlocks
{
param
:=
&
types
.
ReqBlocks
{
Start
:
height
,
Start
:
height
,
End
:
height
,
End
:
height
,
}
}
head
,
err
:=
a
.
api
.
GetHeaders
(
param
)
head
,
err
:=
a
.
api
.
GetHeaders
(
param
)
if
err
!=
nil
||
len
(
head
.
Items
)
==
0
{
if
err
!=
nil
||
len
(
head
.
Items
)
==
0
{
...
@@ -381,7 +381,7 @@ func (a *action) getActiveRule() (*auty.RuleConfig, error) {
...
@@ -381,7 +381,7 @@ func (a *action) getActiveRule() (*auty.RuleConfig, error) {
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
}
else
{
// 载入系统默认值
}
else
{
// 载入系统默认值
rule
.
BoardAttendRatio
=
boardAttendRatio
rule
.
BoardAttendRatio
=
boardAttendRatio
rule
.
BoardApproveRatio
=
boardApproveRatio
rule
.
BoardApproveRatio
=
boardApproveRatio
rule
.
PubOpposeRatio
=
pubOpposeRatio
rule
.
PubOpposeRatio
=
pubOpposeRatio
...
@@ -440,4 +440,3 @@ func copyAutonomyProposalBoard(cur *auty.AutonomyProposalBoard) *auty.AutonomyPr
...
@@ -440,4 +440,3 @@ func copyAutonomyProposalBoard(cur *auty.AutonomyProposalBoard) *auty.AutonomyPr
}
}
return
&
newAut
return
&
newAut
}
}
plugin/dapp/autonomy/executor/boardaction_test.go
View file @
cf9a539d
...
@@ -7,21 +7,21 @@ package executor
...
@@ -7,21 +7,21 @@ package executor
import
(
import
(
"testing"
"testing"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
"github.com/33cn/chain33/account"
"github.com/stretchr/testify/require"
"github.com/33cn/chain33/types"
apimock
"github.com/33cn/chain33/client/mocks"
apimock
"github.com/33cn/chain33/client/mocks"
dbmock
"github.com/33cn/chain33/common/db/mocks"
"github.com/33cn/chain33/common/crypto"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common"
commonlog
"github.com/33cn/chain33/common/log"
"github.com/33cn/chain33/common/address"
"github.com/33cn/chain33/common/crypto"
dbm
"github.com/33cn/chain33/common/db"
dbm
"github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/account"
dbmock
"github.com/33cn/chain33/common/db/mocks"
commonlog
"github.com/33cn/chain33/common/log"
_
"github.com/33cn/chain33/system"
_
"github.com/33cn/chain33/system"
"github.com/stretchr/testify/mock"
"github.com/33cn/chain33/common/address"
drivers
"github.com/33cn/chain33/system/dapp"
drivers
"github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/util"
"github.com/33cn/chain33/util"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
)
)
type
execEnv
struct
{
type
execEnv
struct
{
...
@@ -88,7 +88,6 @@ func InitEnv() (*execEnv, drivers.Driver, dbm.KV, dbm.KVDB) {
...
@@ -88,7 +88,6 @@ func InitEnv() (*execEnv, drivers.Driver, dbm.KV, dbm.KVDB) {
stateDB
,
_
:=
dbm
.
NewGoMemDB
(
"state"
,
"state"
,
100
)
stateDB
,
_
:=
dbm
.
NewGoMemDB
(
"state"
,
"state"
,
100
)
_
,
_
,
kvdb
:=
util
.
CreateTestDB
()
_
,
_
,
kvdb
:=
util
.
CreateTestDB
()
accCoin
:=
account
.
NewCoinsAccount
()
accCoin
:=
account
.
NewCoinsAccount
()
accCoin
.
SetDB
(
stateDB
)
accCoin
.
SetDB
(
stateDB
)
accCoin
.
SaveAccount
(
&
accountA
)
accCoin
.
SaveAccount
(
&
accountA
)
...
@@ -97,7 +96,7 @@ func InitEnv() (*execEnv, drivers.Driver, dbm.KV, dbm.KVDB) {
...
@@ -97,7 +96,7 @@ func InitEnv() (*execEnv, drivers.Driver, dbm.KV, dbm.KVDB) {
accCoin
.
SaveAccount
(
&
accountC
)
accCoin
.
SaveAccount
(
&
accountC
)
accCoin
.
SaveAccount
(
&
accountD
)
accCoin
.
SaveAccount
(
&
accountD
)
//total ticket balance
//total ticket balance
accCoin
.
SaveAccount
(
&
types
.
Account
{
Balance
:
total
*
4
,
accCoin
.
SaveAccount
(
&
types
.
Account
{
Balance
:
total
*
4
,
Frozen
:
0
,
Frozen
:
0
,
Addr
:
"16htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp"
})
Addr
:
"16htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp"
})
...
@@ -198,7 +197,7 @@ func propBoardTx(parm *auty.ProposalBoard) (*types.Transaction, error) {
...
@@ -198,7 +197,7 @@ func propBoardTx(parm *auty.ProposalBoard) (*types.Transaction, error) {
func
revokeProposalBoard
(
t
*
testing
.
T
,
env
*
execEnv
,
exec
drivers
.
Driver
,
stateDB
dbm
.
KV
,
kvdb
dbm
.
KVDB
,
save
bool
)
{
func
revokeProposalBoard
(
t
*
testing
.
T
,
env
*
execEnv
,
exec
drivers
.
Driver
,
stateDB
dbm
.
KV
,
kvdb
dbm
.
KVDB
,
save
bool
)
{
proposalID
:=
env
.
txHash
proposalID
:=
env
.
txHash
opt2
:=
&
auty
.
RevokeProposalBoard
{
opt2
:=
&
auty
.
RevokeProposalBoard
{
ProposalID
:
proposalID
,
ProposalID
:
proposalID
,
}
}
rtx
,
err
:=
revokeProposalBoardTx
(
opt2
)
rtx
,
err
:=
revokeProposalBoardTx
(
opt2
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
...
@@ -252,14 +251,14 @@ func voteProposalBoard(t *testing.T, env *execEnv, exec drivers.Driver, stateDB
...
@@ -252,14 +251,14 @@ func voteProposalBoard(t *testing.T, env *execEnv, exec drivers.Driver, stateDB
hear
:=
&
types
.
Header
{
StateHash
:
[]
byte
(
""
)}
hear
:=
&
types
.
Header
{
StateHash
:
[]
byte
(
""
)}
api
.
On
(
"GetHeaders"
,
mock
.
Anything
)
.
api
.
On
(
"GetHeaders"
,
mock
.
Anything
)
.
Return
(
&
types
.
Headers
{
Return
(
&
types
.
Headers
{
Items
:
[]
*
types
.
Header
{
hear
}},
nil
)
Items
:
[]
*
types
.
Header
{
hear
}},
nil
)
acc
:=
&
types
.
Account
{
acc
:=
&
types
.
Account
{
Currency
:
0
,
Currency
:
0
,
Balance
:
total
*
4
,
Balance
:
total
*
4
,
}
}
val
:=
types
.
Encode
(
acc
)
val
:=
types
.
Encode
(
acc
)
values
:=
[][]
byte
{
val
}
values
:=
[][]
byte
{
val
}
api
.
On
(
"StoreGet"
,
mock
.
Anything
)
.
Return
(
&
types
.
StoreReplyValue
{
Values
:
values
},
nil
)
.
Once
()
api
.
On
(
"StoreGet"
,
mock
.
Anything
)
.
Return
(
&
types
.
StoreReplyValue
{
Values
:
values
},
nil
)
.
Once
()
acc
=
&
types
.
Account
{
acc
=
&
types
.
Account
{
Currency
:
0
,
Currency
:
0
,
...
@@ -267,7 +266,7 @@ func voteProposalBoard(t *testing.T, env *execEnv, exec drivers.Driver, stateDB
...
@@ -267,7 +266,7 @@ func voteProposalBoard(t *testing.T, env *execEnv, exec drivers.Driver, stateDB
}
}
val1
:=
types
.
Encode
(
acc
)
val1
:=
types
.
Encode
(
acc
)
values1
:=
[][]
byte
{
val1
}
values1
:=
[][]
byte
{
val1
}
api
.
On
(
"StoreGet"
,
mock
.
Anything
)
.
Return
(
&
types
.
StoreReplyValue
{
Values
:
values1
},
nil
)
.
Once
()
api
.
On
(
"StoreGet"
,
mock
.
Anything
)
.
Return
(
&
types
.
StoreReplyValue
{
Values
:
values1
},
nil
)
.
Once
()
exec
.
SetAPI
(
api
)
exec
.
SetAPI
(
api
)
proposalID
:=
env
.
txHash
proposalID
:=
env
.
txHash
...
@@ -285,7 +284,7 @@ func voteProposalBoard(t *testing.T, env *execEnv, exec drivers.Driver, stateDB
...
@@ -285,7 +284,7 @@ func voteProposalBoard(t *testing.T, env *execEnv, exec drivers.Driver, stateDB
for
_
,
record
:=
range
records
{
for
_
,
record
:=
range
records
{
opt
:=
&
auty
.
VoteProposalBoard
{
opt
:=
&
auty
.
VoteProposalBoard
{
ProposalID
:
proposalID
,
ProposalID
:
proposalID
,
Approve
:
record
.
appr
,
Approve
:
record
.
appr
,
}
}
tx
,
err
:=
voteProposalBoardTx
(
opt
)
tx
,
err
:=
voteProposalBoardTx
(
opt
)
...
@@ -324,7 +323,7 @@ func voteProposalBoard(t *testing.T, env *execEnv, exec drivers.Driver, stateDB
...
@@ -324,7 +323,7 @@ func voteProposalBoard(t *testing.T, env *execEnv, exec drivers.Driver, stateDB
}
}
val
:=
types
.
Encode
(
acc
)
val
:=
types
.
Encode
(
acc
)
values
:=
[][]
byte
{
val
}
values
:=
[][]
byte
{
val
}
api
.
On
(
"StoreGet"
,
mock
.
Anything
)
.
Return
(
&
types
.
StoreReplyValue
{
Values
:
values
},
nil
)
.
Once
()
api
.
On
(
"StoreGet"
,
mock
.
Anything
)
.
Return
(
&
types
.
StoreReplyValue
{
Values
:
values
},
nil
)
.
Once
()
exec
.
SetAPI
(
api
)
exec
.
SetAPI
(
api
)
}
}
// check
// check
...
@@ -364,19 +363,19 @@ func terminateProposalBoard(t *testing.T, env *execEnv, exec drivers.Driver, sta
...
@@ -364,19 +363,19 @@ func terminateProposalBoard(t *testing.T, env *execEnv, exec drivers.Driver, sta
hear
:=
&
types
.
Header
{
StateHash
:
[]
byte
(
""
)}
hear
:=
&
types
.
Header
{
StateHash
:
[]
byte
(
""
)}
api
.
On
(
"GetHeaders"
,
mock
.
Anything
)
.
api
.
On
(
"GetHeaders"
,
mock
.
Anything
)
.
Return
(
&
types
.
Headers
{
Return
(
&
types
.
Headers
{
Items
:
[]
*
types
.
Header
{
hear
}},
nil
)
Items
:
[]
*
types
.
Header
{
hear
}},
nil
)
acc
:=
&
types
.
Account
{
acc
:=
&
types
.
Account
{
Currency
:
0
,
Currency
:
0
,
Balance
:
total
*
4
,
Balance
:
total
*
4
,
}
}
val
:=
types
.
Encode
(
acc
)
val
:=
types
.
Encode
(
acc
)
values
:=
[][]
byte
{
val
}
values
:=
[][]
byte
{
val
}
api
.
On
(
"StoreGet"
,
mock
.
Anything
)
.
Return
(
&
types
.
StoreReplyValue
{
Values
:
values
},
nil
)
.
Once
()
api
.
On
(
"StoreGet"
,
mock
.
Anything
)
.
Return
(
&
types
.
StoreReplyValue
{
Values
:
values
},
nil
)
.
Once
()
exec
.
SetAPI
(
api
)
exec
.
SetAPI
(
api
)
proposalID
:=
env
.
txHash
proposalID
:=
env
.
txHash
opt
:=
&
auty
.
TerminateProposalBoard
{
opt
:=
&
auty
.
TerminateProposalBoard
{
ProposalID
:
proposalID
,
ProposalID
:
proposalID
,
}
}
tx
,
err
:=
terminateProposalBoardTx
(
opt
)
tx
,
err
:=
terminateProposalBoardTx
(
opt
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
...
@@ -441,11 +440,11 @@ func TestGetStartHeightVoteAccount(t *testing.T) {
...
@@ -441,11 +440,11 @@ func TestGetStartHeightVoteAccount(t *testing.T) {
}
}
val
:=
types
.
Encode
(
acc
)
val
:=
types
.
Encode
(
acc
)
values
:=
[][]
byte
{
val
}
values
:=
[][]
byte
{
val
}
api
.
On
(
"StoreGet"
,
mock
.
Anything
)
.
Return
(
&
types
.
StoreReplyValue
{
Values
:
values
},
nil
)
api
.
On
(
"StoreGet"
,
mock
.
Anything
)
.
Return
(
&
types
.
StoreReplyValue
{
Values
:
values
},
nil
)
hear
:=
&
types
.
Header
{
StateHash
:
[]
byte
(
""
)}
hear
:=
&
types
.
Header
{
StateHash
:
[]
byte
(
""
)}
api
.
On
(
"GetHeaders"
,
mock
.
Anything
)
.
api
.
On
(
"GetHeaders"
,
mock
.
Anything
)
.
Return
(
&
types
.
Headers
{
Return
(
&
types
.
Headers
{
Items
:
[]
*
types
.
Header
{
hear
}},
nil
)
Items
:
[]
*
types
.
Header
{
hear
}},
nil
)
account
,
err
:=
action
.
getStartHeightVoteAccount
(
addr
,
0
)
account
,
err
:=
action
.
getStartHeightVoteAccount
(
addr
,
0
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
account
)
require
.
NotNil
(
t
,
account
)
...
@@ -457,13 +456,13 @@ func TestGetReceiptLog(t *testing.T) {
...
@@ -457,13 +456,13 @@ func TestGetReceiptLog(t *testing.T) {
PropBoard
:
&
auty
.
ProposalBoard
{
Year
:
1800
,
Month
:
1
},
PropBoard
:
&
auty
.
ProposalBoard
{
Year
:
1800
,
Month
:
1
},
VoteResult
:
&
auty
.
VoteResult
{
TotalVotes
:
100
},
VoteResult
:
&
auty
.
VoteResult
{
TotalVotes
:
100
},
Status
:
1
,
Status
:
1
,
Address
:
"121"
,
Address
:
"121"
,
}
}
cur
:=
&
auty
.
AutonomyProposalBoard
{
cur
:=
&
auty
.
AutonomyProposalBoard
{
PropBoard
:
&
auty
.
ProposalBoard
{
Year
:
1900
,
Month
:
1
},
PropBoard
:
&
auty
.
ProposalBoard
{
Year
:
1900
,
Month
:
1
},
VoteResult
:
&
auty
.
VoteResult
{
TotalVotes
:
100
},
VoteResult
:
&
auty
.
VoteResult
{
TotalVotes
:
100
},
Status
:
2
,
Status
:
2
,
Address
:
"123"
,
Address
:
"123"
,
}
}
log
:=
getReceiptLog
(
pre
,
cur
,
2
)
log
:=
getReceiptLog
(
pre
,
cur
,
2
)
require
.
Equal
(
t
,
int32
(
2
),
log
.
Ty
)
require
.
Equal
(
t
,
int32
(
2
),
log
.
Ty
)
...
@@ -481,7 +480,7 @@ func TestCopyAutonomyProposalBoard(t *testing.T) {
...
@@ -481,7 +480,7 @@ func TestCopyAutonomyProposalBoard(t *testing.T) {
CurRule
:
&
auty
.
RuleConfig
{
BoardAttendRatio
:
100
},
CurRule
:
&
auty
.
RuleConfig
{
BoardAttendRatio
:
100
},
VoteResult
:
&
auty
.
VoteResult
{
TotalVotes
:
100
},
VoteResult
:
&
auty
.
VoteResult
{
TotalVotes
:
100
},
Status
:
2
,
Status
:
2
,
Address
:
"123"
,
Address
:
"123"
,
}
}
pre
:=
copyAutonomyProposalBoard
(
cur
)
pre
:=
copyAutonomyProposalBoard
(
cur
)
cur
.
PropBoard
.
Year
=
1800
cur
.
PropBoard
.
Year
=
1800
...
...
plugin/dapp/autonomy/executor/exec.go
View file @
cf9a539d
plugin/dapp/autonomy/executor/exec_del_local.go
View file @
cf9a539d
...
@@ -16,7 +16,7 @@ func (a *Autonomy) ExecDelLocal_PropBoard(payload *auty.ProposalBoard, tx *types
...
@@ -16,7 +16,7 @@ func (a *Autonomy) ExecDelLocal_PropBoard(payload *auty.ProposalBoard, tx *types
}
}
// ExecDelLocal_RvkPropBoard 撤销提案
// ExecDelLocal_RvkPropBoard 撤销提案
func
(
a
*
Autonomy
)
ExecDelLocal_RvkPropBoard
(
payload
*
auty
.
RevokeProposalBoard
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
){
func
(
a
*
Autonomy
)
ExecDelLocal_RvkPropBoard
(
payload
*
auty
.
RevokeProposalBoard
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
return
a
.
execDelLocalBoard
(
receiptData
)
return
a
.
execDelLocalBoard
(
receiptData
)
}
}
...
@@ -37,7 +37,7 @@ func (a *Autonomy) ExecDelLocal_PropProject(payload *auty.ProposalProject, tx *t
...
@@ -37,7 +37,7 @@ func (a *Autonomy) ExecDelLocal_PropProject(payload *auty.ProposalProject, tx *t
}
}
// ExecDelLocal_RvkPropProject 撤销提案
// ExecDelLocal_RvkPropProject 撤销提案
func
(
a
*
Autonomy
)
ExecDelLocal_RvkPropProject
(
payload
*
auty
.
RevokeProposalProject
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
){
func
(
a
*
Autonomy
)
ExecDelLocal_RvkPropProject
(
payload
*
auty
.
RevokeProposalProject
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
return
a
.
execDelLocalProject
(
receiptData
)
return
a
.
execDelLocalProject
(
receiptData
)
}
}
...
@@ -63,7 +63,7 @@ func (a *Autonomy) ExecDelLocal_PropRule(payload *auty.ProposalRule, tx *types.T
...
@@ -63,7 +63,7 @@ func (a *Autonomy) ExecDelLocal_PropRule(payload *auty.ProposalRule, tx *types.T
}
}
// ExecDelLocal_RvkPropRule 撤销提案规则
// ExecDelLocal_RvkPropRule 撤销提案规则
func
(
a
*
Autonomy
)
ExecDelLocal_RvkPropRule
(
payload
*
auty
.
RevokeProposalRule
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
){
func
(
a
*
Autonomy
)
ExecDelLocal_RvkPropRule
(
payload
*
auty
.
RevokeProposalRule
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
return
a
.
execDelLocalRule
(
receiptData
)
return
a
.
execDelLocalRule
(
receiptData
)
}
}
...
...
plugin/dapp/autonomy/executor/exec_local.go
View file @
cf9a539d
...
@@ -16,7 +16,7 @@ func (a *Autonomy) ExecLocal_PropBoard(payload *auty.ProposalBoard, tx *types.Tr
...
@@ -16,7 +16,7 @@ func (a *Autonomy) ExecLocal_PropBoard(payload *auty.ProposalBoard, tx *types.Tr
}
}
// ExecLocal_RvkPropBoard 撤销提案
// ExecLocal_RvkPropBoard 撤销提案
func
(
a
*
Autonomy
)
ExecLocal_RvkPropBoard
(
payload
*
auty
.
RevokeProposalBoard
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
){
func
(
a
*
Autonomy
)
ExecLocal_RvkPropBoard
(
payload
*
auty
.
RevokeProposalBoard
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
return
a
.
execLocalBoard
(
receiptData
)
return
a
.
execLocalBoard
(
receiptData
)
}
}
...
@@ -37,7 +37,7 @@ func (a *Autonomy) ExecLocal_PropProject(payload *auty.ProposalProject, tx *type
...
@@ -37,7 +37,7 @@ func (a *Autonomy) ExecLocal_PropProject(payload *auty.ProposalProject, tx *type
}
}
// ExecLocal_RvkPropProject 撤销提案项目
// ExecLocal_RvkPropProject 撤销提案项目
func
(
a
*
Autonomy
)
ExecLocal_RvkPropProject
(
payload
*
auty
.
RevokeProposalProject
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
){
func
(
a
*
Autonomy
)
ExecLocal_RvkPropProject
(
payload
*
auty
.
RevokeProposalProject
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
return
a
.
execLocalProject
(
receiptData
)
return
a
.
execLocalProject
(
receiptData
)
}
}
...
@@ -63,7 +63,7 @@ func (a *Autonomy) ExecLocal_PropRule(payload *auty.ProposalRule, tx *types.Tran
...
@@ -63,7 +63,7 @@ func (a *Autonomy) ExecLocal_PropRule(payload *auty.ProposalRule, tx *types.Tran
}
}
// ExecLocal_RvkPropRule 撤销提案规则
// ExecLocal_RvkPropRule 撤销提案规则
func
(
a
*
Autonomy
)
ExecLocal_RvkPropRule
(
payload
*
auty
.
RevokeProposalRule
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
){
func
(
a
*
Autonomy
)
ExecLocal_RvkPropRule
(
payload
*
auty
.
RevokeProposalRule
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
return
a
.
execLocalRule
(
receiptData
)
return
a
.
execLocalRule
(
receiptData
)
}
}
...
...
plugin/dapp/autonomy/executor/kv.go
View file @
cf9a539d
...
@@ -41,7 +41,7 @@ func boardVotesRecord(txHash string) []byte {
...
@@ -41,7 +41,7 @@ func boardVotesRecord(txHash string) []byte {
}
}
func
calcBoardKey4StatusHeight
(
status
int32
,
heightindex
string
)
[]
byte
{
func
calcBoardKey4StatusHeight
(
status
int32
,
heightindex
string
)
[]
byte
{
key
:=
fmt
.
Sprintf
(
localBoardPrefix
+
"%d-"
+
"%s"
,
status
,
heightindex
)
key
:=
fmt
.
Sprintf
(
localBoardPrefix
+
"%d-"
+
"%s"
,
status
,
heightindex
)
return
[]
byte
(
key
)
return
[]
byte
(
key
)
}
}
...
@@ -56,7 +56,7 @@ func propProjectID(txHash string) []byte {
...
@@ -56,7 +56,7 @@ func propProjectID(txHash string) []byte {
}
}
func
calcProjectKey4StatusHeight
(
status
int32
,
heightindex
string
)
[]
byte
{
func
calcProjectKey4StatusHeight
(
status
int32
,
heightindex
string
)
[]
byte
{
key
:=
fmt
.
Sprintf
(
localProjectPrefix
+
"%d-"
+
"%s"
,
status
,
heightindex
)
key
:=
fmt
.
Sprintf
(
localProjectPrefix
+
"%d-"
+
"%s"
,
status
,
heightindex
)
return
[]
byte
(
key
)
return
[]
byte
(
key
)
}
}
...
@@ -75,7 +75,7 @@ func propRuleID(txHash string) []byte {
...
@@ -75,7 +75,7 @@ func propRuleID(txHash string) []byte {
}
}
func
calcRuleKey4StatusHeight
(
status
int32
,
heightindex
string
)
[]
byte
{
func
calcRuleKey4StatusHeight
(
status
int32
,
heightindex
string
)
[]
byte
{
key
:=
fmt
.
Sprintf
(
localRulePrefix
+
"%d-"
+
"%s"
,
status
,
heightindex
)
key
:=
fmt
.
Sprintf
(
localRulePrefix
+
"%d-"
+
"%s"
,
status
,
heightindex
)
return
[]
byte
(
key
)
return
[]
byte
(
key
)
}
}
...
@@ -85,6 +85,6 @@ var (
...
@@ -85,6 +85,6 @@ var (
)
)
func
calcCommentHeight
(
ID
,
heightindex
string
)
[]
byte
{
func
calcCommentHeight
(
ID
,
heightindex
string
)
[]
byte
{
key
:=
fmt
.
Sprintf
(
localCommentPrefix
+
"%s-"
+
"%s"
,
ID
,
heightindex
)
key
:=
fmt
.
Sprintf
(
localCommentPrefix
+
"%s-"
+
"%s"
,
ID
,
heightindex
)
return
[]
byte
(
key
)
return
[]
byte
(
key
)
}
}
plugin/dapp/autonomy/executor/project.go
View file @
cf9a539d
plugin/dapp/autonomy/executor/project_test.go
View file @
cf9a539d
...
@@ -6,11 +6,12 @@ package executor
...
@@ -6,11 +6,12 @@ package executor
import
(
import
(
"testing"
"testing"
"github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/util"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/require"
"github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/util"
)
)
func
TestExecLocalProject
(
t
*
testing
.
T
)
{
func
TestExecLocalProject
(
t
*
testing
.
T
)
{
...
@@ -33,7 +34,7 @@ func TestExecLocalProject(t *testing.T) {
...
@@ -33,7 +34,7 @@ func TestExecLocalProject(t *testing.T) {
}
}
receipt
:=
&
types
.
ReceiptData
{
receipt
:=
&
types
.
ReceiptData
{
Logs
:
[]
*
types
.
ReceiptLog
{
Logs
:
[]
*
types
.
ReceiptLog
{
{
Ty
:
auty
.
TyLogPropProject
,
Log
:
types
.
Encode
(
receiptProject
)},
{
Ty
:
auty
.
TyLogPropProject
,
Log
:
types
.
Encode
(
receiptProject
)},
},
},
}
}
set
,
err
:=
au
.
execLocalProject
(
receipt
)
set
,
err
:=
au
.
execLocalProject
(
receipt
)
...
@@ -53,7 +54,7 @@ func TestExecLocalProject(t *testing.T) {
...
@@ -53,7 +54,7 @@ func TestExecLocalProject(t *testing.T) {
}
}
set
,
err
=
au
.
execLocalProject
(
&
types
.
ReceiptData
{
set
,
err
=
au
.
execLocalProject
(
&
types
.
ReceiptData
{
Logs
:
[]
*
types
.
ReceiptLog
{
Logs
:
[]
*
types
.
ReceiptLog
{
{
Ty
:
auty
.
TyLogRvkPropProject
,
Log
:
types
.
Encode
(
receiptProject1
)},
{
Ty
:
auty
.
TyLogRvkPropProject
,
Log
:
types
.
Encode
(
receiptProject1
)},
},
},
})
})
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
...
@@ -78,7 +79,7 @@ func TestExecLocalProject(t *testing.T) {
...
@@ -78,7 +79,7 @@ func TestExecLocalProject(t *testing.T) {
}
}
set
,
err
=
au
.
execLocalProject
(
&
types
.
ReceiptData
{
set
,
err
=
au
.
execLocalProject
(
&
types
.
ReceiptData
{
Logs
:
[]
*
types
.
ReceiptLog
{
Logs
:
[]
*
types
.
ReceiptLog
{
{
Ty
:
auty
.
TyLogVotePropProject
,
Log
:
types
.
Encode
(
receiptProject2
)},
{
Ty
:
auty
.
TyLogVotePropProject
,
Log
:
types
.
Encode
(
receiptProject2
)},
},
},
})
})
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
...
@@ -110,7 +111,7 @@ func TestExecDelLocalProject(t *testing.T) {
...
@@ -110,7 +111,7 @@ func TestExecDelLocalProject(t *testing.T) {
}
}
receipt
:=
&
types
.
ReceiptData
{
receipt
:=
&
types
.
ReceiptData
{
Logs
:
[]
*
types
.
ReceiptLog
{
Logs
:
[]
*
types
.
ReceiptLog
{
{
Ty
:
auty
.
TyLogPropProject
,
Log
:
types
.
Encode
(
receiptProject
)},
{
Ty
:
auty
.
TyLogPropProject
,
Log
:
types
.
Encode
(
receiptProject
)},
},
},
}
}
set
,
err
:=
au
.
execDelLocalProject
(
receipt
)
set
,
err
:=
au
.
execDelLocalProject
(
receipt
)
...
@@ -131,7 +132,7 @@ func TestExecDelLocalProject(t *testing.T) {
...
@@ -131,7 +132,7 @@ func TestExecDelLocalProject(t *testing.T) {
}
}
set
,
err
=
au
.
execDelLocalProject
(
&
types
.
ReceiptData
{
set
,
err
=
au
.
execDelLocalProject
(
&
types
.
ReceiptData
{
Logs
:
[]
*
types
.
ReceiptLog
{
Logs
:
[]
*
types
.
ReceiptLog
{
{
Ty
:
auty
.
TyLogVotePropProject
,
Log
:
types
.
Encode
(
receiptProject2
)},
{
Ty
:
auty
.
TyLogVotePropProject
,
Log
:
types
.
Encode
(
receiptProject2
)},
},
},
})
})
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
...
@@ -152,7 +153,7 @@ func TestGetProposalProject(t *testing.T) {
...
@@ -152,7 +153,7 @@ func TestGetProposalProject(t *testing.T) {
au
.
SetStateDB
(
storedb
)
au
.
SetStateDB
(
storedb
)
tx
:=
"1111111111111111111"
tx
:=
"1111111111111111111"
storedb
.
Set
(
propProjectID
(
tx
),
types
.
Encode
(
&
auty
.
AutonomyProposalProject
{}))
storedb
.
Set
(
propProjectID
(
tx
),
types
.
Encode
(
&
auty
.
AutonomyProposalProject
{}))
rsp
,
err
:=
au
.
getProposalProject
(
&
types
.
ReqString
{
Data
:
tx
})
rsp
,
err
:=
au
.
getProposalProject
(
&
types
.
ReqString
{
Data
:
tx
})
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
rsp
)
require
.
NotNil
(
t
,
rsp
)
require
.
Equal
(
t
,
len
(
rsp
.
(
*
auty
.
ReplyQueryProposalProject
)
.
PropProjects
),
1
)
require
.
Equal
(
t
,
len
(
rsp
.
(
*
auty
.
ReplyQueryProposalProject
)
.
PropProjects
),
1
)
...
@@ -207,9 +208,9 @@ func TestListProposalProject(t *testing.T) {
...
@@ -207,9 +208,9 @@ func TestListProposalProject(t *testing.T) {
// 反向查找
// 反向查找
req
:=
&
auty
.
ReqQueryProposalProject
{
req
:=
&
auty
.
ReqQueryProposalProject
{
Status
:
auty
.
AutonomyStatusProposalProject
,
Status
:
auty
.
AutonomyStatusProposalProject
,
Count
:
10
,
Count
:
10
,
Direction
:
0
,
Direction
:
0
,
Index
:
-
1
,
Index
:
-
1
,
}
}
rsp
,
err
:=
au
.
listProposalProject
(
req
)
rsp
,
err
:=
au
.
listProposalProject
(
req
)
...
@@ -224,9 +225,9 @@ func TestListProposalProject(t *testing.T) {
...
@@ -224,9 +225,9 @@ func TestListProposalProject(t *testing.T) {
// 正向查找
// 正向查找
req
=
&
auty
.
ReqQueryProposalProject
{
req
=
&
auty
.
ReqQueryProposalProject
{
Status
:
auty
.
AutonomyStatusProposalProject
,
Status
:
auty
.
AutonomyStatusProposalProject
,
Count
:
10
,
Count
:
10
,
Direction
:
1
,
Direction
:
1
,
Index
:
-
1
,
Index
:
-
1
,
}
}
rsp
,
err
=
au
.
listProposalProject
(
req
)
rsp
,
err
=
au
.
listProposalProject
(
req
)
...
@@ -239,9 +240,9 @@ func TestListProposalProject(t *testing.T) {
...
@@ -239,9 +240,9 @@ func TestListProposalProject(t *testing.T) {
// 翻页查找
// 翻页查找
req
=
&
auty
.
ReqQueryProposalProject
{
req
=
&
auty
.
ReqQueryProposalProject
{
Status
:
auty
.
AutonomyStatusProposalProject
,
Status
:
auty
.
AutonomyStatusProposalProject
,
Count
:
1
,
Count
:
1
,
Direction
:
0
,
Direction
:
0
,
Index
:
-
1
,
Index
:
-
1
,
}
}
rsp
,
err
=
au
.
listProposalProject
(
req
)
rsp
,
err
=
au
.
listProposalProject
(
req
)
...
@@ -254,9 +255,9 @@ func TestListProposalProject(t *testing.T) {
...
@@ -254,9 +255,9 @@ func TestListProposalProject(t *testing.T) {
//
//
Index
:=
height
*
types
.
MaxTxsPerBlock
+
int64
(
index
)
Index
:=
height
*
types
.
MaxTxsPerBlock
+
int64
(
index
)
req
=
&
auty
.
ReqQueryProposalProject
{
req
=
&
auty
.
ReqQueryProposalProject
{
Status
:
auty
.
AutonomyStatusProposalProject
,
Status
:
auty
.
AutonomyStatusProposalProject
,
Count
:
10
,
Count
:
10
,
Direction
:
0
,
Direction
:
0
,
Index
:
Index
,
Index
:
Index
,
}
}
rsp
,
err
=
au
.
listProposalProject
(
req
)
rsp
,
err
=
au
.
listProposalProject
(
req
)
...
...
plugin/dapp/autonomy/executor/projectaction.go
View file @
cf9a539d
...
@@ -12,7 +12,6 @@ import (
...
@@ -12,7 +12,6 @@ import (
"github.com/33cn/chain33/common/address"
"github.com/33cn/chain33/common/address"
)
)
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 "
,
"addr"
,
prob
.
ToAddr
,
"check toAddr error"
,
err
)
alog
.
Error
(
"propProject "
,
"addr"
,
prob
.
ToAddr
,
"check toAddr error"
,
err
)
...
@@ -64,11 +63,11 @@ func (a *action) propProject(prob *auty.ProposalProject) (*types.Receipt, error)
...
@@ -64,11 +63,11 @@ func (a *action) propProject(prob *auty.ProposalProject) (*types.Receipt, error)
isPubVote
=
true
isPubVote
=
true
}
}
cur
:=
&
auty
.
AutonomyProposalProject
{
cur
:=
&
auty
.
AutonomyProposalProject
{
PropProject
:
prob
,
PropProject
:
prob
,
CurRule
:
rule
,
CurRule
:
rule
,
Boards
:
pboard
.
Boards
,
Boards
:
pboard
.
Boards
,
BoardVoteRes
:
&
auty
.
VoteResult
{
TotalVotes
:
int32
(
len
(
pboard
.
Boards
))},
BoardVoteRes
:
&
auty
.
VoteResult
{
TotalVotes
:
int32
(
len
(
pboard
.
Boards
))},
PubVote
:
&
auty
.
PublicVote
{
Publicity
:
isPubVote
},
PubVote
:
&
auty
.
PublicVote
{
Publicity
:
isPubVote
},
Status
:
auty
.
AutonomyStatusProposalProject
,
Status
:
auty
.
AutonomyStatusProposalProject
,
Address
:
a
.
fromaddr
,
Address
:
a
.
fromaddr
,
Height
:
a
.
height
,
Height
:
a
.
height
,
...
@@ -220,9 +219,9 @@ func (a *action) votePropProject(voteProb *auty.VoteProposalProject) (*types.Rec
...
@@ -220,9 +219,9 @@ func (a *action) votePropProject(voteProb *auty.VoteProposalProject) (*types.Rec
}
}
if
cur
.
BoardVoteRes
.
TotalVotes
!=
0
&&
if
cur
.
BoardVoteRes
.
TotalVotes
!=
0
&&
cur
.
BoardVoteRes
.
ApproveVotes
+
cur
.
BoardVoteRes
.
OpposeVotes
!=
0
&&
cur
.
BoardVoteRes
.
ApproveVotes
+
cur
.
BoardVoteRes
.
OpposeVotes
!=
0
&&
float32
(
cur
.
BoardVoteRes
.
ApproveVotes
+
cur
.
BoardVoteRes
.
OpposeVotes
)
/
float32
(
cur
.
BoardVoteRes
.
TotalVotes
)
>=
float32
(
cur
.
CurRule
.
BoardAttendRatio
)
/
100.0
&&
float32
(
cur
.
BoardVoteRes
.
ApproveVotes
+
cur
.
BoardVoteRes
.
OpposeVotes
)
/
float32
(
cur
.
BoardVoteRes
.
TotalVotes
)
>=
float32
(
cur
.
CurRule
.
BoardAttendRatio
)
/
100.0
&&
float32
(
cur
.
BoardVoteRes
.
ApproveVotes
)
/
float32
(
cur
.
BoardVoteRes
.
ApproveVotes
+
cur
.
BoardVoteRes
.
OpposeVotes
)
>=
float32
(
cur
.
CurRule
.
BoardApproveRatio
)
/
100.0
{
float32
(
cur
.
BoardVoteRes
.
ApproveVotes
)
/
float32
(
cur
.
BoardVoteRes
.
ApproveVotes
+
cur
.
BoardVoteRes
.
OpposeVotes
)
>=
float32
(
cur
.
CurRule
.
BoardApproveRatio
)
/
100.0
{
cur
.
BoardVoteRes
.
Pass
=
true
cur
.
BoardVoteRes
.
Pass
=
true
cur
.
PropProject
.
RealEndBlockHeight
=
a
.
height
cur
.
PropProject
.
RealEndBlockHeight
=
a
.
height
}
}
...
@@ -306,7 +305,7 @@ func (a *action) pubVotePropProject(voteProb *auty.PubVoteProposalProject) (*typ
...
@@ -306,7 +305,7 @@ func (a *action) pubVotePropProject(voteProb *auty.PubVoteProposalProject) (*typ
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
cur
.
PubVote
.
TotalVotes
=
int32
(
account
.
Balance
/
ticketPrice
)
cur
.
PubVote
.
TotalVotes
=
int32
(
account
.
Balance
/
ticketPrice
)
}
}
// 获取该地址票数
// 获取该地址票数
...
@@ -315,14 +314,14 @@ func (a *action) pubVotePropProject(voteProb *auty.PubVoteProposalProject) (*typ
...
@@ -315,14 +314,14 @@ func (a *action) pubVotePropProject(voteProb *auty.PubVoteProposalProject) (*typ
return
nil
,
err
return
nil
,
err
}
}
if
voteProb
.
Oppose
{
//投反对票
if
voteProb
.
Oppose
{
//投反对票
cur
.
PubVote
.
OpposeVotes
+=
int32
(
account
.
Balance
/
ticketPrice
)
cur
.
PubVote
.
OpposeVotes
+=
int32
(
account
.
Balance
/
ticketPrice
)
}
}
var
logs
[]
*
types
.
ReceiptLog
var
logs
[]
*
types
.
ReceiptLog
var
kv
[]
*
types
.
KeyValue
var
kv
[]
*
types
.
KeyValue
if
cur
.
PubVote
.
TotalVotes
!=
0
&&
if
cur
.
PubVote
.
TotalVotes
!=
0
&&
float32
(
cur
.
PubVote
.
OpposeVotes
)
/
float32
(
cur
.
PubVote
.
TotalVotes
)
>=
float32
(
cur
.
CurRule
.
PubOpposeRatio
)
/
100.0
{
float32
(
cur
.
PubVote
.
OpposeVotes
)
/
float32
(
cur
.
PubVote
.
TotalVotes
)
>=
float32
(
cur
.
CurRule
.
PubOpposeRatio
)
/
100.0
{
cur
.
PubVote
.
PubPass
=
false
cur
.
PubVote
.
PubPass
=
false
cur
.
PropProject
.
RealEndBlockHeight
=
a
.
height
cur
.
PropProject
.
RealEndBlockHeight
=
a
.
height
...
@@ -374,7 +373,7 @@ func (a *action) tmintPropProject(tmintProb *auty.TerminateProposalProject) (*ty
...
@@ -374,7 +373,7 @@ func (a *action) tmintPropProject(tmintProb *auty.TerminateProposalProject) (*ty
// 公示期间不能终止
// 公示期间不能终止
if
cur
.
PubVote
.
Publicity
&&
cur
.
PubVote
.
PubPass
&&
if
cur
.
PubVote
.
Publicity
&&
cur
.
PubVote
.
PubPass
&&
a
.
height
<=
cur
.
PropProject
.
RealEndBlockHeight
+
int64
(
cur
.
CurRule
.
PublicPeriod
)
{
a
.
height
<=
cur
.
PropProject
.
RealEndBlockHeight
+
int64
(
cur
.
CurRule
.
PublicPeriod
)
{
err
:=
auty
.
ErrTerminatePeriod
err
:=
auty
.
ErrTerminatePeriod
alog
.
Error
(
"tmintPropProject "
,
"addr"
,
a
.
fromaddr
,
"status"
,
cur
.
Status
,
alog
.
Error
(
"tmintPropProject "
,
"addr"
,
a
.
fromaddr
,
"status"
,
cur
.
Status
,
"in publicity vote period can not terminate"
,
tmintProb
.
ProposalID
,
"err"
,
err
)
"in publicity vote period can not terminate"
,
tmintProb
.
ProposalID
,
"err"
,
err
)
...
@@ -392,9 +391,9 @@ func (a *action) tmintPropProject(tmintProb *auty.TerminateProposalProject) (*ty
...
@@ -392,9 +391,9 @@ func (a *action) tmintPropProject(tmintProb *auty.TerminateProposalProject) (*ty
}
}
if
cur
.
BoardVoteRes
.
TotalVotes
!=
0
&&
if
cur
.
BoardVoteRes
.
TotalVotes
!=
0
&&
cur
.
BoardVoteRes
.
ApproveVotes
+
cur
.
BoardVoteRes
.
OpposeVotes
!=
0
&&
cur
.
BoardVoteRes
.
ApproveVotes
+
cur
.
BoardVoteRes
.
OpposeVotes
!=
0
&&
float32
(
cur
.
BoardVoteRes
.
ApproveVotes
+
cur
.
BoardVoteRes
.
OpposeVotes
)
/
float32
(
cur
.
BoardVoteRes
.
TotalVotes
)
>=
float32
(
cur
.
CurRule
.
BoardAttendRatio
)
/
100.0
&&
float32
(
cur
.
BoardVoteRes
.
ApproveVotes
+
cur
.
BoardVoteRes
.
OpposeVotes
)
/
float32
(
cur
.
BoardVoteRes
.
TotalVotes
)
>=
float32
(
cur
.
CurRule
.
BoardAttendRatio
)
/
100.0
&&
float32
(
cur
.
BoardVoteRes
.
ApproveVotes
)
/
float32
(
cur
.
BoardVoteRes
.
ApproveVotes
+
cur
.
BoardVoteRes
.
OpposeVotes
)
>=
float32
(
cur
.
CurRule
.
BoardApproveRatio
)
/
100.0
{
float32
(
cur
.
BoardVoteRes
.
ApproveVotes
)
/
float32
(
cur
.
BoardVoteRes
.
ApproveVotes
+
cur
.
BoardVoteRes
.
OpposeVotes
)
>=
float32
(
cur
.
CurRule
.
BoardApproveRatio
)
/
100.0
{
cur
.
BoardVoteRes
.
Pass
=
true
cur
.
BoardVoteRes
.
Pass
=
true
}
else
{
}
else
{
cur
.
BoardVoteRes
.
Pass
=
false
cur
.
BoardVoteRes
.
Pass
=
false
...
@@ -407,10 +406,10 @@ func (a *action) tmintPropProject(tmintProb *auty.TerminateProposalProject) (*ty
...
@@ -407,10 +406,10 @@ func (a *action) tmintPropProject(tmintProb *auty.TerminateProposalProject) (*ty
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
cur
.
PubVote
.
TotalVotes
=
int32
(
account
.
Balance
/
ticketPrice
)
cur
.
PubVote
.
TotalVotes
=
int32
(
account
.
Balance
/
ticketPrice
)
}
}
if
cur
.
PubVote
.
TotalVotes
!=
0
&&
if
cur
.
PubVote
.
TotalVotes
!=
0
&&
float32
(
cur
.
PubVote
.
OpposeVotes
)
/
float32
(
cur
.
PubVote
.
TotalVotes
)
>=
float32
(
cur
.
CurRule
.
PubOpposeRatio
)
/
100.0
{
float32
(
cur
.
PubVote
.
OpposeVotes
)
/
float32
(
cur
.
PubVote
.
TotalVotes
)
>=
float32
(
cur
.
CurRule
.
PubOpposeRatio
)
/
100.0
{
cur
.
PubVote
.
PubPass
=
false
cur
.
PubVote
.
PubPass
=
false
}
}
}
}
...
@@ -507,7 +506,7 @@ func copyAutonomyProposalProject(cur *auty.AutonomyProposalProject) *auty.Autono
...
@@ -507,7 +506,7 @@ func copyAutonomyProposalProject(cur *auty.AutonomyProposalProject) *auty.Autono
return
nil
return
nil
}
}
newAut
:=
*
cur
newAut
:=
*
cur
if
cur
.
PropProject
!=
nil
{
if
cur
.
PropProject
!=
nil
{
newProject
:=
*
cur
.
GetPropProject
()
newProject
:=
*
cur
.
GetPropProject
()
newAut
.
PropProject
=
&
newProject
newAut
.
PropProject
=
&
newProject
}
}
...
@@ -525,4 +524,3 @@ func copyAutonomyProposalProject(cur *auty.AutonomyProposalProject) *auty.Autono
...
@@ -525,4 +524,3 @@ func copyAutonomyProposalProject(cur *auty.AutonomyProposalProject) *auty.Autono
}
}
return
&
newAut
return
&
newAut
}
}
plugin/dapp/autonomy/executor/projectaction_test.go
View file @
cf9a539d
...
@@ -7,17 +7,17 @@ package executor
...
@@ -7,17 +7,17 @@ package executor
import
(
import
(
"testing"
"testing"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
"github.com/33cn/chain33/account"
"github.com/stretchr/testify/require"
"github.com/33cn/chain33/types"
apimock
"github.com/33cn/chain33/client/mocks"
apimock
"github.com/33cn/chain33/client/mocks"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common/address"
dbm
"github.com/33cn/chain33/common/db"
dbm
"github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/account"
_
"github.com/33cn/chain33/system"
_
"github.com/33cn/chain33/system"
"github.com/stretchr/testify/mock"
"github.com/33cn/chain33/common/address"
drivers
"github.com/33cn/chain33/system/dapp"
drivers
"github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
)
)
//const (
//const (
...
@@ -39,9 +39,9 @@ func InitBoard(stateDB dbm.KV) {
...
@@ -39,9 +39,9 @@ func InitBoard(stateDB dbm.KV) {
Month
:
11
,
Month
:
11
,
Day
:
1
,
Day
:
1
,
Boards
:
[]
string
{
AddrA
,
AddrB
,
AddrC
,
AddrD
},
Boards
:
[]
string
{
AddrA
,
AddrB
,
AddrC
,
AddrD
},
StartBlockHeight
:
1
,
StartBlockHeight
:
1
,
EndBlockHeight
:
10
,
EndBlockHeight
:
10
,
RealEndBlockHeight
:
5
,
RealEndBlockHeight
:
5
,
}
}
stateDB
.
Set
(
activeBoardID
(),
types
.
Encode
(
board
))
stateDB
.
Set
(
activeBoardID
(),
types
.
Encode
(
board
))
}
}
...
@@ -53,7 +53,7 @@ func InitRule(stateDB dbm.KV) {
...
@@ -53,7 +53,7 @@ func InitRule(stateDB dbm.KV) {
BoardApproveRatio
:
boardApproveRatio
,
BoardApproveRatio
:
boardApproveRatio
,
PubOpposeRatio
:
pubOpposeRatio
,
PubOpposeRatio
:
pubOpposeRatio
,
ProposalAmount
:
proposalAmount
,
ProposalAmount
:
proposalAmount
,
LargeProjectAmount
:
types
.
Coin
*
100
,
LargeProjectAmount
:
types
.
Coin
*
100
,
PublicPeriod
:
publicPeriod
,
PublicPeriod
:
publicPeriod
,
}
}
stateDB
.
Set
(
activeRuleID
(),
types
.
Encode
(
rule
))
stateDB
.
Set
(
activeRuleID
(),
types
.
Encode
(
rule
))
...
@@ -74,24 +74,24 @@ func TestPropProject(t *testing.T) {
...
@@ -74,24 +74,24 @@ func TestPropProject(t *testing.T) {
env
,
exec
,
_
,
_
:=
InitEnv
()
env
,
exec
,
_
,
_
:=
InitEnv
()
opts
:=
[]
*
auty
.
ProposalProject
{
opts
:=
[]
*
auty
.
ProposalProject
{
&
auty
.
ProposalProject
{
// check toaddr
{
// check toaddr
ToAddr
:
"1111111111"
,
ToAddr
:
"1111111111"
,
StartBlockHeight
:
env
.
blockHeight
+
5
,
StartBlockHeight
:
env
.
blockHeight
+
5
,
EndBlockHeight
:
env
.
blockHeight
+
10
,
EndBlockHeight
:
env
.
blockHeight
+
10
,
},
},
&
auty
.
ProposalProject
{
// check amount
{
// check amount
Amount
:
0
,
Amount
:
0
,
ToAddr
:
AddrA
,
ToAddr
:
AddrA
,
StartBlockHeight
:
env
.
blockHeight
+
5
,
StartBlockHeight
:
env
.
blockHeight
+
5
,
EndBlockHeight
:
env
.
blockHeight
+
10
,
EndBlockHeight
:
env
.
blockHeight
+
10
,
},
},
&
auty
.
ProposalProject
{
// check StartBlockHeight EndBlockHeight
{
// check StartBlockHeight EndBlockHeight
Amount
:
10
,
Amount
:
10
,
ToAddr
:
AddrA
,
ToAddr
:
AddrA
,
StartBlockHeight
:
env
.
blockHeight
-
1
,
StartBlockHeight
:
env
.
blockHeight
-
1
,
EndBlockHeight
:
env
.
blockHeight
-
1
,
EndBlockHeight
:
env
.
blockHeight
-
1
,
},
},
&
auty
.
ProposalProject
{
// check activeboard
{
// check activeboard
Amount
:
100
,
Amount
:
100
,
ToAddr
:
AddrA
,
ToAddr
:
AddrA
,
StartBlockHeight
:
env
.
blockHeight
+
5
,
StartBlockHeight
:
env
.
blockHeight
+
5
,
...
@@ -99,7 +99,7 @@ func TestPropProject(t *testing.T) {
...
@@ -99,7 +99,7 @@ func TestPropProject(t *testing.T) {
},
},
}
}
result
:=
[]
error
{
result
:=
[]
error
{
types
.
ErrInvalidAddress
,
types
.
ErrInvalidAddress
,
types
.
ErrInvalidParam
,
types
.
ErrInvalidParam
,
types
.
ErrInvalidParam
,
types
.
ErrInvalidParam
,
...
@@ -232,7 +232,7 @@ func propProjectTx(parm *auty.ProposalProject) (*types.Transaction, error) {
...
@@ -232,7 +232,7 @@ func propProjectTx(parm *auty.ProposalProject) (*types.Transaction, error) {
func
revokeProposalProject
(
t
*
testing
.
T
,
env
*
execEnv
,
exec
drivers
.
Driver
,
stateDB
dbm
.
KV
,
kvdb
dbm
.
KVDB
,
save
bool
)
{
func
revokeProposalProject
(
t
*
testing
.
T
,
env
*
execEnv
,
exec
drivers
.
Driver
,
stateDB
dbm
.
KV
,
kvdb
dbm
.
KVDB
,
save
bool
)
{
proposalID
:=
env
.
txHash
proposalID
:=
env
.
txHash
opt2
:=
&
auty
.
RevokeProposalProject
{
opt2
:=
&
auty
.
RevokeProposalProject
{
ProposalID
:
proposalID
,
ProposalID
:
proposalID
,
}
}
rtx
,
err
:=
revokeProposalProjectTx
(
opt2
)
rtx
,
err
:=
revokeProposalProjectTx
(
opt2
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
...
@@ -294,14 +294,14 @@ func voteProposalProject(t *testing.T, env *execEnv, exec drivers.Driver, stateD
...
@@ -294,14 +294,14 @@ func voteProposalProject(t *testing.T, env *execEnv, exec drivers.Driver, stateD
hear
:=
&
types
.
Header
{
StateHash
:
[]
byte
(
""
)}
hear
:=
&
types
.
Header
{
StateHash
:
[]
byte
(
""
)}
api
.
On
(
"GetHeaders"
,
mock
.
Anything
)
.
api
.
On
(
"GetHeaders"
,
mock
.
Anything
)
.
Return
(
&
types
.
Headers
{
Return
(
&
types
.
Headers
{
Items
:
[]
*
types
.
Header
{
hear
}},
nil
)
Items
:
[]
*
types
.
Header
{
hear
}},
nil
)
acc
:=
&
types
.
Account
{
acc
:=
&
types
.
Account
{
Currency
:
0
,
Currency
:
0
,
Balance
:
total
*
4
,
Balance
:
total
*
4
,
}
}
val
:=
types
.
Encode
(
acc
)
val
:=
types
.
Encode
(
acc
)
values
:=
[][]
byte
{
val
}
values
:=
[][]
byte
{
val
}
api
.
On
(
"StoreGet"
,
mock
.
Anything
)
.
Return
(
&
types
.
StoreReplyValue
{
Values
:
values
},
nil
)
.
Once
()
api
.
On
(
"StoreGet"
,
mock
.
Anything
)
.
Return
(
&
types
.
StoreReplyValue
{
Values
:
values
},
nil
)
.
Once
()
acc
=
&
types
.
Account
{
acc
=
&
types
.
Account
{
Currency
:
0
,
Currency
:
0
,
...
@@ -309,7 +309,7 @@ func voteProposalProject(t *testing.T, env *execEnv, exec drivers.Driver, stateD
...
@@ -309,7 +309,7 @@ func voteProposalProject(t *testing.T, env *execEnv, exec drivers.Driver, stateD
}
}
val1
:=
types
.
Encode
(
acc
)
val1
:=
types
.
Encode
(
acc
)
values1
:=
[][]
byte
{
val1
}
values1
:=
[][]
byte
{
val1
}
api
.
On
(
"StoreGet"
,
mock
.
Anything
)
.
Return
(
&
types
.
StoreReplyValue
{
Values
:
values1
},
nil
)
.
Once
()
api
.
On
(
"StoreGet"
,
mock
.
Anything
)
.
Return
(
&
types
.
StoreReplyValue
{
Values
:
values1
},
nil
)
.
Once
()
exec
.
SetAPI
(
api
)
exec
.
SetAPI
(
api
)
proposalID
:=
env
.
txHash
proposalID
:=
env
.
txHash
...
@@ -327,7 +327,7 @@ func voteProposalProject(t *testing.T, env *execEnv, exec drivers.Driver, stateD
...
@@ -327,7 +327,7 @@ func voteProposalProject(t *testing.T, env *execEnv, exec drivers.Driver, stateD
for
_
,
record
:=
range
records
{
for
_
,
record
:=
range
records
{
opt
:=
&
auty
.
VoteProposalProject
{
opt
:=
&
auty
.
VoteProposalProject
{
ProposalID
:
proposalID
,
ProposalID
:
proposalID
,
Approve
:
record
.
appr
,
Approve
:
record
.
appr
,
}
}
tx
,
err
:=
voteProposalProjectTx
(
opt
)
tx
,
err
:=
voteProposalProjectTx
(
opt
)
...
@@ -366,7 +366,7 @@ func voteProposalProject(t *testing.T, env *execEnv, exec drivers.Driver, stateD
...
@@ -366,7 +366,7 @@ func voteProposalProject(t *testing.T, env *execEnv, exec drivers.Driver, stateD
}
}
val
:=
types
.
Encode
(
acc
)
val
:=
types
.
Encode
(
acc
)
values
:=
[][]
byte
{
val
}
values
:=
[][]
byte
{
val
}
api
.
On
(
"StoreGet"
,
mock
.
Anything
)
.
Return
(
&
types
.
StoreReplyValue
{
Values
:
values
},
nil
)
.
Once
()
api
.
On
(
"StoreGet"
,
mock
.
Anything
)
.
Return
(
&
types
.
StoreReplyValue
{
Values
:
values
},
nil
)
.
Once
()
exec
.
SetAPI
(
api
)
exec
.
SetAPI
(
api
)
}
}
}
}
...
@@ -408,14 +408,14 @@ func pubVoteProposalProject(t *testing.T, env *execEnv, exec drivers.Driver, sta
...
@@ -408,14 +408,14 @@ func pubVoteProposalProject(t *testing.T, env *execEnv, exec drivers.Driver, sta
hear
:=
&
types
.
Header
{
StateHash
:
[]
byte
(
""
)}
hear
:=
&
types
.
Header
{
StateHash
:
[]
byte
(
""
)}
api
.
On
(
"GetHeaders"
,
mock
.
Anything
)
.
api
.
On
(
"GetHeaders"
,
mock
.
Anything
)
.
Return
(
&
types
.
Headers
{
Return
(
&
types
.
Headers
{
Items
:
[]
*
types
.
Header
{
hear
}},
nil
)
Items
:
[]
*
types
.
Header
{
hear
}},
nil
)
acc
:=
&
types
.
Account
{
acc
:=
&
types
.
Account
{
Currency
:
0
,
Currency
:
0
,
Balance
:
total
*
4
,
Balance
:
total
*
4
,
}
}
val
:=
types
.
Encode
(
acc
)
val
:=
types
.
Encode
(
acc
)
values
:=
[][]
byte
{
val
}
values
:=
[][]
byte
{
val
}
api
.
On
(
"StoreGet"
,
mock
.
Anything
)
.
Return
(
&
types
.
StoreReplyValue
{
Values
:
values
},
nil
)
.
Once
()
api
.
On
(
"StoreGet"
,
mock
.
Anything
)
.
Return
(
&
types
.
StoreReplyValue
{
Values
:
values
},
nil
)
.
Once
()
acc
=
&
types
.
Account
{
acc
=
&
types
.
Account
{
Currency
:
0
,
Currency
:
0
,
...
@@ -423,7 +423,7 @@ func pubVoteProposalProject(t *testing.T, env *execEnv, exec drivers.Driver, sta
...
@@ -423,7 +423,7 @@ func pubVoteProposalProject(t *testing.T, env *execEnv, exec drivers.Driver, sta
}
}
val1
:=
types
.
Encode
(
acc
)
val1
:=
types
.
Encode
(
acc
)
values1
:=
[][]
byte
{
val1
}
values1
:=
[][]
byte
{
val1
}
api
.
On
(
"StoreGet"
,
mock
.
Anything
)
.
Return
(
&
types
.
StoreReplyValue
{
Values
:
values1
},
nil
)
.
Once
()
api
.
On
(
"StoreGet"
,
mock
.
Anything
)
.
Return
(
&
types
.
StoreReplyValue
{
Values
:
values1
},
nil
)
.
Once
()
exec
.
SetAPI
(
api
)
exec
.
SetAPI
(
api
)
proposalID
:=
env
.
txHash
proposalID
:=
env
.
txHash
...
@@ -441,7 +441,7 @@ func pubVoteProposalProject(t *testing.T, env *execEnv, exec drivers.Driver, sta
...
@@ -441,7 +441,7 @@ func pubVoteProposalProject(t *testing.T, env *execEnv, exec drivers.Driver, sta
for
_
,
record
:=
range
records
{
for
_
,
record
:=
range
records
{
opt
:=
&
auty
.
PubVoteProposalProject
{
opt
:=
&
auty
.
PubVoteProposalProject
{
ProposalID
:
proposalID
,
ProposalID
:
proposalID
,
Oppose
:
record
.
appr
,
Oppose
:
record
.
appr
,
}
}
tx
,
err
:=
pubVoteProposalProjectTx
(
opt
)
tx
,
err
:=
pubVoteProposalProjectTx
(
opt
)
...
@@ -480,7 +480,7 @@ func pubVoteProposalProject(t *testing.T, env *execEnv, exec drivers.Driver, sta
...
@@ -480,7 +480,7 @@ func pubVoteProposalProject(t *testing.T, env *execEnv, exec drivers.Driver, sta
}
}
val
:=
types
.
Encode
(
acc
)
val
:=
types
.
Encode
(
acc
)
values
:=
[][]
byte
{
val
}
values
:=
[][]
byte
{
val
}
api
.
On
(
"StoreGet"
,
mock
.
Anything
)
.
Return
(
&
types
.
StoreReplyValue
{
Values
:
values
},
nil
)
.
Once
()
api
.
On
(
"StoreGet"
,
mock
.
Anything
)
.
Return
(
&
types
.
StoreReplyValue
{
Values
:
values
},
nil
)
.
Once
()
exec
.
SetAPI
(
api
)
exec
.
SetAPI
(
api
)
}
}
}
}
...
@@ -493,7 +493,7 @@ func checkPubVoteProposalProjectResult(t *testing.T, stateDB dbm.KV, proposalID
...
@@ -493,7 +493,7 @@ func checkPubVoteProposalProjectResult(t *testing.T, stateDB dbm.KV, proposalID
account
:=
accCoin
.
LoadExecAccount
(
AddrA
,
address
.
ExecAddress
(
auty
.
AutonomyX
))
account
:=
accCoin
.
LoadExecAccount
(
AddrA
,
address
.
ExecAddress
(
auty
.
AutonomyX
))
require
.
Equal
(
t
,
int64
(
0
),
account
.
Frozen
)
require
.
Equal
(
t
,
int64
(
0
),
account
.
Frozen
)
account
=
accCoin
.
LoadExecAccount
(
autonomyFundAddr
,
address
.
ExecAddress
(
auty
.
AutonomyX
))
account
=
accCoin
.
LoadExecAccount
(
autonomyFundAddr
,
address
.
ExecAddress
(
auty
.
AutonomyX
))
require
.
Equal
(
t
,
int64
(
proposalAmount
)
+
testProjectAmount
,
account
.
Balance
)
require
.
Equal
(
t
,
int64
(
proposalAmount
)
+
testProjectAmount
,
account
.
Balance
)
// status
// status
value
,
err
:=
stateDB
.
Get
(
propProjectID
(
proposalID
))
value
,
err
:=
stateDB
.
Get
(
propProjectID
(
proposalID
))
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
...
@@ -522,19 +522,19 @@ func terminateProposalProject(t *testing.T, env *execEnv, exec drivers.Driver, s
...
@@ -522,19 +522,19 @@ func terminateProposalProject(t *testing.T, env *execEnv, exec drivers.Driver, s
hear
:=
&
types
.
Header
{
StateHash
:
[]
byte
(
""
)}
hear
:=
&
types
.
Header
{
StateHash
:
[]
byte
(
""
)}
api
.
On
(
"GetHeaders"
,
mock
.
Anything
)
.
api
.
On
(
"GetHeaders"
,
mock
.
Anything
)
.
Return
(
&
types
.
Headers
{
Return
(
&
types
.
Headers
{
Items
:
[]
*
types
.
Header
{
hear
}},
nil
)
Items
:
[]
*
types
.
Header
{
hear
}},
nil
)
acc
:=
&
types
.
Account
{
acc
:=
&
types
.
Account
{
Currency
:
0
,
Currency
:
0
,
Balance
:
total
*
4
,
Balance
:
total
*
4
,
}
}
val
:=
types
.
Encode
(
acc
)
val
:=
types
.
Encode
(
acc
)
values
:=
[][]
byte
{
val
}
values
:=
[][]
byte
{
val
}
api
.
On
(
"StoreGet"
,
mock
.
Anything
)
.
Return
(
&
types
.
StoreReplyValue
{
Values
:
values
},
nil
)
.
Once
()
api
.
On
(
"StoreGet"
,
mock
.
Anything
)
.
Return
(
&
types
.
StoreReplyValue
{
Values
:
values
},
nil
)
.
Once
()
exec
.
SetAPI
(
api
)
exec
.
SetAPI
(
api
)
proposalID
:=
env
.
txHash
proposalID
:=
env
.
txHash
opt
:=
&
auty
.
TerminateProposalProject
{
opt
:=
&
auty
.
TerminateProposalProject
{
ProposalID
:
proposalID
,
ProposalID
:
proposalID
,
}
}
tx
,
err
:=
terminateProposalProjectTx
(
opt
)
tx
,
err
:=
terminateProposalProjectTx
(
opt
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
...
@@ -592,19 +592,19 @@ func terminateProposalProjectTx(parm *auty.TerminateProposalProject) (*types.Tra
...
@@ -592,19 +592,19 @@ func terminateProposalProjectTx(parm *auty.TerminateProposalProject) (*types.Tra
func
TestGetProjectReceiptLog
(
t
*
testing
.
T
)
{
func
TestGetProjectReceiptLog
(
t
*
testing
.
T
)
{
pre
:=
&
auty
.
AutonomyProposalProject
{
pre
:=
&
auty
.
AutonomyProposalProject
{
PropProject
:
&
auty
.
ProposalProject
{
Year
:
1800
,
Month
:
1
},
PropProject
:
&
auty
.
ProposalProject
{
Year
:
1800
,
Month
:
1
},
CurRule
:
&
auty
.
RuleConfig
{
BoardAttendRatio
:
80
},
CurRule
:
&
auty
.
RuleConfig
{
BoardAttendRatio
:
80
},
Boards
:
[]
string
{
"111"
,
"222"
,
"333"
},
Boards
:
[]
string
{
"111"
,
"222"
,
"333"
},
BoardVoteRes
:
&
auty
.
VoteResult
{
TotalVotes
:
100
},
BoardVoteRes
:
&
auty
.
VoteResult
{
TotalVotes
:
100
},
Status
:
1
,
Status
:
1
,
Address
:
"121"
,
Address
:
"121"
,
}
}
cur
:=
&
auty
.
AutonomyProposalProject
{
cur
:=
&
auty
.
AutonomyProposalProject
{
PropProject
:
&
auty
.
ProposalProject
{
Year
:
1900
,
Month
:
1
},
PropProject
:
&
auty
.
ProposalProject
{
Year
:
1900
,
Month
:
1
},
CurRule
:
&
auty
.
RuleConfig
{
BoardAttendRatio
:
90
},
CurRule
:
&
auty
.
RuleConfig
{
BoardAttendRatio
:
90
},
Boards
:
[]
string
{
"555"
,
"666"
,
"777"
},
Boards
:
[]
string
{
"555"
,
"666"
,
"777"
},
BoardVoteRes
:
&
auty
.
VoteResult
{
TotalVotes
:
100
},
BoardVoteRes
:
&
auty
.
VoteResult
{
TotalVotes
:
100
},
Status
:
2
,
Status
:
2
,
Address
:
"123"
,
Address
:
"123"
,
}
}
log
:=
getProjectReceiptLog
(
pre
,
cur
,
2
)
log
:=
getProjectReceiptLog
(
pre
,
cur
,
2
)
require
.
Equal
(
t
,
int32
(
2
),
log
.
Ty
)
require
.
Equal
(
t
,
int32
(
2
),
log
.
Ty
)
...
@@ -623,12 +623,12 @@ func TestCopyAutonomyProposalProject(t *testing.T) {
...
@@ -623,12 +623,12 @@ func TestCopyAutonomyProposalProject(t *testing.T) {
require
.
Nil
(
t
,
copyAutonomyProposalProject
(
nil
))
require
.
Nil
(
t
,
copyAutonomyProposalProject
(
nil
))
cur
:=
&
auty
.
AutonomyProposalProject
{
cur
:=
&
auty
.
AutonomyProposalProject
{
PropProject
:
&
auty
.
ProposalProject
{
Year
:
1800
,
Month
:
1
},
PropProject
:
&
auty
.
ProposalProject
{
Year
:
1800
,
Month
:
1
},
CurRule
:
&
auty
.
RuleConfig
{
BoardAttendRatio
:
80
},
CurRule
:
&
auty
.
RuleConfig
{
BoardAttendRatio
:
80
},
Boards
:
[]
string
{
"111"
,
"222"
,
"333"
},
Boards
:
[]
string
{
"111"
,
"222"
,
"333"
},
BoardVoteRes
:
&
auty
.
VoteResult
{
TotalVotes
:
100
},
BoardVoteRes
:
&
auty
.
VoteResult
{
TotalVotes
:
100
},
PubVote
:
&
auty
.
PublicVote
{
Publicity
:
true
},
PubVote
:
&
auty
.
PublicVote
{
Publicity
:
true
},
Status
:
2
,
Status
:
2
,
Address
:
"123"
,
Address
:
"123"
,
}
}
pre
:=
copyAutonomyProposalProject
(
cur
)
pre
:=
copyAutonomyProposalProject
(
cur
)
cur
.
PropProject
.
Year
=
1900
cur
.
PropProject
.
Year
=
1900
...
...
plugin/dapp/autonomy/executor/query.go
View file @
cf9a539d
...
@@ -19,7 +19,6 @@ func (a *Autonomy) Query_ListProposalBoard(in *auty.ReqQueryProposalBoard) (type
...
@@ -19,7 +19,6 @@ func (a *Autonomy) Query_ListProposalBoard(in *auty.ReqQueryProposalBoard) (type
return
a
.
listProposalBoard
(
in
)
return
a
.
listProposalBoard
(
in
)
}
}
// Query_GetProposalProject 查询提案项目
// Query_GetProposalProject 查询提案项目
func
(
a
*
Autonomy
)
Query_GetProposalProject
(
in
*
types
.
ReqString
)
(
types
.
Message
,
error
)
{
func
(
a
*
Autonomy
)
Query_GetProposalProject
(
in
*
types
.
ReqString
)
(
types
.
Message
,
error
)
{
return
a
.
getProposalProject
(
in
)
return
a
.
getProposalProject
(
in
)
...
@@ -30,7 +29,6 @@ func (a *Autonomy) Query_ListProposalProject(in *auty.ReqQueryProposalProject) (
...
@@ -30,7 +29,6 @@ func (a *Autonomy) Query_ListProposalProject(in *auty.ReqQueryProposalProject) (
return
a
.
listProposalProject
(
in
)
return
a
.
listProposalProject
(
in
)
}
}
// Query_GetProposalRule 查询提案规则
// Query_GetProposalRule 查询提案规则
func
(
a
*
Autonomy
)
Query_GetProposalRule
(
in
*
types
.
ReqString
)
(
types
.
Message
,
error
)
{
func
(
a
*
Autonomy
)
Query_GetProposalRule
(
in
*
types
.
ReqString
)
(
types
.
Message
,
error
)
{
return
a
.
getProposalRule
(
in
)
return
a
.
getProposalRule
(
in
)
...
@@ -41,7 +39,6 @@ func (a *Autonomy) Query_ListProposalRule(in *auty.ReqQueryProposalRule) (types.
...
@@ -41,7 +39,6 @@ func (a *Autonomy) Query_ListProposalRule(in *auty.ReqQueryProposalRule) (types.
return
a
.
listProposalRule
(
in
)
return
a
.
listProposalRule
(
in
)
}
}
// Query_ListProposalComment 批量查询提案评论
// Query_ListProposalComment 批量查询提案评论
func
(
a
*
Autonomy
)
Query_ListProposalComment
(
in
*
auty
.
ReqQueryProposalComment
)
(
types
.
Message
,
error
)
{
func
(
a
*
Autonomy
)
Query_ListProposalComment
(
in
*
auty
.
ReqQueryProposalComment
)
(
types
.
Message
,
error
)
{
return
a
.
listProposalComment
(
in
)
return
a
.
listProposalComment
(
in
)
...
...
plugin/dapp/autonomy/executor/rule.go
View file @
cf9a539d
plugin/dapp/autonomy/executor/rule_test.go
View file @
cf9a539d
...
@@ -6,11 +6,12 @@ package executor
...
@@ -6,11 +6,12 @@ package executor
import
(
import
(
"testing"
"testing"
"github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/util"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/require"
"github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/util"
)
)
func
TestExecLocalRule
(
t
*
testing
.
T
)
{
func
TestExecLocalRule
(
t
*
testing
.
T
)
{
...
@@ -31,7 +32,7 @@ func TestExecLocalRule(t *testing.T) {
...
@@ -31,7 +32,7 @@ func TestExecLocalRule(t *testing.T) {
}
}
receipt
:=
&
types
.
ReceiptData
{
receipt
:=
&
types
.
ReceiptData
{
Logs
:
[]
*
types
.
ReceiptLog
{
Logs
:
[]
*
types
.
ReceiptLog
{
{
Ty
:
auty
.
TyLogPropRule
,
Log
:
types
.
Encode
(
receiptRule
)},
{
Ty
:
auty
.
TyLogPropRule
,
Log
:
types
.
Encode
(
receiptRule
)},
},
},
}
}
set
,
err
:=
au
.
execLocalRule
(
receipt
)
set
,
err
:=
au
.
execLocalRule
(
receipt
)
...
@@ -51,7 +52,7 @@ func TestExecLocalRule(t *testing.T) {
...
@@ -51,7 +52,7 @@ func TestExecLocalRule(t *testing.T) {
}
}
set
,
err
=
au
.
execLocalRule
(
&
types
.
ReceiptData
{
set
,
err
=
au
.
execLocalRule
(
&
types
.
ReceiptData
{
Logs
:
[]
*
types
.
ReceiptLog
{
Logs
:
[]
*
types
.
ReceiptLog
{
{
Ty
:
auty
.
TyLogRvkPropRule
,
Log
:
types
.
Encode
(
receiptRule1
)},
{
Ty
:
auty
.
TyLogRvkPropRule
,
Log
:
types
.
Encode
(
receiptRule1
)},
},
},
})
})
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
...
@@ -76,7 +77,7 @@ func TestExecLocalRule(t *testing.T) {
...
@@ -76,7 +77,7 @@ func TestExecLocalRule(t *testing.T) {
}
}
set
,
err
=
au
.
execLocalRule
(
&
types
.
ReceiptData
{
set
,
err
=
au
.
execLocalRule
(
&
types
.
ReceiptData
{
Logs
:
[]
*
types
.
ReceiptLog
{
Logs
:
[]
*
types
.
ReceiptLog
{
{
Ty
:
auty
.
TyLogVotePropRule
,
Log
:
types
.
Encode
(
receiptRule2
)},
{
Ty
:
auty
.
TyLogVotePropRule
,
Log
:
types
.
Encode
(
receiptRule2
)},
},
},
})
})
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
...
@@ -106,7 +107,7 @@ func TestExecDelLocalRule(t *testing.T) {
...
@@ -106,7 +107,7 @@ func TestExecDelLocalRule(t *testing.T) {
}
}
receipt
:=
&
types
.
ReceiptData
{
receipt
:=
&
types
.
ReceiptData
{
Logs
:
[]
*
types
.
ReceiptLog
{
Logs
:
[]
*
types
.
ReceiptLog
{
{
Ty
:
auty
.
TyLogPropRule
,
Log
:
types
.
Encode
(
receiptRule
)},
{
Ty
:
auty
.
TyLogPropRule
,
Log
:
types
.
Encode
(
receiptRule
)},
},
},
}
}
set
,
err
:=
au
.
execDelLocalRule
(
receipt
)
set
,
err
:=
au
.
execDelLocalRule
(
receipt
)
...
@@ -127,7 +128,7 @@ func TestExecDelLocalRule(t *testing.T) {
...
@@ -127,7 +128,7 @@ func TestExecDelLocalRule(t *testing.T) {
}
}
set
,
err
=
au
.
execDelLocalRule
(
&
types
.
ReceiptData
{
set
,
err
=
au
.
execDelLocalRule
(
&
types
.
ReceiptData
{
Logs
:
[]
*
types
.
ReceiptLog
{
Logs
:
[]
*
types
.
ReceiptLog
{
{
Ty
:
auty
.
TyLogVotePropRule
,
Log
:
types
.
Encode
(
receiptRule2
)},
{
Ty
:
auty
.
TyLogVotePropRule
,
Log
:
types
.
Encode
(
receiptRule2
)},
},
},
})
})
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
...
@@ -148,7 +149,7 @@ func TestGetProposalRule(t *testing.T) {
...
@@ -148,7 +149,7 @@ func TestGetProposalRule(t *testing.T) {
au
.
SetStateDB
(
storedb
)
au
.
SetStateDB
(
storedb
)
tx
:=
"1111111111111111111"
tx
:=
"1111111111111111111"
storedb
.
Set
(
propRuleID
(
tx
),
types
.
Encode
(
&
auty
.
AutonomyProposalRule
{}))
storedb
.
Set
(
propRuleID
(
tx
),
types
.
Encode
(
&
auty
.
AutonomyProposalRule
{}))
rsp
,
err
:=
au
.
getProposalRule
(
&
types
.
ReqString
{
Data
:
tx
})
rsp
,
err
:=
au
.
getProposalRule
(
&
types
.
ReqString
{
Data
:
tx
})
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
rsp
)
require
.
NotNil
(
t
,
rsp
)
require
.
Equal
(
t
,
len
(
rsp
.
(
*
auty
.
ReplyQueryProposalRule
)
.
PropRules
),
1
)
require
.
Equal
(
t
,
len
(
rsp
.
(
*
auty
.
ReplyQueryProposalRule
)
.
PropRules
),
1
)
...
@@ -201,9 +202,9 @@ func TestListProposalRule(t *testing.T) {
...
@@ -201,9 +202,9 @@ func TestListProposalRule(t *testing.T) {
// 反向查找
// 反向查找
req
:=
&
auty
.
ReqQueryProposalRule
{
req
:=
&
auty
.
ReqQueryProposalRule
{
Status
:
auty
.
AutonomyStatusProposalRule
,
Status
:
auty
.
AutonomyStatusProposalRule
,
Count
:
10
,
Count
:
10
,
Direction
:
0
,
Direction
:
0
,
Index
:
-
1
,
Index
:
-
1
,
}
}
rsp
,
err
:=
au
.
listProposalRule
(
req
)
rsp
,
err
:=
au
.
listProposalRule
(
req
)
...
@@ -218,9 +219,9 @@ func TestListProposalRule(t *testing.T) {
...
@@ -218,9 +219,9 @@ func TestListProposalRule(t *testing.T) {
// 正向查找
// 正向查找
req
=
&
auty
.
ReqQueryProposalRule
{
req
=
&
auty
.
ReqQueryProposalRule
{
Status
:
auty
.
AutonomyStatusProposalRule
,
Status
:
auty
.
AutonomyStatusProposalRule
,
Count
:
10
,
Count
:
10
,
Direction
:
1
,
Direction
:
1
,
Index
:
-
1
,
Index
:
-
1
,
}
}
rsp
,
err
=
au
.
listProposalRule
(
req
)
rsp
,
err
=
au
.
listProposalRule
(
req
)
...
@@ -233,9 +234,9 @@ func TestListProposalRule(t *testing.T) {
...
@@ -233,9 +234,9 @@ func TestListProposalRule(t *testing.T) {
// 翻页查找
// 翻页查找
req
=
&
auty
.
ReqQueryProposalRule
{
req
=
&
auty
.
ReqQueryProposalRule
{
Status
:
auty
.
AutonomyStatusProposalRule
,
Status
:
auty
.
AutonomyStatusProposalRule
,
Count
:
1
,
Count
:
1
,
Direction
:
0
,
Direction
:
0
,
Index
:
-
1
,
Index
:
-
1
,
}
}
rsp
,
err
=
au
.
listProposalRule
(
req
)
rsp
,
err
=
au
.
listProposalRule
(
req
)
...
@@ -248,9 +249,9 @@ func TestListProposalRule(t *testing.T) {
...
@@ -248,9 +249,9 @@ func TestListProposalRule(t *testing.T) {
//
//
Index
:=
height
*
types
.
MaxTxsPerBlock
+
int64
(
index
)
Index
:=
height
*
types
.
MaxTxsPerBlock
+
int64
(
index
)
req
=
&
auty
.
ReqQueryProposalRule
{
req
=
&
auty
.
ReqQueryProposalRule
{
Status
:
auty
.
AutonomyStatusProposalRule
,
Status
:
auty
.
AutonomyStatusProposalRule
,
Count
:
10
,
Count
:
10
,
Direction
:
0
,
Direction
:
0
,
Index
:
Index
,
Index
:
Index
,
}
}
rsp
,
err
=
au
.
listProposalRule
(
req
)
rsp
,
err
=
au
.
listProposalRule
(
req
)
...
@@ -266,18 +267,18 @@ func TestExecLocalCommentProp(t *testing.T) {
...
@@ -266,18 +267,18 @@ func TestExecLocalCommentProp(t *testing.T) {
propID
:=
"11111111111111"
propID
:=
"11111111111111"
Repcmt
:=
"2222222222"
Repcmt
:=
"2222222222"
comment
:=
"3333333333"
comment
:=
"3333333333"
receiptCmt
:=
&
auty
.
ReceiptProposalComment
{
receiptCmt
:=
&
auty
.
ReceiptProposalComment
{
Cmt
:
&
auty
.
Comment
{
Cmt
:
&
auty
.
Comment
{
ProposalID
:
propID
,
ProposalID
:
propID
,
RepCmtHash
:
Repcmt
,
RepCmtHash
:
Repcmt
,
Comment
:
comment
,
Comment
:
comment
,
},
},
Height
:
11
,
Height
:
11
,
Index
:
1
,
Index
:
1
,
}
}
receipt
:=
&
types
.
ReceiptData
{
receipt
:=
&
types
.
ReceiptData
{
Logs
:
[]
*
types
.
ReceiptLog
{
Logs
:
[]
*
types
.
ReceiptLog
{
{
Ty
:
auty
.
TyLogCommentProp
,
Log
:
types
.
Encode
(
receiptCmt
)},
{
Ty
:
auty
.
TyLogCommentProp
,
Log
:
types
.
Encode
(
receiptCmt
)},
},
},
}
}
set
,
err
:=
au
.
execLocalCommentProp
(
receipt
)
set
,
err
:=
au
.
execLocalCommentProp
(
receipt
)
...
@@ -293,18 +294,18 @@ func TestExecDelLocalCommentProp(t *testing.T) {
...
@@ -293,18 +294,18 @@ func TestExecDelLocalCommentProp(t *testing.T) {
propID
:=
"11111111111111"
propID
:=
"11111111111111"
Repcmt
:=
"2222222222"
Repcmt
:=
"2222222222"
comment
:=
"3333333333"
comment
:=
"3333333333"
receiptCmt
:=
&
auty
.
ReceiptProposalComment
{
receiptCmt
:=
&
auty
.
ReceiptProposalComment
{
Cmt
:
&
auty
.
Comment
{
Cmt
:
&
auty
.
Comment
{
ProposalID
:
propID
,
ProposalID
:
propID
,
RepCmtHash
:
Repcmt
,
RepCmtHash
:
Repcmt
,
Comment
:
comment
,
Comment
:
comment
,
},
},
Height
:
11
,
Height
:
11
,
Index
:
1
,
Index
:
1
,
}
}
receipt
:=
&
types
.
ReceiptData
{
receipt
:=
&
types
.
ReceiptData
{
Logs
:
[]
*
types
.
ReceiptLog
{
Logs
:
[]
*
types
.
ReceiptLog
{
{
Ty
:
auty
.
TyLogCommentProp
,
Log
:
types
.
Encode
(
receiptCmt
)},
{
Ty
:
auty
.
TyLogCommentProp
,
Log
:
types
.
Encode
(
receiptCmt
)},
},
},
}
}
set
,
err
:=
au
.
execDelLocalCommentProp
(
receipt
)
set
,
err
:=
au
.
execDelLocalCommentProp
(
receipt
)
...
@@ -346,8 +347,8 @@ func TestListProposalComment(t *testing.T) {
...
@@ -346,8 +347,8 @@ func TestListProposalComment(t *testing.T) {
testcase
=
append
(
testcase
,
testcase1
...
)
testcase
=
append
(
testcase
,
testcase1
...
)
testcase
=
append
(
testcase
,
testcase2
...
)
testcase
=
append
(
testcase
,
testcase2
...
)
cur
:=
&
auty
.
RelationCmt
{
cur
:=
&
auty
.
RelationCmt
{
RepCmtHash
:
"aaaaaa"
,
RepCmtHash
:
"aaaaaa"
,
Comment
:
"bbbbbbbbbb"
,
Comment
:
"bbbbbbbbbb"
,
}
}
for
_
,
tcase
:=
range
testcase
{
for
_
,
tcase
:=
range
testcase
{
key
:=
calcCommentHeight
(
tcase
.
propId
,
key
:=
calcCommentHeight
(
tcase
.
propId
,
...
@@ -360,9 +361,9 @@ func TestListProposalComment(t *testing.T) {
...
@@ -360,9 +361,9 @@ func TestListProposalComment(t *testing.T) {
// 反向查找
// 反向查找
req
:=
&
auty
.
ReqQueryProposalComment
{
req
:=
&
auty
.
ReqQueryProposalComment
{
ProposalID
:
propID2
,
ProposalID
:
propID2
,
Count
:
10
,
Count
:
10
,
Direction
:
0
,
Direction
:
0
,
Index
:
-
1
,
Index
:
-
1
,
}
}
rsp
,
err
:=
au
.
listProposalComment
(
req
)
rsp
,
err
:=
au
.
listProposalComment
(
req
)
...
@@ -377,9 +378,9 @@ func TestListProposalComment(t *testing.T) {
...
@@ -377,9 +378,9 @@ func TestListProposalComment(t *testing.T) {
// 正向查找
// 正向查找
req
=
&
auty
.
ReqQueryProposalComment
{
req
=
&
auty
.
ReqQueryProposalComment
{
ProposalID
:
propID2
,
ProposalID
:
propID2
,
Count
:
10
,
Count
:
10
,
Direction
:
1
,
Direction
:
1
,
Index
:
-
1
,
Index
:
-
1
,
}
}
rsp
,
err
=
au
.
listProposalComment
(
req
)
rsp
,
err
=
au
.
listProposalComment
(
req
)
...
@@ -392,9 +393,9 @@ func TestListProposalComment(t *testing.T) {
...
@@ -392,9 +393,9 @@ func TestListProposalComment(t *testing.T) {
// 翻页查找
// 翻页查找
req
=
&
auty
.
ReqQueryProposalComment
{
req
=
&
auty
.
ReqQueryProposalComment
{
ProposalID
:
propID2
,
ProposalID
:
propID2
,
Count
:
1
,
Count
:
1
,
Direction
:
0
,
Direction
:
0
,
Index
:
-
1
,
Index
:
-
1
,
}
}
rsp
,
err
=
au
.
listProposalComment
(
req
)
rsp
,
err
=
au
.
listProposalComment
(
req
)
...
@@ -407,9 +408,9 @@ func TestListProposalComment(t *testing.T) {
...
@@ -407,9 +408,9 @@ func TestListProposalComment(t *testing.T) {
//
//
Index
:=
height
*
types
.
MaxTxsPerBlock
+
int64
(
index
)
Index
:=
height
*
types
.
MaxTxsPerBlock
+
int64
(
index
)
req
=
&
auty
.
ReqQueryProposalComment
{
req
=
&
auty
.
ReqQueryProposalComment
{
ProposalID
:
propID2
,
ProposalID
:
propID2
,
Count
:
10
,
Count
:
10
,
Direction
:
0
,
Direction
:
0
,
Index
:
Index
,
Index
:
Index
,
}
}
rsp
,
err
=
au
.
listProposalComment
(
req
)
rsp
,
err
=
au
.
listProposalComment
(
req
)
...
...
plugin/dapp/autonomy/executor/ruleaction.go
View file @
cf9a539d
...
@@ -12,8 +12,6 @@ import (
...
@@ -12,8 +12,6 @@ import (
"github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/system/dapp"
)
)
func
(
a
*
action
)
propRule
(
prob
*
auty
.
ProposalRule
)
(
*
types
.
Receipt
,
error
)
{
func
(
a
*
action
)
propRule
(
prob
*
auty
.
ProposalRule
)
(
*
types
.
Receipt
,
error
)
{
//如果全小于等于0,则说明该提案规则参数不正确
//如果全小于等于0,则说明该提案规则参数不正确
if
prob
.
RuleCfg
==
nil
||
prob
.
RuleCfg
.
BoardAttendRatio
<=
0
&&
prob
.
RuleCfg
.
BoardApproveRatio
<=
0
&&
if
prob
.
RuleCfg
==
nil
||
prob
.
RuleCfg
.
BoardAttendRatio
<=
0
&&
prob
.
RuleCfg
.
BoardApproveRatio
<=
0
&&
...
@@ -53,7 +51,7 @@ func (a *action) propRule(prob *auty.ProposalRule) (*types.Receipt, error) {
...
@@ -53,7 +51,7 @@ func (a *action) propRule(prob *auty.ProposalRule) (*types.Receipt, error) {
kv
=
append
(
kv
,
receipt
.
KV
...
)
kv
=
append
(
kv
,
receipt
.
KV
...
)
cur
:=
&
auty
.
AutonomyProposalRule
{
cur
:=
&
auty
.
AutonomyProposalRule
{
PropRule
:
prob
,
PropRule
:
prob
,
CurRule
:
rule
,
CurRule
:
rule
,
VoteResult
:
&
auty
.
VoteResult
{},
VoteResult
:
&
auty
.
VoteResult
{},
Status
:
auty
.
AutonomyStatusProposalRule
,
Status
:
auty
.
AutonomyStatusProposalRule
,
...
@@ -169,7 +167,7 @@ func (a *action) votePropRule(voteProb *auty.VoteProposalRule) (*types.Receipt,
...
@@ -169,7 +167,7 @@ func (a *action) votePropRule(voteProb *auty.VoteProposalRule) (*types.Receipt,
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
cur
.
VoteResult
.
TotalVotes
=
int32
(
account
.
Balance
/
ticketPrice
)
cur
.
VoteResult
.
TotalVotes
=
int32
(
account
.
Balance
/
ticketPrice
)
}
}
// 获取可投票数
// 获取可投票数
...
@@ -178,9 +176,9 @@ func (a *action) votePropRule(voteProb *auty.VoteProposalRule) (*types.Receipt,
...
@@ -178,9 +176,9 @@ func (a *action) votePropRule(voteProb *auty.VoteProposalRule) (*types.Receipt,
return
nil
,
err
return
nil
,
err
}
}
if
voteProb
.
Approve
{
if
voteProb
.
Approve
{
cur
.
VoteResult
.
ApproveVotes
+=
int32
(
account
.
Balance
/
ticketPrice
)
cur
.
VoteResult
.
ApproveVotes
+=
int32
(
account
.
Balance
/
ticketPrice
)
}
else
{
}
else
{
cur
.
VoteResult
.
OpposeVotes
+=
int32
(
account
.
Balance
/
ticketPrice
)
cur
.
VoteResult
.
OpposeVotes
+=
int32
(
account
.
Balance
/
ticketPrice
)
}
}
var
logs
[]
*
types
.
ReceiptLog
var
logs
[]
*
types
.
ReceiptLog
...
@@ -198,9 +196,9 @@ func (a *action) votePropRule(voteProb *auty.VoteProposalRule) (*types.Receipt,
...
@@ -198,9 +196,9 @@ func (a *action) votePropRule(voteProb *auty.VoteProposalRule) (*types.Receipt,
}
}
if
cur
.
VoteResult
.
TotalVotes
!=
0
&&
if
cur
.
VoteResult
.
TotalVotes
!=
0
&&
cur
.
VoteResult
.
ApproveVotes
+
cur
.
VoteResult
.
OpposeVotes
!=
0
&&
cur
.
VoteResult
.
ApproveVotes
+
cur
.
VoteResult
.
OpposeVotes
!=
0
&&
float32
(
cur
.
VoteResult
.
ApproveVotes
+
cur
.
VoteResult
.
OpposeVotes
)
/
float32
(
cur
.
VoteResult
.
TotalVotes
)
>=
float32
(
pubAttendRatio
)
/
100.0
&&
float32
(
cur
.
VoteResult
.
ApproveVotes
+
cur
.
VoteResult
.
OpposeVotes
)
/
float32
(
cur
.
VoteResult
.
TotalVotes
)
>=
float32
(
pubAttendRatio
)
/
100.0
&&
float32
(
cur
.
VoteResult
.
ApproveVotes
)
/
float32
(
cur
.
VoteResult
.
ApproveVotes
+
cur
.
VoteResult
.
OpposeVotes
)
>=
float32
(
pubApproveRatio
)
/
100.0
{
float32
(
cur
.
VoteResult
.
ApproveVotes
)
/
float32
(
cur
.
VoteResult
.
ApproveVotes
+
cur
.
VoteResult
.
OpposeVotes
)
>=
float32
(
pubApproveRatio
)
/
100.0
{
cur
.
VoteResult
.
Pass
=
true
cur
.
VoteResult
.
Pass
=
true
cur
.
PropRule
.
RealEndBlockHeight
=
a
.
height
cur
.
PropRule
.
RealEndBlockHeight
=
a
.
height
}
}
...
@@ -218,7 +216,7 @@ func (a *action) votePropRule(voteProb *auty.VoteProposalRule) (*types.Receipt,
...
@@ -218,7 +216,7 @@ func (a *action) votePropRule(voteProb *auty.VoteProposalRule) (*types.Receipt,
// 更新系统规则
// 更新系统规则
if
cur
.
VoteResult
.
Pass
{
if
cur
.
VoteResult
.
Pass
{
upRule
:=
upgradeRule
(
cur
.
CurRule
,
cur
.
PropRule
.
RuleCfg
)
upRule
:=
upgradeRule
(
cur
.
CurRule
,
cur
.
PropRule
.
RuleCfg
)
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
activeRuleID
(),
Value
:
types
.
Encode
(
upRule
)})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
activeRuleID
(),
Value
:
types
.
Encode
(
upRule
)})
}
}
ty
:=
auty
.
TyLogVotePropRule
ty
:=
auty
.
TyLogVotePropRule
...
@@ -265,11 +263,11 @@ func (a *action) tmintPropRule(tmintProb *auty.TerminateProposalRule) (*types.Re
...
@@ -265,11 +263,11 @@ func (a *action) tmintPropRule(tmintProb *auty.TerminateProposalRule) (*types.Re
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
cur
.
VoteResult
.
TotalVotes
=
int32
(
account
.
Balance
/
ticketPrice
)
cur
.
VoteResult
.
TotalVotes
=
int32
(
account
.
Balance
/
ticketPrice
)
}
}
if
float32
(
cur
.
VoteResult
.
ApproveVotes
+
cur
.
VoteResult
.
OpposeVotes
)
/
float32
(
cur
.
VoteResult
.
TotalVotes
)
>=
float32
(
pubAttendRatio
)
/
100.0
&&
if
float32
(
cur
.
VoteResult
.
ApproveVotes
+
cur
.
VoteResult
.
OpposeVotes
)
/
float32
(
cur
.
VoteResult
.
TotalVotes
)
>=
float32
(
pubAttendRatio
)
/
100.0
&&
float32
(
cur
.
VoteResult
.
ApproveVotes
)
/
float32
(
cur
.
VoteResult
.
ApproveVotes
+
cur
.
VoteResult
.
OpposeVotes
)
>=
float32
(
pubApproveRatio
)
/
100.0
{
float32
(
cur
.
VoteResult
.
ApproveVotes
)
/
float32
(
cur
.
VoteResult
.
ApproveVotes
+
cur
.
VoteResult
.
OpposeVotes
)
>=
float32
(
pubApproveRatio
)
/
100.0
{
cur
.
VoteResult
.
Pass
=
true
cur
.
VoteResult
.
Pass
=
true
}
else
{
}
else
{
cur
.
VoteResult
.
Pass
=
false
cur
.
VoteResult
.
Pass
=
false
...
@@ -298,7 +296,7 @@ func (a *action) tmintPropRule(tmintProb *auty.TerminateProposalRule) (*types.Re
...
@@ -298,7 +296,7 @@ func (a *action) tmintPropRule(tmintProb *auty.TerminateProposalRule) (*types.Re
// 更新系统规则
// 更新系统规则
if
cur
.
VoteResult
.
Pass
{
if
cur
.
VoteResult
.
Pass
{
upRule
:=
upgradeRule
(
cur
.
CurRule
,
cur
.
PropRule
.
RuleCfg
)
upRule
:=
upgradeRule
(
cur
.
CurRule
,
cur
.
PropRule
.
RuleCfg
)
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
activeRuleID
(),
Value
:
types
.
Encode
(
upRule
)})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
activeRuleID
(),
Value
:
types
.
Encode
(
upRule
)})
}
}
receiptLog
:=
getRuleReceiptLog
(
pre
,
cur
,
auty
.
TyLogTmintPropRule
)
receiptLog
:=
getRuleReceiptLog
(
pre
,
cur
,
auty
.
TyLogTmintPropRule
)
logs
=
append
(
logs
,
receiptLog
)
logs
=
append
(
logs
,
receiptLog
)
...
@@ -342,7 +340,7 @@ func (a *action) commentProp(cm *auty.Comment) (*types.Receipt, error) {
...
@@ -342,7 +340,7 @@ func (a *action) commentProp(cm *auty.Comment) (*types.Receipt, error) {
func
getCommentReceiptLog
(
cur
*
auty
.
Comment
,
height
int64
,
index
int32
,
ty
int32
)
*
types
.
ReceiptLog
{
func
getCommentReceiptLog
(
cur
*
auty
.
Comment
,
height
int64
,
index
int32
,
ty
int32
)
*
types
.
ReceiptLog
{
log
:=
&
types
.
ReceiptLog
{}
log
:=
&
types
.
ReceiptLog
{}
log
.
Ty
=
ty
log
.
Ty
=
ty
r
:=
&
auty
.
ReceiptProposalComment
{
Cmt
:
cur
,
Height
:
height
,
Index
:
index
}
r
:=
&
auty
.
ReceiptProposalComment
{
Cmt
:
cur
,
Height
:
height
,
Index
:
index
}
log
.
Log
=
types
.
Encode
(
r
)
log
.
Log
=
types
.
Encode
(
r
)
return
log
return
log
}
}
...
@@ -419,5 +417,3 @@ func upgradeRule(cur, modify *auty.RuleConfig) *auty.RuleConfig {
...
@@ -419,5 +417,3 @@ func upgradeRule(cur, modify *auty.RuleConfig) *auty.RuleConfig {
}
}
return
&
new
return
&
new
}
}
plugin/dapp/autonomy/executor/ruleaction_test.go
View file @
cf9a539d
...
@@ -7,17 +7,17 @@ package executor
...
@@ -7,17 +7,17 @@ package executor
import
(
import
(
"testing"
"testing"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
"github.com/33cn/chain33/account"
"github.com/stretchr/testify/require"
"github.com/33cn/chain33/types"
apimock
"github.com/33cn/chain33/client/mocks"
apimock
"github.com/33cn/chain33/client/mocks"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common/address"
dbm
"github.com/33cn/chain33/common/db"
dbm
"github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/account"
_
"github.com/33cn/chain33/system"
_
"github.com/33cn/chain33/system"
"github.com/stretchr/testify/mock"
"github.com/33cn/chain33/common/address"
drivers
"github.com/33cn/chain33/system/dapp"
drivers
"github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
)
)
const
(
const
(
...
@@ -64,8 +64,7 @@ func testPropRule(t *testing.T, env *execEnv, exec drivers.Driver, stateDB dbm.K
...
@@ -64,8 +64,7 @@ func testPropRule(t *testing.T, env *execEnv, exec drivers.Driver, stateDB dbm.K
PubOpposeRatio
:
testPubOpposeRatio
,
PubOpposeRatio
:
testPubOpposeRatio
,
ProposalAmount
:
testProposalAmount
,
ProposalAmount
:
testProposalAmount
,
LargeProjectAmount
:
testLargeProjectAmount
,
LargeProjectAmount
:
testLargeProjectAmount
,
PublicPeriod
:
testPublicPeriod
,
PublicPeriod
:
testPublicPeriod
,
},
},
StartBlockHeight
:
env
.
blockHeight
+
5
,
StartBlockHeight
:
env
.
blockHeight
+
5
,
EndBlockHeight
:
env
.
blockHeight
+
10
,
EndBlockHeight
:
env
.
blockHeight
+
10
,
...
@@ -125,7 +124,7 @@ func propRuleTx(parm *auty.ProposalRule) (*types.Transaction, error) {
...
@@ -125,7 +124,7 @@ func propRuleTx(parm *auty.ProposalRule) (*types.Transaction, error) {
func
revokeProposalRule
(
t
*
testing
.
T
,
env
*
execEnv
,
exec
drivers
.
Driver
,
stateDB
dbm
.
KV
,
kvdb
dbm
.
KVDB
,
save
bool
)
{
func
revokeProposalRule
(
t
*
testing
.
T
,
env
*
execEnv
,
exec
drivers
.
Driver
,
stateDB
dbm
.
KV
,
kvdb
dbm
.
KVDB
,
save
bool
)
{
proposalID
:=
env
.
txHash
proposalID
:=
env
.
txHash
opt2
:=
&
auty
.
RevokeProposalRule
{
opt2
:=
&
auty
.
RevokeProposalRule
{
ProposalID
:
proposalID
,
ProposalID
:
proposalID
,
}
}
rtx
,
err
:=
revokeProposalRuleTx
(
opt2
)
rtx
,
err
:=
revokeProposalRuleTx
(
opt2
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
...
@@ -171,7 +170,7 @@ func revokeProposalRule(t *testing.T, env *execEnv, exec drivers.Driver, stateDB
...
@@ -171,7 +170,7 @@ func revokeProposalRule(t *testing.T, env *execEnv, exec drivers.Driver, stateDB
require
.
Equal
(
t
,
rule
.
BoardAttendRatio
,
boardAttendRatio
)
require
.
Equal
(
t
,
rule
.
BoardAttendRatio
,
boardAttendRatio
)
require
.
Equal
(
t
,
rule
.
BoardApproveRatio
,
boardApproveRatio
)
require
.
Equal
(
t
,
rule
.
BoardApproveRatio
,
boardApproveRatio
)
require
.
Equal
(
t
,
rule
.
PubOpposeRatio
,
pubOpposeRatio
)
require
.
Equal
(
t
,
rule
.
PubOpposeRatio
,
pubOpposeRatio
)
require
.
Equal
(
t
,
rule
.
ProposalAmount
,
proposalAmount
)
require
.
Equal
(
t
,
rule
.
ProposalAmount
,
proposalAmount
)
require
.
Equal
(
t
,
rule
.
LargeProjectAmount
,
largeProjectAmount
)
require
.
Equal
(
t
,
rule
.
LargeProjectAmount
,
largeProjectAmount
)
require
.
Equal
(
t
,
rule
.
PublicPeriod
,
publicPeriod
)
require
.
Equal
(
t
,
rule
.
PublicPeriod
,
publicPeriod
)
}
}
...
@@ -194,14 +193,14 @@ func voteProposalRule(t *testing.T, env *execEnv, exec drivers.Driver, stateDB d
...
@@ -194,14 +193,14 @@ func voteProposalRule(t *testing.T, env *execEnv, exec drivers.Driver, stateDB d
hear
:=
&
types
.
Header
{
StateHash
:
[]
byte
(
""
)}
hear
:=
&
types
.
Header
{
StateHash
:
[]
byte
(
""
)}
api
.
On
(
"GetHeaders"
,
mock
.
Anything
)
.
api
.
On
(
"GetHeaders"
,
mock
.
Anything
)
.
Return
(
&
types
.
Headers
{
Return
(
&
types
.
Headers
{
Items
:
[]
*
types
.
Header
{
hear
}},
nil
)
Items
:
[]
*
types
.
Header
{
hear
}},
nil
)
acc
:=
&
types
.
Account
{
acc
:=
&
types
.
Account
{
Currency
:
0
,
Currency
:
0
,
Balance
:
total
*
4
,
Balance
:
total
*
4
,
}
}
val
:=
types
.
Encode
(
acc
)
val
:=
types
.
Encode
(
acc
)
values
:=
[][]
byte
{
val
}
values
:=
[][]
byte
{
val
}
api
.
On
(
"StoreGet"
,
mock
.
Anything
)
.
Return
(
&
types
.
StoreReplyValue
{
Values
:
values
},
nil
)
.
Once
()
api
.
On
(
"StoreGet"
,
mock
.
Anything
)
.
Return
(
&
types
.
StoreReplyValue
{
Values
:
values
},
nil
)
.
Once
()
acc
=
&
types
.
Account
{
acc
=
&
types
.
Account
{
Currency
:
0
,
Currency
:
0
,
...
@@ -209,7 +208,7 @@ func voteProposalRule(t *testing.T, env *execEnv, exec drivers.Driver, stateDB d
...
@@ -209,7 +208,7 @@ func voteProposalRule(t *testing.T, env *execEnv, exec drivers.Driver, stateDB d
}
}
val1
:=
types
.
Encode
(
acc
)
val1
:=
types
.
Encode
(
acc
)
values1
:=
[][]
byte
{
val1
}
values1
:=
[][]
byte
{
val1
}
api
.
On
(
"StoreGet"
,
mock
.
Anything
)
.
Return
(
&
types
.
StoreReplyValue
{
Values
:
values1
},
nil
)
.
Once
()
api
.
On
(
"StoreGet"
,
mock
.
Anything
)
.
Return
(
&
types
.
StoreReplyValue
{
Values
:
values1
},
nil
)
.
Once
()
exec
.
SetAPI
(
api
)
exec
.
SetAPI
(
api
)
proposalID
:=
env
.
txHash
proposalID
:=
env
.
txHash
...
@@ -227,7 +226,7 @@ func voteProposalRule(t *testing.T, env *execEnv, exec drivers.Driver, stateDB d
...
@@ -227,7 +226,7 @@ func voteProposalRule(t *testing.T, env *execEnv, exec drivers.Driver, stateDB d
for
_
,
record
:=
range
records
{
for
_
,
record
:=
range
records
{
opt
:=
&
auty
.
VoteProposalRule
{
opt
:=
&
auty
.
VoteProposalRule
{
ProposalID
:
proposalID
,
ProposalID
:
proposalID
,
Approve
:
record
.
appr
,
Approve
:
record
.
appr
,
}
}
tx
,
err
:=
voteProposalRuleTx
(
opt
)
tx
,
err
:=
voteProposalRuleTx
(
opt
)
...
@@ -266,7 +265,7 @@ func voteProposalRule(t *testing.T, env *execEnv, exec drivers.Driver, stateDB d
...
@@ -266,7 +265,7 @@ func voteProposalRule(t *testing.T, env *execEnv, exec drivers.Driver, stateDB d
}
}
val
:=
types
.
Encode
(
acc
)
val
:=
types
.
Encode
(
acc
)
values
:=
[][]
byte
{
val
}
values
:=
[][]
byte
{
val
}
api
.
On
(
"StoreGet"
,
mock
.
Anything
)
.
Return
(
&
types
.
StoreReplyValue
{
Values
:
values
},
nil
)
.
Once
()
api
.
On
(
"StoreGet"
,
mock
.
Anything
)
.
Return
(
&
types
.
StoreReplyValue
{
Values
:
values
},
nil
)
.
Once
()
exec
.
SetAPI
(
api
)
exec
.
SetAPI
(
api
)
}
}
// check
// check
...
@@ -298,7 +297,7 @@ func voteProposalRule(t *testing.T, env *execEnv, exec drivers.Driver, stateDB d
...
@@ -298,7 +297,7 @@ func voteProposalRule(t *testing.T, env *execEnv, exec drivers.Driver, stateDB d
require
.
Equal
(
t
,
rule
.
BoardAttendRatio
,
testBoardAttendRatio
)
require
.
Equal
(
t
,
rule
.
BoardAttendRatio
,
testBoardAttendRatio
)
require
.
Equal
(
t
,
rule
.
BoardApproveRatio
,
testBoardApproveRatio
)
require
.
Equal
(
t
,
rule
.
BoardApproveRatio
,
testBoardApproveRatio
)
require
.
Equal
(
t
,
rule
.
PubOpposeRatio
,
testPubOpposeRatio
)
require
.
Equal
(
t
,
rule
.
PubOpposeRatio
,
testPubOpposeRatio
)
require
.
Equal
(
t
,
rule
.
ProposalAmount
,
proposalAmount
)
require
.
Equal
(
t
,
rule
.
ProposalAmount
,
proposalAmount
)
require
.
Equal
(
t
,
rule
.
LargeProjectAmount
,
testLargeProjectAmount
)
require
.
Equal
(
t
,
rule
.
LargeProjectAmount
,
testLargeProjectAmount
)
require
.
Equal
(
t
,
rule
.
PublicPeriod
,
testPublicPeriod
)
require
.
Equal
(
t
,
rule
.
PublicPeriod
,
testPublicPeriod
)
}
}
...
@@ -321,19 +320,19 @@ func terminateProposalRule(t *testing.T, env *execEnv, exec drivers.Driver, stat
...
@@ -321,19 +320,19 @@ func terminateProposalRule(t *testing.T, env *execEnv, exec drivers.Driver, stat
hear
:=
&
types
.
Header
{
StateHash
:
[]
byte
(
""
)}
hear
:=
&
types
.
Header
{
StateHash
:
[]
byte
(
""
)}
api
.
On
(
"GetHeaders"
,
mock
.
Anything
)
.
api
.
On
(
"GetHeaders"
,
mock
.
Anything
)
.
Return
(
&
types
.
Headers
{
Return
(
&
types
.
Headers
{
Items
:
[]
*
types
.
Header
{
hear
}},
nil
)
Items
:
[]
*
types
.
Header
{
hear
}},
nil
)
acc
:=
&
types
.
Account
{
acc
:=
&
types
.
Account
{
Currency
:
0
,
Currency
:
0
,
Balance
:
total
*
4
,
Balance
:
total
*
4
,
}
}
val
:=
types
.
Encode
(
acc
)
val
:=
types
.
Encode
(
acc
)
values
:=
[][]
byte
{
val
}
values
:=
[][]
byte
{
val
}
api
.
On
(
"StoreGet"
,
mock
.
Anything
)
.
Return
(
&
types
.
StoreReplyValue
{
Values
:
values
},
nil
)
.
Once
()
api
.
On
(
"StoreGet"
,
mock
.
Anything
)
.
Return
(
&
types
.
StoreReplyValue
{
Values
:
values
},
nil
)
.
Once
()
exec
.
SetAPI
(
api
)
exec
.
SetAPI
(
api
)
proposalID
:=
env
.
txHash
proposalID
:=
env
.
txHash
opt
:=
&
auty
.
TerminateProposalRule
{
opt
:=
&
auty
.
TerminateProposalRule
{
ProposalID
:
proposalID
,
ProposalID
:
proposalID
,
}
}
tx
,
err
:=
terminateProposalRuleTx
(
opt
)
tx
,
err
:=
terminateProposalRuleTx
(
opt
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
...
@@ -380,7 +379,7 @@ func terminateProposalRule(t *testing.T, env *execEnv, exec drivers.Driver, stat
...
@@ -380,7 +379,7 @@ func terminateProposalRule(t *testing.T, env *execEnv, exec drivers.Driver, stat
require
.
Equal
(
t
,
rule
.
BoardAttendRatio
,
boardAttendRatio
)
require
.
Equal
(
t
,
rule
.
BoardAttendRatio
,
boardAttendRatio
)
require
.
Equal
(
t
,
rule
.
BoardApproveRatio
,
boardApproveRatio
)
require
.
Equal
(
t
,
rule
.
BoardApproveRatio
,
boardApproveRatio
)
require
.
Equal
(
t
,
rule
.
PubOpposeRatio
,
pubOpposeRatio
)
require
.
Equal
(
t
,
rule
.
PubOpposeRatio
,
pubOpposeRatio
)
require
.
Equal
(
t
,
rule
.
ProposalAmount
,
proposalAmount
)
require
.
Equal
(
t
,
rule
.
ProposalAmount
,
proposalAmount
)
require
.
Equal
(
t
,
rule
.
LargeProjectAmount
,
largeProjectAmount
)
require
.
Equal
(
t
,
rule
.
LargeProjectAmount
,
largeProjectAmount
)
require
.
Equal
(
t
,
rule
.
PublicPeriod
,
publicPeriod
)
require
.
Equal
(
t
,
rule
.
PublicPeriod
,
publicPeriod
)
}
}
...
@@ -401,13 +400,13 @@ func TestGetRuleReceiptLog(t *testing.T) {
...
@@ -401,13 +400,13 @@ func TestGetRuleReceiptLog(t *testing.T) {
PropRule
:
&
auty
.
ProposalRule
{
Year
:
1800
,
Month
:
1
},
PropRule
:
&
auty
.
ProposalRule
{
Year
:
1800
,
Month
:
1
},
VoteResult
:
&
auty
.
VoteResult
{
TotalVotes
:
100
},
VoteResult
:
&
auty
.
VoteResult
{
TotalVotes
:
100
},
Status
:
1
,
Status
:
1
,
Address
:
"121"
,
Address
:
"121"
,
}
}
cur
:=
&
auty
.
AutonomyProposalRule
{
cur
:=
&
auty
.
AutonomyProposalRule
{
PropRule
:
&
auty
.
ProposalRule
{
Year
:
1900
,
Month
:
1
},
PropRule
:
&
auty
.
ProposalRule
{
Year
:
1900
,
Month
:
1
},
VoteResult
:
&
auty
.
VoteResult
{
TotalVotes
:
100
},
VoteResult
:
&
auty
.
VoteResult
{
TotalVotes
:
100
},
Status
:
2
,
Status
:
2
,
Address
:
"123"
,
Address
:
"123"
,
}
}
log
:=
getRuleReceiptLog
(
pre
,
cur
,
2
)
log
:=
getRuleReceiptLog
(
pre
,
cur
,
2
)
require
.
Equal
(
t
,
int32
(
2
),
log
.
Ty
)
require
.
Equal
(
t
,
int32
(
2
),
log
.
Ty
)
...
@@ -421,11 +420,11 @@ func TestGetRuleReceiptLog(t *testing.T) {
...
@@ -421,11 +420,11 @@ func TestGetRuleReceiptLog(t *testing.T) {
func
TestCopyAutonomyProposalRule
(
t
*
testing
.
T
)
{
func
TestCopyAutonomyProposalRule
(
t
*
testing
.
T
)
{
require
.
Nil
(
t
,
copyAutonomyProposalRule
(
nil
))
require
.
Nil
(
t
,
copyAutonomyProposalRule
(
nil
))
cur
:=
&
auty
.
AutonomyProposalRule
{
cur
:=
&
auty
.
AutonomyProposalRule
{
PropRule
:
&
auty
.
ProposalRule
{
Year
:
1900
,
Month
:
1
,
RuleCfg
:&
auty
.
RuleConfig
{
BoardApproveRatio
:
80
}},
PropRule
:
&
auty
.
ProposalRule
{
Year
:
1900
,
Month
:
1
,
RuleCfg
:
&
auty
.
RuleConfig
{
BoardApproveRatio
:
80
}},
CurRule
:
&
auty
.
RuleConfig
{
BoardApproveRatio
:
100
},
CurRule
:
&
auty
.
RuleConfig
{
BoardApproveRatio
:
100
},
VoteResult
:
&
auty
.
VoteResult
{
TotalVotes
:
100
},
VoteResult
:
&
auty
.
VoteResult
{
TotalVotes
:
100
},
Status
:
2
,
Status
:
2
,
Address
:
"123"
,
Address
:
"123"
,
}
}
pre
:=
copyAutonomyProposalRule
(
cur
)
pre
:=
copyAutonomyProposalRule
(
cur
)
cur
.
PropRule
.
Year
=
1800
cur
.
PropRule
.
Year
=
1800
...
@@ -469,7 +468,7 @@ func TestUpgradeRule(t *testing.T) {
...
@@ -469,7 +468,7 @@ func TestUpgradeRule(t *testing.T) {
require
.
Equal
(
t
,
new
.
BoardAttendRatio
,
cur
.
BoardAttendRatio
)
require
.
Equal
(
t
,
new
.
BoardAttendRatio
,
cur
.
BoardAttendRatio
)
require
.
Equal
(
t
,
new
.
BoardApproveRatio
,
cur
.
BoardApproveRatio
)
require
.
Equal
(
t
,
new
.
BoardApproveRatio
,
cur
.
BoardApproveRatio
)
require
.
Equal
(
t
,
new
.
PubOpposeRatio
,
cur
.
PubOpposeRatio
)
require
.
Equal
(
t
,
new
.
PubOpposeRatio
,
cur
.
PubOpposeRatio
)
require
.
Equal
(
t
,
new
.
ProposalAmount
,
cur
.
ProposalAmount
)
require
.
Equal
(
t
,
new
.
ProposalAmount
,
cur
.
ProposalAmount
)
require
.
Equal
(
t
,
new
.
LargeProjectAmount
,
cur
.
LargeProjectAmount
)
require
.
Equal
(
t
,
new
.
LargeProjectAmount
,
cur
.
LargeProjectAmount
)
require
.
Equal
(
t
,
new
.
PublicPeriod
,
cur
.
PublicPeriod
)
require
.
Equal
(
t
,
new
.
PublicPeriod
,
cur
.
PublicPeriod
)
...
@@ -486,7 +485,7 @@ func TestUpgradeRule(t *testing.T) {
...
@@ -486,7 +485,7 @@ func TestUpgradeRule(t *testing.T) {
require
.
Equal
(
t
,
new
.
BoardAttendRatio
,
modify
.
BoardAttendRatio
)
require
.
Equal
(
t
,
new
.
BoardAttendRatio
,
modify
.
BoardAttendRatio
)
require
.
Equal
(
t
,
new
.
BoardApproveRatio
,
modify
.
BoardApproveRatio
)
require
.
Equal
(
t
,
new
.
BoardApproveRatio
,
modify
.
BoardApproveRatio
)
require
.
Equal
(
t
,
new
.
PubOpposeRatio
,
modify
.
PubOpposeRatio
)
require
.
Equal
(
t
,
new
.
PubOpposeRatio
,
modify
.
PubOpposeRatio
)
require
.
Equal
(
t
,
new
.
ProposalAmount
,
modify
.
ProposalAmount
)
require
.
Equal
(
t
,
new
.
ProposalAmount
,
modify
.
ProposalAmount
)
require
.
Equal
(
t
,
new
.
LargeProjectAmount
,
modify
.
LargeProjectAmount
)
require
.
Equal
(
t
,
new
.
LargeProjectAmount
,
modify
.
LargeProjectAmount
)
require
.
Equal
(
t
,
new
.
PublicPeriod
,
modify
.
PublicPeriod
)
require
.
Equal
(
t
,
new
.
PublicPeriod
,
modify
.
PublicPeriod
)
}
}
...
@@ -514,9 +513,9 @@ func TestTransfer(t *testing.T) {
...
@@ -514,9 +513,9 @@ func TestTransfer(t *testing.T) {
accCoin
:=
account
.
NewCoinsAccount
()
accCoin
:=
account
.
NewCoinsAccount
()
accCoin
.
SetDB
(
stateDB
)
accCoin
.
SetDB
(
stateDB
)
account
:=
accCoin
.
LoadExecAccount
(
AddrA
,
address
.
ExecAddress
(
auty
.
AutonomyX
))
account
:=
accCoin
.
LoadExecAccount
(
AddrA
,
address
.
ExecAddress
(
auty
.
AutonomyX
))
require
.
Equal
(
t
,
total
-
types
.
Coin
*
190
,
account
.
Balance
)
require
.
Equal
(
t
,
total
-
types
.
Coin
*
190
,
account
.
Balance
)
account
=
accCoin
.
LoadExecAccount
(
autonomyFundAddr
,
address
.
ExecAddress
(
auty
.
AutonomyX
))
account
=
accCoin
.
LoadExecAccount
(
autonomyFundAddr
,
address
.
ExecAddress
(
auty
.
AutonomyX
))
require
.
Equal
(
t
,
types
.
Coin
*
190
,
account
.
Balance
)
require
.
Equal
(
t
,
types
.
Coin
*
190
,
account
.
Balance
)
}
}
func
transferFundTx
(
parm
*
auty
.
TransferFund
)
(
*
types
.
Transaction
,
error
)
{
func
transferFundTx
(
parm
*
auty
.
TransferFund
)
(
*
types
.
Transaction
,
error
)
{
...
@@ -539,7 +538,7 @@ func TestComment(t *testing.T) {
...
@@ -539,7 +538,7 @@ func TestComment(t *testing.T) {
opt1
:=
&
auty
.
Comment
{
opt1
:=
&
auty
.
Comment
{
ProposalID
:
propID
,
ProposalID
:
propID
,
RepCmtHash
:
Repcmt
,
RepCmtHash
:
Repcmt
,
Comment
:
comment
,
Comment
:
comment
,
}
}
pbtx
,
err
:=
commentPropTx
(
opt1
)
pbtx
,
err
:=
commentPropTx
(
opt1
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
...
...
plugin/dapp/autonomy/rpc/board_jrpc_channel_test.go
View file @
cf9a539d
...
@@ -9,10 +9,10 @@ import (
...
@@ -9,10 +9,10 @@ import (
"github.com/33cn/chain33/rpc/jsonclient"
"github.com/33cn/chain33/rpc/jsonclient"
rpctypes
"github.com/33cn/chain33/rpc/types"
rpctypes
"github.com/33cn/chain33/rpc/types"
"github.com/33cn/chain33/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
_
"github.com/33cn/chain33/system"
_
"github.com/33cn/chain33/system"
"github.com/33cn/chain33/types"
_
"github.com/33cn/plugin/plugin"
_
"github.com/33cn/plugin/plugin"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
)
)
func
testPropBoardTxCmd
(
t
*
testing
.
T
,
jrpc
*
jsonclient
.
JSONClient
)
error
{
func
testPropBoardTxCmd
(
t
*
testing
.
T
,
jrpc
*
jsonclient
.
JSONClient
)
error
{
...
@@ -58,4 +58,3 @@ func testListProposalBoardCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
...
@@ -58,4 +58,3 @@ func testListProposalBoardCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
rep
=
&
auty
.
ReplyQueryProposalBoard
{}
rep
=
&
auty
.
ReplyQueryProposalBoard
{}
return
jrpc
.
Call
(
"Chain33.Query"
,
params
,
rep
)
return
jrpc
.
Call
(
"Chain33.Query"
,
params
,
rep
)
}
}
plugin/dapp/autonomy/rpc/jrpc.go
View file @
cf9a539d
plugin/dapp/autonomy/rpc/project_jrpc_channel_test.go
View file @
cf9a539d
...
@@ -9,13 +9,12 @@ import (
...
@@ -9,13 +9,12 @@ import (
"github.com/33cn/chain33/rpc/jsonclient"
"github.com/33cn/chain33/rpc/jsonclient"
rpctypes
"github.com/33cn/chain33/rpc/types"
rpctypes
"github.com/33cn/chain33/rpc/types"
"github.com/33cn/chain33/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
_
"github.com/33cn/chain33/system"
_
"github.com/33cn/chain33/system"
"github.com/33cn/chain33/types"
_
"github.com/33cn/plugin/plugin"
_
"github.com/33cn/plugin/plugin"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
)
)
func
testPropProjectTxCmd
(
t
*
testing
.
T
,
jrpc
*
jsonclient
.
JSONClient
)
error
{
func
testPropProjectTxCmd
(
t
*
testing
.
T
,
jrpc
*
jsonclient
.
JSONClient
)
error
{
params
:=
&
auty
.
ProposalProject
{}
params
:=
&
auty
.
ProposalProject
{}
var
res
string
var
res
string
...
@@ -65,4 +64,3 @@ func testListProposalProjectCmd(t *testing.T, jrpc *jsonclient.JSONClient) error
...
@@ -65,4 +64,3 @@ func testListProposalProjectCmd(t *testing.T, jrpc *jsonclient.JSONClient) error
rep
=
&
auty
.
ReplyQueryProposalProject
{}
rep
=
&
auty
.
ReplyQueryProposalProject
{}
return
jrpc
.
Call
(
"Chain33.Query"
,
params
,
rep
)
return
jrpc
.
Call
(
"Chain33.Query"
,
params
,
rep
)
}
}
plugin/dapp/autonomy/rpc/rpc.go
View file @
cf9a539d
plugin/dapp/autonomy/rpc/rule_jrpc_channel_test.go
View file @
cf9a539d
...
@@ -9,10 +9,10 @@ import (
...
@@ -9,10 +9,10 @@ import (
"github.com/33cn/chain33/rpc/jsonclient"
"github.com/33cn/chain33/rpc/jsonclient"
rpctypes
"github.com/33cn/chain33/rpc/types"
rpctypes
"github.com/33cn/chain33/rpc/types"
"github.com/33cn/chain33/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
_
"github.com/33cn/chain33/system"
_
"github.com/33cn/chain33/system"
"github.com/33cn/chain33/types"
_
"github.com/33cn/plugin/plugin"
_
"github.com/33cn/plugin/plugin"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
)
)
func
testPropRuleTxCmd
(
t
*
testing
.
T
,
jrpc
*
jsonclient
.
JSONClient
)
error
{
func
testPropRuleTxCmd
(
t
*
testing
.
T
,
jrpc
*
jsonclient
.
JSONClient
)
error
{
...
...
plugin/dapp/autonomy/types/autonomy.pb.go
View file @
cf9a539d
This diff is collapsed.
Click to expand it.
plugin/dapp/autonomy/types/board.pb.go
View file @
cf9a539d
This diff is collapsed.
Click to expand it.
plugin/dapp/autonomy/types/const.go
View file @
cf9a539d
...
@@ -85,7 +85,6 @@ const (
...
@@ -85,7 +85,6 @@ const (
ListProposalComment
=
"ListProposalComment"
ListProposalComment
=
"ListProposalComment"
)
)
//包的名字可以通过配置文件来配置
//包的名字可以通过配置文件来配置
//建议用github的组织名称,或者用户名字开头, 再加上自己的插件的名字
//建议用github的组织名称,或者用户名字开头, 再加上自己的插件的名字
//如果发生重名,可以通过配置文件修改这些名字
//如果发生重名,可以通过配置文件修改这些名字
...
...
plugin/dapp/autonomy/types/lcommon.pb.go
View file @
cf9a539d
...
@@ -3,30 +3,62 @@
...
@@ -3,30 +3,62 @@
package
types
package
types
import
proto
"github.com/golang/protobuf/proto"
import
(
import
fmt
"fmt"
fmt
"fmt"
import
math
"math"
math
"math"
proto
"github.com/golang/protobuf/proto"
)
// Reference imports to suppress errors if they are not otherwise used.
// Reference imports to suppress errors if they are not otherwise used.
var
_
=
proto
.
Marshal
var
_
=
proto
.
Marshal
var
_
=
fmt
.
Errorf
var
_
=
fmt
.
Errorf
var
_
=
math
.
Inf
var
_
=
math
.
Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const
_
=
proto
.
ProtoPackageIsVersion2
// please upgrade the proto package
type
VoteResult
struct
{
type
VoteResult
struct
{
// 总票数
// 总票数
TotalVotes
int32
`protobuf:"varint,1,opt,name=totalVotes" json:"totalVotes,omitempty"`
TotalVotes
int32
`protobuf:"varint,1,opt,name=totalVotes
,proto3
" json:"totalVotes,omitempty"`
// 赞成票
// 赞成票
ApproveVotes
int32
`protobuf:"varint,2,opt,name=approveVotes" json:"approveVotes,omitempty"`
ApproveVotes
int32
`protobuf:"varint,2,opt,name=approveVotes
,proto3
" json:"approveVotes,omitempty"`
// 反对票
// 反对票
OpposeVotes
int32
`protobuf:"varint,3,opt,name=opposeVotes" json:"opposeVotes,omitempty"`
OpposeVotes
int32
`protobuf:"varint,3,opt,name=opposeVotes
,proto3
" json:"opposeVotes,omitempty"`
// 是否通过
// 是否通过
Pass
bool
`protobuf:"varint,4,opt,name=pass" json:"pass,omitempty"`
Pass
bool
`protobuf:"varint,4,opt,name=pass,proto3" json:"pass,omitempty"`
XXX_NoUnkeyedLiteral
struct
{}
`json:"-"`
XXX_unrecognized
[]
byte
`json:"-"`
XXX_sizecache
int32
`json:"-"`
}
}
func
(
m
*
VoteResult
)
Reset
()
{
*
m
=
VoteResult
{}
}
func
(
m
*
VoteResult
)
Reset
()
{
*
m
=
VoteResult
{}
}
func
(
m
*
VoteResult
)
String
()
string
{
return
proto
.
CompactTextString
(
m
)
}
func
(
m
*
VoteResult
)
String
()
string
{
return
proto
.
CompactTextString
(
m
)
}
func
(
*
VoteResult
)
ProtoMessage
()
{}
func
(
*
VoteResult
)
ProtoMessage
()
{}
func
(
*
VoteResult
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
fileDescriptor2
,
[]
int
{
0
}
}
func
(
*
VoteResult
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
fileDescriptor_d916a933dd8220ff
,
[]
int
{
0
}
}
func
(
m
*
VoteResult
)
XXX_Unmarshal
(
b
[]
byte
)
error
{
return
xxx_messageInfo_VoteResult
.
Unmarshal
(
m
,
b
)
}
func
(
m
*
VoteResult
)
XXX_Marshal
(
b
[]
byte
,
deterministic
bool
)
([]
byte
,
error
)
{
return
xxx_messageInfo_VoteResult
.
Marshal
(
b
,
m
,
deterministic
)
}
func
(
m
*
VoteResult
)
XXX_Merge
(
src
proto
.
Message
)
{
xxx_messageInfo_VoteResult
.
Merge
(
m
,
src
)
}
func
(
m
*
VoteResult
)
XXX_Size
()
int
{
return
xxx_messageInfo_VoteResult
.
Size
(
m
)
}
func
(
m
*
VoteResult
)
XXX_DiscardUnknown
()
{
xxx_messageInfo_VoteResult
.
DiscardUnknown
(
m
)
}
var
xxx_messageInfo_VoteResult
proto
.
InternalMessageInfo
func
(
m
*
VoteResult
)
GetTotalVotes
()
int32
{
func
(
m
*
VoteResult
)
GetTotalVotes
()
int32
{
if
m
!=
nil
{
if
m
!=
nil
{
...
@@ -58,19 +90,42 @@ func (m *VoteResult) GetPass() bool {
...
@@ -58,19 +90,42 @@ func (m *VoteResult) GetPass() bool {
type
PublicVote
struct
{
type
PublicVote
struct
{
// 是否需要公示
// 是否需要公示
Publicity
bool
`protobuf:"varint,1,opt,name=publicity" json:"publicity,omitempty"`
Publicity
bool
`protobuf:"varint,1,opt,name=publicity
,proto3
" json:"publicity,omitempty"`
// 总票数
// 总票数
TotalVotes
int32
`protobuf:"varint,2,opt,name=totalVotes" json:"totalVotes,omitempty"`
TotalVotes
int32
`protobuf:"varint,2,opt,name=totalVotes
,proto3
" json:"totalVotes,omitempty"`
// 全体持票人反对票
// 全体持票人反对票
OpposeVotes
int32
`protobuf:"varint,3,opt,name=opposeVotes" json:"opposeVotes,omitempty"`
OpposeVotes
int32
`protobuf:"varint,3,opt,name=opposeVotes
,proto3
" json:"opposeVotes,omitempty"`
// 是否通过
// 是否通过
PubPass
bool
`protobuf:"varint,4,opt,name=pubPass" json:"pubPass,omitempty"`
PubPass
bool
`protobuf:"varint,4,opt,name=pubPass,proto3" json:"pubPass,omitempty"`
XXX_NoUnkeyedLiteral
struct
{}
`json:"-"`
XXX_unrecognized
[]
byte
`json:"-"`
XXX_sizecache
int32
`json:"-"`
}
}
func
(
m
*
PublicVote
)
Reset
()
{
*
m
=
PublicVote
{}
}
func
(
m
*
PublicVote
)
Reset
()
{
*
m
=
PublicVote
{}
}
func
(
m
*
PublicVote
)
String
()
string
{
return
proto
.
CompactTextString
(
m
)
}
func
(
m
*
PublicVote
)
String
()
string
{
return
proto
.
CompactTextString
(
m
)
}
func
(
*
PublicVote
)
ProtoMessage
()
{}
func
(
*
PublicVote
)
ProtoMessage
()
{}
func
(
*
PublicVote
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
fileDescriptor2
,
[]
int
{
1
}
}
func
(
*
PublicVote
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
fileDescriptor_d916a933dd8220ff
,
[]
int
{
1
}
}
func
(
m
*
PublicVote
)
XXX_Unmarshal
(
b
[]
byte
)
error
{
return
xxx_messageInfo_PublicVote
.
Unmarshal
(
m
,
b
)
}
func
(
m
*
PublicVote
)
XXX_Marshal
(
b
[]
byte
,
deterministic
bool
)
([]
byte
,
error
)
{
return
xxx_messageInfo_PublicVote
.
Marshal
(
b
,
m
,
deterministic
)
}
func
(
m
*
PublicVote
)
XXX_Merge
(
src
proto
.
Message
)
{
xxx_messageInfo_PublicVote
.
Merge
(
m
,
src
)
}
func
(
m
*
PublicVote
)
XXX_Size
()
int
{
return
xxx_messageInfo_PublicVote
.
Size
(
m
)
}
func
(
m
*
PublicVote
)
XXX_DiscardUnknown
()
{
xxx_messageInfo_PublicVote
.
DiscardUnknown
(
m
)
}
var
xxx_messageInfo_PublicVote
proto
.
InternalMessageInfo
func
(
m
*
PublicVote
)
GetPublicity
()
bool
{
func
(
m
*
PublicVote
)
GetPublicity
()
bool
{
if
m
!=
nil
{
if
m
!=
nil
{
...
@@ -101,13 +156,36 @@ func (m *PublicVote) GetPubPass() bool {
...
@@ -101,13 +156,36 @@ func (m *PublicVote) GetPubPass() bool {
}
}
type
VotesRecord
struct
{
type
VotesRecord
struct
{
Address
[]
string
`protobuf:"bytes,1,rep,name=address" json:"address,omitempty"`
Address
[]
string
`protobuf:"bytes,1,rep,name=address,proto3" json:"address,omitempty"`
XXX_NoUnkeyedLiteral
struct
{}
`json:"-"`
XXX_unrecognized
[]
byte
`json:"-"`
XXX_sizecache
int32
`json:"-"`
}
}
func
(
m
*
VotesRecord
)
Reset
()
{
*
m
=
VotesRecord
{}
}
func
(
m
*
VotesRecord
)
Reset
()
{
*
m
=
VotesRecord
{}
}
func
(
m
*
VotesRecord
)
String
()
string
{
return
proto
.
CompactTextString
(
m
)
}
func
(
m
*
VotesRecord
)
String
()
string
{
return
proto
.
CompactTextString
(
m
)
}
func
(
*
VotesRecord
)
ProtoMessage
()
{}
func
(
*
VotesRecord
)
ProtoMessage
()
{}
func
(
*
VotesRecord
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
fileDescriptor2
,
[]
int
{
2
}
}
func
(
*
VotesRecord
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
fileDescriptor_d916a933dd8220ff
,
[]
int
{
2
}
}
func
(
m
*
VotesRecord
)
XXX_Unmarshal
(
b
[]
byte
)
error
{
return
xxx_messageInfo_VotesRecord
.
Unmarshal
(
m
,
b
)
}
func
(
m
*
VotesRecord
)
XXX_Marshal
(
b
[]
byte
,
deterministic
bool
)
([]
byte
,
error
)
{
return
xxx_messageInfo_VotesRecord
.
Marshal
(
b
,
m
,
deterministic
)
}
func
(
m
*
VotesRecord
)
XXX_Merge
(
src
proto
.
Message
)
{
xxx_messageInfo_VotesRecord
.
Merge
(
m
,
src
)
}
func
(
m
*
VotesRecord
)
XXX_Size
()
int
{
return
xxx_messageInfo_VotesRecord
.
Size
(
m
)
}
func
(
m
*
VotesRecord
)
XXX_DiscardUnknown
()
{
xxx_messageInfo_VotesRecord
.
DiscardUnknown
(
m
)
}
var
xxx_messageInfo_VotesRecord
proto
.
InternalMessageInfo
func
(
m
*
VotesRecord
)
GetAddress
()
[]
string
{
func
(
m
*
VotesRecord
)
GetAddress
()
[]
string
{
if
m
!=
nil
{
if
m
!=
nil
{
...
@@ -118,23 +196,46 @@ func (m *VotesRecord) GetAddress() []string {
...
@@ -118,23 +196,46 @@ func (m *VotesRecord) GetAddress() []string {
type
RuleConfig
struct
{
type
RuleConfig
struct
{
// 董事会成员参与率,以%为单位,只保留整数部分
// 董事会成员参与率,以%为单位,只保留整数部分
BoardAttendRatio
int32
`protobuf:"varint,1,opt,name=boardAttendRatio" json:"boardAttendRatio,omitempty"`
BoardAttendRatio
int32
`protobuf:"varint,1,opt,name=boardAttendRatio
,proto3
" json:"boardAttendRatio,omitempty"`
// 董事会成员赞成率
// 董事会成员赞成率
BoardApproveRatio
int32
`protobuf:"varint,2,opt,name=boardApproveRatio" json:"boardApproveRatio,omitempty"`
BoardApproveRatio
int32
`protobuf:"varint,2,opt,name=boardApproveRatio
,proto3
" json:"boardApproveRatio,omitempty"`
// 全体持票人否决率
// 全体持票人否决率
PubOpposeRatio
int32
`protobuf:"varint,3,opt,name=pubOpposeRatio" json:"pubOpposeRatio,omitempty"`
PubOpposeRatio
int32
`protobuf:"varint,3,opt,name=pubOpposeRatio
,proto3
" json:"pubOpposeRatio,omitempty"`
// 提案金额
// 提案金额
ProposalAmount
int64
`protobuf:"varint,4,opt,name=proposalAmount" json:"proposalAmount,omitempty"`
ProposalAmount
int64
`protobuf:"varint,4,opt,name=proposalAmount
,proto3
" json:"proposalAmount,omitempty"`
// 重大项目公示金额阈值
// 重大项目公示金额阈值
LargeProjectAmount
int64
`protobuf:"varint,5,opt,name=largeProjectAmount" json:"largeProjectAmount,omitempty"`
LargeProjectAmount
int64
`protobuf:"varint,5,opt,name=largeProjectAmount
,proto3
" json:"largeProjectAmount,omitempty"`
// 重大项目公示时间(以区块数为单位)
// 重大项目公示时间(以区块数为单位)
PublicPeriod
int32
`protobuf:"varint,6,opt,name=publicPeriod" json:"publicPeriod,omitempty"`
PublicPeriod
int32
`protobuf:"varint,6,opt,name=publicPeriod,proto3" json:"publicPeriod,omitempty"`
XXX_NoUnkeyedLiteral
struct
{}
`json:"-"`
XXX_unrecognized
[]
byte
`json:"-"`
XXX_sizecache
int32
`json:"-"`
}
}
func
(
m
*
RuleConfig
)
Reset
()
{
*
m
=
RuleConfig
{}
}
func
(
m
*
RuleConfig
)
Reset
()
{
*
m
=
RuleConfig
{}
}
func
(
m
*
RuleConfig
)
String
()
string
{
return
proto
.
CompactTextString
(
m
)
}
func
(
m
*
RuleConfig
)
String
()
string
{
return
proto
.
CompactTextString
(
m
)
}
func
(
*
RuleConfig
)
ProtoMessage
()
{}
func
(
*
RuleConfig
)
ProtoMessage
()
{}
func
(
*
RuleConfig
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
fileDescriptor2
,
[]
int
{
3
}
}
func
(
*
RuleConfig
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
fileDescriptor_d916a933dd8220ff
,
[]
int
{
3
}
}
func
(
m
*
RuleConfig
)
XXX_Unmarshal
(
b
[]
byte
)
error
{
return
xxx_messageInfo_RuleConfig
.
Unmarshal
(
m
,
b
)
}
func
(
m
*
RuleConfig
)
XXX_Marshal
(
b
[]
byte
,
deterministic
bool
)
([]
byte
,
error
)
{
return
xxx_messageInfo_RuleConfig
.
Marshal
(
b
,
m
,
deterministic
)
}
func
(
m
*
RuleConfig
)
XXX_Merge
(
src
proto
.
Message
)
{
xxx_messageInfo_RuleConfig
.
Merge
(
m
,
src
)
}
func
(
m
*
RuleConfig
)
XXX_Size
()
int
{
return
xxx_messageInfo_RuleConfig
.
Size
(
m
)
}
func
(
m
*
RuleConfig
)
XXX_DiscardUnknown
()
{
xxx_messageInfo_RuleConfig
.
DiscardUnknown
(
m
)
}
var
xxx_messageInfo_RuleConfig
proto
.
InternalMessageInfo
func
(
m
*
RuleConfig
)
GetBoardAttendRatio
()
int32
{
func
(
m
*
RuleConfig
)
GetBoardAttendRatio
()
int32
{
if
m
!=
nil
{
if
m
!=
nil
{
...
@@ -185,9 +286,9 @@ func init() {
...
@@ -185,9 +286,9 @@ func init() {
proto
.
RegisterType
((
*
RuleConfig
)(
nil
),
"types.RuleConfig"
)
proto
.
RegisterType
((
*
RuleConfig
)(
nil
),
"types.RuleConfig"
)
}
}
func
init
()
{
proto
.
RegisterFile
(
"lcommon.proto"
,
fileDescriptor
2
)
}
func
init
()
{
proto
.
RegisterFile
(
"lcommon.proto"
,
fileDescriptor
_d916a933dd8220ff
)
}
var
fileDescriptor
2
=
[]
byte
{
var
fileDescriptor
_d916a933dd8220ff
=
[]
byte
{
// 314 bytes of a gzipped FileDescriptorProto
// 314 bytes of a gzipped FileDescriptorProto
0x1f
,
0x8b
,
0x08
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x02
,
0xff
,
0x84
,
0x92
,
0x3d
,
0x4e
,
0xf3
,
0x40
,
0x1f
,
0x8b
,
0x08
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x02
,
0xff
,
0x84
,
0x92
,
0x3d
,
0x4e
,
0xf3
,
0x40
,
0x10
,
0x86
,
0xe5
,
0xfc
,
0x7d
,
0xc9
,
0xe4
,
0x03
,
0xc1
,
0x54
,
0x2e
,
0x10
,
0x8a
,
0x5c
,
0x40
,
0x84
,
0x10
,
0x86
,
0xe5
,
0xfc
,
0x7d
,
0xc9
,
0xe4
,
0x03
,
0xc1
,
0x54
,
0x2e
,
0x10
,
0x8a
,
0x5c
,
0x40
,
0x84
,
...
...
plugin/dapp/autonomy/types/project.pb.go
View file @
cf9a539d
This diff is collapsed.
Click to expand it.
plugin/dapp/autonomy/types/rule.pb.go
View file @
cf9a539d
This diff is collapsed.
Click to expand it.
plugin/dapp/autonomy/types/types.go
View file @
cf9a539d
...
@@ -6,6 +6,7 @@ package types
...
@@ -6,6 +6,7 @@ package types
import
(
import
(
"reflect"
"reflect"
log
"github.com/33cn/chain33/common/log/log15"
log
"github.com/33cn/chain33/common/log/log15"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
)
)
...
@@ -64,7 +65,6 @@ func (a *AutonomyType) GetLogMap() map[int64]*types.LogInfo {
...
@@ -64,7 +65,6 @@ func (a *AutonomyType) GetLogMap() map[int64]*types.LogInfo {
TyLogTmintPropRule
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptProposalRule
{}),
Name
:
"LogTmintPropRule"
},
TyLogTmintPropRule
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptProposalRule
{}),
Name
:
"LogTmintPropRule"
},
TyLogCommentProp
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptProposalComment
{}),
Name
:
"LogCommentProp"
},
TyLogCommentProp
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptProposalComment
{}),
Name
:
"LogCommentProp"
},
}
}
}
}
...
...
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