Commit 85ca220e authored by mdj33's avatar mdj33

fix ut

parent ca80cac4
...@@ -23,6 +23,7 @@ import ( ...@@ -23,6 +23,7 @@ import (
auty "github.com/33cn/plugin/plugin/dapp/autonomy/types" auty "github.com/33cn/plugin/plugin/dapp/autonomy/types"
ticket "github.com/33cn/plugin/plugin/dapp/ticket/executor" ticket "github.com/33cn/plugin/plugin/dapp/ticket/executor"
ticketTy "github.com/33cn/plugin/plugin/dapp/ticket/types" ticketTy "github.com/33cn/plugin/plugin/dapp/ticket/types"
"github.com/pkg/errors"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock" "github.com/stretchr/testify/mock"
) )
...@@ -195,43 +196,43 @@ func TestPropBoard(t *testing.T) { ...@@ -195,43 +196,43 @@ func TestPropBoard(t *testing.T) {
opts := []*auty.ProposalBoard{ opts := []*auty.ProposalBoard{
{ // ErrRepeatAddr { // ErrRepeatAddr
Update: true, BoardUpdate: auty.BoardUpdate_ADD,
Boards: []string{"18e1nfiux7aVSfN2zYUZhbidMRokbBSPA6", "18e1nfiux7aVSfN2zYUZhbidMRokbBSPA6"}, Boards: []string{"18e1nfiux7aVSfN2zYUZhbidMRokbBSPA6", "18e1nfiux7aVSfN2zYUZhbidMRokbBSPA6"},
StartBlockHeight: env.blockHeight + 5, StartBlockHeight: env.blockHeight + 5,
EndBlockHeight: env.blockHeight + startEndBlockPeriod + 10, EndBlockHeight: env.blockHeight + startEndBlockPeriod + 10,
}, },
{ // ErrRepeatAddr { // ErrRepeatAddr
Update: true, BoardUpdate: auty.BoardUpdate_ADD,
Boards: []string{"18e1nfiux7aVSfN2zYUZhbidMRokbBSPA6", AddrA}, Boards: []string{"18e1nfiux7aVSfN2zYUZhbidMRokbBSPA6", AddrA},
StartBlockHeight: env.blockHeight + 5, StartBlockHeight: env.blockHeight + 5,
EndBlockHeight: env.blockHeight + startEndBlockPeriod + 10, EndBlockHeight: env.blockHeight + startEndBlockPeriod + 10,
}, },
{ // ErrBoardNumber { // ErrBoardNumber
Update: true, BoardUpdate: auty.BoardUpdate_ADD,
StartBlockHeight: env.blockHeight + 5, StartBlockHeight: env.blockHeight + 5,
EndBlockHeight: env.blockHeight + startEndBlockPeriod + 10, EndBlockHeight: env.blockHeight + startEndBlockPeriod + 10,
}, },
{ // 正常 { // 正常
Update: true, BoardUpdate: auty.BoardUpdate_ADD,
Boards: []string{"18e1nfiux7aVSfN2zYUZhbidMRokbBSPA6"}, Boards: []string{"18e1nfiux7aVSfN2zYUZhbidMRokbBSPA6"},
StartBlockHeight: env.blockHeight + 5, StartBlockHeight: env.blockHeight + 5,
EndBlockHeight: env.blockHeight + startEndBlockPeriod + 10, EndBlockHeight: env.blockHeight + startEndBlockPeriod + 10,
}, },
{ // ErrRepeatAddr { // ErrRepeatAddr
Update: false, BoardUpdate: auty.BoardUpdate_WHOLE,
Boards: []string{"18e1nfiux7aVSfN2zYUZhbidMRokbBSPA6", "18e1nfiux7aVSfN2zYUZhbidMRokbBSPA6"}, Boards: []string{"18e1nfiux7aVSfN2zYUZhbidMRokbBSPA6", "18e1nfiux7aVSfN2zYUZhbidMRokbBSPA6"},
StartBlockHeight: env.blockHeight + 5, StartBlockHeight: env.blockHeight + 5,
EndBlockHeight: env.blockHeight + startEndBlockPeriod + 10, EndBlockHeight: env.blockHeight + startEndBlockPeriod + 10,
}, },
{ // ErrBoardNumber { // ErrBoardNumber
Update: false, BoardUpdate: auty.BoardUpdate_WHOLE,
Boards: []string{"18e1nfiux7aVSfN2zYUZhbidMRokbBSPA6", AddrA}, Boards: []string{"18e1nfiux7aVSfN2zYUZhbidMRokbBSPA6", AddrA},
StartBlockHeight: env.blockHeight + 5, StartBlockHeight: env.blockHeight + 5,
EndBlockHeight: env.blockHeight + startEndBlockPeriod + 10, EndBlockHeight: env.blockHeight + startEndBlockPeriod + 10,
}, },
{ // 正常 { // 正常
Update: false, BoardUpdate: auty.BoardUpdate_WHOLE,
Boards: boards, Boards: boards,
StartBlockHeight: env.blockHeight + 5, StartBlockHeight: env.blockHeight + 5,
EndBlockHeight: env.blockHeight + startEndBlockPeriod + 10, EndBlockHeight: env.blockHeight + startEndBlockPeriod + 10,
...@@ -256,7 +257,8 @@ func TestPropBoard(t *testing.T) { ...@@ -256,7 +257,8 @@ func TestPropBoard(t *testing.T) {
pbtx, err = signTx(pbtx, PrivKeyA) pbtx, err = signTx(pbtx, PrivKeyA)
assert.NoError(t, err) assert.NoError(t, err)
_, err = exec.Exec(pbtx, i) _, err = exec.Exec(pbtx, i)
assert.Equal(t, err, result[i]) assert.Equal(t, errors.Cause(err), result[i])
} }
} }
...@@ -290,6 +292,7 @@ func testPropBoard(t *testing.T, env *ExecEnv, exec drivers.Driver, stateDB dbm. ...@@ -290,6 +292,7 @@ func testPropBoard(t *testing.T, env *ExecEnv, exec drivers.Driver, stateDB dbm.
Month: 7, Month: 7,
Day: 10, Day: 10,
Boards: boards, Boards: boards,
BoardUpdate: auty.BoardUpdate_WHOLE,
StartBlockHeight: env.blockHeight + 5, StartBlockHeight: env.blockHeight + 5,
EndBlockHeight: env.blockHeight + startEndBlockPeriod + 10, EndBlockHeight: env.blockHeight + startEndBlockPeriod + 10,
} }
...@@ -423,19 +426,19 @@ func voteProposalBoard(t *testing.T, env *ExecEnv, exec drivers.Driver, stateDB ...@@ -423,19 +426,19 @@ func voteProposalBoard(t *testing.T, env *ExecEnv, exec drivers.Driver, stateDB
// 4人参与投票,3人赞成票,1人反对票 // 4人参与投票,3人赞成票,1人反对票
type record struct { type record struct {
priv string priv string
appr bool vote auty.AutonomyVoteOption
origin []string origin []string
} }
records := []record{ records := []record{
{priv: PrivKeyA, appr: false}, {priv: PrivKeyA, vote: auty.AutonomyVoteOption_OPPOSE},
{priv: PrivKey1, appr: true, origin: []string{AddrB, AddrC, AddrD}}, {priv: PrivKey1, vote: auty.AutonomyVoteOption_APPROVE, origin: []string{AddrB, AddrC, AddrD}},
} }
InitMinerAddr(stateDB, []string{AddrB, AddrC, AddrD}, Addr1) InitMinerAddr(stateDB, []string{AddrB, AddrC, AddrD}, Addr1)
for i, record := range records { for i, record := range records {
opt := &auty.VoteProposalBoard{ opt := &auty.VoteProposalBoard{
ProposalID: proposalID, ProposalID: proposalID,
Approve: record.appr, VoteOption: record.vote,
OriginAddr: record.origin, OriginAddr: record.origin,
} }
tx, err := voteProposalBoardTx(opt) tx, err := voteProposalBoardTx(opt)
......
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