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
43b37845
Commit
43b37845
authored
Jul 10, 2019
by
liuyuhang
Committed by
33cn
Aug 14, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add test
parent
894cc1eb
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
13 deletions
+37
-13
boardaction.go
plugin/dapp/autonomy/executor/boardaction.go
+2
-2
boardaction_test.go
plugin/dapp/autonomy/executor/boardaction_test.go
+35
-11
No files found.
plugin/dapp/autonomy/executor/boardaction.go
View file @
43b37845
...
...
@@ -87,14 +87,14 @@ func (a *action) rvkPropBoard(rvkProb *auty.RevokeProposalBoard) (*types.Receipt
// 获取GameID
value
,
err
:=
a
.
db
.
Get
(
propBoardID
(
rvkProb
.
ProposalID
))
if
err
!=
nil
{
alog
.
Error
(
"rvkPropBoard "
,
"addr"
,
a
.
fromaddr
,
"execaddr"
,
a
.
execaddr
,
"get
round
failed"
,
alog
.
Error
(
"rvkPropBoard "
,
"addr"
,
a
.
fromaddr
,
"execaddr"
,
a
.
execaddr
,
"get
ProposalBoard)
failed"
,
rvkProb
.
ProposalID
,
"err"
,
err
)
return
nil
,
err
}
var
cur
auty
.
AutonomyProposalBoard
err
=
types
.
Decode
(
value
,
&
cur
)
if
err
!=
nil
{
alog
.
Error
(
"rvkPropBoard "
,
"addr"
,
a
.
fromaddr
,
"execaddr"
,
a
.
execaddr
,
"decode
roun
d failed"
,
alog
.
Error
(
"rvkPropBoard "
,
"addr"
,
a
.
fromaddr
,
"execaddr"
,
a
.
execaddr
,
"decode
ProposalBoar
d failed"
,
rvkProb
.
ProposalID
,
"err"
,
err
)
return
nil
,
err
}
...
...
plugin/dapp/autonomy/executor/boardaction_test.go
View file @
43b37845
...
...
@@ -20,6 +20,7 @@ import (
_
"github.com/33cn/chain33/system"
"github.com/stretchr/testify/mock"
"github.com/33cn/chain33/common/address"
"github.com/33cn/chain33/util"
)
type
execEnv
struct
{
...
...
@@ -60,7 +61,6 @@ var (
func
init
()
{
commonlog
.
SetLogLevel
(
"error"
)
//types.AllowUserExec = append(types.AllowUserExec, []byte("coins"))
}
func
TestProposalBoard
(
t
*
testing
.
T
)
{
...
...
@@ -98,7 +98,7 @@ func TestProposalBoard(t *testing.T) {
}
stateDB
,
_
:=
dbm
.
NewGoMemDB
(
"state"
,
"state"
,
100
)
localDB
:=
new
(
dbmock
.
KVDB
)
_
,
_
,
kvdb
:=
util
.
CreateTestDB
(
)
api
:=
new
(
apimock
.
QueueProtocolAPI
)
accCoin
:=
account
.
NewCoinsAccount
()
...
...
@@ -109,13 +109,13 @@ func TestProposalBoard(t *testing.T) {
accCoin
.
SaveAccount
(
&
accountC
)
accCoin
.
SaveAccount
(
&
accountD
)
driver
:=
newAutonomy
()
driver
.
SetEnv
(
env
.
blockHeight
,
env
.
blockTime
,
env
.
difficulty
)
driver
.
SetStateDB
(
stateDB
)
driver
.
SetLocalDB
(
localDB
)
driver
.
SetAPI
(
api
)
exec
:=
newAutonomy
()
exec
.
SetStateDB
(
stateDB
)
exec
.
SetLocalDB
(
kvdb
)
exec
.
SetEnv
(
env
.
blockHeight
,
env
.
blockTime
,
env
.
difficulty
)
exec
.
SetAPI
(
api
)
// PropBoard
Tx
// PropBoard
opt1
:=
&
auty
.
ProposalBoard
{
Year
:
2019
,
Month
:
7
,
...
...
@@ -128,14 +128,38 @@ func TestProposalBoard(t *testing.T) {
require
.
NoError
(
t
,
err
)
pbtx
,
err
=
signTx
(
pbtx
,
PrivKeyA
)
require
.
NoError
(
t
,
err
)
exec
:=
newAutonomy
()
exec
.
SetStateDB
(
stateDB
)
exec
.
SetLocalDB
(
localDB
)
exec
.
SetEnv
(
env
.
blockHeight
,
env
.
blockTime
,
env
.
difficulty
)
receipt
,
err
:=
exec
.
Exec
(
pbtx
,
int
(
1
))
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
receipt
)
for
_
,
kv
:=
range
receipt
.
KV
{
stateDB
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
receiptDate
:=
&
types
.
ReceiptData
{
Ty
:
receipt
.
Ty
,
Logs
:
receipt
.
Logs
}
set
,
err
:=
exec
.
ExecLocal
(
pbtx
,
receiptDate
,
int
(
1
))
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
for
_
,
kv
:=
range
set
.
KV
{
kvdb
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
//RevokeProposalBoard
proposalID
:=
common
.
ToHex
(
pbtx
.
Hash
())
opt2
:=
&
auty
.
RevokeProposalBoard
{
ProposalID
:
proposalID
,
}
rtx
,
err
:=
revokeProposalBoardTx
(
opt2
)
require
.
NoError
(
t
,
err
)
rtx
,
err
=
signTx
(
rtx
,
PrivKeyA
)
require
.
NoError
(
t
,
err
)
exec
.
SetEnv
(
env
.
blockHeight
,
env
.
blockTime
,
env
.
difficulty
)
receipt
,
err
=
exec
.
Exec
(
rtx
,
int
(
1
))
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
receipt
)
}
func
propBoardTx
(
parm
*
auty
.
ProposalBoard
)
(
*
types
.
Transaction
,
error
)
{
...
...
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