Commit cf9a539d authored by vipwzw's avatar vipwzw Committed by 33cn

auto ci

parent 8c44c577
...@@ -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{
...@@ -97,12 +96,12 @@ func proposalBoard(cmd *cobra.Command, args []string) { ...@@ -97,12 +96,12 @@ func proposalBoard(cmd *cobra.Command, args []string) {
boards := strings.Split(boardstr, "-") boards := strings.Split(boardstr, "-")
params := &auty.ProposalBoard{ params := &auty.ProposalBoard{
Year: year, Year: year,
Month: month, Month: month,
Day: day, Day: day,
Boards: boards, Boards: boards,
StartBlockHeight: startBlock, StartBlockHeight: startBlock,
EndBlockHeight: endBlock, EndBlockHeight: endBlock,
} }
var res string var res string
...@@ -131,7 +130,7 @@ func revokeProposalBoard(cmd *cobra.Command, args []string) { ...@@ -131,7 +130,7 @@ func revokeProposalBoard(cmd *cobra.Command, args []string) {
ID, _ := cmd.Flags().GetString("proposalID") ID, _ := cmd.Flags().GetString("proposalID")
params := &auty.RevokeProposalBoard{ params := &auty.RevokeProposalBoard{
ProposalID: ID, ProposalID: ID,
} }
var res string var res string
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "autonomy.RevokeProposalBoardTx", params, &res) ctx := jsonrpc.NewRPCCtx(rpcLaddr, "autonomy.RevokeProposalBoardTx", params, &res)
...@@ -167,8 +166,8 @@ func voteProposalBoard(cmd *cobra.Command, args []string) { ...@@ -167,8 +166,8 @@ func voteProposalBoard(cmd *cobra.Command, args []string) {
} }
params := &auty.VoteProposalBoard{ params := &auty.VoteProposalBoard{
ProposalID: ID, ProposalID: ID,
Approve: isapp, Approve: isapp,
} }
var res string var res string
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "autonomy.VoteProposalBoardTx", params, &res) ctx := jsonrpc.NewRPCCtx(rpcLaddr, "autonomy.VoteProposalBoardTx", params, &res)
...@@ -196,7 +195,7 @@ func terminateProposalBoard(cmd *cobra.Command, args []string) { ...@@ -196,7 +195,7 @@ func terminateProposalBoard(cmd *cobra.Command, args []string) {
ID, _ := cmd.Flags().GetString("proposalID") ID, _ := cmd.Flags().GetString("proposalID")
params := &auty.RevokeProposalBoard{ params := &auty.RevokeProposalBoard{
ProposalID: ID, ProposalID: ID,
} }
var res string var res string
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "autonomy.TerminateProposalBoardTx", params, &res) ctx := jsonrpc.NewRPCCtx(rpcLaddr, "autonomy.TerminateProposalBoardTx", params, &res)
...@@ -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")
...@@ -239,7 +238,7 @@ func showProposalBoard(cmd *cobra.Command, args []string) { ...@@ -239,7 +238,7 @@ func showProposalBoard(cmd *cobra.Command, args []string) {
params.Execer = auty.AutonomyX params.Execer = auty.AutonomyX
if 0 == typ { if 0 == typ {
req := types.ReqString{ req := types.ReqString{
Data: propID, Data: propID,
} }
params.FuncName = auty.GetProposalBoard params.FuncName = auty.GetProposalBoard
params.Payload = types.MustPBToJSON(&req) params.Payload = types.MustPBToJSON(&req)
......
...@@ -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 创建提案命令
...@@ -70,20 +70,20 @@ func proposalProject(cmd *cobra.Command, args []string) { ...@@ -70,20 +70,20 @@ func proposalProject(cmd *cobra.Command, args []string) {
projectNeedBlockNum, _ := cmd.Flags().GetInt32("projectNeedBlockNum") projectNeedBlockNum, _ := cmd.Flags().GetInt32("projectNeedBlockNum")
params := &auty.ProposalProject{ params := &auty.ProposalProject{
Year: year, Year: year,
Month: month, Month: month,
Day: day, Day: day,
FirstStage: firstStage, FirstStage: firstStage,
LastStage: lastStage, LastStage: lastStage,
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
...@@ -112,7 +112,7 @@ func revokeProposalProject(cmd *cobra.Command, args []string) { ...@@ -112,7 +112,7 @@ func revokeProposalProject(cmd *cobra.Command, args []string) {
ID, _ := cmd.Flags().GetString("proposalID") ID, _ := cmd.Flags().GetString("proposalID")
params := &auty.RevokeProposalProject{ params := &auty.RevokeProposalProject{
ProposalID: ID, ProposalID: ID,
} }
var res string var res string
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "autonomy.RevokeProposalProjectTx", params, &res) ctx := jsonrpc.NewRPCCtx(rpcLaddr, "autonomy.RevokeProposalProjectTx", params, &res)
...@@ -148,8 +148,8 @@ func voteProposalProject(cmd *cobra.Command, args []string) { ...@@ -148,8 +148,8 @@ func voteProposalProject(cmd *cobra.Command, args []string) {
} }
params := &auty.VoteProposalProject{ params := &auty.VoteProposalProject{
ProposalID: ID, ProposalID: ID,
Approve: isapp, Approve: isapp,
} }
var res string var res string
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "autonomy.VoteProposalProjectTx", params, &res) ctx := jsonrpc.NewRPCCtx(rpcLaddr, "autonomy.VoteProposalProjectTx", params, &res)
...@@ -186,15 +186,14 @@ func pubVoteProposalProject(cmd *cobra.Command, args []string) { ...@@ -186,15 +186,14 @@ func pubVoteProposalProject(cmd *cobra.Command, args []string) {
} }
params := &auty.PubVoteProposalProject{ params := &auty.PubVoteProposalProject{
ProposalID: ID, ProposalID: ID,
Oppose: isopp, Oppose: isopp,
} }
var res string var res string
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "autonomy.PubVoteProposalProjectTx", params, &res) ctx := jsonrpc.NewRPCCtx(rpcLaddr, "autonomy.PubVoteProposalProjectTx", params, &res)
ctx.RunWithoutMarshal() ctx.RunWithoutMarshal()
} }
// TerminateProposalProject 终止提案 // TerminateProposalProject 终止提案
func TerminateProposalProjectCmd() *cobra.Command { func TerminateProposalProjectCmd() *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
...@@ -216,7 +215,7 @@ func terminateProposalProject(cmd *cobra.Command, args []string) { ...@@ -216,7 +215,7 @@ func terminateProposalProject(cmd *cobra.Command, args []string) {
ID, _ := cmd.Flags().GetString("proposalID") ID, _ := cmd.Flags().GetString("proposalID")
params := &auty.RevokeProposalProject{ params := &auty.RevokeProposalProject{
ProposalID: ID, ProposalID: ID,
} }
var res string var res string
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "autonomy.TerminateProposalProjectTx", params, &res) ctx := jsonrpc.NewRPCCtx(rpcLaddr, "autonomy.TerminateProposalProjectTx", params, &res)
...@@ -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")
...@@ -259,7 +258,7 @@ func showProposalProject(cmd *cobra.Command, args []string) { ...@@ -259,7 +258,7 @@ func showProposalProject(cmd *cobra.Command, args []string) {
params.Execer = auty.AutonomyX params.Execer = auty.AutonomyX
if 0 == typ { if 0 == typ {
req := types.ReqString{ req := types.ReqString{
Data: propID, Data: propID,
} }
params.FuncName = auty.GetProposalProject params.FuncName = auty.GetProposalProject
params.Payload = types.MustPBToJSON(&req) params.Payload = types.MustPBToJSON(&req)
...@@ -278,4 +277,4 @@ func showProposalProject(cmd *cobra.Command, args []string) { ...@@ -278,4 +277,4 @@ func showProposalProject(cmd *cobra.Command, args []string) {
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, rep) ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, rep)
ctx.Run() ctx.Run()
} }
\ No newline at end of file
...@@ -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 创建提案命令
...@@ -61,17 +61,17 @@ func proposalRule(cmd *cobra.Command, args []string) { ...@@ -61,17 +61,17 @@ func proposalRule(cmd *cobra.Command, args []string) {
params := &auty.ProposalRule{ params := &auty.ProposalRule{
Year: year, Year: year,
Month: month, Month: month,
Day: day, Day: day,
RuleCfg: &auty.RuleConfig{ RuleCfg: &auty.RuleConfig{
BoardAttendRatio: boardAttendRatio, BoardAttendRatio: boardAttendRatio,
BoardApproveRatio: boardApproveRatio, BoardApproveRatio: boardApproveRatio,
PubOpposeRatio: pubOpposeRatio, PubOpposeRatio: pubOpposeRatio,
ProposalAmount: proposalAmount * types.Coin, ProposalAmount: proposalAmount * types.Coin,
LargeProjectAmount: largeProjectAmount * types.Coin, LargeProjectAmount: largeProjectAmount * types.Coin,
PublicPeriod: publicPeriod, PublicPeriod: publicPeriod,
}, },
StartBlockHeight: startBlock, StartBlockHeight: startBlock,
EndBlockHeight: endBlock, EndBlockHeight: endBlock,
} }
var res string var res string
...@@ -100,7 +100,7 @@ func revokeProposalRule(cmd *cobra.Command, args []string) { ...@@ -100,7 +100,7 @@ func revokeProposalRule(cmd *cobra.Command, args []string) {
ID, _ := cmd.Flags().GetString("proposalID") ID, _ := cmd.Flags().GetString("proposalID")
params := &auty.RevokeProposalRule{ params := &auty.RevokeProposalRule{
ProposalID: ID, ProposalID: ID,
} }
var res string var res string
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "autonomy.RevokeProposalRuleTx", params, &res) ctx := jsonrpc.NewRPCCtx(rpcLaddr, "autonomy.RevokeProposalRuleTx", params, &res)
...@@ -136,8 +136,8 @@ func voteProposalRule(cmd *cobra.Command, args []string) { ...@@ -136,8 +136,8 @@ func voteProposalRule(cmd *cobra.Command, args []string) {
} }
params := &auty.VoteProposalRule{ params := &auty.VoteProposalRule{
ProposalID: ID, ProposalID: ID,
Approve: isapp, Approve: isapp,
} }
var res string var res string
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "autonomy.VoteProposalRuleTx", params, &res) ctx := jsonrpc.NewRPCCtx(rpcLaddr, "autonomy.VoteProposalRuleTx", params, &res)
...@@ -165,7 +165,7 @@ func terminateProposalRule(cmd *cobra.Command, args []string) { ...@@ -165,7 +165,7 @@ func terminateProposalRule(cmd *cobra.Command, args []string) {
ID, _ := cmd.Flags().GetString("proposalID") ID, _ := cmd.Flags().GetString("proposalID")
params := &auty.RevokeProposalRule{ params := &auty.RevokeProposalRule{
ProposalID: ID, ProposalID: ID,
} }
var res string var res string
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "autonomy.TerminateProposalRuleTx", params, &res) ctx := jsonrpc.NewRPCCtx(rpcLaddr, "autonomy.TerminateProposalRuleTx", params, &res)
...@@ -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")
...@@ -208,7 +208,7 @@ func showProposalRule(cmd *cobra.Command, args []string) { ...@@ -208,7 +208,7 @@ func showProposalRule(cmd *cobra.Command, args []string) {
params.Execer = auty.AutonomyX params.Execer = auty.AutonomyX
if 0 == typ { if 0 == typ {
req := types.ReqString{ req := types.ReqString{
Data: propID, Data: propID,
} }
params.FuncName = auty.GetProposalRule params.FuncName = auty.GetProposalRule
params.Payload = types.MustPBToJSON(&req) params.Payload = types.MustPBToJSON(&req)
...@@ -248,11 +248,11 @@ func addTransferFundflags(cmd *cobra.Command) { ...@@ -248,11 +248,11 @@ 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
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "autonomy.TransferFundTx", params, &res) ctx := jsonrpc.NewRPCCtx(rpcLaddr, "autonomy.TransferFundTx", params, &res)
...@@ -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")
...@@ -325,10 +325,10 @@ func showProposalComment(cmd *cobra.Command, args []string) { ...@@ -325,10 +325,10 @@ func showProposalComment(cmd *cobra.Command, args []string) {
params.Execer = auty.AutonomyX params.Execer = auty.AutonomyX
req := auty.ReqQueryProposalComment{ req := auty.ReqQueryProposalComment{
ProposalID: propID, ProposalID: propID,
Count: count, Count: count,
Direction: direction, Direction: direction,
Index: index, Index: index,
} }
params.FuncName = auty.ListProposalComment params.FuncName = auty.ListProposalComment
params.Payload = types.MustPBToJSON(&req) params.Payload = types.MustPBToJSON(&req)
......
...@@ -5,21 +5,20 @@ ...@@ -5,21 +5,20 @@
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 (
alog = log.New("module", "execs.autonomy") alog = log.New("module", "execs.autonomy")
driverName = auty.AutonomyX driverName = auty.AutonomyX
autonomyAddr = address.ExecAddress(auty.AutonomyX) autonomyAddr = address.ExecAddress(auty.AutonomyX)
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{}))
......
...@@ -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
} }
...@@ -125,7 +126,7 @@ func(a *Autonomy) listProposalBoard(req *auty.ReqQueryProposalBoard) (types.Mess ...@@ -125,7 +126,7 @@ func(a *Autonomy) listProposalBoard(req *auty.ReqQueryProposalBoard) (types.Mess
key = nil key = nil
} else { //翻页查找指定的txhash列表 } else { //翻页查找指定的txhash列表
heightstr := genHeightIndexStr(req.GetIndex()) heightstr := genHeightIndexStr(req.GetIndex())
key = calcBoardKey4StatusHeight(req.Status, heightstr) key = calcBoardKey4StatusHeight(req.Status, heightstr)
} }
prefix := calcBoardKey4StatusHeight(req.Status, "") prefix := calcBoardKey4StatusHeight(req.Status, "")
values, err = localDb.List(prefix, key, req.Count, req.GetDirection()) values, err = localDb.List(prefix, key, req.Count, req.GetDirection())
...@@ -150,4 +151,4 @@ func(a *Autonomy) listProposalBoard(req *auty.ReqQueryProposalBoard) (types.Mess ...@@ -150,4 +151,4 @@ func(a *Autonomy) listProposalBoard(req *auty.ReqQueryProposalBoard) (types.Mess
func genHeightIndexStr(index int64) string { func genHeightIndexStr(index int64) string {
return fmt.Sprintf("%018d", index) return fmt.Sprintf("%018d", index)
} }
\ No newline at end of file
...@@ -6,32 +6,33 @@ package executor ...@@ -6,32 +6,33 @@ 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) {
au := &Autonomy{} au := &Autonomy{}
//TyLogPropBoard //TyLogPropBoard
cur := &auty.AutonomyProposalBoard{ cur := &auty.AutonomyProposalBoard{
PropBoard: &auty.ProposalBoard{}, PropBoard: &auty.ProposalBoard{},
CurRule: &auty.RuleConfig{}, CurRule: &auty.RuleConfig{},
VoteResult: &auty.VoteResult{}, VoteResult: &auty.VoteResult{},
Status: auty.AutonomyStatusProposalBoard, Status: auty.AutonomyStatusProposalBoard,
Address: "11111111111111", Address: "11111111111111",
Height: 1, Height: 1,
Index: 2, Index: 2,
} }
receiptBoard := &auty.ReceiptProposalBoard{ receiptBoard := &auty.ReceiptProposalBoard{
Prev: nil, Prev: nil,
Current: cur, Current: cur,
} }
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)
...@@ -46,12 +47,12 @@ func TestExecLocalBoard(t *testing.T) { ...@@ -46,12 +47,12 @@ func TestExecLocalBoard(t *testing.T) {
cur.Height = 2 cur.Height = 2
cur.Index = 3 cur.Index = 3
receiptBoard1 := &auty.ReceiptProposalBoard{ receiptBoard1 := &auty.ReceiptProposalBoard{
Prev: pre1, Prev: pre1,
Current: cur, Current: cur,
} }
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)
...@@ -71,12 +72,12 @@ func TestExecLocalBoard(t *testing.T) { ...@@ -71,12 +72,12 @@ func TestExecLocalBoard(t *testing.T) {
cur.Height = 2 cur.Height = 2
cur.Index = 3 cur.Index = 3
receiptBoard2 := &auty.ReceiptProposalBoard{ receiptBoard2 := &auty.ReceiptProposalBoard{
Prev: pre2, Prev: pre2,
Current: cur, Current: cur,
} }
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)
...@@ -92,21 +93,21 @@ func TestExecDelLocalBoard(t *testing.T) { ...@@ -92,21 +93,21 @@ func TestExecDelLocalBoard(t *testing.T) {
au := &Autonomy{} au := &Autonomy{}
//TyLogPropBoard //TyLogPropBoard
cur := &auty.AutonomyProposalBoard{ cur := &auty.AutonomyProposalBoard{
PropBoard: &auty.ProposalBoard{}, PropBoard: &auty.ProposalBoard{},
CurRule: &auty.RuleConfig{}, CurRule: &auty.RuleConfig{},
VoteResult: &auty.VoteResult{}, VoteResult: &auty.VoteResult{},
Status: auty.AutonomyStatusProposalBoard, Status: auty.AutonomyStatusProposalBoard,
Address: "11111111111111", Address: "11111111111111",
Height: 1, Height: 1,
Index: 2, Index: 2,
} }
receiptBoard := &auty.ReceiptProposalBoard{ receiptBoard := &auty.ReceiptProposalBoard{
Prev: nil, Prev: nil,
Current: cur, Current: cur,
} }
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)
...@@ -122,12 +123,12 @@ func TestExecDelLocalBoard(t *testing.T) { ...@@ -122,12 +123,12 @@ func TestExecDelLocalBoard(t *testing.T) {
cur.Height = 2 cur.Height = 2
cur.Index = 3 cur.Index = 3
receiptBoard2 := &auty.ReceiptProposalBoard{ receiptBoard2 := &auty.ReceiptProposalBoard{
Prev: pre1, Prev: pre1,
Current: cur, Current: cur,
} }
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)
...@@ -181,13 +182,13 @@ func TestListProposalBoard(t *testing.T) { ...@@ -181,13 +182,13 @@ func TestListProposalBoard(t *testing.T) {
testcase = append(testcase, testcase1...) testcase = append(testcase, testcase1...)
testcase = append(testcase, testcase2...) testcase = append(testcase, testcase2...)
cur := &auty.AutonomyProposalBoard{ cur := &auty.AutonomyProposalBoard{
PropBoard: &auty.ProposalBoard{}, PropBoard: &auty.ProposalBoard{},
CurRule: &auty.RuleConfig{}, CurRule: &auty.RuleConfig{},
VoteResult: &auty.VoteResult{}, VoteResult: &auty.VoteResult{},
Status: auty.AutonomyStatusProposalBoard, Status: auty.AutonomyStatusProposalBoard,
Address: "11111111111111", Address: "11111111111111",
Height: 1, Height: 1,
Index: 2, Index: 2,
} }
for _, tcase := range testcase { for _, tcase := range testcase {
key := calcBoardKey4StatusHeight(tcase.status, key := calcBoardKey4StatusHeight(tcase.status,
...@@ -201,10 +202,10 @@ func TestListProposalBoard(t *testing.T) { ...@@ -201,10 +202,10 @@ 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)
require.NoError(t, err) require.NoError(t, err)
...@@ -218,10 +219,10 @@ func TestListProposalBoard(t *testing.T) { ...@@ -218,10 +219,10 @@ 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)
require.NoError(t, err) require.NoError(t, err)
...@@ -233,10 +234,10 @@ func TestListProposalBoard(t *testing.T) { ...@@ -233,10 +234,10 @@ 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)
require.NoError(t, err) require.NoError(t, err)
...@@ -248,10 +249,10 @@ func TestListProposalBoard(t *testing.T) { ...@@ -248,10 +249,10 @@ 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)
require.Equal(t, len(rsp.(*auty.ReplyQueryProposalBoard).PropBoards), 2) require.Equal(t, len(rsp.(*auty.ReplyQueryProposalBoard).PropBoards), 2)
...@@ -259,4 +260,4 @@ func TestListProposalBoard(t *testing.T) { ...@@ -259,4 +260,4 @@ func TestListProposalBoard(t *testing.T) {
require.Equal(t, rsp.(*auty.ReplyQueryProposalBoard).PropBoards[0].Index, int32(testcase2[1].index)) require.Equal(t, rsp.(*auty.ReplyQueryProposalBoard).PropBoards[0].Index, int32(testcase2[1].index))
require.Equal(t, rsp.(*auty.ReplyQueryProposalBoard).PropBoards[1].Height, testcase2[0].height) require.Equal(t, rsp.(*auty.ReplyQueryProposalBoard).PropBoards[1].Height, testcase2[0].height)
require.Equal(t, rsp.(*auty.ReplyQueryProposalBoard).PropBoards[1].Index, int32(testcase2[0].index)) require.Equal(t, rsp.(*auty.ReplyQueryProposalBoard).PropBoards[1].Index, int32(testcase2[0].index))
} }
\ No newline at end of file
...@@ -6,28 +6,28 @@ package executor ...@@ -6,28 +6,28 @@ 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"
) )
const ( const (
minBoards = 3 minBoards = 3
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 // 董事会成员赞成率,以%计,可修改
pubAttendRatio int32 = 50 // 全体持票人参与率,以%计 pubAttendRatio int32 = 50 // 全体持票人参与率,以%计
pubApproveRatio int32 = 50 // 全体持票人赞成率,以%计 pubApproveRatio int32 = 50 // 全体持票人赞成率,以%计
pubOpposeRatio int32 = 33 // 全体持票人否决率,以%计 pubOpposeRatio int32 = 33 // 全体持票人否决率,以%计
) )
type action struct { type action struct {
...@@ -52,19 +52,19 @@ func newAction(a *Autonomy, tx *types.Transaction, index int32) *action { ...@@ -52,19 +52,19 @@ func newAction(a *Autonomy, tx *types.Transaction, index int32) *action {
func (a *action) propBoard(prob *auty.ProposalBoard) (*types.Receipt, error) { func (a *action) propBoard(prob *auty.ProposalBoard) (*types.Receipt, error) {
if len(prob.Boards) > maxBoards || len(prob.Boards) < minBoards { if len(prob.Boards) > maxBoards || len(prob.Boards) < minBoards {
alog.Error("propBoard ", "proposal boards number is invaild", len(prob.Boards)) alog.Error("propBoard ", "proposal boards number is invaild", len(prob.Boards))
return nil, types.ErrInvalidParam return nil, types.ErrInvalidParam
} }
if prob.StartBlockHeight < a.height || prob.EndBlockHeight < a.height { if prob.StartBlockHeight < a.height || prob.EndBlockHeight < a.height {
alog.Error("propBoard height invaild", "StartBlockHeight", prob.StartBlockHeight, "EndBlockHeight", alog.Error("propBoard height invaild", "StartBlockHeight", prob.StartBlockHeight, "EndBlockHeight",
prob.EndBlockHeight, "height", a.height) prob.EndBlockHeight, "height", a.height)
return nil, types.ErrInvalidParam return nil, types.ErrInvalidParam
} }
for _, board := range prob.Boards { for _, board := range prob.Boards {
if err := address.CheckAddress(board); err != nil { if err := address.CheckAddress(board); err != nil {
alog.Error("propBoard ", "addr", board, "check toAddr error", err) alog.Error("propBoard ", "addr", board, "check toAddr error", err)
return nil, types.ErrInvalidAddress return nil, types.ErrInvalidAddress
} }
} }
...@@ -88,13 +88,13 @@ func (a *action) propBoard(prob *auty.ProposalBoard) (*types.Receipt, error) { ...@@ -88,13 +88,13 @@ 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,
Height: a.height, Height: a.height,
Index: a.index, Index: a.index,
} }
kv = append(kv, &types.KeyValue{Key: propBoardID(common.ToHex(a.txhash)), Value: types.Encode(cur)}) kv = append(kv, &types.KeyValue{Key: propBoardID(common.ToHex(a.txhash)), Value: types.Encode(cur)})
...@@ -197,12 +197,12 @@ func (a *action) votePropBoard(voteProb *auty.VoteProposalBoard) (*types.Receipt ...@@ -197,12 +197,12 @@ func (a *action) votePropBoard(voteProb *auty.VoteProposalBoard) (*types.Receipt
votes.Address = append(votes.Address, a.fromaddr) votes.Address = append(votes.Address, a.fromaddr)
if cur.GetVoteResult().TotalVotes == 0 { //需要统计票数 if cur.GetVoteResult().TotalVotes == 0 { //需要统计票数
addr := "16htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp" addr := "16htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp"
account, err := a.getStartHeightVoteAccount(addr, start) account, err := a.getStartHeightVoteAccount(addr, start)
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,13 +381,13 @@ func (a *action) getActiveRule() (*auty.RuleConfig, error) { ...@@ -381,13 +381,13 @@ 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
rule.ProposalAmount = proposalAmount rule.ProposalAmount = proposalAmount
rule.LargeProjectAmount = largeProjectAmount rule.LargeProjectAmount = largeProjectAmount
rule.PublicPeriod = publicPeriod rule.PublicPeriod = publicPeriod
} }
return rule, nil return rule, nil
} }
...@@ -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
} }
...@@ -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 {
...@@ -45,7 +45,7 @@ var ( ...@@ -45,7 +45,7 @@ var (
AddrD = "1MCftFynyvG2F4ED5mdHYgziDxx6vDrScs" AddrD = "1MCftFynyvG2F4ED5mdHYgziDxx6vDrScs"
boards = []string{"1KSBd17H7ZK8iT37aJztFB22XGwsPTdwE4", "1JRNjdEqp4LJ5fqycUBm9ayCKSeeskgMKR", "1NLHPEcbTWWxxU3dGUZBhayjrCHD3psX7k"} boards = []string{"1KSBd17H7ZK8iT37aJztFB22XGwsPTdwE4", "1JRNjdEqp4LJ5fqycUBm9ayCKSeeskgMKR", "1NLHPEcbTWWxxU3dGUZBhayjrCHD3psX7k"}
total = types.Coin * 30000 total = types.Coin * 30000
) )
func init() { func init() {
...@@ -78,17 +78,16 @@ func InitEnv() (*execEnv, drivers.Driver, dbm.KV, dbm.KVDB) { ...@@ -78,17 +78,16 @@ func InitEnv() (*execEnv, drivers.Driver, dbm.KV, dbm.KVDB) {
} }
env := &execEnv{ env := &execEnv{
blockTime: 1539918074, blockTime: 1539918074,
blockHeight: 10, blockHeight: 10,
index: 2, index: 2,
difficulty: 1539918074, difficulty: 1539918074,
txHash: "", txHash: "",
} }
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,9 +96,9 @@ func InitEnv() (*execEnv, drivers.Driver, dbm.KV, dbm.KVDB) { ...@@ -97,9 +96,9 @@ 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"})
exec := newAutonomy() exec := newAutonomy()
exec.SetStateDB(stateDB) exec.SetStateDB(stateDB)
...@@ -133,13 +132,13 @@ func TestTerminateProposalBoard(t *testing.T) { ...@@ -133,13 +132,13 @@ func TestTerminateProposalBoard(t *testing.T) {
} }
func testPropBoard(t *testing.T, env *execEnv, exec drivers.Driver, stateDB dbm.KV, kvdb dbm.KVDB, save bool) { func testPropBoard(t *testing.T, env *execEnv, exec drivers.Driver, stateDB dbm.KV, kvdb dbm.KVDB, save bool) {
opt1 := &auty.ProposalBoard{ opt1 := &auty.ProposalBoard{
Year: 2019, Year: 2019,
Month: 7, Month: 7,
Day: 10, Day: 10,
Boards: boards, Boards: boards,
StartBlockHeight: env.blockHeight + 5, StartBlockHeight: env.blockHeight + 5,
EndBlockHeight: env.blockHeight + 10, EndBlockHeight: env.blockHeight + 10,
} }
pbtx, err := propBoardTx(opt1) pbtx, err := propBoardTx(opt1)
require.NoError(t, err) require.NoError(t, err)
...@@ -197,8 +196,8 @@ func propBoardTx(parm *auty.ProposalBoard) (*types.Transaction, error) { ...@@ -197,8 +196,8 @@ 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,22 +251,22 @@ func voteProposalBoard(t *testing.T, env *execEnv, exec drivers.Driver, stateDB ...@@ -252,22 +251,22 @@ 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,
Balance: total, Balance: total,
} }
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
...@@ -284,9 +283,9 @@ func voteProposalBoard(t *testing.T, env *execEnv, exec drivers.Driver, stateDB ...@@ -284,9 +283,9 @@ 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)
require.NoError(t, err) require.NoError(t, err)
...@@ -320,11 +319,11 @@ func voteProposalBoard(t *testing.T, env *execEnv, exec drivers.Driver, stateDB ...@@ -320,11 +319,11 @@ func voteProposalBoard(t *testing.T, env *execEnv, exec drivers.Driver, stateDB
// 每次需要重新设置 // 每次需要重新设置
acc := &types.Account{ acc := &types.Account{
Currency: 0, Currency: 0,
Balance: total, Balance: total,
} }
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)
...@@ -437,15 +436,15 @@ func TestGetStartHeightVoteAccount(t *testing.T) { ...@@ -437,15 +436,15 @@ func TestGetStartHeightVoteAccount(t *testing.T) {
api.On("GetLastHeader", mock.Anything).Return(&types.Header{StateHash: []byte("")}, nil) api.On("GetLastHeader", mock.Anything).Return(&types.Header{StateHash: []byte("")}, nil)
acc := &types.Account{ acc := &types.Account{
Currency: 0, Currency: 0,
Balance: types.Coin, Balance: types.Coin,
} }
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)
...@@ -454,16 +453,16 @@ func TestGetStartHeightVoteAccount(t *testing.T) { ...@@ -454,16 +453,16 @@ func TestGetStartHeightVoteAccount(t *testing.T) {
func TestGetReceiptLog(t *testing.T) { func TestGetReceiptLog(t *testing.T) {
pre := &auty.AutonomyProposalBoard{ pre := &auty.AutonomyProposalBoard{
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)
...@@ -477,11 +476,11 @@ func TestGetReceiptLog(t *testing.T) { ...@@ -477,11 +476,11 @@ func TestGetReceiptLog(t *testing.T) {
func TestCopyAutonomyProposalBoard(t *testing.T) { func TestCopyAutonomyProposalBoard(t *testing.T) {
require.Nil(t, copyAutonomyProposalBoard(nil)) require.Nil(t, copyAutonomyProposalBoard(nil))
cur := &auty.AutonomyProposalBoard{ cur := &auty.AutonomyProposalBoard{
PropBoard: &auty.ProposalBoard{Year: 1900, Month: 1}, PropBoard: &auty.ProposalBoard{Year: 1900, Month: 1},
CurRule: &auty.RuleConfig{BoardAttendRatio: 100}, 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
...@@ -518,4 +517,4 @@ func signTx(tx *types.Transaction, hexPrivKey string) (*types.Transaction, error ...@@ -518,4 +517,4 @@ func signTx(tx *types.Transaction, hexPrivKey string) (*types.Transaction, error
tx.Sign(int32(signType), privKey) tx.Sign(int32(signType), privKey)
return tx, nil return tx, nil
} }
\ No newline at end of file
...@@ -100,4 +100,4 @@ func (a *Autonomy) Exec_Transfer(payload *auty.TransferFund, tx *types.Transacti ...@@ -100,4 +100,4 @@ func (a *Autonomy) Exec_Transfer(payload *auty.TransferFund, tx *types.Transacti
func (a *Autonomy) Exec_CommentProp(payload *auty.Comment, tx *types.Transaction, index int) (*types.Receipt, error) { func (a *Autonomy) Exec_CommentProp(payload *auty.Comment, tx *types.Transaction, index int) (*types.Receipt, error) {
action := newAction(a, tx, int32(index)) action := newAction(a, tx, int32(index))
return action.commentProp(payload) return action.commentProp(payload)
} }
\ No newline at end of file
...@@ -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)
} }
...@@ -80,4 +80,4 @@ func (a *Autonomy) ExecDelLocal_TmintPropRule(payload *auty.TerminateProposalRul ...@@ -80,4 +80,4 @@ func (a *Autonomy) ExecDelLocal_TmintPropRule(payload *auty.TerminateProposalRul
// ExecDelLocal_TmintPropRule 终止提案规则 // ExecDelLocal_TmintPropRule 终止提案规则
func (a *Autonomy) ExecDelLocal_CommentProp(payload *auty.Comment, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (a *Autonomy) ExecDelLocal_CommentProp(payload *auty.Comment, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return a.execDelLocalCommentProp(receiptData) return a.execDelLocalCommentProp(receiptData)
} }
\ No newline at end of file
...@@ -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)
} }
...@@ -80,4 +80,4 @@ func (a *Autonomy) ExecLocal_TmintPropRule(payload *auty.TerminateProposalRule, ...@@ -80,4 +80,4 @@ func (a *Autonomy) ExecLocal_TmintPropRule(payload *auty.TerminateProposalRule,
// ExecLocal_Comment 评论提案 // ExecLocal_Comment 评论提案
func (a *Autonomy) ExecLocal_CommentProp(payload *auty.Comment, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (a *Autonomy) ExecLocal_CommentProp(payload *auty.Comment, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return a.execLocalCommentProp(receiptData) return a.execLocalCommentProp(receiptData)
} }
\ No newline at end of file
...@@ -11,7 +11,7 @@ import ( ...@@ -11,7 +11,7 @@ import (
) )
var ( var (
idPrefix = "mavl-" + auty.AutonomyX + "-" idPrefix = "mavl-" + auty.AutonomyX + "-"
votesRecordPrefix = idPrefix + "vote" + "-" votesRecordPrefix = idPrefix + "vote" + "-"
localPrefix = "LODB-" + auty.AutonomyX + "-" localPrefix = "LODB-" + auty.AutonomyX + "-"
...@@ -23,8 +23,8 @@ func votesRecord(txHash string) []byte { ...@@ -23,8 +23,8 @@ func votesRecord(txHash string) []byte {
var ( var (
// board // board
boardPrefix = idPrefix + "board" + "-" boardPrefix = idPrefix + "board" + "-"
localBoardPrefix = localPrefix + "board" + "-" localBoardPrefix = localPrefix + "board" + "-"
boardVotesRecordPrefix = boardPrefix + "vote" + "-" boardVotesRecordPrefix = boardPrefix + "vote" + "-"
) )
...@@ -41,13 +41,13 @@ func boardVotesRecord(txHash string) []byte { ...@@ -41,13 +41,13 @@ 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)
} }
var ( var (
// project // project
projectPrefix = idPrefix + "project" + "-" projectPrefix = idPrefix + "project" + "-"
localProjectPrefix = localPrefix + "project" + "-" localProjectPrefix = localPrefix + "project" + "-"
) )
...@@ -56,13 +56,13 @@ func propProjectID(txHash string) []byte { ...@@ -56,13 +56,13 @@ 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)
} }
var ( var (
// rule // rule
rulePrefix = idPrefix + "rule" + "-" rulePrefix = idPrefix + "rule" + "-"
localRulePrefix = localPrefix + "rule" + "-" localRulePrefix = localPrefix + "rule" + "-"
) )
...@@ -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)
} }
\ No newline at end of file
...@@ -126,7 +126,7 @@ func (a *Autonomy) listProposalProject(req *auty.ReqQueryProposalProject) (types ...@@ -126,7 +126,7 @@ func (a *Autonomy) listProposalProject(req *auty.ReqQueryProposalProject) (types
key = nil key = nil
} else { //翻页查找指定的txhash列表 } else { //翻页查找指定的txhash列表
heightstr := genHeightIndexStr(req.GetIndex()) heightstr := genHeightIndexStr(req.GetIndex())
key = calcProjectKey4StatusHeight(req.Status, heightstr) key = calcProjectKey4StatusHeight(req.Status, heightstr)
} }
prefix := calcProjectKey4StatusHeight(req.Status, "") prefix := calcProjectKey4StatusHeight(req.Status, "")
values, err = localDb.List(prefix, key, req.Count, req.GetDirection()) values, err = localDb.List(prefix, key, req.Count, req.GetDirection())
...@@ -147,4 +147,4 @@ func (a *Autonomy) listProposalProject(req *auty.ReqQueryProposalProject) (types ...@@ -147,4 +147,4 @@ func (a *Autonomy) listProposalProject(req *auty.ReqQueryProposalProject) (types
rep.PropProjects = append(rep.PropProjects, prop) rep.PropProjects = append(rep.PropProjects, prop)
} }
return &rep, nil return &rep, nil
} }
\ No newline at end of file
...@@ -6,34 +6,35 @@ package executor ...@@ -6,34 +6,35 @@ 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) {
au := &Autonomy{} au := &Autonomy{}
//TyLogPropProject //TyLogPropProject
cur := &auty.AutonomyProposalProject{ cur := &auty.AutonomyProposalProject{
PropProject: &auty.ProposalProject{}, PropProject: &auty.ProposalProject{},
CurRule: &auty.RuleConfig{}, CurRule: &auty.RuleConfig{},
Boards: []string{"111", "222", "333"}, Boards: []string{"111", "222", "333"},
BoardVoteRes: &auty.VoteResult{}, BoardVoteRes: &auty.VoteResult{},
PubVote: &auty.PublicVote{}, PubVote: &auty.PublicVote{},
Status: auty.AutonomyStatusProposalProject, Status: auty.AutonomyStatusProposalProject,
Address: "11111111111111", Address: "11111111111111",
Height: 1, Height: 1,
Index: 2, Index: 2,
} }
receiptProject := &auty.ReceiptProposalProject{ receiptProject := &auty.ReceiptProposalProject{
Prev: nil, Prev: nil,
Current: cur, Current: cur,
} }
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)
...@@ -48,12 +49,12 @@ func TestExecLocalProject(t *testing.T) { ...@@ -48,12 +49,12 @@ func TestExecLocalProject(t *testing.T) {
cur.Height = 2 cur.Height = 2
cur.Index = 3 cur.Index = 3
receiptProject1 := &auty.ReceiptProposalProject{ receiptProject1 := &auty.ReceiptProposalProject{
Prev: pre1, Prev: pre1,
Current: cur, Current: cur,
} }
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)
...@@ -73,12 +74,12 @@ func TestExecLocalProject(t *testing.T) { ...@@ -73,12 +74,12 @@ func TestExecLocalProject(t *testing.T) {
cur.Height = 2 cur.Height = 2
cur.Index = 3 cur.Index = 3
receiptProject2 := &auty.ReceiptProposalProject{ receiptProject2 := &auty.ReceiptProposalProject{
Prev: pre2, Prev: pre2,
Current: cur, Current: cur,
} }
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)
...@@ -94,23 +95,23 @@ func TestExecDelLocalProject(t *testing.T) { ...@@ -94,23 +95,23 @@ func TestExecDelLocalProject(t *testing.T) {
au := &Autonomy{} au := &Autonomy{}
//TyLogPropProject //TyLogPropProject
cur := &auty.AutonomyProposalProject{ cur := &auty.AutonomyProposalProject{
PropProject: &auty.ProposalProject{}, PropProject: &auty.ProposalProject{},
CurRule: &auty.RuleConfig{}, CurRule: &auty.RuleConfig{},
Boards: []string{"111", "222", "333"}, Boards: []string{"111", "222", "333"},
BoardVoteRes: &auty.VoteResult{}, BoardVoteRes: &auty.VoteResult{},
PubVote: &auty.PublicVote{}, PubVote: &auty.PublicVote{},
Status: auty.AutonomyStatusProposalProject, Status: auty.AutonomyStatusProposalProject,
Address: "11111111111111", Address: "11111111111111",
Height: 1, Height: 1,
Index: 2, Index: 2,
} }
receiptProject := &auty.ReceiptProposalProject{ receiptProject := &auty.ReceiptProposalProject{
Prev: nil, Prev: nil,
Current: cur, Current: cur,
} }
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)
...@@ -126,12 +127,12 @@ func TestExecDelLocalProject(t *testing.T) { ...@@ -126,12 +127,12 @@ func TestExecDelLocalProject(t *testing.T) {
cur.Height = 2 cur.Height = 2
cur.Index = 3 cur.Index = 3
receiptProject2 := &auty.ReceiptProposalProject{ receiptProject2 := &auty.ReceiptProposalProject{
Prev: pre1, Prev: pre1,
Current: cur, Current: cur,
} }
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)
...@@ -185,15 +186,15 @@ func TestListProposalProject(t *testing.T) { ...@@ -185,15 +186,15 @@ func TestListProposalProject(t *testing.T) {
testcase = append(testcase, testcase1...) testcase = append(testcase, testcase1...)
testcase = append(testcase, testcase2...) testcase = append(testcase, testcase2...)
cur := &auty.AutonomyProposalProject{ cur := &auty.AutonomyProposalProject{
PropProject: &auty.ProposalProject{}, PropProject: &auty.ProposalProject{},
CurRule: &auty.RuleConfig{}, CurRule: &auty.RuleConfig{},
Boards: []string{"111", "222", "333"}, Boards: []string{"111", "222", "333"},
BoardVoteRes: &auty.VoteResult{}, BoardVoteRes: &auty.VoteResult{},
PubVote: &auty.PublicVote{}, PubVote: &auty.PublicVote{},
Status: auty.AutonomyStatusProposalProject, Status: auty.AutonomyStatusProposalProject,
Address: "11111111111111", Address: "11111111111111",
Height: 1, Height: 1,
Index: 2, Index: 2,
} }
for _, tcase := range testcase { for _, tcase := range testcase {
key := calcProjectKey4StatusHeight(tcase.status, key := calcProjectKey4StatusHeight(tcase.status,
...@@ -207,10 +208,10 @@ func TestListProposalProject(t *testing.T) { ...@@ -207,10 +208,10 @@ 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)
require.NoError(t, err) require.NoError(t, err)
...@@ -224,10 +225,10 @@ func TestListProposalProject(t *testing.T) { ...@@ -224,10 +225,10 @@ 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)
require.NoError(t, err) require.NoError(t, err)
...@@ -239,10 +240,10 @@ func TestListProposalProject(t *testing.T) { ...@@ -239,10 +240,10 @@ 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)
require.NoError(t, err) require.NoError(t, err)
...@@ -254,10 +255,10 @@ func TestListProposalProject(t *testing.T) { ...@@ -254,10 +255,10 @@ 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)
require.Equal(t, len(rsp.(*auty.ReplyQueryProposalProject).PropProjects), 2) require.Equal(t, len(rsp.(*auty.ReplyQueryProposalProject).PropProjects), 2)
...@@ -265,4 +266,4 @@ func TestListProposalProject(t *testing.T) { ...@@ -265,4 +266,4 @@ func TestListProposalProject(t *testing.T) {
require.Equal(t, rsp.(*auty.ReplyQueryProposalProject).PropProjects[0].Index, int32(testcase2[1].index)) require.Equal(t, rsp.(*auty.ReplyQueryProposalProject).PropProjects[0].Index, int32(testcase2[1].index))
require.Equal(t, rsp.(*auty.ReplyQueryProposalProject).PropProjects[1].Height, testcase2[0].height) require.Equal(t, rsp.(*auty.ReplyQueryProposalProject).PropProjects[1].Height, testcase2[0].height)
require.Equal(t, rsp.(*auty.ReplyQueryProposalProject).PropProjects[1].Index, int32(testcase2[0].index)) require.Equal(t, rsp.(*auty.ReplyQueryProposalProject).PropProjects[1].Index, int32(testcase2[0].index))
} }
\ No newline at end of file
...@@ -12,17 +12,16 @@ import ( ...@@ -12,17 +12,16 @@ 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)
return nil, types.ErrInvalidAddress return nil, types.ErrInvalidAddress
} }
if prob.StartBlockHeight < a.height || prob.EndBlockHeight < a.height || prob.Amount <= 0 { if prob.StartBlockHeight < a.height || prob.EndBlockHeight < a.height || prob.Amount <= 0 {
alog.Error("propProject height or amount invaild", "StartBlockHeight", prob.StartBlockHeight, "EndBlockHeight", alog.Error("propProject height or amount invaild", "StartBlockHeight", prob.StartBlockHeight, "EndBlockHeight",
prob.EndBlockHeight, "height", a.height, "amount", prob.Amount) prob.EndBlockHeight, "height", a.height, "amount", prob.Amount)
return nil, types.ErrInvalidParam return nil, types.ErrInvalidParam
} }
// 获取董事会成员 // 获取董事会成员
...@@ -64,15 +63,15 @@ func (a *action) propProject(prob *auty.ProposalProject) (*types.Receipt, error) ...@@ -64,15 +63,15 @@ 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,
Index: a.index, Index: a.index,
} }
kv = append(kv, &types.KeyValue{Key: propProjectID(common.ToHex(a.txhash)), Value: types.Encode(cur)}) kv = append(kv, &types.KeyValue{Key: propProjectID(common.ToHex(a.txhash)), Value: types.Encode(cur)})
receiptLog := getProjectReceiptLog(nil, cur, auty.TyLogPropProject) receiptLog := getProjectReceiptLog(nil, cur, auty.TyLogPropProject)
...@@ -154,7 +153,7 @@ func (a *action) votePropProject(voteProb *auty.VoteProposalProject) (*types.Rec ...@@ -154,7 +153,7 @@ func (a *action) votePropProject(voteProb *auty.VoteProposalProject) (*types.Rec
pre := copyAutonomyProposalProject(cur) pre := copyAutonomyProposalProject(cur)
// 检查当前状态 // 检查当前状态
if cur.Status == auty.AutonomyStatusRvkPropProject || if cur.Status == auty.AutonomyStatusRvkPropProject ||
cur.Status == auty.AutonomyStatusPubVotePropProject || cur.Status == auty.AutonomyStatusPubVotePropProject ||
cur.Status == auty.AutonomyStatusTmintPropProject { cur.Status == auty.AutonomyStatusTmintPropProject {
err := auty.ErrProposalStatus err := auty.ErrProposalStatus
...@@ -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,16 +314,16 @@ func (a *action) pubVotePropProject(voteProb *auty.PubVoteProposalProject) (*typ ...@@ -315,16 +314,16 @@ 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
// 解冻项目金 // 解冻项目金
receiptPrj, err := a.coinsAccount.ExecActive(autonomyFundAddr, a.execaddr, cur.PropProject.Amount) receiptPrj, err := a.coinsAccount.ExecActive(autonomyFundAddr, a.execaddr, cur.PropProject.Amount)
...@@ -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,11 +406,11 @@ func (a *action) tmintPropProject(tmintProb *auty.TerminateProposalProject) (*ty ...@@ -407,11 +406,11 @@ 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
} }
} }
...@@ -431,8 +430,8 @@ func (a *action) tmintPropProject(tmintProb *auty.TerminateProposalProject) (*ty ...@@ -431,8 +430,8 @@ func (a *action) tmintPropProject(tmintProb *auty.TerminateProposalProject) (*ty
kv = append(kv, receipt.KV...) kv = append(kv, receipt.KV...)
} }
if (cur.PubVote.Publicity && cur.PubVote.PubPass) || // 需要公示且公示通过 if (cur.PubVote.Publicity && cur.PubVote.PubPass) || // 需要公示且公示通过
(!cur.PubVote.Publicity && cur.BoardVoteRes.Pass) { // 不需要公示且董事会通过 (!cur.PubVote.Publicity && cur.BoardVoteRes.Pass) { // 不需要公示且董事会通过
// 提案通过,将工程金额从基金付款给承包商 // 提案通过,将工程金额从基金付款给承包商
receipt, err := a.coinsAccount.ExecTransferFrozen(autonomyFundAddr, cur.PropProject.ToAddr, a.execaddr, cur.PropProject.Amount) receipt, err := a.coinsAccount.ExecTransferFrozen(autonomyFundAddr, cur.PropProject.ToAddr, a.execaddr, cur.PropProject.Amount)
if err != nil { if err != nil {
...@@ -480,12 +479,12 @@ func (a *action) getActiveBoard() (*auty.ProposalBoard, error) { ...@@ -480,12 +479,12 @@ func (a *action) getActiveBoard() (*auty.ProposalBoard, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
pboard := &auty.ProposalBoard{} pboard := &auty.ProposalBoard{}
err = types.Decode(value, pboard) err = types.Decode(value, pboard)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if len(pboard.Boards) > maxBoards || len(pboard.Boards) < minBoards { if len(pboard.Boards) > maxBoards || len(pboard.Boards) < minBoards {
err = auty.ErrNoActiveBoard err = auty.ErrNoActiveBoard
return nil, err return nil, err
} }
...@@ -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
} }
...@@ -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,8 +39,7 @@ func (a *Autonomy) Query_ListProposalRule(in *auty.ReqQueryProposalRule) (types. ...@@ -41,8 +39,7 @@ 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)
} }
\ No newline at end of file
...@@ -124,7 +124,7 @@ func (a *Autonomy) listProposalRule(req *auty.ReqQueryProposalRule) (types.Messa ...@@ -124,7 +124,7 @@ func (a *Autonomy) listProposalRule(req *auty.ReqQueryProposalRule) (types.Messa
key = nil key = nil
} else { //翻页查找指定的txhash列表 } else { //翻页查找指定的txhash列表
heightstr := genHeightIndexStr(req.GetIndex()) heightstr := genHeightIndexStr(req.GetIndex())
key = calcRuleKey4StatusHeight(req.Status, heightstr) key = calcRuleKey4StatusHeight(req.Status, heightstr)
} }
prefix := calcRuleKey4StatusHeight(req.Status, "") prefix := calcRuleKey4StatusHeight(req.Status, "")
values, err = localDb.List(prefix, key, req.Count, req.GetDirection()) values, err = localDb.List(prefix, key, req.Count, req.GetDirection())
...@@ -175,9 +175,9 @@ func saveCommentHeightIndex(res *auty.ReceiptProposalComment) (kvs []*types.KeyV ...@@ -175,9 +175,9 @@ func saveCommentHeightIndex(res *auty.ReceiptProposalComment) (kvs []*types.KeyV
kv.Key = calcCommentHeight(res.Cmt.ProposalID, dapp.HeightIndexStr(res.Height, int64(res.Index))) kv.Key = calcCommentHeight(res.Cmt.ProposalID, dapp.HeightIndexStr(res.Height, int64(res.Index)))
kv.Value = types.Encode(&auty.RelationCmt{ kv.Value = types.Encode(&auty.RelationCmt{
RepCmtHash: res.Cmt.RepCmtHash, RepCmtHash: res.Cmt.RepCmtHash,
Comment: res.Cmt.Comment, Comment: res.Cmt.Comment,
Height: res.Height, Height: res.Height,
Index: res.Index, Index: res.Index,
}) })
kvs = append(kvs, kv) kvs = append(kvs, kv)
return kvs return kvs
...@@ -227,7 +227,7 @@ func (a *Autonomy) listProposalComment(req *auty.ReqQueryProposalComment) (types ...@@ -227,7 +227,7 @@ func (a *Autonomy) listProposalComment(req *auty.ReqQueryProposalComment) (types
key = nil key = nil
} else { //翻页查找指定的txhash列表 } else { //翻页查找指定的txhash列表
heightstr := genHeightIndexStr(req.GetIndex()) heightstr := genHeightIndexStr(req.GetIndex())
key = calcCommentHeight(req.ProposalID, heightstr) key = calcCommentHeight(req.ProposalID, heightstr)
} }
prefix := calcCommentHeight(req.ProposalID, "") prefix := calcCommentHeight(req.ProposalID, "")
values, err = localDb.List(prefix, key, req.Count, req.GetDirection()) values, err = localDb.List(prefix, key, req.Count, req.GetDirection())
...@@ -248,4 +248,4 @@ func (a *Autonomy) listProposalComment(req *auty.ReqQueryProposalComment) (types ...@@ -248,4 +248,4 @@ func (a *Autonomy) listProposalComment(req *auty.ReqQueryProposalComment) (types
rep.RltCmt = append(rep.RltCmt, cmt) rep.RltCmt = append(rep.RltCmt, cmt)
} }
return &rep, nil return &rep, nil
} }
\ No newline at end of file
...@@ -6,32 +6,33 @@ package executor ...@@ -6,32 +6,33 @@ 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) {
au := &Autonomy{} au := &Autonomy{}
//TyLogPropRule //TyLogPropRule
cur := &auty.AutonomyProposalRule{ cur := &auty.AutonomyProposalRule{
PropRule: &auty.ProposalRule{}, PropRule: &auty.ProposalRule{},
CurRule: &auty.RuleConfig{}, CurRule: &auty.RuleConfig{},
VoteResult: &auty.VoteResult{}, VoteResult: &auty.VoteResult{},
Status: auty.AutonomyStatusProposalRule, Status: auty.AutonomyStatusProposalRule,
Address: "11111111111111", Address: "11111111111111",
Height: 1, Height: 1,
Index: 2, Index: 2,
} }
receiptRule := &auty.ReceiptProposalRule{ receiptRule := &auty.ReceiptProposalRule{
Prev: nil, Prev: nil,
Current: cur, Current: cur,
} }
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)
...@@ -46,12 +47,12 @@ func TestExecLocalRule(t *testing.T) { ...@@ -46,12 +47,12 @@ func TestExecLocalRule(t *testing.T) {
cur.Height = 2 cur.Height = 2
cur.Index = 3 cur.Index = 3
receiptRule1 := &auty.ReceiptProposalRule{ receiptRule1 := &auty.ReceiptProposalRule{
Prev: pre1, Prev: pre1,
Current: cur, Current: cur,
} }
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)
...@@ -71,12 +72,12 @@ func TestExecLocalRule(t *testing.T) { ...@@ -71,12 +72,12 @@ func TestExecLocalRule(t *testing.T) {
cur.Height = 2 cur.Height = 2
cur.Index = 3 cur.Index = 3
receiptRule2 := &auty.ReceiptProposalRule{ receiptRule2 := &auty.ReceiptProposalRule{
Prev: pre2, Prev: pre2,
Current: cur, Current: cur,
} }
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)
...@@ -92,21 +93,21 @@ func TestExecDelLocalRule(t *testing.T) { ...@@ -92,21 +93,21 @@ func TestExecDelLocalRule(t *testing.T) {
au := &Autonomy{} au := &Autonomy{}
//TyLogPropRule //TyLogPropRule
cur := &auty.AutonomyProposalRule{ cur := &auty.AutonomyProposalRule{
PropRule: &auty.ProposalRule{}, PropRule: &auty.ProposalRule{},
CurRule: &auty.RuleConfig{}, CurRule: &auty.RuleConfig{},
VoteResult: &auty.VoteResult{}, VoteResult: &auty.VoteResult{},
Status: auty.AutonomyStatusProposalRule, Status: auty.AutonomyStatusProposalRule,
Address: "11111111111111", Address: "11111111111111",
Height: 1, Height: 1,
Index: 2, Index: 2,
} }
receiptRule := &auty.ReceiptProposalRule{ receiptRule := &auty.ReceiptProposalRule{
Prev: nil, Prev: nil,
Current: cur, Current: cur,
} }
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)
...@@ -122,12 +123,12 @@ func TestExecDelLocalRule(t *testing.T) { ...@@ -122,12 +123,12 @@ func TestExecDelLocalRule(t *testing.T) {
cur.Height = 2 cur.Height = 2
cur.Index = 3 cur.Index = 3
receiptRule2 := &auty.ReceiptProposalRule{ receiptRule2 := &auty.ReceiptProposalRule{
Prev: pre1, Prev: pre1,
Current: cur, Current: cur,
} }
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)
...@@ -181,13 +182,13 @@ func TestListProposalRule(t *testing.T) { ...@@ -181,13 +182,13 @@ func TestListProposalRule(t *testing.T) {
testcase = append(testcase, testcase1...) testcase = append(testcase, testcase1...)
testcase = append(testcase, testcase2...) testcase = append(testcase, testcase2...)
cur := &auty.AutonomyProposalRule{ cur := &auty.AutonomyProposalRule{
PropRule: &auty.ProposalRule{}, PropRule: &auty.ProposalRule{},
CurRule: &auty.RuleConfig{}, CurRule: &auty.RuleConfig{},
VoteResult: &auty.VoteResult{}, VoteResult: &auty.VoteResult{},
Status: auty.AutonomyStatusProposalRule, Status: auty.AutonomyStatusProposalRule,
Address: "11111111111111", Address: "11111111111111",
Height: 1, Height: 1,
Index: 2, Index: 2,
} }
for _, tcase := range testcase { for _, tcase := range testcase {
key := calcRuleKey4StatusHeight(tcase.status, key := calcRuleKey4StatusHeight(tcase.status,
...@@ -201,10 +202,10 @@ func TestListProposalRule(t *testing.T) { ...@@ -201,10 +202,10 @@ 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)
require.NoError(t, err) require.NoError(t, err)
...@@ -218,10 +219,10 @@ func TestListProposalRule(t *testing.T) { ...@@ -218,10 +219,10 @@ 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)
require.NoError(t, err) require.NoError(t, err)
...@@ -233,10 +234,10 @@ func TestListProposalRule(t *testing.T) { ...@@ -233,10 +234,10 @@ 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)
require.NoError(t, err) require.NoError(t, err)
...@@ -248,10 +249,10 @@ func TestListProposalRule(t *testing.T) { ...@@ -248,10 +249,10 @@ 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)
require.Equal(t, len(rsp.(*auty.ReplyQueryProposalRule).PropRules), 2) require.Equal(t, len(rsp.(*auty.ReplyQueryProposalRule).PropRules), 2)
...@@ -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)
...@@ -328,7 +329,7 @@ func TestListProposalComment(t *testing.T) { ...@@ -328,7 +329,7 @@ func TestListProposalComment(t *testing.T) {
index int64 index int64
} }
propID := "3333333333" propID := "3333333333"
propID1 := "2222222" propID1 := "2222222"
propID2 := "111111111111" propID2 := "111111111111"
...@@ -346,24 +347,24 @@ func TestListProposalComment(t *testing.T) { ...@@ -346,24 +347,24 @@ 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,
dapp.HeightIndexStr(tcase.height, int64(tcase.index))) dapp.HeightIndexStr(tcase.height, int64(tcase.index)))
cur.Height = tcase.height cur.Height = tcase.height
cur.Index = int32(tcase.index) cur.Index = int32(tcase.index)
value := types.Encode(cur) value := types.Encode(cur)
kvdb.Set(key, value) kvdb.Set(key, value)
} }
// 反向查找 // 反向查找
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)
require.NoError(t, err) require.NoError(t, err)
...@@ -377,10 +378,10 @@ func TestListProposalComment(t *testing.T) { ...@@ -377,10 +378,10 @@ 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)
require.NoError(t, err) require.NoError(t, err)
...@@ -392,10 +393,10 @@ func TestListProposalComment(t *testing.T) { ...@@ -392,10 +393,10 @@ 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)
require.NoError(t, err) require.NoError(t, err)
...@@ -407,10 +408,10 @@ func TestListProposalComment(t *testing.T) { ...@@ -407,10 +408,10 @@ 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)
require.Equal(t, len(rsp.(*auty.ReplyQueryProposalComment).RltCmt), 2) require.Equal(t, len(rsp.(*auty.ReplyQueryProposalComment).RltCmt), 2)
......
...@@ -12,25 +12,23 @@ import ( ...@@ -12,25 +12,23 @@ 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 &&
prob.RuleCfg.PubOpposeRatio <= 0 && prob.RuleCfg.ProposalAmount <= 0 && prob.RuleCfg.LargeProjectAmount <= 0 && prob.RuleCfg.PubOpposeRatio <= 0 && prob.RuleCfg.ProposalAmount <= 0 && prob.RuleCfg.LargeProjectAmount <= 0 &&
prob.RuleCfg.PublicPeriod <= 0 { prob.RuleCfg.PublicPeriod <= 0 {
alog.Error("propRule ", "ProposalRule RuleCfg invaild or have no modify param", prob.RuleCfg) alog.Error("propRule ", "ProposalRule RuleCfg invaild or have no modify param", prob.RuleCfg)
return nil, types.ErrInvalidParam return nil, types.ErrInvalidParam
} }
if prob.RuleCfg.BoardAttendRatio > 100 || prob.RuleCfg.BoardApproveRatio > 100 || prob.RuleCfg.PubOpposeRatio > 100 { if prob.RuleCfg.BoardAttendRatio > 100 || prob.RuleCfg.BoardApproveRatio > 100 || prob.RuleCfg.PubOpposeRatio > 100 {
alog.Error("propRule RuleCfg invaild", "BoardAttendRatio", prob.RuleCfg.BoardAttendRatio, "BoardApproveRatio", alog.Error("propRule RuleCfg invaild", "BoardAttendRatio", prob.RuleCfg.BoardAttendRatio, "BoardApproveRatio",
prob.RuleCfg.BoardApproveRatio, "PubOpposeRatio", prob.RuleCfg.PubOpposeRatio) prob.RuleCfg.BoardApproveRatio, "PubOpposeRatio", prob.RuleCfg.PubOpposeRatio)
return nil, types.ErrInvalidParam return nil, types.ErrInvalidParam
} }
if prob.StartBlockHeight < a.height || prob.EndBlockHeight < a.height { if prob.StartBlockHeight < a.height || prob.EndBlockHeight < a.height {
alog.Error("propRule height invaild", "StartBlockHeight", prob.StartBlockHeight, "EndBlockHeight", alog.Error("propRule height invaild", "StartBlockHeight", prob.StartBlockHeight, "EndBlockHeight",
prob.EndBlockHeight, "height", a.height) prob.EndBlockHeight, "height", a.height)
return nil, types.ErrInvalidParam return nil, types.ErrInvalidParam
} }
// 获取当前生效提案规则,并且将不修改的规则补齐 // 获取当前生效提案规则,并且将不修改的规则补齐
...@@ -53,13 +51,13 @@ func (a *action) propRule(prob *auty.ProposalRule) (*types.Receipt, error) { ...@@ -53,13 +51,13 @@ 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,
Address: a.fromaddr, Address: a.fromaddr,
Height: a.height, Height: a.height,
Index: a.index, Index: a.index,
} }
key := propRuleID(common.ToHex(a.txhash)) key := propRuleID(common.ToHex(a.txhash))
...@@ -164,12 +162,12 @@ func (a *action) votePropRule(voteProb *auty.VoteProposalRule) (*types.Receipt, ...@@ -164,12 +162,12 @@ func (a *action) votePropRule(voteProb *auty.VoteProposalRule) (*types.Receipt,
votes.Address = append(votes.Address, a.fromaddr) votes.Address = append(votes.Address, a.fromaddr)
if cur.GetVoteResult().TotalVotes == 0 { //需要统计票数 if cur.GetVoteResult().TotalVotes == 0 { //需要统计票数
addr := "16htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp" addr := "16htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp"
account, err := a.getStartHeightVoteAccount(addr, start) account, err := a.getStartHeightVoteAccount(addr, start)
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)
...@@ -307,7 +305,7 @@ func (a *action) tmintPropRule(tmintProb *auty.TerminateProposalRule) (*types.Re ...@@ -307,7 +305,7 @@ func (a *action) tmintPropRule(tmintProb *auty.TerminateProposalRule) (*types.Re
} }
func (a *action) transfer(tf *auty.TransferFund) (*types.Receipt, error) { func (a *action) transfer(tf *auty.TransferFund) (*types.Receipt, error) {
if a.execaddr != dapp.ExecAddress(string(auty.AutonomyX)) { if a.execaddr != dapp.ExecAddress(string(auty.AutonomyX)) {
err := auty.ErrNoAutonomyExec err := auty.ErrNoAutonomyExec
alog.Error("autonomy transfer ", "addr", a.fromaddr, "execaddr", a.execaddr, "this exec is not autonomy", err) alog.Error("autonomy transfer ", "addr", a.fromaddr, "execaddr", a.execaddr, "this exec is not autonomy", err)
return nil, err return nil, err
...@@ -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
} }
...@@ -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)
} }
...@@ -213,4 +213,4 @@ func (c *Jrpc) CommentProposalTx(parm *auty.Comment, result *interface{}) error ...@@ -213,4 +213,4 @@ func (c *Jrpc) CommentProposalTx(parm *auty.Comment, result *interface{}) error
*result = hex.EncodeToString(reply.Data) *result = hex.EncodeToString(reply.Data)
return nil return nil
} }
\ No newline at end of file
...@@ -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)
} }
...@@ -237,4 +237,4 @@ func (c *channelClient) commentProposal(ctx context.Context, head *auty.Comment) ...@@ -237,4 +237,4 @@ func (c *channelClient) commentProposal(ctx context.Context, head *auty.Comment)
return nil, err return nil, err
} }
return &types.UnsignTx{Data: data}, nil return &types.UnsignTx{Data: data}, nil
} }
\ No newline at end of file
...@@ -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 {
...@@ -79,4 +79,4 @@ func testListProposalCommentCmd(t *testing.T, jrpc *jsonclient.JSONClient) error ...@@ -79,4 +79,4 @@ func testListProposalCommentCmd(t *testing.T, jrpc *jsonclient.JSONClient) error
params.Payload = types.MustPBToJSON(req) params.Payload = types.MustPBToJSON(req)
rep = &auty.ReplyQueryProposalComment{} rep = &auty.ReplyQueryProposalComment{}
return jrpc.Call("Chain33.Query", params, rep) return jrpc.Call("Chain33.Query", params, rep)
} }
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
...@@ -6,7 +6,7 @@ package types ...@@ -6,7 +6,7 @@ package types
// autonomy action ty // autonomy action ty
const ( const (
AutonomyActionPropBoard = iota + 1 AutonomyActionPropBoard = iota + 1
AutonomyActionRvkPropBoard AutonomyActionRvkPropBoard
AutonomyActionVotePropBoard AutonomyActionVotePropBoard
AutonomyActionTmintPropBoard AutonomyActionTmintPropBoard
...@@ -42,7 +42,7 @@ const ( ...@@ -42,7 +42,7 @@ const (
TyLogVotePropRule = 2123 TyLogVotePropRule = 2123
TyLogTmintPropRule = 2124 TyLogTmintPropRule = 2124
TyLogCommentProp = 2131 TyLogCommentProp = 2131
) )
// status // status
...@@ -70,22 +70,21 @@ const ( ...@@ -70,22 +70,21 @@ const (
const ( const (
// GetProposalBoard 用于在cmd里面的区分不同的查询 // GetProposalBoard 用于在cmd里面的区分不同的查询
GetProposalBoard = "GetProposalBoard" GetProposalBoard = "GetProposalBoard"
// ListProposalBoard // ListProposalBoard
ListProposalBoard = "ListProposalBoard" ListProposalBoard = "ListProposalBoard"
// GetProposalProject 用于在cmd里面的区分不同的查询 // GetProposalProject 用于在cmd里面的区分不同的查询
GetProposalProject = "GetProposalProject" GetProposalProject = "GetProposalProject"
// ListProposalProject // ListProposalProject
ListProposalProject = "ListProposalProject" ListProposalProject = "ListProposalProject"
// GetProposalRule 用于在cmd里面的区分不同的查询 // GetProposalRule 用于在cmd里面的区分不同的查询
GetProposalRule = "GetProposalRule" GetProposalRule = "GetProposalRule"
// ListProposalRule // ListProposalRule
ListProposalRule = "ListProposalRule" ListProposalRule = "ListProposalRule"
// ListProposalComment // ListProposalComment
ListProposalComment = "ListProposalComment" ListProposalComment = "ListProposalComment"
) )
//包的名字可以通过配置文件来配置 //包的名字可以通过配置文件来配置
//建议用github的组织名称,或者用户名字开头, 再加上自己的插件的名字 //建议用github的组织名称,或者用户名字开头, 再加上自己的插件的名字
//如果发生重名,可以通过配置文件修改这些名字 //如果发生重名,可以通过配置文件修改这些名字
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -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"
) )
...@@ -47,24 +48,23 @@ func (a *AutonomyType) GetName() string { ...@@ -47,24 +48,23 @@ func (a *AutonomyType) GetName() string {
// GetLogMap 获得日志类型列表 // GetLogMap 获得日志类型列表
func (a *AutonomyType) GetLogMap() map[int64]*types.LogInfo { func (a *AutonomyType) GetLogMap() map[int64]*types.LogInfo {
return map[int64]*types.LogInfo{ return map[int64]*types.LogInfo{
TyLogPropBoard: {Ty: reflect.TypeOf(ReceiptProposalBoard{}), Name: "LogPropBoard"}, TyLogPropBoard: {Ty: reflect.TypeOf(ReceiptProposalBoard{}), Name: "LogPropBoard"},
TyLogRvkPropBoard: {Ty: reflect.TypeOf(ReceiptProposalBoard{}), Name: "LogRvkPropBoard"}, TyLogRvkPropBoard: {Ty: reflect.TypeOf(ReceiptProposalBoard{}), Name: "LogRvkPropBoard"},
TyLogVotePropBoard: {Ty: reflect.TypeOf(ReceiptProposalBoard{}), Name: "LogVotePropBoard"}, TyLogVotePropBoard: {Ty: reflect.TypeOf(ReceiptProposalBoard{}), Name: "LogVotePropBoard"},
TyLogTmintPropBoard: {Ty: reflect.TypeOf(ReceiptProposalBoard{}), Name: "LogTmintPropBoard"}, TyLogTmintPropBoard: {Ty: reflect.TypeOf(ReceiptProposalBoard{}), Name: "LogTmintPropBoard"},
TyLogPropProject: {Ty: reflect.TypeOf(ReceiptProposalProject{}), Name: "LogPropProject"}, TyLogPropProject: {Ty: reflect.TypeOf(ReceiptProposalProject{}), Name: "LogPropProject"},
TyLogRvkPropProject: {Ty: reflect.TypeOf(ReceiptProposalProject{}), Name: "LogRvkPropProject"}, TyLogRvkPropProject: {Ty: reflect.TypeOf(ReceiptProposalProject{}), Name: "LogRvkPropProject"},
TyLogVotePropProject: {Ty: reflect.TypeOf(ReceiptProposalProject{}), Name: "LogVotePropProject"}, TyLogVotePropProject: {Ty: reflect.TypeOf(ReceiptProposalProject{}), Name: "LogVotePropProject"},
TyLogPubVotePropProject: {Ty: reflect.TypeOf(ReceiptProposalProject{}), Name: "LogPubVotePropProject"}, TyLogPubVotePropProject: {Ty: reflect.TypeOf(ReceiptProposalProject{}), Name: "LogPubVotePropProject"},
TyLogTmintPropProject: {Ty: reflect.TypeOf(ReceiptProposalProject{}), Name: "LogTmintPropProject"}, TyLogTmintPropProject: {Ty: reflect.TypeOf(ReceiptProposalProject{}), Name: "LogTmintPropProject"},
TyLogPropRule: {Ty: reflect.TypeOf(ReceiptProposalRule{}), Name: "LogPropRule"}, TyLogPropRule: {Ty: reflect.TypeOf(ReceiptProposalRule{}), Name: "LogPropRule"},
TyLogRvkPropRule: {Ty: reflect.TypeOf(ReceiptProposalRule{}), Name: "LogRvkPropRule"}, TyLogRvkPropRule: {Ty: reflect.TypeOf(ReceiptProposalRule{}), Name: "LogRvkPropRule"},
TyLogVotePropRule: {Ty: reflect.TypeOf(ReceiptProposalRule{}), Name: "LogVotePropRule"}, TyLogVotePropRule: {Ty: reflect.TypeOf(ReceiptProposalRule{}), Name: "LogVotePropRule"},
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"},
} }
} }
...@@ -76,23 +76,23 @@ func (a *AutonomyType) GetPayload() types.Message { ...@@ -76,23 +76,23 @@ func (a *AutonomyType) GetPayload() types.Message {
// GetTypeMap 获得Action 方法列表 // GetTypeMap 获得Action 方法列表
func (a *AutonomyType) GetTypeMap() map[string]int32 { func (a *AutonomyType) GetTypeMap() map[string]int32 {
return map[string]int32{ return map[string]int32{
"PropBoard": AutonomyActionPropBoard, "PropBoard": AutonomyActionPropBoard,
"RvkPropBoard": AutonomyActionRvkPropBoard, "RvkPropBoard": AutonomyActionRvkPropBoard,
"VotePropBoard": AutonomyActionVotePropBoard, "VotePropBoard": AutonomyActionVotePropBoard,
"TmintPropBoard": AutonomyActionTmintPropBoard, "TmintPropBoard": AutonomyActionTmintPropBoard,
"PropProject": AutonomyActionPropProject, "PropProject": AutonomyActionPropProject,
"RvkPropProject": AutonomyActionRvkPropProject, "RvkPropProject": AutonomyActionRvkPropProject,
"VotePropProject": AutonomyActionVotePropProject, "VotePropProject": AutonomyActionVotePropProject,
"PubVotePropProject": AutonomyActionPubVotePropProject, "PubVotePropProject": AutonomyActionPubVotePropProject,
"TmintPropProject": AutonomyActionTmintPropProject, "TmintPropProject": AutonomyActionTmintPropProject,
"PropRule": AutonomyActionPropRule, "PropRule": AutonomyActionPropRule,
"RvkPropRule": AutonomyActionRvkPropRule, "RvkPropRule": AutonomyActionRvkPropRule,
"VotePropRule": AutonomyActionVotePropRule, "VotePropRule": AutonomyActionVotePropRule,
"TmintPropRule": AutonomyActionTmintPropRule, "TmintPropRule": AutonomyActionTmintPropRule,
"Transfer": AutonomyActionTransfer, "Transfer": AutonomyActionTransfer,
"CommentProp": AutonomyActionCommentProp, "CommentProp": AutonomyActionCommentProp,
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment