Commit bacdd6cf authored by liuyuhang's avatar liuyuhang Committed by 33cn

modify linter

parent cf9a539d
...@@ -117,9 +117,9 @@ type RoundState struct { ...@@ -117,9 +117,9 @@ type RoundState struct {
// RoundStateMessage ... // RoundStateMessage ...
func (rs *RoundState) RoundStateMessage() *tmtypes.NewRoundStepMsg { func (rs *RoundState) RoundStateMessage() *tmtypes.NewRoundStepMsg {
return &tmtypes.NewRoundStepMsg{ return &tmtypes.NewRoundStepMsg{
Height: rs.Height, Height: rs.Height,
Round: int32(rs.Round), Round: int32(rs.Round),
Step: int32(rs.Step), Step: int32(rs.Step),
SecondsSinceStartTime: int32(time.Since(rs.StartTime).Seconds()), SecondsSinceStartTime: int32(time.Since(rs.StartTime).Seconds()),
LastCommitRound: int32(rs.LastCommit.Round()), LastCommitRound: int32(rs.LastCommit.Round()),
} }
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
source ../dapp-test-common.sh source ../dapp-test-common.sh
MAIN_HTTP="" MAIN_HTTP=""
txhash="" #txhash=""
function run_testcases() { function run_testcases() {
echo "run_testcases" echo "run_testcases"
...@@ -32,4 +32,4 @@ function rpc_test() { ...@@ -32,4 +32,4 @@ function rpc_test() {
fi fi
} }
debug_function rpc_test "$1" #debug_function rpc_test "$1"
#!/usr/bin/env bash #!/usr/bin/env bash
CLI="docker exec ${NODE3} /root/chain33-cli" #CLI="docker exec ${NODE3} /root/chain33-cli"
...@@ -174,7 +174,7 @@ func voteProposalBoard(cmd *cobra.Command, args []string) { ...@@ -174,7 +174,7 @@ func voteProposalBoard(cmd *cobra.Command, args []string) {
ctx.RunWithoutMarshal() ctx.RunWithoutMarshal()
} }
// TerminateProposalBoard 终止提案 // TerminateProposalBoardCmd 终止提案
func TerminateProposalBoardCmd() *cobra.Command { func TerminateProposalBoardCmd() *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "terminateBoard", Use: "terminateBoard",
......
...@@ -194,7 +194,7 @@ func pubVoteProposalProject(cmd *cobra.Command, args []string) { ...@@ -194,7 +194,7 @@ func pubVoteProposalProject(cmd *cobra.Command, args []string) {
ctx.RunWithoutMarshal() ctx.RunWithoutMarshal()
} }
// TerminateProposalProject 终止提案 // TerminateProposalProjectCmd 终止提案
func TerminateProposalProjectCmd() *cobra.Command { func TerminateProposalProjectCmd() *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "terminateProject", Use: "terminateProject",
......
...@@ -144,7 +144,7 @@ func voteProposalRule(cmd *cobra.Command, args []string) { ...@@ -144,7 +144,7 @@ func voteProposalRule(cmd *cobra.Command, args []string) {
ctx.RunWithoutMarshal() ctx.RunWithoutMarshal()
} }
// TerminateProposalRule 终止提案 // TerminateProposalRuleCmd 终止提案
func TerminateProposalRuleCmd() *cobra.Command { func TerminateProposalRuleCmd() *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "terminateRule", Use: "terminateRule",
......
...@@ -15,7 +15,6 @@ import ( ...@@ -15,7 +15,6 @@ import (
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)
autonomyFundAddr = address.ExecAddress("autonomyfund") autonomyFundAddr = address.ExecAddress("autonomyfund")
) )
......
...@@ -255,6 +255,7 @@ func TestListProposalBoard(t *testing.T) { ...@@ -255,6 +255,7 @@ func TestListProposalBoard(t *testing.T) {
Index: Index, Index: Index,
} }
rsp, err = au.listProposalBoard(req) rsp, err = au.listProposalBoard(req)
require.NoError(t, err)
require.Equal(t, len(rsp.(*auty.ReplyQueryProposalBoard).PropBoards), 2) require.Equal(t, len(rsp.(*auty.ReplyQueryProposalBoard).PropBoards), 2)
require.Equal(t, rsp.(*auty.ReplyQueryProposalBoard).PropBoards[0].Height, testcase2[1].height) require.Equal(t, rsp.(*auty.ReplyQueryProposalBoard).PropBoards[0].Height, testcase2[1].height)
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))
......
...@@ -24,7 +24,8 @@ import ( ...@@ -24,7 +24,8 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
type execEnv struct { // ExecEnv exec environment
type ExecEnv struct {
blockTime int64 // 1539918074 blockTime int64 // 1539918074
blockHeight int64 blockHeight int64
index int index int
...@@ -52,7 +53,8 @@ func init() { ...@@ -52,7 +53,8 @@ func init() {
commonlog.SetLogLevel("error") commonlog.SetLogLevel("error")
} }
func InitEnv() (*execEnv, drivers.Driver, dbm.KV, dbm.KVDB) { // InitEnv 初始化环境
func InitEnv() (*ExecEnv, drivers.Driver, dbm.KV, dbm.KVDB) {
accountA := types.Account{ accountA := types.Account{
Balance: total, Balance: total,
Frozen: 0, Frozen: 0,
...@@ -77,7 +79,7 @@ func InitEnv() (*execEnv, drivers.Driver, dbm.KV, dbm.KVDB) { ...@@ -77,7 +79,7 @@ func InitEnv() (*execEnv, drivers.Driver, dbm.KV, dbm.KVDB) {
Addr: AddrD, Addr: AddrD,
} }
env := &execEnv{ env := &ExecEnv{
blockTime: 1539918074, blockTime: 1539918074,
blockHeight: 10, blockHeight: 10,
index: 2, index: 2,
...@@ -131,7 +133,7 @@ func TestTerminateProposalBoard(t *testing.T) { ...@@ -131,7 +133,7 @@ func TestTerminateProposalBoard(t *testing.T) {
terminateProposalBoard(t, env, exec, stateDB, kvdb, true) terminateProposalBoard(t, env, exec, stateDB, kvdb, true)
} }
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,
...@@ -194,7 +196,7 @@ func propBoardTx(parm *auty.ProposalBoard) (*types.Transaction, error) { ...@@ -194,7 +196,7 @@ func propBoardTx(parm *auty.ProposalBoard) (*types.Transaction, error) {
return types.CreateFormatTx(types.ExecName(auty.AutonomyX), types.Encode(val)) return types.CreateFormatTx(types.ExecName(auty.AutonomyX), types.Encode(val))
} }
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,
...@@ -244,7 +246,7 @@ func revokeProposalBoardTx(parm *auty.RevokeProposalBoard) (*types.Transaction, ...@@ -244,7 +246,7 @@ func revokeProposalBoardTx(parm *auty.RevokeProposalBoard) (*types.Transaction,
return types.CreateFormatTx(types.ExecName(auty.AutonomyX), types.Encode(val)) return types.CreateFormatTx(types.ExecName(auty.AutonomyX), types.Encode(val))
} }
func voteProposalBoard(t *testing.T, env *execEnv, exec drivers.Driver, stateDB dbm.KV, kvdb dbm.KVDB, save bool) { func voteProposalBoard(t *testing.T, env *ExecEnv, exec drivers.Driver, stateDB dbm.KV, kvdb dbm.KVDB, save bool) {
api := new(apimock.QueueProtocolAPI) api := new(apimock.QueueProtocolAPI)
api.On("StoreList", mock.Anything).Return(&types.StoreListReply{}, nil) api.On("StoreList", mock.Anything).Return(&types.StoreListReply{}, nil)
api.On("GetLastHeader", mock.Anything).Return(&types.Header{StateHash: []byte("")}, nil) api.On("GetLastHeader", mock.Anything).Return(&types.Header{StateHash: []byte("")}, nil)
...@@ -356,7 +358,7 @@ func voteProposalBoardTx(parm *auty.VoteProposalBoard) (*types.Transaction, erro ...@@ -356,7 +358,7 @@ func voteProposalBoardTx(parm *auty.VoteProposalBoard) (*types.Transaction, erro
return types.CreateFormatTx(types.ExecName(auty.AutonomyX), types.Encode(val)) return types.CreateFormatTx(types.ExecName(auty.AutonomyX), types.Encode(val))
} }
func terminateProposalBoard(t *testing.T, env *execEnv, exec drivers.Driver, stateDB dbm.KV, kvdb dbm.KVDB, save bool) { func terminateProposalBoard(t *testing.T, env *ExecEnv, exec drivers.Driver, stateDB dbm.KV, kvdb dbm.KVDB, save bool) {
api := new(apimock.QueueProtocolAPI) api := new(apimock.QueueProtocolAPI)
api.On("StoreList", mock.Anything).Return(&types.StoreListReply{}, nil) api.On("StoreList", mock.Anything).Return(&types.StoreListReply{}, nil)
api.On("GetLastHeader", mock.Anything).Return(&types.Header{StateHash: []byte("")}, nil) api.On("GetLastHeader", mock.Anything).Return(&types.Header{StateHash: []byte("")}, nil)
......
...@@ -10,6 +10,7 @@ import ( ...@@ -10,6 +10,7 @@ import (
) )
// 提案董事会相关 // 提案董事会相关
// Exec_PropBoard 创建提案 // Exec_PropBoard 创建提案
func (a *Autonomy) Exec_PropBoard(payload *auty.ProposalBoard, tx *types.Transaction, index int) (*types.Receipt, error) { func (a *Autonomy) Exec_PropBoard(payload *auty.ProposalBoard, tx *types.Transaction, index int) (*types.Receipt, error) {
action := newAction(a, tx, int32(index)) action := newAction(a, tx, int32(index))
...@@ -35,37 +36,39 @@ func (a *Autonomy) Exec_TmintPropBoard(payload *auty.TerminateProposalBoard, tx ...@@ -35,37 +36,39 @@ func (a *Autonomy) Exec_TmintPropBoard(payload *auty.TerminateProposalBoard, tx
} }
// 提案项目相关 // 提案项目相关
// Exec_PropProject 创建提案项目 // Exec_PropProject 创建提案项目
func (a *Autonomy) Exec_PropProject(payload *auty.ProposalProject, tx *types.Transaction, index int) (*types.Receipt, error) { func (a *Autonomy) Exec_PropProject(payload *auty.ProposalProject, tx *types.Transaction, index int) (*types.Receipt, error) {
action := newAction(a, tx, int32(index)) action := newAction(a, tx, int32(index))
return action.propProject(payload) return action.propProject(payload)
} }
// Exec_RvkPropBoard 撤销提案项目 // Exec_RvkPropProject 撤销提案项目
func (a *Autonomy) Exec_RvkPropProject(payload *auty.RevokeProposalProject, tx *types.Transaction, index int) (*types.Receipt, error) { func (a *Autonomy) Exec_RvkPropProject(payload *auty.RevokeProposalProject, tx *types.Transaction, index int) (*types.Receipt, error) {
action := newAction(a, tx, int32(index)) action := newAction(a, tx, int32(index))
return action.rvkPropProject(payload) return action.rvkPropProject(payload)
} }
// Exec_VotePropBoard 投票提案项目 // Exec_VotePropProject 投票提案项目
func (a *Autonomy) Exec_VotePropProject(payload *auty.VoteProposalProject, tx *types.Transaction, index int) (*types.Receipt, error) { func (a *Autonomy) Exec_VotePropProject(payload *auty.VoteProposalProject, tx *types.Transaction, index int) (*types.Receipt, error) {
action := newAction(a, tx, int32(index)) action := newAction(a, tx, int32(index))
return action.votePropProject(payload) return action.votePropProject(payload)
} }
// Exec_VotePropBoard 投票提案项目 // Exec_PubVotePropProject 投票提案项目
func (a *Autonomy) Exec_PubVotePropProject(payload *auty.PubVoteProposalProject, tx *types.Transaction, index int) (*types.Receipt, error) { func (a *Autonomy) Exec_PubVotePropProject(payload *auty.PubVoteProposalProject, tx *types.Transaction, index int) (*types.Receipt, error) {
action := newAction(a, tx, int32(index)) action := newAction(a, tx, int32(index))
return action.pubVotePropProject(payload) return action.pubVotePropProject(payload)
} }
// Exec_TmintPropBoard 终止提案项目 // Exec_TmintPropProject 终止提案项目
func (a *Autonomy) Exec_TmintPropProject(payload *auty.TerminateProposalProject, tx *types.Transaction, index int) (*types.Receipt, error) { func (a *Autonomy) Exec_TmintPropProject(payload *auty.TerminateProposalProject, tx *types.Transaction, index int) (*types.Receipt, error) {
action := newAction(a, tx, int32(index)) action := newAction(a, tx, int32(index))
return action.tmintPropProject(payload) return action.tmintPropProject(payload)
} }
// 提案规则相关 // 提案规则相关
// Exec_PropRule 创建提案规则 // Exec_PropRule 创建提案规则
func (a *Autonomy) Exec_PropRule(payload *auty.ProposalRule, tx *types.Transaction, index int) (*types.Receipt, error) { func (a *Autonomy) Exec_PropRule(payload *auty.ProposalRule, tx *types.Transaction, index int) (*types.Receipt, error) {
action := newAction(a, tx, int32(index)) action := newAction(a, tx, int32(index))
...@@ -96,7 +99,7 @@ func (a *Autonomy) Exec_Transfer(payload *auty.TransferFund, tx *types.Transacti ...@@ -96,7 +99,7 @@ func (a *Autonomy) Exec_Transfer(payload *auty.TransferFund, tx *types.Transacti
return action.transfer(payload) return action.transfer(payload)
} }
// Exec_Comment 评论提案 // Exec_CommentProp 评论提案
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)
......
...@@ -10,6 +10,7 @@ import ( ...@@ -10,6 +10,7 @@ import (
) )
// 提案董事会相关 // 提案董事会相关
// ExecDelLocal_PropBoard 创建提案董事会 // ExecDelLocal_PropBoard 创建提案董事会
func (a *Autonomy) ExecDelLocal_PropBoard(payload *auty.ProposalBoard, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (a *Autonomy) ExecDelLocal_PropBoard(payload *auty.ProposalBoard, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return a.execDelLocalBoard(receiptData) return a.execDelLocalBoard(receiptData)
...@@ -31,6 +32,7 @@ func (a *Autonomy) ExecDelLocal_TmintPropBoard(payload *auty.TerminateProposalBo ...@@ -31,6 +32,7 @@ func (a *Autonomy) ExecDelLocal_TmintPropBoard(payload *auty.TerminateProposalBo
} }
// 提案项目相关 // 提案项目相关
// ExecDelLocal_PropProject 创建提案项目 // ExecDelLocal_PropProject 创建提案项目
func (a *Autonomy) ExecDelLocal_PropProject(payload *auty.ProposalProject, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (a *Autonomy) ExecDelLocal_PropProject(payload *auty.ProposalProject, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return a.execDelLocalProject(receiptData) return a.execDelLocalProject(receiptData)
...@@ -57,6 +59,7 @@ func (a *Autonomy) ExecDelLocal_TmintPropProject(payload *auty.TerminateProposal ...@@ -57,6 +59,7 @@ func (a *Autonomy) ExecDelLocal_TmintPropProject(payload *auty.TerminateProposal
} }
// 提案规则相关 // 提案规则相关
// ExecDelLocal_PropRule 创建提案规则 // ExecDelLocal_PropRule 创建提案规则
func (a *Autonomy) ExecDelLocal_PropRule(payload *auty.ProposalRule, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (a *Autonomy) ExecDelLocal_PropRule(payload *auty.ProposalRule, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return a.execDelLocalRule(receiptData) return a.execDelLocalRule(receiptData)
...@@ -77,7 +80,7 @@ func (a *Autonomy) ExecDelLocal_TmintPropRule(payload *auty.TerminateProposalRul ...@@ -77,7 +80,7 @@ func (a *Autonomy) ExecDelLocal_TmintPropRule(payload *auty.TerminateProposalRul
return a.execDelLocalRule(receiptData) return a.execDelLocalRule(receiptData)
} }
// ExecDelLocal_TmintPropRule 终止提案规则 // ExecDelLocal_CommentProp 终止提案规则
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)
} }
...@@ -10,6 +10,7 @@ import ( ...@@ -10,6 +10,7 @@ import (
) )
// 提案董事会相关 // 提案董事会相关
// ExecLocal_PropBoard 创建提案 // ExecLocal_PropBoard 创建提案
func (a *Autonomy) ExecLocal_PropBoard(payload *auty.ProposalBoard, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (a *Autonomy) ExecLocal_PropBoard(payload *auty.ProposalBoard, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return a.execLocalBoard(receiptData) return a.execLocalBoard(receiptData)
...@@ -31,6 +32,7 @@ func (a *Autonomy) ExecLocal_TmintPropBoard(payload *auty.TerminateProposalBoard ...@@ -31,6 +32,7 @@ func (a *Autonomy) ExecLocal_TmintPropBoard(payload *auty.TerminateProposalBoard
} }
// 提案项目相关 // 提案项目相关
// ExecLocal_PropProject 创建提案项目 // ExecLocal_PropProject 创建提案项目
func (a *Autonomy) ExecLocal_PropProject(payload *auty.ProposalProject, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (a *Autonomy) ExecLocal_PropProject(payload *auty.ProposalProject, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return a.execLocalProject(receiptData) return a.execLocalProject(receiptData)
...@@ -57,6 +59,7 @@ func (a *Autonomy) ExecLocal_TmintPropProject(payload *auty.TerminateProposalPro ...@@ -57,6 +59,7 @@ func (a *Autonomy) ExecLocal_TmintPropProject(payload *auty.TerminateProposalPro
} }
// 提案规则相关 // 提案规则相关
// ExecLocal_PropRule 创建提案规则 // ExecLocal_PropRule 创建提案规则
func (a *Autonomy) ExecLocal_PropRule(payload *auty.ProposalRule, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (a *Autonomy) ExecLocal_PropRule(payload *auty.ProposalRule, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return a.execLocalRule(receiptData) return a.execLocalRule(receiptData)
...@@ -77,7 +80,7 @@ func (a *Autonomy) ExecLocal_TmintPropRule(payload *auty.TerminateProposalRule, ...@@ -77,7 +80,7 @@ func (a *Autonomy) ExecLocal_TmintPropRule(payload *auty.TerminateProposalRule,
return a.execLocalRule(receiptData) return a.execLocalRule(receiptData)
} }
// ExecLocal_Comment 评论提案 // ExecLocal_CommentProp 评论提案
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)
} }
...@@ -29,7 +29,7 @@ var ( ...@@ -29,7 +29,7 @@ var (
) )
func activeBoardID() []byte { func activeBoardID() []byte {
return []byte(fmt.Sprintf("%s", boardPrefix)) return []byte(boardPrefix)
} }
func propBoardID(txHash string) []byte { func propBoardID(txHash string) []byte {
...@@ -67,7 +67,7 @@ var ( ...@@ -67,7 +67,7 @@ var (
) )
func activeRuleID() []byte { func activeRuleID() []byte {
return []byte(fmt.Sprintf("%s", rulePrefix)) return []byte(rulePrefix)
} }
func propRuleID(txHash string) []byte { func propRuleID(txHash string) []byte {
......
...@@ -261,6 +261,7 @@ func TestListProposalProject(t *testing.T) { ...@@ -261,6 +261,7 @@ func TestListProposalProject(t *testing.T) {
Index: Index, Index: Index,
} }
rsp, err = au.listProposalProject(req) rsp, err = au.listProposalProject(req)
require.NoError(t, err)
require.Equal(t, len(rsp.(*auty.ReplyQueryProposalProject).PropProjects), 2) require.Equal(t, len(rsp.(*auty.ReplyQueryProposalProject).PropProjects), 2)
require.Equal(t, rsp.(*auty.ReplyQueryProposalProject).PropProjects[0].Height, testcase2[1].height) require.Equal(t, rsp.(*auty.ReplyQueryProposalProject).PropProjects[0].Height, testcase2[1].height)
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))
......
...@@ -199,9 +199,9 @@ func (a *action) votePropProject(voteProb *auty.VoteProposalProject) (*types.Rec ...@@ -199,9 +199,9 @@ func (a *action) votePropProject(voteProb *auty.VoteProposalProject) (*types.Rec
votes.Address = append(votes.Address, a.fromaddr) votes.Address = append(votes.Address, a.fromaddr)
// 更新投票结果 // 更新投票结果
if voteProb.Approve { if voteProb.Approve {
cur.BoardVoteRes.ApproveVotes += 1 cur.BoardVoteRes.ApproveVotes++
} else { } else {
cur.BoardVoteRes.OpposeVotes += 1 cur.BoardVoteRes.OpposeVotes++
} }
var logs []*types.ReceiptLog var logs []*types.ReceiptLog
......
...@@ -28,6 +28,8 @@ import ( ...@@ -28,6 +28,8 @@ import (
// testLargeProjectAmount int64 = 1 // testLargeProjectAmount int64 = 1
//) //)
var autonomyAddr = address.ExecAddress(auty.AutonomyX)
const ( const (
testProjectAmount int64 = types.Coin * 100 // 工程需要资金 testProjectAmount int64 = types.Coin * 100 // 工程需要资金
) )
...@@ -166,7 +168,7 @@ func TestTerminateProposalProject(t *testing.T) { ...@@ -166,7 +168,7 @@ func TestTerminateProposalProject(t *testing.T) {
terminateProposalProject(t, env, exec, stateDB, kvdb, true) terminateProposalProject(t, env, exec, stateDB, kvdb, true)
} }
func testPropProject(t *testing.T, env *execEnv, exec drivers.Driver, stateDB dbm.KV, kvdb dbm.KVDB, save bool) { func testPropProject(t *testing.T, env *ExecEnv, exec drivers.Driver, stateDB dbm.KV, kvdb dbm.KVDB, save bool) {
opt1 := &auty.ProposalProject{ opt1 := &auty.ProposalProject{
Year: 2019, Year: 2019,
Month: 7, Month: 7,
...@@ -229,7 +231,7 @@ func propProjectTx(parm *auty.ProposalProject) (*types.Transaction, error) { ...@@ -229,7 +231,7 @@ func propProjectTx(parm *auty.ProposalProject) (*types.Transaction, error) {
return types.CreateFormatTx(types.ExecName(auty.AutonomyX), types.Encode(val)) return types.CreateFormatTx(types.ExecName(auty.AutonomyX), types.Encode(val))
} }
func revokeProposalProject(t *testing.T, env *execEnv, exec drivers.Driver, stateDB dbm.KV, kvdb dbm.KVDB, save bool) { func revokeProposalProject(t *testing.T, env *ExecEnv, exec drivers.Driver, stateDB dbm.KV, kvdb dbm.KVDB, save bool) {
proposalID := env.txHash proposalID := env.txHash
opt2 := &auty.RevokeProposalProject{ opt2 := &auty.RevokeProposalProject{
ProposalID: proposalID, ProposalID: proposalID,
...@@ -287,7 +289,7 @@ func revokeProposalProjectTx(parm *auty.RevokeProposalProject) (*types.Transacti ...@@ -287,7 +289,7 @@ func revokeProposalProjectTx(parm *auty.RevokeProposalProject) (*types.Transacti
return types.CreateFormatTx(types.ExecName(auty.AutonomyX), types.Encode(val)) return types.CreateFormatTx(types.ExecName(auty.AutonomyX), types.Encode(val))
} }
func voteProposalProject(t *testing.T, env *execEnv, exec drivers.Driver, stateDB dbm.KV, kvdb dbm.KVDB, save bool) { func voteProposalProject(t *testing.T, env *ExecEnv, exec drivers.Driver, stateDB dbm.KV, kvdb dbm.KVDB, save bool) {
api := new(apimock.QueueProtocolAPI) api := new(apimock.QueueProtocolAPI)
api.On("StoreList", mock.Anything).Return(&types.StoreListReply{}, nil) api.On("StoreList", mock.Anything).Return(&types.StoreListReply{}, nil)
api.On("GetLastHeader", mock.Anything).Return(&types.Header{StateHash: []byte("")}, nil) api.On("GetLastHeader", mock.Anything).Return(&types.Header{StateHash: []byte("")}, nil)
...@@ -401,7 +403,7 @@ func checkVoteProposalProjectResult(t *testing.T, stateDB dbm.KV, proposalID str ...@@ -401,7 +403,7 @@ func checkVoteProposalProjectResult(t *testing.T, stateDB dbm.KV, proposalID str
require.Equal(t, AddrA, cur.Address) require.Equal(t, AddrA, cur.Address)
} }
func pubVoteProposalProject(t *testing.T, env *execEnv, exec drivers.Driver, stateDB dbm.KV, kvdb dbm.KVDB, save bool) { func pubVoteProposalProject(t *testing.T, env *ExecEnv, exec drivers.Driver, stateDB dbm.KV, kvdb dbm.KVDB, save bool) {
api := new(apimock.QueueProtocolAPI) api := new(apimock.QueueProtocolAPI)
api.On("StoreList", mock.Anything).Return(&types.StoreListReply{}, nil) api.On("StoreList", mock.Anything).Return(&types.StoreListReply{}, nil)
api.On("GetLastHeader", mock.Anything).Return(&types.Header{StateHash: []byte("")}, nil) api.On("GetLastHeader", mock.Anything).Return(&types.Header{StateHash: []byte("")}, nil)
...@@ -515,7 +517,7 @@ func pubVoteProposalProjectTx(parm *auty.PubVoteProposalProject) (*types.Transac ...@@ -515,7 +517,7 @@ func pubVoteProposalProjectTx(parm *auty.PubVoteProposalProject) (*types.Transac
return types.CreateFormatTx(types.ExecName(auty.AutonomyX), types.Encode(val)) return types.CreateFormatTx(types.ExecName(auty.AutonomyX), types.Encode(val))
} }
func terminateProposalProject(t *testing.T, env *execEnv, exec drivers.Driver, stateDB dbm.KV, kvdb dbm.KVDB, save bool) { func terminateProposalProject(t *testing.T, env *ExecEnv, exec drivers.Driver, stateDB dbm.KV, kvdb dbm.KVDB, save bool) {
api := new(apimock.QueueProtocolAPI) api := new(apimock.QueueProtocolAPI)
api.On("StoreList", mock.Anything).Return(&types.StoreListReply{}, nil) api.On("StoreList", mock.Anything).Return(&types.StoreListReply{}, nil)
api.On("GetLastHeader", mock.Anything).Return(&types.Header{StateHash: []byte("")}, nil) api.On("GetLastHeader", mock.Anything).Return(&types.Header{StateHash: []byte("")}, nil)
......
...@@ -255,6 +255,7 @@ func TestListProposalRule(t *testing.T) { ...@@ -255,6 +255,7 @@ func TestListProposalRule(t *testing.T) {
Index: Index, Index: Index,
} }
rsp, err = au.listProposalRule(req) rsp, err = au.listProposalRule(req)
require.NoError(t, err)
require.Equal(t, len(rsp.(*auty.ReplyQueryProposalRule).PropRules), 2) require.Equal(t, len(rsp.(*auty.ReplyQueryProposalRule).PropRules), 2)
require.Equal(t, rsp.(*auty.ReplyQueryProposalRule).PropRules[0].Height, testcase2[1].height) require.Equal(t, rsp.(*auty.ReplyQueryProposalRule).PropRules[0].Height, testcase2[1].height)
require.Equal(t, rsp.(*auty.ReplyQueryProposalRule).PropRules[0].Index, int32(testcase2[1].index)) require.Equal(t, rsp.(*auty.ReplyQueryProposalRule).PropRules[0].Index, int32(testcase2[1].index))
...@@ -324,7 +325,7 @@ func TestListProposalComment(t *testing.T) { ...@@ -324,7 +325,7 @@ func TestListProposalComment(t *testing.T) {
au.SetLocalDB(kvdb) au.SetLocalDB(kvdb)
type statu struct { type statu struct {
propId string propID string
height int64 height int64
index int64 index int64
} }
...@@ -351,7 +352,7 @@ func TestListProposalComment(t *testing.T) { ...@@ -351,7 +352,7 @@ func TestListProposalComment(t *testing.T) {
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)
...@@ -414,6 +415,7 @@ func TestListProposalComment(t *testing.T) { ...@@ -414,6 +415,7 @@ func TestListProposalComment(t *testing.T) {
Index: Index, Index: Index,
} }
rsp, err = au.listProposalComment(req) rsp, err = au.listProposalComment(req)
require.NoError(t, err)
require.Equal(t, len(rsp.(*auty.ReplyQueryProposalComment).RltCmt), 2) require.Equal(t, len(rsp.(*auty.ReplyQueryProposalComment).RltCmt), 2)
require.Equal(t, rsp.(*auty.ReplyQueryProposalComment).RltCmt[0].Height, testcase2[1].height) require.Equal(t, rsp.(*auty.ReplyQueryProposalComment).RltCmt[0].Height, testcase2[1].height)
require.Equal(t, rsp.(*auty.ReplyQueryProposalComment).RltCmt[0].Index, int32(testcase2[1].index)) require.Equal(t, rsp.(*auty.ReplyQueryProposalComment).RltCmt[0].Index, int32(testcase2[1].index))
......
...@@ -305,7 +305,7 @@ func (a *action) tmintPropRule(tmintProb *auty.TerminateProposalRule) (*types.Re ...@@ -305,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(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
......
...@@ -53,7 +53,7 @@ func TestTerminateProposalRule(t *testing.T) { ...@@ -53,7 +53,7 @@ func TestTerminateProposalRule(t *testing.T) {
terminateProposalRule(t, env, exec, stateDB, kvdb, true) terminateProposalRule(t, env, exec, stateDB, kvdb, true)
} }
func testPropRule(t *testing.T, env *execEnv, exec drivers.Driver, stateDB dbm.KV, kvdb dbm.KVDB, save bool) { func testPropRule(t *testing.T, env *ExecEnv, exec drivers.Driver, stateDB dbm.KV, kvdb dbm.KVDB, save bool) {
opt1 := &auty.ProposalRule{ opt1 := &auty.ProposalRule{
Year: 2019, Year: 2019,
Month: 7, Month: 7,
...@@ -121,7 +121,7 @@ func propRuleTx(parm *auty.ProposalRule) (*types.Transaction, error) { ...@@ -121,7 +121,7 @@ func propRuleTx(parm *auty.ProposalRule) (*types.Transaction, error) {
return types.CreateFormatTx(types.ExecName(auty.AutonomyX), types.Encode(val)) return types.CreateFormatTx(types.ExecName(auty.AutonomyX), types.Encode(val))
} }
func revokeProposalRule(t *testing.T, env *execEnv, exec drivers.Driver, stateDB dbm.KV, kvdb dbm.KVDB, save bool) { func revokeProposalRule(t *testing.T, env *ExecEnv, exec drivers.Driver, stateDB dbm.KV, kvdb dbm.KVDB, save bool) {
proposalID := env.txHash proposalID := env.txHash
opt2 := &auty.RevokeProposalRule{ opt2 := &auty.RevokeProposalRule{
ProposalID: proposalID, ProposalID: proposalID,
...@@ -186,7 +186,7 @@ func revokeProposalRuleTx(parm *auty.RevokeProposalRule) (*types.Transaction, er ...@@ -186,7 +186,7 @@ func revokeProposalRuleTx(parm *auty.RevokeProposalRule) (*types.Transaction, er
return types.CreateFormatTx(types.ExecName(auty.AutonomyX), types.Encode(val)) return types.CreateFormatTx(types.ExecName(auty.AutonomyX), types.Encode(val))
} }
func voteProposalRule(t *testing.T, env *execEnv, exec drivers.Driver, stateDB dbm.KV, kvdb dbm.KVDB, save bool) { func voteProposalRule(t *testing.T, env *ExecEnv, exec drivers.Driver, stateDB dbm.KV, kvdb dbm.KVDB, save bool) {
api := new(apimock.QueueProtocolAPI) api := new(apimock.QueueProtocolAPI)
api.On("StoreList", mock.Anything).Return(&types.StoreListReply{}, nil) api.On("StoreList", mock.Anything).Return(&types.StoreListReply{}, nil)
api.On("GetLastHeader", mock.Anything).Return(&types.Header{StateHash: []byte("")}, nil) api.On("GetLastHeader", mock.Anything).Return(&types.Header{StateHash: []byte("")}, nil)
...@@ -313,7 +313,7 @@ func voteProposalRuleTx(parm *auty.VoteProposalRule) (*types.Transaction, error) ...@@ -313,7 +313,7 @@ func voteProposalRuleTx(parm *auty.VoteProposalRule) (*types.Transaction, error)
return types.CreateFormatTx(types.ExecName(auty.AutonomyX), types.Encode(val)) return types.CreateFormatTx(types.ExecName(auty.AutonomyX), types.Encode(val))
} }
func terminateProposalRule(t *testing.T, env *execEnv, exec drivers.Driver, stateDB dbm.KV, kvdb dbm.KVDB, save bool) { func terminateProposalRule(t *testing.T, env *ExecEnv, exec drivers.Driver, stateDB dbm.KV, kvdb dbm.KVDB, save bool) {
api := new(apimock.QueueProtocolAPI) api := new(apimock.QueueProtocolAPI)
api.On("StoreList", mock.Anything).Return(&types.StoreListReply{}, nil) api.On("StoreList", mock.Anything).Return(&types.StoreListReply{}, nil)
api.On("GetLastHeader", mock.Anything).Return(&types.Header{StateHash: []byte("")}, nil) api.On("GetLastHeader", mock.Anything).Return(&types.Header{StateHash: []byte("")}, nil)
......
...@@ -13,6 +13,7 @@ import ( ...@@ -13,6 +13,7 @@ import (
) )
// 提案董事会相关 // 提案董事会相关
// PropBoardTx 提案董事会成员RPC接口 // PropBoardTx 提案董事会成员RPC接口
func (c *Jrpc) PropBoardTx(parm *auty.ProposalBoard, result *interface{}) error { func (c *Jrpc) PropBoardTx(parm *auty.ProposalBoard, result *interface{}) error {
if parm == nil { if parm == nil {
...@@ -67,6 +68,7 @@ func (c *Jrpc) TerminateProposalBoardTx(parm *auty.TerminateProposalBoard, resul ...@@ -67,6 +68,7 @@ func (c *Jrpc) TerminateProposalBoardTx(parm *auty.TerminateProposalBoard, resul
} }
// 提案项目相关 // 提案项目相关
// PropProjectTx 提案项目RPC接口 // PropProjectTx 提案项目RPC接口
func (c *Jrpc) PropProjectTx(parm *auty.ProposalProject, result *interface{}) error { func (c *Jrpc) PropProjectTx(parm *auty.ProposalProject, result *interface{}) error {
if parm == nil { if parm == nil {
...@@ -134,6 +136,7 @@ func (c *Jrpc) TerminateProposalProjectTx(parm *auty.TerminateProposalProject, r ...@@ -134,6 +136,7 @@ func (c *Jrpc) TerminateProposalProjectTx(parm *auty.TerminateProposalProject, r
} }
// 提案规则相关 // 提案规则相关
// PropRuleTx 提案规则RPC接口 // PropRuleTx 提案规则RPC接口
func (c *Jrpc) PropRuleTx(parm *auty.ProposalRule, result *interface{}) error { func (c *Jrpc) PropRuleTx(parm *auty.ProposalRule, result *interface{}) error {
if parm == nil { if parm == nil {
...@@ -187,7 +190,7 @@ func (c *Jrpc) TerminateProposalRuleTx(parm *auty.TerminateProposalRule, result ...@@ -187,7 +190,7 @@ func (c *Jrpc) TerminateProposalRuleTx(parm *auty.TerminateProposalRule, result
return nil return nil
} }
// TransferTx 资金转入自治系统合约中 // TransferFundTx 资金转入自治系统合约中
func (c *Jrpc) TransferFundTx(parm *auty.TransferFund, result *interface{}) error { func (c *Jrpc) TransferFundTx(parm *auty.TransferFund, result *interface{}) error {
if parm == nil { if parm == nil {
return types.ErrInvalidParam return types.ErrInvalidParam
......
...@@ -45,7 +45,7 @@ const ( ...@@ -45,7 +45,7 @@ const (
TyLogCommentProp = 2131 TyLogCommentProp = 2131
) )
// status // Board status
const ( const (
AutonomyStatusProposalBoard = iota + 1 AutonomyStatusProposalBoard = iota + 1
AutonomyStatusRvkPropBoard AutonomyStatusRvkPropBoard
...@@ -53,6 +53,7 @@ const ( ...@@ -53,6 +53,7 @@ const (
AutonomyStatusTmintPropBoard AutonomyStatusTmintPropBoard
) )
// Project status
const ( const (
AutonomyStatusProposalProject = iota + 1 AutonomyStatusProposalProject = iota + 1
AutonomyStatusRvkPropProject AutonomyStatusRvkPropProject
...@@ -61,6 +62,7 @@ const ( ...@@ -61,6 +62,7 @@ const (
AutonomyStatusTmintPropProject AutonomyStatusTmintPropProject
) )
// Rule status
const ( const (
AutonomyStatusProposalRule = iota + 1 AutonomyStatusProposalRule = iota + 1
AutonomyStatusRvkPropRule AutonomyStatusRvkPropRule
...@@ -71,17 +73,17 @@ const ( ...@@ -71,17 +73,17 @@ 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"
) )
......
...@@ -13,7 +13,7 @@ var ( ...@@ -13,7 +13,7 @@ var (
ErrProposalStatus = errors.New("ErrProposalStatus") ErrProposalStatus = errors.New("ErrProposalStatus")
// ErrRepeatVoteAddr 重复投票地址 // ErrRepeatVoteAddr 重复投票地址
ErrRepeatVoteAddr = errors.New("ErrRepeatVoteAddr") ErrRepeatVoteAddr = errors.New("ErrRepeatVoteAddr")
// ErrRevokePeriod 非取消提案期间 // ErrRevokeProposalPeriod 非取消提案期间
ErrRevokeProposalPeriod = errors.New("ErrRevokeProposalPeriod") ErrRevokeProposalPeriod = errors.New("ErrRevokeProposalPeriod")
// ErrRevokeProposalPower 不能取消 // ErrRevokeProposalPower 不能取消
ErrRevokeProposalPower = errors.New("ErrRevokeProposalPower") ErrRevokeProposalPower = errors.New("ErrRevokeProposalPower")
......
...@@ -7,14 +7,11 @@ package types ...@@ -7,14 +7,11 @@ package types
import ( import (
"reflect" "reflect"
log "github.com/33cn/chain33/common/log/log15"
"github.com/33cn/chain33/types" "github.com/33cn/chain33/types"
) )
var name string var name string
var tlog = log.New("module", name)
func init() { func init() {
name = AutonomyX name = AutonomyX
types.AllowUserExec = append(types.AllowUserExec, []byte(name)) types.AllowUserExec = append(types.AllowUserExec, []byte(name))
...@@ -23,11 +20,6 @@ func init() { ...@@ -23,11 +20,6 @@ func init() {
types.RegisterDappFork(name, "Enable", 0) types.RegisterDappFork(name, "Enable", 0)
} }
//getRealExecName
func getRealExecName(paraName string) string {
return types.ExecName(paraName + AutonomyX)
}
// NewType 生成新的基础类型 // NewType 生成新的基础类型
func NewType() *AutonomyType { func NewType() *AutonomyType {
c := &AutonomyType{} c := &AutonomyType{}
......
...@@ -73,9 +73,9 @@ func ParseX509CertificateToSm2(x509Cert *x509.Certificate) *sm2.Certificate { ...@@ -73,9 +73,9 @@ func ParseX509CertificateToSm2(x509Cert *x509.Certificate) *sm2.Certificate {
UnknownExtKeyUsage: x509Cert.UnknownExtKeyUsage, UnknownExtKeyUsage: x509Cert.UnknownExtKeyUsage,
BasicConstraintsValid: x509Cert.BasicConstraintsValid, BasicConstraintsValid: x509Cert.BasicConstraintsValid,
IsCA: x509Cert.IsCA, IsCA: x509Cert.IsCA,
MaxPathLen: x509Cert.MaxPathLen, MaxPathLen: x509Cert.MaxPathLen,
MaxPathLenZero: x509Cert.MaxPathLenZero, MaxPathLenZero: x509Cert.MaxPathLenZero,
SubjectKeyId: x509Cert.SubjectKeyId, SubjectKeyId: x509Cert.SubjectKeyId,
AuthorityKeyId: x509Cert.AuthorityKeyId, AuthorityKeyId: x509Cert.AuthorityKeyId,
...@@ -136,9 +136,9 @@ func ParseSm2CertificateToX509(sm2Cert *sm2.Certificate) *x509.Certificate { ...@@ -136,9 +136,9 @@ func ParseSm2CertificateToX509(sm2Cert *sm2.Certificate) *x509.Certificate {
UnknownExtKeyUsage: sm2Cert.UnknownExtKeyUsage, UnknownExtKeyUsage: sm2Cert.UnknownExtKeyUsage,
BasicConstraintsValid: sm2Cert.BasicConstraintsValid, BasicConstraintsValid: sm2Cert.BasicConstraintsValid,
IsCA: sm2Cert.IsCA, IsCA: sm2Cert.IsCA,
MaxPathLen: sm2Cert.MaxPathLen, MaxPathLen: sm2Cert.MaxPathLen,
MaxPathLenZero: sm2Cert.MaxPathLenZero, MaxPathLenZero: sm2Cert.MaxPathLenZero,
SubjectKeyId: sm2Cert.SubjectKeyId, SubjectKeyId: sm2Cert.SubjectKeyId,
AuthorityKeyId: sm2Cert.AuthorityKeyId, AuthorityKeyId: sm2Cert.AuthorityKeyId,
......
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