Commit 740e8c24 authored by mdj33's avatar mdj33 Committed by vipwzw

add ut

parent f1a335fe
......@@ -14,6 +14,9 @@ import (
"github.com/33cn/chain33/common/address"
"github.com/33cn/chain33/types"
pt "github.com/33cn/plugin/plugin/dapp/paracross/types"
typesmocks "github.com/33cn/chain33/types/mocks"
"github.com/stretchr/testify/mock"
"errors"
)
var (
......@@ -222,3 +225,17 @@ func createTxsGroup(txs []*types.Transaction) ([]*types.Transaction, error) {
}
return group.Txs, nil
}
func TestGetBlockHashForkHeightOnMainChain(t *testing.T) {
para := new(client)
grpcClient := &typesmocks.Chain33Client{}
grpcClient.On("GetFork", mock.Anything, &types.ReqKey{Key: []byte("ForkBlockHash")}).Return(&types.Int64{Data: 1}, errors.New("err")).Once()
para.grpcClient = grpcClient
_, err := para.GetBlockHashForkHeightOnMainChain()
assert.NotNil(t, err)
grpcClient.On("GetFork", mock.Anything, &types.ReqKey{Key: []byte("ForkBlockHash")}).Return(&types.Int64{Data: 1}, nil).Once()
ret, err := para.GetBlockHashForkHeightOnMainChain()
assert.Nil(t, err)
assert.Equal(t, int64(1),ret)
}
\ No newline at end of file
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