Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
plugin
Commits
bacdd6cf
Commit
bacdd6cf
authored
Jul 25, 2019
by
liuyuhang
Committed by
33cn
Aug 14, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify linter
parent
cf9a539d
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
74 additions
and
61 deletions
+74
-61
round_state.go
plugin/consensus/tendermint/types/round_state.go
+3
-3
test-rpc.sh
plugin/dapp/autonomy/cmd/build/test-rpc.sh
+2
-2
testcase.sh
plugin/dapp/autonomy/cmd/build/testcase.sh
+1
-1
proposal_board.go
plugin/dapp/autonomy/commands/proposal_board.go
+1
-1
proposal_project.go
plugin/dapp/autonomy/commands/proposal_project.go
+1
-1
proposal_rule.go
plugin/dapp/autonomy/commands/proposal_rule.go
+1
-1
autonomy.go
plugin/dapp/autonomy/executor/autonomy.go
+0
-1
board_test.go
plugin/dapp/autonomy/executor/board_test.go
+1
-0
boardaction_test.go
plugin/dapp/autonomy/executor/boardaction_test.go
+9
-7
exec.go
plugin/dapp/autonomy/executor/exec.go
+8
-5
exec_del_local.go
plugin/dapp/autonomy/executor/exec_del_local.go
+4
-1
exec_local.go
plugin/dapp/autonomy/executor/exec_local.go
+4
-1
kv.go
plugin/dapp/autonomy/executor/kv.go
+2
-2
project_test.go
plugin/dapp/autonomy/executor/project_test.go
+1
-0
projectaction.go
plugin/dapp/autonomy/executor/projectaction.go
+2
-2
projectaction_test.go
plugin/dapp/autonomy/executor/projectaction_test.go
+7
-5
rule_test.go
plugin/dapp/autonomy/executor/rule_test.go
+4
-2
ruleaction.go
plugin/dapp/autonomy/executor/ruleaction.go
+1
-1
ruleaction_test.go
plugin/dapp/autonomy/executor/ruleaction_test.go
+4
-4
jrpc.go
plugin/dapp/autonomy/rpc/jrpc.go
+4
-1
const.go
plugin/dapp/autonomy/types/const.go
+7
-5
errors.go
plugin/dapp/autonomy/types/errors.go
+1
-1
types.go
plugin/dapp/autonomy/types/types.go
+0
-8
certutils.go
...rt/authority/tools/cryptogen/generator/utils/certutils.go
+6
-6
No files found.
plugin/consensus/tendermint/types/round_state.go
View file @
bacdd6cf
...
...
@@ -117,9 +117,9 @@ type RoundState struct {
// RoundStateMessage ...
func
(
rs
*
RoundState
)
RoundStateMessage
()
*
tmtypes
.
NewRoundStepMsg
{
return
&
tmtypes
.
NewRoundStepMsg
{
Height
:
rs
.
Height
,
Round
:
int32
(
rs
.
Round
),
Step
:
int32
(
rs
.
Step
),
Height
:
rs
.
Height
,
Round
:
int32
(
rs
.
Round
),
Step
:
int32
(
rs
.
Step
),
SecondsSinceStartTime
:
int32
(
time
.
Since
(
rs
.
StartTime
)
.
Seconds
()),
LastCommitRound
:
int32
(
rs
.
LastCommit
.
Round
()),
}
...
...
plugin/dapp/autonomy/cmd/build/test-rpc.sh
View file @
bacdd6cf
...
...
@@ -5,7 +5,7 @@
source
../dapp-test-common.sh
MAIN_HTTP
=
""
txhash
=
""
#
txhash=""
function
run_testcases
()
{
echo
"run_testcases"
...
...
@@ -32,4 +32,4 @@ function rpc_test() {
fi
}
debug_function rpc_test
"
$1
"
#
debug_function rpc_test "$1"
plugin/dapp/autonomy/cmd/build/testcase.sh
View file @
bacdd6cf
#!/usr/bin/env bash
CLI
=
"docker exec
${
NODE3
}
/root/chain33-cli"
#
CLI="docker exec ${NODE3} /root/chain33-cli"
plugin/dapp/autonomy/commands/proposal_board.go
View file @
bacdd6cf
...
...
@@ -174,7 +174,7 @@ func voteProposalBoard(cmd *cobra.Command, args []string) {
ctx
.
RunWithoutMarshal
()
}
// TerminateProposalBoard 终止提案
// TerminateProposalBoard
Cmd
终止提案
func
TerminateProposalBoardCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"terminateBoard"
,
...
...
plugin/dapp/autonomy/commands/proposal_project.go
View file @
bacdd6cf
...
...
@@ -194,7 +194,7 @@ func pubVoteProposalProject(cmd *cobra.Command, args []string) {
ctx
.
RunWithoutMarshal
()
}
// TerminateProposalProject 终止提案
// TerminateProposalProject
Cmd
终止提案
func
TerminateProposalProjectCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"terminateProject"
,
...
...
plugin/dapp/autonomy/commands/proposal_rule.go
View file @
bacdd6cf
...
...
@@ -144,7 +144,7 @@ func voteProposalRule(cmd *cobra.Command, args []string) {
ctx
.
RunWithoutMarshal
()
}
// TerminateProposalRule 终止提案
// TerminateProposalRule
Cmd
终止提案
func
TerminateProposalRuleCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"terminateRule"
,
...
...
plugin/dapp/autonomy/executor/autonomy.go
View file @
bacdd6cf
...
...
@@ -15,7 +15,6 @@ import (
var
(
alog
=
log
.
New
(
"module"
,
"execs.autonomy"
)
driverName
=
auty
.
AutonomyX
autonomyAddr
=
address
.
ExecAddress
(
auty
.
AutonomyX
)
autonomyFundAddr
=
address
.
ExecAddress
(
"autonomyfund"
)
)
...
...
plugin/dapp/autonomy/executor/board_test.go
View file @
bacdd6cf
...
...
@@ -255,6 +255,7 @@ func TestListProposalBoard(t *testing.T) {
Index
:
Index
,
}
rsp
,
err
=
au
.
listProposalBoard
(
req
)
require
.
NoError
(
t
,
err
)
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
]
.
Index
,
int32
(
testcase2
[
1
]
.
index
))
...
...
plugin/dapp/autonomy/executor/boardaction_test.go
View file @
bacdd6cf
...
...
@@ -24,7 +24,8 @@ import (
"github.com/stretchr/testify/require"
)
type
execEnv
struct
{
// ExecEnv exec environment
type
ExecEnv
struct
{
blockTime
int64
// 1539918074
blockHeight
int64
index
int
...
...
@@ -52,7 +53,8 @@ func init() {
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
{
Balance
:
total
,
Frozen
:
0
,
...
...
@@ -77,7 +79,7 @@ func InitEnv() (*execEnv, drivers.Driver, dbm.KV, dbm.KVDB) {
Addr
:
AddrD
,
}
env
:=
&
e
xecEnv
{
env
:=
&
E
xecEnv
{
blockTime
:
1539918074
,
blockHeight
:
10
,
index
:
2
,
...
...
@@ -131,7 +133,7 @@ func TestTerminateProposalBoard(t *testing.T) {
terminateProposalBoard
(
t
,
env
,
exec
,
stateDB
,
kvdb
,
true
)
}
func
testPropBoard
(
t
*
testing
.
T
,
env
*
e
xecEnv
,
exec
drivers
.
Driver
,
stateDB
dbm
.
KV
,
kvdb
dbm
.
KVDB
,
save
bool
)
{
func
testPropBoard
(
t
*
testing
.
T
,
env
*
E
xecEnv
,
exec
drivers
.
Driver
,
stateDB
dbm
.
KV
,
kvdb
dbm
.
KVDB
,
save
bool
)
{
opt1
:=
&
auty
.
ProposalBoard
{
Year
:
2019
,
Month
:
7
,
...
...
@@ -194,7 +196,7 @@ func propBoardTx(parm *auty.ProposalBoard) (*types.Transaction, error) {
return
types
.
CreateFormatTx
(
types
.
ExecName
(
auty
.
AutonomyX
),
types
.
Encode
(
val
))
}
func
revokeProposalBoard
(
t
*
testing
.
T
,
env
*
e
xecEnv
,
exec
drivers
.
Driver
,
stateDB
dbm
.
KV
,
kvdb
dbm
.
KVDB
,
save
bool
)
{
func
revokeProposalBoard
(
t
*
testing
.
T
,
env
*
E
xecEnv
,
exec
drivers
.
Driver
,
stateDB
dbm
.
KV
,
kvdb
dbm
.
KVDB
,
save
bool
)
{
proposalID
:=
env
.
txHash
opt2
:=
&
auty
.
RevokeProposalBoard
{
ProposalID
:
proposalID
,
...
...
@@ -244,7 +246,7 @@ func revokeProposalBoardTx(parm *auty.RevokeProposalBoard) (*types.Transaction,
return
types
.
CreateFormatTx
(
types
.
ExecName
(
auty
.
AutonomyX
),
types
.
Encode
(
val
))
}
func
voteProposalBoard
(
t
*
testing
.
T
,
env
*
e
xecEnv
,
exec
drivers
.
Driver
,
stateDB
dbm
.
KV
,
kvdb
dbm
.
KVDB
,
save
bool
)
{
func
voteProposalBoard
(
t
*
testing
.
T
,
env
*
E
xecEnv
,
exec
drivers
.
Driver
,
stateDB
dbm
.
KV
,
kvdb
dbm
.
KVDB
,
save
bool
)
{
api
:=
new
(
apimock
.
QueueProtocolAPI
)
api
.
On
(
"StoreList"
,
mock
.
Anything
)
.
Return
(
&
types
.
StoreListReply
{},
nil
)
api
.
On
(
"GetLastHeader"
,
mock
.
Anything
)
.
Return
(
&
types
.
Header
{
StateHash
:
[]
byte
(
""
)},
nil
)
...
...
@@ -356,7 +358,7 @@ func voteProposalBoardTx(parm *auty.VoteProposalBoard) (*types.Transaction, erro
return
types
.
CreateFormatTx
(
types
.
ExecName
(
auty
.
AutonomyX
),
types
.
Encode
(
val
))
}
func
terminateProposalBoard
(
t
*
testing
.
T
,
env
*
e
xecEnv
,
exec
drivers
.
Driver
,
stateDB
dbm
.
KV
,
kvdb
dbm
.
KVDB
,
save
bool
)
{
func
terminateProposalBoard
(
t
*
testing
.
T
,
env
*
E
xecEnv
,
exec
drivers
.
Driver
,
stateDB
dbm
.
KV
,
kvdb
dbm
.
KVDB
,
save
bool
)
{
api
:=
new
(
apimock
.
QueueProtocolAPI
)
api
.
On
(
"StoreList"
,
mock
.
Anything
)
.
Return
(
&
types
.
StoreListReply
{},
nil
)
api
.
On
(
"GetLastHeader"
,
mock
.
Anything
)
.
Return
(
&
types
.
Header
{
StateHash
:
[]
byte
(
""
)},
nil
)
...
...
plugin/dapp/autonomy/executor/exec.go
View file @
bacdd6cf
...
...
@@ -10,6 +10,7 @@ import (
)
// 提案董事会相关
// Exec_PropBoard 创建提案
func
(
a
*
Autonomy
)
Exec_PropBoard
(
payload
*
auty
.
ProposalBoard
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
action
:=
newAction
(
a
,
tx
,
int32
(
index
))
...
...
@@ -35,37 +36,39 @@ func (a *Autonomy) Exec_TmintPropBoard(payload *auty.TerminateProposalBoard, tx
}
// 提案项目相关
// Exec_PropProject 创建提案项目
func
(
a
*
Autonomy
)
Exec_PropProject
(
payload
*
auty
.
ProposalProject
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
action
:=
newAction
(
a
,
tx
,
int32
(
index
))
return
action
.
propProject
(
payload
)
}
// Exec_RvkProp
Board
撤销提案项目
// Exec_RvkProp
Project
撤销提案项目
func
(
a
*
Autonomy
)
Exec_RvkPropProject
(
payload
*
auty
.
RevokeProposalProject
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
action
:=
newAction
(
a
,
tx
,
int32
(
index
))
return
action
.
rvkPropProject
(
payload
)
}
// Exec_VoteProp
Board
投票提案项目
// Exec_VoteProp
Project
投票提案项目
func
(
a
*
Autonomy
)
Exec_VotePropProject
(
payload
*
auty
.
VoteProposalProject
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
action
:=
newAction
(
a
,
tx
,
int32
(
index
))
return
action
.
votePropProject
(
payload
)
}
// Exec_
VotePropBoard
投票提案项目
// Exec_
PubVotePropProject
投票提案项目
func
(
a
*
Autonomy
)
Exec_PubVotePropProject
(
payload
*
auty
.
PubVoteProposalProject
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
action
:=
newAction
(
a
,
tx
,
int32
(
index
))
return
action
.
pubVotePropProject
(
payload
)
}
// Exec_TmintProp
Board
终止提案项目
// Exec_TmintProp
Project
终止提案项目
func
(
a
*
Autonomy
)
Exec_TmintPropProject
(
payload
*
auty
.
TerminateProposalProject
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
action
:=
newAction
(
a
,
tx
,
int32
(
index
))
return
action
.
tmintPropProject
(
payload
)
}
// 提案规则相关
// Exec_PropRule 创建提案规则
func
(
a
*
Autonomy
)
Exec_PropRule
(
payload
*
auty
.
ProposalRule
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
action
:=
newAction
(
a
,
tx
,
int32
(
index
))
...
...
@@ -96,7 +99,7 @@ func (a *Autonomy) Exec_Transfer(payload *auty.TransferFund, tx *types.Transacti
return
action
.
transfer
(
payload
)
}
// Exec_Comment 评论提案
// Exec_Comment
Prop
评论提案
func
(
a
*
Autonomy
)
Exec_CommentProp
(
payload
*
auty
.
Comment
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
action
:=
newAction
(
a
,
tx
,
int32
(
index
))
return
action
.
commentProp
(
payload
)
...
...
plugin/dapp/autonomy/executor/exec_del_local.go
View file @
bacdd6cf
...
...
@@ -10,6 +10,7 @@ import (
)
// 提案董事会相关
// ExecDelLocal_PropBoard 创建提案董事会
func
(
a
*
Autonomy
)
ExecDelLocal_PropBoard
(
payload
*
auty
.
ProposalBoard
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
return
a
.
execDelLocalBoard
(
receiptData
)
...
...
@@ -31,6 +32,7 @@ func (a *Autonomy) ExecDelLocal_TmintPropBoard(payload *auty.TerminateProposalBo
}
// 提案项目相关
// ExecDelLocal_PropProject 创建提案项目
func
(
a
*
Autonomy
)
ExecDelLocal_PropProject
(
payload
*
auty
.
ProposalProject
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
return
a
.
execDelLocalProject
(
receiptData
)
...
...
@@ -57,6 +59,7 @@ func (a *Autonomy) ExecDelLocal_TmintPropProject(payload *auty.TerminateProposal
}
// 提案规则相关
// ExecDelLocal_PropRule 创建提案规则
func
(
a
*
Autonomy
)
ExecDelLocal_PropRule
(
payload
*
auty
.
ProposalRule
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
return
a
.
execDelLocalRule
(
receiptData
)
...
...
@@ -77,7 +80,7 @@ func (a *Autonomy) ExecDelLocal_TmintPropRule(payload *auty.TerminateProposalRul
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
)
{
return
a
.
execDelLocalCommentProp
(
receiptData
)
}
plugin/dapp/autonomy/executor/exec_local.go
View file @
bacdd6cf
...
...
@@ -10,6 +10,7 @@ import (
)
// 提案董事会相关
// ExecLocal_PropBoard 创建提案
func
(
a
*
Autonomy
)
ExecLocal_PropBoard
(
payload
*
auty
.
ProposalBoard
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
return
a
.
execLocalBoard
(
receiptData
)
...
...
@@ -31,6 +32,7 @@ func (a *Autonomy) ExecLocal_TmintPropBoard(payload *auty.TerminateProposalBoard
}
// 提案项目相关
// ExecLocal_PropProject 创建提案项目
func
(
a
*
Autonomy
)
ExecLocal_PropProject
(
payload
*
auty
.
ProposalProject
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
return
a
.
execLocalProject
(
receiptData
)
...
...
@@ -57,6 +59,7 @@ func (a *Autonomy) ExecLocal_TmintPropProject(payload *auty.TerminateProposalPro
}
// 提案规则相关
// ExecLocal_PropRule 创建提案规则
func
(
a
*
Autonomy
)
ExecLocal_PropRule
(
payload
*
auty
.
ProposalRule
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
return
a
.
execLocalRule
(
receiptData
)
...
...
@@ -77,7 +80,7 @@ func (a *Autonomy) ExecLocal_TmintPropRule(payload *auty.TerminateProposalRule,
return
a
.
execLocalRule
(
receiptData
)
}
// ExecLocal_Comment 评论提案
// ExecLocal_Comment
Prop
评论提案
func
(
a
*
Autonomy
)
ExecLocal_CommentProp
(
payload
*
auty
.
Comment
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
return
a
.
execLocalCommentProp
(
receiptData
)
}
plugin/dapp/autonomy/executor/kv.go
View file @
bacdd6cf
...
...
@@ -29,7 +29,7 @@ var (
)
func
activeBoardID
()
[]
byte
{
return
[]
byte
(
fmt
.
Sprintf
(
"%s"
,
boardPrefix
)
)
return
[]
byte
(
boardPrefix
)
}
func
propBoardID
(
txHash
string
)
[]
byte
{
...
...
@@ -67,7 +67,7 @@ var (
)
func
activeRuleID
()
[]
byte
{
return
[]
byte
(
fmt
.
Sprintf
(
"%s"
,
rulePrefix
)
)
return
[]
byte
(
rulePrefix
)
}
func
propRuleID
(
txHash
string
)
[]
byte
{
...
...
plugin/dapp/autonomy/executor/project_test.go
View file @
bacdd6cf
...
...
@@ -261,6 +261,7 @@ func TestListProposalProject(t *testing.T) {
Index
:
Index
,
}
rsp
,
err
=
au
.
listProposalProject
(
req
)
require
.
NoError
(
t
,
err
)
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
]
.
Index
,
int32
(
testcase2
[
1
]
.
index
))
...
...
plugin/dapp/autonomy/executor/projectaction.go
View file @
bacdd6cf
...
...
@@ -199,9 +199,9 @@ func (a *action) votePropProject(voteProb *auty.VoteProposalProject) (*types.Rec
votes
.
Address
=
append
(
votes
.
Address
,
a
.
fromaddr
)
// 更新投票结果
if
voteProb
.
Approve
{
cur
.
BoardVoteRes
.
ApproveVotes
+=
1
cur
.
BoardVoteRes
.
ApproveVotes
++
}
else
{
cur
.
BoardVoteRes
.
OpposeVotes
+=
1
cur
.
BoardVoteRes
.
OpposeVotes
++
}
var
logs
[]
*
types
.
ReceiptLog
...
...
plugin/dapp/autonomy/executor/projectaction_test.go
View file @
bacdd6cf
...
...
@@ -28,6 +28,8 @@ import (
// testLargeProjectAmount int64 = 1
//)
var
autonomyAddr
=
address
.
ExecAddress
(
auty
.
AutonomyX
)
const
(
testProjectAmount
int64
=
types
.
Coin
*
100
// 工程需要资金
)
...
...
@@ -166,7 +168,7 @@ func TestTerminateProposalProject(t *testing.T) {
terminateProposalProject
(
t
,
env
,
exec
,
stateDB
,
kvdb
,
true
)
}
func
testPropProject
(
t
*
testing
.
T
,
env
*
e
xecEnv
,
exec
drivers
.
Driver
,
stateDB
dbm
.
KV
,
kvdb
dbm
.
KVDB
,
save
bool
)
{
func
testPropProject
(
t
*
testing
.
T
,
env
*
E
xecEnv
,
exec
drivers
.
Driver
,
stateDB
dbm
.
KV
,
kvdb
dbm
.
KVDB
,
save
bool
)
{
opt1
:=
&
auty
.
ProposalProject
{
Year
:
2019
,
Month
:
7
,
...
...
@@ -229,7 +231,7 @@ func propProjectTx(parm *auty.ProposalProject) (*types.Transaction, error) {
return
types
.
CreateFormatTx
(
types
.
ExecName
(
auty
.
AutonomyX
),
types
.
Encode
(
val
))
}
func
revokeProposalProject
(
t
*
testing
.
T
,
env
*
e
xecEnv
,
exec
drivers
.
Driver
,
stateDB
dbm
.
KV
,
kvdb
dbm
.
KVDB
,
save
bool
)
{
func
revokeProposalProject
(
t
*
testing
.
T
,
env
*
E
xecEnv
,
exec
drivers
.
Driver
,
stateDB
dbm
.
KV
,
kvdb
dbm
.
KVDB
,
save
bool
)
{
proposalID
:=
env
.
txHash
opt2
:=
&
auty
.
RevokeProposalProject
{
ProposalID
:
proposalID
,
...
...
@@ -287,7 +289,7 @@ func revokeProposalProjectTx(parm *auty.RevokeProposalProject) (*types.Transacti
return
types
.
CreateFormatTx
(
types
.
ExecName
(
auty
.
AutonomyX
),
types
.
Encode
(
val
))
}
func
voteProposalProject
(
t
*
testing
.
T
,
env
*
e
xecEnv
,
exec
drivers
.
Driver
,
stateDB
dbm
.
KV
,
kvdb
dbm
.
KVDB
,
save
bool
)
{
func
voteProposalProject
(
t
*
testing
.
T
,
env
*
E
xecEnv
,
exec
drivers
.
Driver
,
stateDB
dbm
.
KV
,
kvdb
dbm
.
KVDB
,
save
bool
)
{
api
:=
new
(
apimock
.
QueueProtocolAPI
)
api
.
On
(
"StoreList"
,
mock
.
Anything
)
.
Return
(
&
types
.
StoreListReply
{},
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
require
.
Equal
(
t
,
AddrA
,
cur
.
Address
)
}
func
pubVoteProposalProject
(
t
*
testing
.
T
,
env
*
e
xecEnv
,
exec
drivers
.
Driver
,
stateDB
dbm
.
KV
,
kvdb
dbm
.
KVDB
,
save
bool
)
{
func
pubVoteProposalProject
(
t
*
testing
.
T
,
env
*
E
xecEnv
,
exec
drivers
.
Driver
,
stateDB
dbm
.
KV
,
kvdb
dbm
.
KVDB
,
save
bool
)
{
api
:=
new
(
apimock
.
QueueProtocolAPI
)
api
.
On
(
"StoreList"
,
mock
.
Anything
)
.
Return
(
&
types
.
StoreListReply
{},
nil
)
api
.
On
(
"GetLastHeader"
,
mock
.
Anything
)
.
Return
(
&
types
.
Header
{
StateHash
:
[]
byte
(
""
)},
nil
)
...
...
@@ -515,7 +517,7 @@ func pubVoteProposalProjectTx(parm *auty.PubVoteProposalProject) (*types.Transac
return
types
.
CreateFormatTx
(
types
.
ExecName
(
auty
.
AutonomyX
),
types
.
Encode
(
val
))
}
func
terminateProposalProject
(
t
*
testing
.
T
,
env
*
e
xecEnv
,
exec
drivers
.
Driver
,
stateDB
dbm
.
KV
,
kvdb
dbm
.
KVDB
,
save
bool
)
{
func
terminateProposalProject
(
t
*
testing
.
T
,
env
*
E
xecEnv
,
exec
drivers
.
Driver
,
stateDB
dbm
.
KV
,
kvdb
dbm
.
KVDB
,
save
bool
)
{
api
:=
new
(
apimock
.
QueueProtocolAPI
)
api
.
On
(
"StoreList"
,
mock
.
Anything
)
.
Return
(
&
types
.
StoreListReply
{},
nil
)
api
.
On
(
"GetLastHeader"
,
mock
.
Anything
)
.
Return
(
&
types
.
Header
{
StateHash
:
[]
byte
(
""
)},
nil
)
...
...
plugin/dapp/autonomy/executor/rule_test.go
View file @
bacdd6cf
...
...
@@ -255,6 +255,7 @@ func TestListProposalRule(t *testing.T) {
Index
:
Index
,
}
rsp
,
err
=
au
.
listProposalRule
(
req
)
require
.
NoError
(
t
,
err
)
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
]
.
Index
,
int32
(
testcase2
[
1
]
.
index
))
...
...
@@ -324,7 +325,7 @@ func TestListProposalComment(t *testing.T) {
au
.
SetLocalDB
(
kvdb
)
type
statu
struct
{
propI
d
string
propI
D
string
height
int64
index
int64
}
...
...
@@ -351,7 +352,7 @@ func TestListProposalComment(t *testing.T) {
Comment
:
"bbbbbbbbbb"
,
}
for
_
,
tcase
:=
range
testcase
{
key
:=
calcCommentHeight
(
tcase
.
propI
d
,
key
:=
calcCommentHeight
(
tcase
.
propI
D
,
dapp
.
HeightIndexStr
(
tcase
.
height
,
int64
(
tcase
.
index
)))
cur
.
Height
=
tcase
.
height
cur
.
Index
=
int32
(
tcase
.
index
)
...
...
@@ -414,6 +415,7 @@ func TestListProposalComment(t *testing.T) {
Index
:
Index
,
}
rsp
,
err
=
au
.
listProposalComment
(
req
)
require
.
NoError
(
t
,
err
)
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
]
.
Index
,
int32
(
testcase2
[
1
]
.
index
))
...
...
plugin/dapp/autonomy/executor/ruleaction.go
View file @
bacdd6cf
...
...
@@ -305,7 +305,7 @@ func (a *action) tmintPropRule(tmintProb *auty.TerminateProposalRule) (*types.Re
}
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
alog
.
Error
(
"autonomy transfer "
,
"addr"
,
a
.
fromaddr
,
"execaddr"
,
a
.
execaddr
,
"this exec is not autonomy"
,
err
)
return
nil
,
err
...
...
plugin/dapp/autonomy/executor/ruleaction_test.go
View file @
bacdd6cf
...
...
@@ -53,7 +53,7 @@ func TestTerminateProposalRule(t *testing.T) {
terminateProposalRule
(
t
,
env
,
exec
,
stateDB
,
kvdb
,
true
)
}
func
testPropRule
(
t
*
testing
.
T
,
env
*
e
xecEnv
,
exec
drivers
.
Driver
,
stateDB
dbm
.
KV
,
kvdb
dbm
.
KVDB
,
save
bool
)
{
func
testPropRule
(
t
*
testing
.
T
,
env
*
E
xecEnv
,
exec
drivers
.
Driver
,
stateDB
dbm
.
KV
,
kvdb
dbm
.
KVDB
,
save
bool
)
{
opt1
:=
&
auty
.
ProposalRule
{
Year
:
2019
,
Month
:
7
,
...
...
@@ -121,7 +121,7 @@ func propRuleTx(parm *auty.ProposalRule) (*types.Transaction, error) {
return
types
.
CreateFormatTx
(
types
.
ExecName
(
auty
.
AutonomyX
),
types
.
Encode
(
val
))
}
func
revokeProposalRule
(
t
*
testing
.
T
,
env
*
e
xecEnv
,
exec
drivers
.
Driver
,
stateDB
dbm
.
KV
,
kvdb
dbm
.
KVDB
,
save
bool
)
{
func
revokeProposalRule
(
t
*
testing
.
T
,
env
*
E
xecEnv
,
exec
drivers
.
Driver
,
stateDB
dbm
.
KV
,
kvdb
dbm
.
KVDB
,
save
bool
)
{
proposalID
:=
env
.
txHash
opt2
:=
&
auty
.
RevokeProposalRule
{
ProposalID
:
proposalID
,
...
...
@@ -186,7 +186,7 @@ func revokeProposalRuleTx(parm *auty.RevokeProposalRule) (*types.Transaction, er
return
types
.
CreateFormatTx
(
types
.
ExecName
(
auty
.
AutonomyX
),
types
.
Encode
(
val
))
}
func
voteProposalRule
(
t
*
testing
.
T
,
env
*
e
xecEnv
,
exec
drivers
.
Driver
,
stateDB
dbm
.
KV
,
kvdb
dbm
.
KVDB
,
save
bool
)
{
func
voteProposalRule
(
t
*
testing
.
T
,
env
*
E
xecEnv
,
exec
drivers
.
Driver
,
stateDB
dbm
.
KV
,
kvdb
dbm
.
KVDB
,
save
bool
)
{
api
:=
new
(
apimock
.
QueueProtocolAPI
)
api
.
On
(
"StoreList"
,
mock
.
Anything
)
.
Return
(
&
types
.
StoreListReply
{},
nil
)
api
.
On
(
"GetLastHeader"
,
mock
.
Anything
)
.
Return
(
&
types
.
Header
{
StateHash
:
[]
byte
(
""
)},
nil
)
...
...
@@ -313,7 +313,7 @@ func voteProposalRuleTx(parm *auty.VoteProposalRule) (*types.Transaction, error)
return
types
.
CreateFormatTx
(
types
.
ExecName
(
auty
.
AutonomyX
),
types
.
Encode
(
val
))
}
func
terminateProposalRule
(
t
*
testing
.
T
,
env
*
e
xecEnv
,
exec
drivers
.
Driver
,
stateDB
dbm
.
KV
,
kvdb
dbm
.
KVDB
,
save
bool
)
{
func
terminateProposalRule
(
t
*
testing
.
T
,
env
*
E
xecEnv
,
exec
drivers
.
Driver
,
stateDB
dbm
.
KV
,
kvdb
dbm
.
KVDB
,
save
bool
)
{
api
:=
new
(
apimock
.
QueueProtocolAPI
)
api
.
On
(
"StoreList"
,
mock
.
Anything
)
.
Return
(
&
types
.
StoreListReply
{},
nil
)
api
.
On
(
"GetLastHeader"
,
mock
.
Anything
)
.
Return
(
&
types
.
Header
{
StateHash
:
[]
byte
(
""
)},
nil
)
...
...
plugin/dapp/autonomy/rpc/jrpc.go
View file @
bacdd6cf
...
...
@@ -13,6 +13,7 @@ import (
)
// 提案董事会相关
// PropBoardTx 提案董事会成员RPC接口
func
(
c
*
Jrpc
)
PropBoardTx
(
parm
*
auty
.
ProposalBoard
,
result
*
interface
{})
error
{
if
parm
==
nil
{
...
...
@@ -67,6 +68,7 @@ func (c *Jrpc) TerminateProposalBoardTx(parm *auty.TerminateProposalBoard, resul
}
// 提案项目相关
// PropProjectTx 提案项目RPC接口
func
(
c
*
Jrpc
)
PropProjectTx
(
parm
*
auty
.
ProposalProject
,
result
*
interface
{})
error
{
if
parm
==
nil
{
...
...
@@ -134,6 +136,7 @@ func (c *Jrpc) TerminateProposalProjectTx(parm *auty.TerminateProposalProject, r
}
// 提案规则相关
// PropRuleTx 提案规则RPC接口
func
(
c
*
Jrpc
)
PropRuleTx
(
parm
*
auty
.
ProposalRule
,
result
*
interface
{})
error
{
if
parm
==
nil
{
...
...
@@ -187,7 +190,7 @@ func (c *Jrpc) TerminateProposalRuleTx(parm *auty.TerminateProposalRule, result
return
nil
}
// TransferTx 资金转入自治系统合约中
// Transfer
Fund
Tx 资金转入自治系统合约中
func
(
c
*
Jrpc
)
TransferFundTx
(
parm
*
auty
.
TransferFund
,
result
*
interface
{})
error
{
if
parm
==
nil
{
return
types
.
ErrInvalidParam
...
...
plugin/dapp/autonomy/types/const.go
View file @
bacdd6cf
...
...
@@ -45,7 +45,7 @@ const (
TyLogCommentProp
=
2131
)
// status
//
Board
status
const
(
AutonomyStatusProposalBoard
=
iota
+
1
AutonomyStatusRvkPropBoard
...
...
@@ -53,6 +53,7 @@ const (
AutonomyStatusTmintPropBoard
)
// Project status
const
(
AutonomyStatusProposalProject
=
iota
+
1
AutonomyStatusRvkPropProject
...
...
@@ -61,6 +62,7 @@ const (
AutonomyStatusTmintPropProject
)
// Rule status
const
(
AutonomyStatusProposalRule
=
iota
+
1
AutonomyStatusRvkPropRule
...
...
@@ -71,17 +73,17 @@ const (
const
(
// GetProposalBoard 用于在cmd里面的区分不同的查询
GetProposalBoard
=
"GetProposalBoard"
// ListProposalBoard
// ListProposalBoard
查询多个
ListProposalBoard
=
"ListProposalBoard"
// GetProposalProject 用于在cmd里面的区分不同的查询
GetProposalProject
=
"GetProposalProject"
// ListProposalProject
// ListProposalProject
查询多个
ListProposalProject
=
"ListProposalProject"
// GetProposalRule 用于在cmd里面的区分不同的查询
GetProposalRule
=
"GetProposalRule"
// ListProposalRule
// ListProposalRule
查询多个
ListProposalRule
=
"ListProposalRule"
// ListProposalComment
// ListProposalComment
查询多个
ListProposalComment
=
"ListProposalComment"
)
...
...
plugin/dapp/autonomy/types/errors.go
View file @
bacdd6cf
...
...
@@ -13,7 +13,7 @@ var (
ErrProposalStatus
=
errors
.
New
(
"ErrProposalStatus"
)
// ErrRepeatVoteAddr 重复投票地址
ErrRepeatVoteAddr
=
errors
.
New
(
"ErrRepeatVoteAddr"
)
// ErrRevokePeriod 非取消提案期间
// ErrRevokeP
roposalP
eriod 非取消提案期间
ErrRevokeProposalPeriod
=
errors
.
New
(
"ErrRevokeProposalPeriod"
)
// ErrRevokeProposalPower 不能取消
ErrRevokeProposalPower
=
errors
.
New
(
"ErrRevokeProposalPower"
)
...
...
plugin/dapp/autonomy/types/types.go
View file @
bacdd6cf
...
...
@@ -7,14 +7,11 @@ package types
import
(
"reflect"
log
"github.com/33cn/chain33/common/log/log15"
"github.com/33cn/chain33/types"
)
var
name
string
var
tlog
=
log
.
New
(
"module"
,
name
)
func
init
()
{
name
=
AutonomyX
types
.
AllowUserExec
=
append
(
types
.
AllowUserExec
,
[]
byte
(
name
))
...
...
@@ -23,11 +20,6 @@ func init() {
types
.
RegisterDappFork
(
name
,
"Enable"
,
0
)
}
//getRealExecName
func
getRealExecName
(
paraName
string
)
string
{
return
types
.
ExecName
(
paraName
+
AutonomyX
)
}
// NewType 生成新的基础类型
func
NewType
()
*
AutonomyType
{
c
:=
&
AutonomyType
{}
...
...
plugin/dapp/cert/authority/tools/cryptogen/generator/utils/certutils.go
View file @
bacdd6cf
...
...
@@ -73,9 +73,9 @@ func ParseX509CertificateToSm2(x509Cert *x509.Certificate) *sm2.Certificate {
UnknownExtKeyUsage
:
x509Cert
.
UnknownExtKeyUsage
,
BasicConstraintsValid
:
x509Cert
.
BasicConstraintsValid
,
IsCA
:
x509Cert
.
IsCA
,
MaxPathLen
:
x509Cert
.
MaxPathLen
,
MaxPathLenZero
:
x509Cert
.
MaxPathLenZero
,
IsCA
:
x509Cert
.
IsCA
,
MaxPathLen
:
x509Cert
.
MaxPathLen
,
MaxPathLenZero
:
x509Cert
.
MaxPathLenZero
,
SubjectKeyId
:
x509Cert
.
SubjectKeyId
,
AuthorityKeyId
:
x509Cert
.
AuthorityKeyId
,
...
...
@@ -136,9 +136,9 @@ func ParseSm2CertificateToX509(sm2Cert *sm2.Certificate) *x509.Certificate {
UnknownExtKeyUsage
:
sm2Cert
.
UnknownExtKeyUsage
,
BasicConstraintsValid
:
sm2Cert
.
BasicConstraintsValid
,
IsCA
:
sm2Cert
.
IsCA
,
MaxPathLen
:
sm2Cert
.
MaxPathLen
,
MaxPathLenZero
:
sm2Cert
.
MaxPathLenZero
,
IsCA
:
sm2Cert
.
IsCA
,
MaxPathLen
:
sm2Cert
.
MaxPathLen
,
MaxPathLenZero
:
sm2Cert
.
MaxPathLenZero
,
SubjectKeyId
:
sm2Cert
.
SubjectKeyId
,
AuthorityKeyId
:
sm2Cert
.
AuthorityKeyId
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment