Commit 3e9375be authored by mdj33's avatar mdj33 Committed by vipwzw

add ut

parent b3754930
...@@ -90,7 +90,7 @@ func TestSetAutoMining(t *testing.T) { ...@@ -90,7 +90,7 @@ func TestSetAutoMining(t *testing.T) {
func testCloseTicketsOK(t *testing.T) { func testCloseTicketsOK(t *testing.T) {
api := &mocks.QueueProtocolAPI{} api := &mocks.QueueProtocolAPI{}
g := newGrpc(api) g := newGrpc(api)
var in = new(types.ReqNil) var in = &ty.TicketClose{}
api.On("ExecWalletFunc", "ticket", "CloseTickets", in).Return(&types.ReplyHashes{}, nil) api.On("ExecWalletFunc", "ticket", "CloseTickets", in).Return(&types.ReplyHashes{}, nil)
data, err := g.CloseTickets(context.Background(), in) data, err := g.CloseTickets(context.Background(), in)
assert.Nil(t, err, "the error should be nil") assert.Nil(t, err, "the error should be nil")
......
...@@ -14,10 +14,12 @@ import ( ...@@ -14,10 +14,12 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
_ "github.com/33cn/chain33/system" _ "github.com/33cn/chain33/system"
"github.com/33cn/chain33/types"
_ "github.com/33cn/plugin/plugin" _ "github.com/33cn/plugin/plugin"
) )
func Test_WalletTicket(t *testing.T) { func Test_WalletTicket(t *testing.T) {
minerAddr := "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
t.Log("Begin wallet ticket test") t.Log("Begin wallet ticket test")
cfg, sub := testnode.GetDefaultConfig() cfg, sub := testnode.GetDefaultConfig()
...@@ -26,7 +28,7 @@ func Test_WalletTicket(t *testing.T) { ...@@ -26,7 +28,7 @@ func Test_WalletTicket(t *testing.T) {
defer mock33.Close() defer mock33.Close()
err := mock33.WaitHeight(0) err := mock33.WaitHeight(0)
assert.Nil(t, err) assert.Nil(t, err)
msg, err := mock33.GetAPI().Query(ty.TicketX, "TicketList", &ty.TicketList{Addr: "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv", Status: 1}) msg, err := mock33.GetAPI().Query(ty.TicketX, "TicketList", &ty.TicketList{Addr: minerAddr, Status: 1})
assert.Nil(t, err) assert.Nil(t, err)
ticketList := msg.(*ty.ReplyTicketList) ticketList := msg.(*ty.ReplyTicketList)
assert.NotNil(t, ticketList) assert.NotNil(t, ticketList)
...@@ -37,5 +39,11 @@ func Test_WalletTicket(t *testing.T) { ...@@ -37,5 +39,11 @@ func Test_WalletTicket(t *testing.T) {
header, err := mock33.GetAPI().GetLastHeader() header, err := mock33.GetAPI().GetLastHeader()
require.Equal(t, err, nil) require.Equal(t, err, nil)
require.Equal(t, header.Height >= 2, true) require.Equal(t, header.Height >= 2, true)
in := &ty.TicketClose{MinerAddress: minerAddr}
msg, err = mock33.GetAPI().ExecWalletFunc(ty.TicketX, "CloseTickets", in)
assert.Nil(t, err)
hashes := msg.(*types.ReplyHashes)
assert.NotNil(t, hashes)
t.Log("End wallet ticket test") t.Log("End wallet ticket test")
} }
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