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

fixbug #253

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