Commit 12a5d47e authored by kingwang's avatar kingwang Committed by 33cn

fixbug #253

parent c5730591
......@@ -10,7 +10,6 @@ import (
"fmt"
"os"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/rpc/jsonclient"
rpctypes "github.com/33cn/chain33/rpc/types"
"github.com/33cn/chain33/types"
......@@ -130,7 +129,7 @@ func closeTicket(cmd *cobra.Command, args []string) {
MinerAddress: bindAddr,
}
var res types.ReplyHashes
var res rpctypes.ReplyHashes
rpc, err := jsonclient.NewJSONClient(rpcLaddr)
if err != nil {
fmt.Fprintln(os.Stderr, err)
......@@ -146,12 +145,7 @@ func closeTicket(cmd *cobra.Command, args []string) {
return
}
var tx txHashes
for _, hash := range res.Hashes {
tx.Hashes = append(tx.Hashes, common.ToHex(hash))
}
data, err := json.MarshalIndent(tx, "", " ")
data, err := json.MarshalIndent(res, "", " ")
if err != nil {
fmt.Fprintln(os.Stderr, err)
return
......
......@@ -46,13 +46,13 @@ func TestJRPCChannel(t *testing.T) {
}
func testCountTicketCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
var res types.ReplyHashes
return jrpc.Call("ticket.CloseTickets", nil, &res)
var res int64
return jrpc.Call("ticket.GetTicketCount", nil, &res)
}
func testCloseTicketCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
var res int64
return jrpc.Call("ticket.GetTicketCount", nil, &res)
var res types.ReplyHashes
return jrpc.Call("ticket.CloseTickets", nil, &res)
}
func testGetColdAddrByMinerCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
......
......@@ -5,8 +5,6 @@
package rpc
import (
"encoding/hex"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common/address"
rpctypes "github.com/33cn/chain33/rpc/types"
......@@ -115,7 +113,7 @@ func (c *Jrpc) CloseTickets(in *ty.TicketClose, result *interface{}) error {
}
var hashes rpctypes.ReplyHashes
for _, has := range resp.Hashes {
hashes.Hashes = append(hashes.Hashes, hex.EncodeToString(has))
hashes.Hashes = append(hashes.Hashes, common.ToHex(has))
}
*result = &hashes
return nil
......
......@@ -8,9 +8,12 @@ package rpc_test
import (
"testing"
rpctypes "github.com/33cn/chain33/rpc/types"
_ "github.com/33cn/chain33/system"
"github.com/33cn/chain33/util/testnode"
_ "github.com/33cn/plugin/plugin"
ty "github.com/33cn/plugin/plugin/dapp/ticket/types"
"github.com/stretchr/testify/assert"
)
func TestNewTicket(t *testing.T) {
......@@ -19,4 +22,10 @@ func TestNewTicket(t *testing.T) {
mock33 := testnode.NewWithConfig(cfg, sub, nil)
defer mock33.Close()
mock33.WaitHeight(5)
mock33.Listen()
//选票(可以用hotwallet 关闭选票)
in := &ty.TicketClose{MinerAddress: mock33.GetHotAddress()}
var res rpctypes.ReplyHashes
err := mock33.GetJSONC().Call("ticket.CloseTickets", in, &res)
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