Commit b284bc43 authored by mdj33's avatar mdj33 Committed by vipwzw

ut correct

parent 07164d7a
...@@ -57,6 +57,7 @@ var ( ...@@ -57,6 +57,7 @@ var (
TokenSymbol = "X" TokenSymbol = "X"
MainBlockHeightForTransfer = int64(9) MainBlockHeightForTransfer = int64(9)
tempTitle = ""
) )
type CommitTestSuite struct { type CommitTestSuite struct {
...@@ -138,7 +139,7 @@ func (suite *CommitTestSuite) SetupSuite() { ...@@ -138,7 +139,7 @@ func (suite *CommitTestSuite) SetupSuite() {
Items: []*types.BlockDetail{blockDetail}, Items: []*types.BlockDetail{blockDetail},
}, nil) }, nil)
suite.api.On("GetBlockHash", &types.ReqInt{Height: MainBlockHeight}).Return( suite.api.On("GetBlockHash", &types.ReqInt{Height: MainBlockHeight}).Return(
&types.ReplyHash{Hash: MainBlockHash10}, nil) &types.ReplyHash{Hash: CurBlock}, nil)
} }
func (suite *CommitTestSuite) TestSetup() { func (suite *CommitTestSuite) TestSetup() {
...@@ -331,7 +332,12 @@ func (suite *CommitTestSuite) TestExec() { ...@@ -331,7 +332,12 @@ func (suite *CommitTestSuite) TestExec() {
} }
func TestCommitSuite(t *testing.T) { func TestCommitSuite(t *testing.T) {
tempTitle = types.GetTitle()
types.SetTitleOnlyForTest(Title)
suite.Run(t, new(CommitTestSuite)) suite.Run(t, new(CommitTestSuite))
types.SetTitleOnlyForTest(tempTitle)
} }
func TestGetTitle(t *testing.T) { func TestGetTitle(t *testing.T) {
......
...@@ -15,8 +15,8 @@ import ( ...@@ -15,8 +15,8 @@ import (
"github.com/33cn/chain33/types" "github.com/33cn/chain33/types"
pt "github.com/33cn/plugin/plugin/dapp/paracross/types" pt "github.com/33cn/plugin/plugin/dapp/paracross/types"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"golang.org/x/net/context" "golang.org/x/net/context"
"github.com/stretchr/testify/mock"
) )
func newGrpc(api *mocks.QueueProtocolAPI) *channelClient { func newGrpc(api *mocks.QueueProtocolAPI) *channelClient {
...@@ -35,6 +35,7 @@ func TestChannelClient_GetTitle(t *testing.T) { ...@@ -35,6 +35,7 @@ func TestChannelClient_GetTitle(t *testing.T) {
client.Init("paracross", nil, nil, nil) client.Init("paracross", nil, nil, nil)
req := &types.ReqString{Data: "xxxxxxxxxxx"} req := &types.ReqString{Data: "xxxxxxxxxxx"}
api.On("Query", pt.GetExecName(), "GetTitle", req).Return(&pt.ParacrossStatus{}, nil) api.On("Query", pt.GetExecName(), "GetTitle", req).Return(&pt.ParacrossStatus{}, nil)
api.On("GetLastHeader", mock.Anything).Return(&types.Header{}, nil).Once()
_, err := client.GetTitle(context.Background(), req) _, err := client.GetTitle(context.Background(), req)
assert.Nil(t, err) assert.Nil(t, err)
} }
...@@ -46,7 +47,7 @@ func TestJrpc_GetTitle(t *testing.T) { ...@@ -46,7 +47,7 @@ func TestJrpc_GetTitle(t *testing.T) {
var result interface{} var result interface{}
api.On("Query", pt.GetExecName(), "GetTitle", req).Return(&pt.ParacrossStatus{ api.On("Query", pt.GetExecName(), "GetTitle", req).Return(&pt.ParacrossStatus{
Title: "user.p.para", Height: int64(64), BlockHash: []byte{177, 17, 9, 106, 247, 117, 90, 242, 221, 160, 157, 31, 33, 51, 10, 99, 77, 47, 245, 223, 59, 64, 121, 121, 215, 167, 152, 17, 223, 218, 173, 83}}, nil) Title: "user.p.para", Height: int64(64), BlockHash: []byte{177, 17, 9, 106, 247, 117, 90, 242, 221, 160, 157, 31, 33, 51, 10, 99, 77, 47, 245, 223, 59, 64, 121, 121, 215, 167, 152, 17, 223, 218, 173, 83}}, nil)
api.On("GetLastHeader", mock.Anything).Return(&types.Header{}, nil) api.On("GetLastHeader", mock.Anything).Return(&types.Header{}, nil).Once()
err := j.GetHeight(req, &result) err := j.GetHeight(req, &result)
assert.Nil(t, err) assert.Nil(t, err)
} }
......
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